2004-05-29 10:17:37 +00:00
|
|
|
/*
|
|
|
|
|
* Unicode Hexadecimal mode for QEmacs.
|
2007-12-03 16:10:38 +00:00
|
|
|
*
|
2014-01-04 15:54:48 +00:00
|
|
|
* Copyright (c) 2000-2001 Fabrice Bellard.
|
Remove references to global `qe_state` (#45)
* Remove references to global `qe_state`
Add `QEmacsState *qs` field in context and object structures:
- `QEditScreen`, `EditState` (renamed from `qe_state`), `QuitState`
- `WinWindow` (win32.c), `X11State` (x11.c), `QEArgs` (cmd line arguments)
- `CmdLineOptionDef::func_arg()`, `QEModeData`
- move `QEKeyContext` to `QEmacsState`
Pass `QEmacsState *qs` to configuration and state functions:
- all `module_xxx_init` and static `xxx_init` functions
- `QEDisplay::dpy_init()`, `qe_register_display()`, `screen_init()̀`
- `load_input_methods()`, `unload_input_methods()`
- `register_input_method()`, `find_input_method()`
- `find_resource_file()`, `open_resource_file()`
- `qe_find_current_binding()`, `qe_list_bindings()`
- `qe_register_mode()`, `qe_find_mode()`, `qe_find_mode_filename()`
- `qe_register_cmd_line_options()`, `set_user_option()`, `set_tty_charset()`
- `qe_register_commands()`, `qe_register_bindings()`, `qe_find_cmd()`
- `qe_register_completion()`, `qe_register_variables()`
- `eb_register_data_type()`, `parse_command_line()`
- `eb_trace_bytes()`, `qe_toggle_control_h()` (split from `do_toggle_control_h()`)
- `unget_key()`, `qe_grab_keys()`, `qe_ungrab_keys()`, `qe_key_process()`
- `eb_new()`, `eb_find()`, `eb_find_new()`, `eb_scratch()`, `eb_find_file()`
- `new_shell_buffer()` `macro_add_key()`, `clear_macro(), `stop_macro()`
- `check_window()`, `check_buffer()`, `qe_kill_buffer()`, `qe_get_history()`
- `qe_register_charset()`, `find_charset()`
Add error message handlers:
- add `QEDisplay::dpy_error()` method
- add `qe_cfg_error()`, use for all expression parsing errors
- pass opaque pointer to `css_error()`
- add `qe_put_error()` and `qe_dpy_error()`
Add context argument:
- always pass a non-null window pointer to `do_refresh()`, `new_help_buffer()`
Rename functions:
- `find_resource_file` -> `qe_find_resource_file`
- `open_resource_file` -> `qe_open_resource_file`
- `input_methods_init` -> `qe_input_methods_init`
- `load_input_methods` -> `qe_load_input_methods`
- `unload_input_methods` -> `qe_unload_input_methods`
- `find_input_methods` -> `qe_find_input_methods`
- `register_input_method` -> `qe_register_input_method`
- `parse_command_line` -> `qe_parse_command_line`
- `eb_trace_bytes` -> `qe_trace_bytes`
- `eb_init` -> `qe_data_init`
- `eb_count_buffers` -> `qe_count_buffers`
- `eb_get_buffer_from_index` -> `qe_get_buffer_from_index`
- `init_all_modules` -> `qe_init_all_modules`
- `exit_all_modules` -> `qe_exit_all_modules`
- `load_all_modules` -> `qe_load_all_modules`
- `maybe_set_mark` -> `do_maybe_set_mark`
- `unget_key` -> `qe_unget_key`
- `minibuffer_init` -> `qe_minibuffer_init`
- `edit_display` -> `qe_display`
- `new_yank_buffer` -> `qe_new_yank_buffer`
- `new_shell_buffer` -> `qe_new_shell_buffer`
- `shell_find_mode` -> `qe_shell_find_mode`
- `save_selection` -> `qe_save_selection`
- `register_emulation_bindings` -> `qe_register_emulation_bindings`
- `macro_add_key` -> `qe_macro_add_key`
- `clear_macro` -> `qe_clear_macro`
- `stop_macro` -> `qe_stop_macro`
- `eb_format_message` -> `qe_format_message`
- `screen_init` -> `qe_screen_init`
- `charset_jis_init` -> `qe_charset_jis_init`
- `charset_more_init` -> `qe_charset_more_init`
- `check_window` -> `qe_check_window`
- `check_buffer` -> `qe_check_buffer`
- `eb_find_file` -> `qe_find_buffer_file`
- `eb_find` -> `qe_find_buffer_name`
- `eb_new` -> `qe_new_buffer`
- `eb_find_new` -> `qe_new_buffer` with `BC_REUSE`
- `eb_scratch` -> `qe_new_buffer` with `BC_REUSE | BC_CLEAR`
- `find_charset` -> `qe_find_charset`
Add asan, msan and ubsan targets
Fix `qe_encode64` buffer length computation.
Add `qe_new_shell_buffer` flags `SF_REUSE_BUFFER` and `SF_ERASE_BUFFER`
Bumped version to 6.3.3
fix redundant typedef
fix compilation errors
2024-12-01 23:34:00 +01:00
|
|
|
* Copyright (c) 2002-2024 Charlie Gordon.
|
2004-05-29 10:17:37 +00:00
|
|
|
*
|
2023-03-05 02:04:02 +01:00
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
|
|
|
* in the Software without restriction, including without limitation the rights
|
|
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
|
|
|
* furnished to do so, subject to the following conditions:
|
2004-05-29 10:17:37 +00:00
|
|
|
*
|
2023-03-05 02:04:02 +01:00
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
|
* all copies or substantial portions of the Software.
|
2004-05-29 10:17:37 +00:00
|
|
|
*
|
2023-03-05 02:04:02 +01:00
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
|
* THE SOFTWARE.
|
2004-05-29 10:17:37 +00:00
|
|
|
*/
|
2007-12-03 16:10:38 +00:00
|
|
|
|
2004-05-29 10:17:37 +00:00
|
|
|
#include "qe.h"
|
|
|
|
|
|
2014-04-02 12:58:12 +00:00
|
|
|
enum {
|
|
|
|
|
UNIHEX_STYLE_OFFSET = QE_STYLE_COMMENT,
|
|
|
|
|
UNIHEX_STYLE_DUMP = QE_STYLE_FUNCTION,
|
|
|
|
|
};
|
|
|
|
|
|
2014-06-01 13:54:58 +00:00
|
|
|
static int unihex_mode_init(EditState *s, EditBuffer *b, int flags)
|
2004-05-29 10:17:37 +00:00
|
|
|
{
|
2014-06-01 13:54:58 +00:00
|
|
|
if (s) {
|
2022-10-29 19:43:38 +02:00
|
|
|
int offset, max_offset, w;
|
|
|
|
|
char32_t c, maxc;
|
2014-06-01 13:54:58 +00:00
|
|
|
|
|
|
|
|
/* unihex mode is incompatible with EOL_DOS eol type */
|
|
|
|
|
eb_set_charset(s->b, s->b->charset, EOL_UNIX);
|
|
|
|
|
|
|
|
|
|
/* Compute max width of character in hex dump (limit to first 64K) */
|
2017-03-19 15:39:25 +00:00
|
|
|
maxc = 0xFFFF;
|
Various improvements for consistency
* add -Wno-packed compiler option
* add CONFIG_REGEX flag, undefined for tiny build
* disable regex commands in tiny build
* add documentation for some search commands and APIs
* reorder search tags for readability
* add isearch_yank_char
* use emacs names for:
isearch-repeat-backward, isearch-repeat-forward,
isearch-ring-advance, isearch-ring-retreat,
isearch-yank-word-or-char
* add occur alias for list-matching-lines
* add char32_to_utf8()
* restored some macros in cutils.h:
likely(x), unlikely(x), __maybe_unused, BOOL, FALSE, TRUE
* remove max(), min(), maxp(), minp(), clampp()
* add typed arithmetic functions:
min_int(), max_int(), clamp_int(), min3_int(), max3_int()
min_offset(), max_offset(), clamp_offset()
* use typed functions everywhere
* bump version to 5.4.1d
2022-11-21 00:20:18 +01:00
|
|
|
max_offset = min_offset(65536, s->b->total_size);
|
2014-06-01 13:54:58 +00:00
|
|
|
for (offset = 0; offset < max_offset;) {
|
|
|
|
|
c = eb_nextc(s->b, offset, &offset);
|
2022-10-29 19:43:38 +02:00
|
|
|
if (maxc < c)
|
|
|
|
|
maxc = c;
|
2014-06-01 13:54:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
s->hex_mode = 1;
|
|
|
|
|
s->hex_nibble = 0;
|
2017-03-19 15:39:25 +00:00
|
|
|
s->unihex_mode = w = snprintf(NULL, 0, "%x", maxc);
|
Various improvements for consistency
* add -Wno-packed compiler option
* add CONFIG_REGEX flag, undefined for tiny build
* disable regex commands in tiny build
* add documentation for some search commands and APIs
* reorder search tags for readability
* add isearch_yank_char
* use emacs names for:
isearch-repeat-backward, isearch-repeat-forward,
isearch-ring-advance, isearch-ring-retreat,
isearch-yank-word-or-char
* add occur alias for list-matching-lines
* add char32_to_utf8()
* restored some macros in cutils.h:
likely(x), unlikely(x), __maybe_unused, BOOL, FALSE, TRUE
* remove max(), min(), maxp(), minp(), clampp()
* add typed arithmetic functions:
min_int(), max_int(), clamp_int(), min3_int(), max3_int()
min_offset(), max_offset(), clamp_offset()
* use typed functions everywhere
* bump version to 5.4.1d
2022-11-21 00:20:18 +01:00
|
|
|
s->dump_width = clamp_int((s->width - 8 - 2 - 2 - 1) / (w + 3), 8, 16);
|
2022-08-29 18:41:29 +02:00
|
|
|
s->overwrite = 1;
|
2017-04-25 17:41:27 +00:00
|
|
|
/* XXX: should come from mode.default_wrap */
|
2014-06-01 13:54:58 +00:00
|
|
|
s->wrap = WRAP_TRUNCATE;
|
2014-01-12 01:39:10 +00:00
|
|
|
}
|
2004-05-29 10:17:37 +00:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-29 19:43:38 +02:00
|
|
|
static int unihex_to_disp(char32_t c) {
|
2017-03-19 15:39:25 +00:00
|
|
|
/* Prevent display of C0 and C1 control codes and invalid code points */
|
2017-03-15 07:38:58 +00:00
|
|
|
if (c < ' ' || c == 127 || (c >= 128 && c < 160)
|
|
|
|
|
|| (c >= 0xD800 && c <= 0xDFFF) || c > 0x10FFFF)
|
2008-04-22 09:04:20 +00:00
|
|
|
c = '.';
|
|
|
|
|
return c;
|
|
|
|
|
}
|
|
|
|
|
|
2004-05-29 10:17:37 +00:00
|
|
|
static int unihex_backward_offset(EditState *s, int offset)
|
|
|
|
|
{
|
|
|
|
|
int pos;
|
2007-12-20 20:39:18 +00:00
|
|
|
|
2014-01-04 15:54:48 +00:00
|
|
|
/* CG: beware: offset may fall inside a character */
|
2004-05-29 10:17:37 +00:00
|
|
|
pos = eb_get_char_offset(s->b, offset);
|
2015-08-13 23:26:59 +00:00
|
|
|
pos = align(pos, s->dump_width);
|
2004-05-29 10:17:37 +00:00
|
|
|
return eb_goto_char(s->b, pos);
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-23 15:51:51 +00:00
|
|
|
static int unihex_display_line(EditState *s, DisplayState *ds, int offset)
|
2004-05-29 10:17:37 +00:00
|
|
|
{
|
2022-10-29 19:43:38 +02:00
|
|
|
int j, len, ateof, dump_width, w;
|
2014-01-12 01:39:10 +00:00
|
|
|
int offset1, offset2;
|
2022-10-29 19:43:38 +02:00
|
|
|
char32_t c, maxc, b;
|
2014-01-04 15:54:48 +00:00
|
|
|
/* CG: array size is incorrect, should be smaller */
|
2022-10-29 19:43:38 +02:00
|
|
|
char32_t buf[LINE_MAX_SIZE];
|
|
|
|
|
char32_t pos[LINE_MAX_SIZE];
|
2004-05-29 10:17:37 +00:00
|
|
|
|
|
|
|
|
display_bol(ds);
|
|
|
|
|
|
2014-04-02 12:58:12 +00:00
|
|
|
ds->style = UNIHEX_STYLE_OFFSET;
|
2026-03-14 21:21:31 +01:00
|
|
|
display_printf(ds, -1, -1, "%08x ", (unsigned)offset);
|
2014-01-12 01:39:10 +00:00
|
|
|
//int charpos = eb_get_char_offset(s->b, offset);
|
|
|
|
|
//display_printf(ds, -1, -1, "%08x ", charpos);
|
2014-01-04 15:54:48 +00:00
|
|
|
//display_printf(ds, -1, -1, "%08x %08x ", charpos, offset);
|
2004-05-29 10:17:37 +00:00
|
|
|
|
Various improvements for consistency
* add -Wno-packed compiler option
* add CONFIG_REGEX flag, undefined for tiny build
* disable regex commands in tiny build
* add documentation for some search commands and APIs
* reorder search tags for readability
* add isearch_yank_char
* use emacs names for:
isearch-repeat-backward, isearch-repeat-forward,
isearch-ring-advance, isearch-ring-retreat,
isearch-yank-word-or-char
* add occur alias for list-matching-lines
* add char32_to_utf8()
* restored some macros in cutils.h:
likely(x), unlikely(x), __maybe_unused, BOOL, FALSE, TRUE
* remove max(), min(), maxp(), minp(), clampp()
* add typed arithmetic functions:
min_int(), max_int(), clamp_int(), min3_int(), max3_int()
min_offset(), max_offset(), clamp_offset()
* use typed functions everywhere
* bump version to 5.4.1d
2022-11-21 00:20:18 +01:00
|
|
|
dump_width = min_int(LINE_MAX_SIZE - 1, s->dump_width);
|
2008-04-22 09:04:20 +00:00
|
|
|
ateof = 0;
|
2004-05-29 10:17:37 +00:00
|
|
|
len = 0;
|
2017-03-19 15:39:25 +00:00
|
|
|
maxc = 0;
|
2015-08-13 23:26:59 +00:00
|
|
|
for (j = 0; j < dump_width && offset < s->b->total_size; j++) {
|
2014-01-04 15:54:48 +00:00
|
|
|
pos[len] = offset;
|
2017-03-19 15:39:25 +00:00
|
|
|
buf[len] = c = eb_nextc(s->b, offset, &offset);
|
|
|
|
|
if (maxc < c)
|
|
|
|
|
maxc = c;
|
2014-01-04 15:54:48 +00:00
|
|
|
len++;
|
2004-05-29 10:17:37 +00:00
|
|
|
}
|
|
|
|
|
pos[len] = offset;
|
|
|
|
|
|
2017-03-19 15:39:25 +00:00
|
|
|
/* adjust s->unihex_mode if a larger character has been found */
|
|
|
|
|
while (s->unihex_mode < 8 && maxc >> (s->unihex_mode * 4) != 0)
|
|
|
|
|
s->unihex_mode++;
|
|
|
|
|
|
2014-04-02 12:58:12 +00:00
|
|
|
ds->style = UNIHEX_STYLE_DUMP;
|
2008-01-09 13:41:40 +00:00
|
|
|
|
2015-08-13 23:26:59 +00:00
|
|
|
for (j = 0; j < dump_width; j++) {
|
2004-05-29 10:17:37 +00:00
|
|
|
display_char(ds, -1, -1, ' ');
|
2008-04-22 09:04:20 +00:00
|
|
|
offset1 = pos[j];
|
|
|
|
|
offset2 = pos[j + 1];
|
2004-05-29 10:17:37 +00:00
|
|
|
if (j < len) {
|
2014-01-12 01:39:10 +00:00
|
|
|
display_printhex(ds, offset1, offset2, buf[j], s->unihex_mode);
|
|
|
|
|
//ds->cur_hex_mode = 1;
|
|
|
|
|
//display_printf(ds, offset1, offset2, "%0*x", s->unihex_mode, buf[j]);
|
|
|
|
|
//ds->cur_hex_mode = 0;
|
2004-05-29 10:17:37 +00:00
|
|
|
} else {
|
2008-04-05 18:16:30 +00:00
|
|
|
if (!ateof) {
|
|
|
|
|
ateof = 1;
|
2008-04-22 09:04:20 +00:00
|
|
|
offset2 = offset1 + 1;
|
2004-05-29 10:17:37 +00:00
|
|
|
} else {
|
2008-04-22 09:04:20 +00:00
|
|
|
offset2 = offset1 = -1;
|
2004-05-29 10:17:37 +00:00
|
|
|
}
|
2008-04-22 09:04:20 +00:00
|
|
|
ds->cur_hex_mode = s->hex_mode;
|
2014-02-10 03:24:34 +00:00
|
|
|
display_printf(ds, offset1, offset2, "%*c", s->unihex_mode, ' ');
|
2008-04-22 09:04:20 +00:00
|
|
|
ds->cur_hex_mode = 0;
|
2004-05-29 10:17:37 +00:00
|
|
|
}
|
|
|
|
|
if ((j & 7) == 7)
|
|
|
|
|
display_char(ds, -1, -1, ' ');
|
|
|
|
|
}
|
2008-04-22 09:04:20 +00:00
|
|
|
display_char(ds, -1, -1, ' ');
|
|
|
|
|
|
2008-01-09 13:41:40 +00:00
|
|
|
ds->style = 0;
|
|
|
|
|
|
2004-05-29 10:17:37 +00:00
|
|
|
display_char(ds, -1, -1, ' ');
|
|
|
|
|
|
2008-04-22 09:04:20 +00:00
|
|
|
ateof = 0;
|
2015-08-13 23:26:59 +00:00
|
|
|
for (j = 0; j < dump_width; j++) {
|
2008-04-22 09:04:20 +00:00
|
|
|
offset1 = pos[j];
|
|
|
|
|
offset2 = pos[j + 1];
|
2004-05-29 10:17:37 +00:00
|
|
|
if (j < len) {
|
|
|
|
|
b = buf[j];
|
2014-01-04 15:54:48 +00:00
|
|
|
b = unihex_to_disp(b);
|
2004-05-29 10:17:37 +00:00
|
|
|
} else {
|
|
|
|
|
b = ' ';
|
2008-04-05 18:16:30 +00:00
|
|
|
if (!ateof) {
|
|
|
|
|
ateof = 1;
|
2008-04-22 09:04:20 +00:00
|
|
|
offset2 = offset1 + 1;
|
2004-05-29 10:17:37 +00:00
|
|
|
} else {
|
2008-04-22 09:04:20 +00:00
|
|
|
offset2 = offset1 = -1;
|
2004-05-29 10:17:37 +00:00
|
|
|
}
|
|
|
|
|
}
|
2022-09-27 22:30:05 +02:00
|
|
|
w = qe_wcwidth(b);
|
2022-08-29 02:55:50 +02:00
|
|
|
if (w == 0) {
|
2017-03-16 09:16:31 +00:00
|
|
|
/* insert space to make accent stand on its own */
|
|
|
|
|
display_char(ds, offset1, offset2, ' ');
|
|
|
|
|
display_char(ds, -1, -1, b);
|
|
|
|
|
} else {
|
|
|
|
|
display_char(ds, offset1, offset2, b);
|
|
|
|
|
}
|
2017-03-15 23:42:23 +00:00
|
|
|
/* spacing out single width glyphs may be less readable */
|
2022-08-29 02:55:50 +02:00
|
|
|
if (w < 2) {
|
2014-01-04 15:54:48 +00:00
|
|
|
display_char(ds, -1, -1, ' ');
|
2017-03-15 23:42:23 +00:00
|
|
|
}
|
2004-05-29 10:17:37 +00:00
|
|
|
}
|
|
|
|
|
display_eol(ds, -1, -1);
|
|
|
|
|
|
2015-08-13 23:26:59 +00:00
|
|
|
if (len >= dump_width)
|
2004-05-29 10:17:37 +00:00
|
|
|
return offset;
|
|
|
|
|
else
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
2006-12-31 19:34:00 +00:00
|
|
|
static void unihex_move_bol(EditState *s)
|
2004-05-29 10:17:37 +00:00
|
|
|
{
|
|
|
|
|
int pos;
|
|
|
|
|
|
|
|
|
|
pos = eb_get_char_offset(s->b, s->offset);
|
2015-08-13 23:26:59 +00:00
|
|
|
pos = align(pos, s->dump_width);
|
2004-05-29 10:17:37 +00:00
|
|
|
s->offset = eb_goto_char(s->b, pos);
|
|
|
|
|
}
|
|
|
|
|
|
2006-12-31 19:34:00 +00:00
|
|
|
static void unihex_move_eol(EditState *s)
|
2004-05-29 10:17:37 +00:00
|
|
|
{
|
|
|
|
|
int pos;
|
|
|
|
|
|
|
|
|
|
pos = eb_get_char_offset(s->b, s->offset);
|
|
|
|
|
|
2007-12-18 12:18:02 +00:00
|
|
|
/* CG: should include the last character! */
|
2015-08-13 23:26:59 +00:00
|
|
|
pos = align(pos, s->dump_width) + s->dump_width - 1;
|
2004-05-29 10:17:37 +00:00
|
|
|
|
|
|
|
|
s->offset = eb_goto_char(s->b, pos);
|
|
|
|
|
}
|
|
|
|
|
|
2006-12-31 19:34:00 +00:00
|
|
|
static void unihex_move_left_right(EditState *s, int dir)
|
2004-05-29 10:17:37 +00:00
|
|
|
{
|
|
|
|
|
if (dir > 0) {
|
2016-12-23 19:51:48 +00:00
|
|
|
s->offset = eb_next(s->b, s->offset);
|
2004-05-29 10:17:37 +00:00
|
|
|
} else {
|
2016-12-23 19:51:48 +00:00
|
|
|
s->offset = eb_prev(s->b, s->offset);
|
2004-05-29 10:17:37 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2006-12-31 19:34:00 +00:00
|
|
|
static void unihex_move_up_down(EditState *s, int dir)
|
2004-05-29 10:17:37 +00:00
|
|
|
{
|
|
|
|
|
int pos;
|
|
|
|
|
|
|
|
|
|
pos = eb_get_char_offset(s->b, s->offset);
|
|
|
|
|
|
2015-08-13 23:26:59 +00:00
|
|
|
pos += dir * s->dump_width;
|
2004-05-29 10:17:37 +00:00
|
|
|
|
|
|
|
|
s->offset = eb_goto_char(s->b, pos);
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-16 14:00:28 +00:00
|
|
|
static void unihex_mode_line(EditState *s, buf_t *out)
|
2014-01-04 15:54:48 +00:00
|
|
|
{
|
2014-01-16 14:00:28 +00:00
|
|
|
basic_mode_line(s, out, '-');
|
2022-09-06 09:51:16 +02:00
|
|
|
buf_printf(out, "--0x%x--0x%x--%s",
|
2026-03-14 21:21:31 +01:00
|
|
|
(unsigned)eb_get_char_offset(s->b, s->offset),
|
|
|
|
|
(unsigned)s->offset, s->b->charset->name);
|
2014-01-16 14:00:28 +00:00
|
|
|
buf_printf(out, "--%d%%", compute_percent(s->offset, s->b->total_size));
|
2014-01-04 15:54:48 +00:00
|
|
|
}
|
|
|
|
|
|
2014-02-10 03:24:34 +00:00
|
|
|
static int unihex_mode_probe(ModeDef *mode, ModeProbeData *p)
|
|
|
|
|
{
|
|
|
|
|
/* XXX: should check for non 8 bit characters */
|
2017-03-19 15:39:25 +00:00
|
|
|
/* XXX: should auto-detect if content has non ASCII utf8 contents */
|
2014-02-10 03:24:34 +00:00
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-22 17:13:26 +02:00
|
|
|
/* additional mode specific bindings */
|
|
|
|
|
static const char * const unihex_bindings[] = {
|
|
|
|
|
// XXX: Should use fallback mode for these bindings
|
2022-08-30 10:00:42 +02:00
|
|
|
"C-left", "decrease-width",
|
|
|
|
|
"C-right", "increase-width",
|
|
|
|
|
"TAB, S-TAB", "toggle-hex",
|
2022-08-22 17:13:26 +02:00
|
|
|
NULL
|
|
|
|
|
};
|
|
|
|
|
|
2007-12-06 17:43:47 +00:00
|
|
|
static ModeDef unihex_mode = {
|
2014-01-04 15:54:48 +00:00
|
|
|
.name = "unihex",
|
2014-02-10 03:24:34 +00:00
|
|
|
.mode_probe = unihex_mode_probe,
|
2008-01-03 09:51:29 +00:00
|
|
|
.mode_init = unihex_mode_init,
|
2016-12-23 15:51:51 +00:00
|
|
|
.display_line = unihex_display_line,
|
|
|
|
|
.backward_offset = unihex_backward_offset,
|
2007-12-06 17:43:47 +00:00
|
|
|
.move_up_down = unihex_move_up_down,
|
|
|
|
|
.move_left_right = unihex_move_left_right,
|
|
|
|
|
.move_bol = unihex_move_bol,
|
|
|
|
|
.move_eol = unihex_move_eol,
|
2016-12-23 15:51:51 +00:00
|
|
|
.move_bof = text_move_bof,
|
|
|
|
|
.move_eof = text_move_eof,
|
2007-12-06 17:43:47 +00:00
|
|
|
.scroll_up_down = text_scroll_up_down,
|
|
|
|
|
.mouse_goto = text_mouse_goto,
|
2016-06-07 08:56:39 +00:00
|
|
|
.write_char = hex_write_char,
|
2014-01-04 15:54:48 +00:00
|
|
|
.get_mode_line = unihex_mode_line,
|
2022-08-22 17:13:26 +02:00
|
|
|
.bindings = unihex_bindings,
|
2022-08-16 22:39:51 +02:00
|
|
|
// XXX: Should use fallback mode for other bindings
|
|
|
|
|
//.fallback = &binary_mode,
|
2004-05-29 10:17:37 +00:00
|
|
|
};
|
|
|
|
|
|
2024-05-19 19:15:08 +02:00
|
|
|
static int unihex_init(QEmacsState *qs) {
|
Remove references to global `qe_state` (#45)
* Remove references to global `qe_state`
Add `QEmacsState *qs` field in context and object structures:
- `QEditScreen`, `EditState` (renamed from `qe_state`), `QuitState`
- `WinWindow` (win32.c), `X11State` (x11.c), `QEArgs` (cmd line arguments)
- `CmdLineOptionDef::func_arg()`, `QEModeData`
- move `QEKeyContext` to `QEmacsState`
Pass `QEmacsState *qs` to configuration and state functions:
- all `module_xxx_init` and static `xxx_init` functions
- `QEDisplay::dpy_init()`, `qe_register_display()`, `screen_init()̀`
- `load_input_methods()`, `unload_input_methods()`
- `register_input_method()`, `find_input_method()`
- `find_resource_file()`, `open_resource_file()`
- `qe_find_current_binding()`, `qe_list_bindings()`
- `qe_register_mode()`, `qe_find_mode()`, `qe_find_mode_filename()`
- `qe_register_cmd_line_options()`, `set_user_option()`, `set_tty_charset()`
- `qe_register_commands()`, `qe_register_bindings()`, `qe_find_cmd()`
- `qe_register_completion()`, `qe_register_variables()`
- `eb_register_data_type()`, `parse_command_line()`
- `eb_trace_bytes()`, `qe_toggle_control_h()` (split from `do_toggle_control_h()`)
- `unget_key()`, `qe_grab_keys()`, `qe_ungrab_keys()`, `qe_key_process()`
- `eb_new()`, `eb_find()`, `eb_find_new()`, `eb_scratch()`, `eb_find_file()`
- `new_shell_buffer()` `macro_add_key()`, `clear_macro(), `stop_macro()`
- `check_window()`, `check_buffer()`, `qe_kill_buffer()`, `qe_get_history()`
- `qe_register_charset()`, `find_charset()`
Add error message handlers:
- add `QEDisplay::dpy_error()` method
- add `qe_cfg_error()`, use for all expression parsing errors
- pass opaque pointer to `css_error()`
- add `qe_put_error()` and `qe_dpy_error()`
Add context argument:
- always pass a non-null window pointer to `do_refresh()`, `new_help_buffer()`
Rename functions:
- `find_resource_file` -> `qe_find_resource_file`
- `open_resource_file` -> `qe_open_resource_file`
- `input_methods_init` -> `qe_input_methods_init`
- `load_input_methods` -> `qe_load_input_methods`
- `unload_input_methods` -> `qe_unload_input_methods`
- `find_input_methods` -> `qe_find_input_methods`
- `register_input_method` -> `qe_register_input_method`
- `parse_command_line` -> `qe_parse_command_line`
- `eb_trace_bytes` -> `qe_trace_bytes`
- `eb_init` -> `qe_data_init`
- `eb_count_buffers` -> `qe_count_buffers`
- `eb_get_buffer_from_index` -> `qe_get_buffer_from_index`
- `init_all_modules` -> `qe_init_all_modules`
- `exit_all_modules` -> `qe_exit_all_modules`
- `load_all_modules` -> `qe_load_all_modules`
- `maybe_set_mark` -> `do_maybe_set_mark`
- `unget_key` -> `qe_unget_key`
- `minibuffer_init` -> `qe_minibuffer_init`
- `edit_display` -> `qe_display`
- `new_yank_buffer` -> `qe_new_yank_buffer`
- `new_shell_buffer` -> `qe_new_shell_buffer`
- `shell_find_mode` -> `qe_shell_find_mode`
- `save_selection` -> `qe_save_selection`
- `register_emulation_bindings` -> `qe_register_emulation_bindings`
- `macro_add_key` -> `qe_macro_add_key`
- `clear_macro` -> `qe_clear_macro`
- `stop_macro` -> `qe_stop_macro`
- `eb_format_message` -> `qe_format_message`
- `screen_init` -> `qe_screen_init`
- `charset_jis_init` -> `qe_charset_jis_init`
- `charset_more_init` -> `qe_charset_more_init`
- `check_window` -> `qe_check_window`
- `check_buffer` -> `qe_check_buffer`
- `eb_find_file` -> `qe_find_buffer_file`
- `eb_find` -> `qe_find_buffer_name`
- `eb_new` -> `qe_new_buffer`
- `eb_find_new` -> `qe_new_buffer` with `BC_REUSE`
- `eb_scratch` -> `qe_new_buffer` with `BC_REUSE | BC_CLEAR`
- `find_charset` -> `qe_find_charset`
Add asan, msan and ubsan targets
Fix `qe_encode64` buffer length computation.
Add `qe_new_shell_buffer` flags `SF_REUSE_BUFFER` and `SF_ERASE_BUFFER`
Bumped version to 6.3.3
fix redundant typedef
fix compilation errors
2024-12-01 23:34:00 +01:00
|
|
|
qe_register_mode(qs, &unihex_mode, MODEF_VIEW);
|
2004-05-29 10:17:37 +00:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
qe_module_init(unihex_init);
|