Commit graph

37 commits

Author SHA1 Message Date
Charlie Gordon
227c3dc5e8 Help: improve describe-xxx functions and help popups
* rename and pass flags to byte quoting functions:
  `byte_quote` -> `strquote_byte`
* add `eb_print_style` to output data to a buffer in a given style
* add `eb_print_field` to output a field name and value using styles
* use styles in describe commands
* improve byte stats and page layout output in `describe-buffer`
* add `wall-chart` command (sorted list of bindings)
* add `describe-help` command
2026-06-18 23:30:17 +02:00
Charlie Gordon
77e57d11c7 Colorization: improve colorization of diff and process output
* improve color combining code for diff/patch output: preserve code
  syntax coloring on red or green background.
* improve `curline_style` handling (needs more work)
* add `QETermStyle` transparent color handling in `apply_style`
* highlight trailing blanks in a single place
* transpose `qe_term_get_style()` arguments for consistency
* add `qe_term_style_string()` and `qe_styledef_string()`
* extend style string parser to accept missing foreground color
2026-06-09 14:19:28 -04:00
Charlie Gordon
699bdff915 Simplify mode probing
* add `filenames` specification in `ModeDef` structures
* generic mode probing can match a list of filenames
* remove unneeded mode_probe functions
* this enables diff coloring on Makefile
2026-06-05 18:42:56 -04:00
Charlie Gordon
ca1eb2ff88 util: simplifications and doc fixes
* add `qe_shell_match` to replace `fnmatch`
* fix some documentation errors
2026-05-17 12:17:25 +02:00
Charlie Gordon
43b5851958 Update README.md, VERSION and copyrights
* VERSION bumped to 6.4.1
2025-02-10 07:51:29 +01:00
Charlie Gordon
af492d00b6 Improve tcl colorizer
* use complete list of internal commands
* use tcl specific word parser
* fix quoted and braced string parsers
* improve variable colorizer
* add custom cases in probe function
* add `ustr_match_str`
2025-02-09 12:54:27 +01:00
Charlie Gordon
13f0d3bec9
Improve C-like language colorizers (#53)
* add `CLANG_C_TYPES` flag for generic C types
* add `CLANG_C_KEYWORDS` flag for generic C keywords
* add `CLANG_T_TYPES` flag for generic `xxx_t` types
* more explicit regex testing
* support for `u`, `U` and `u64` encoding prefixes
* improve comment detection in diff output for js and c3
* change `get_c_identifier` API for consistency
* add `is_c_identifier_start()` and `is_c_identifier_part()`
* move `qe_haslower` to **util.c**
* update C2 language keyword and type lists
* improve Pike colorizer
2024-12-14 20:27:25 +01:00
Charlie Gordon
57c46f97bc
Fix asan crash bug (#49)
- add debug info in asan, msan and ubsan builds
- avoid function call in `qe_unaccent` for ASCII chars
- fix `find_ligature` return type to detect simple ligatures with a simple test
- fix crash bug in `expand_ligature`, behavior was bogus anyway.
2024-12-05 12:04:58 +01:00
Charlie Gordon
d447da9ce0 Improve mouse support
Mouse:
- add `shift` state in all mouse events
- pass `QEmacsState *qs` to `qe_mouse_event`
- support non drag mouse events with `-m:2` command line option
- dragging beyond window borders generates scrolling events
  (should autorepeat, should have menu line at the top for scrolling up)
- cancel active search on mouse_goto
- do not mouse activate window if current active window is modal (popup or
  minibuf)
- handle double and triple click: select by words or lines
- handle shift click: extend selection
- add `EditState::mouse_down_offset` for initial dragging buffer offset
- pass `QEEvent *ev` to `mouse_goto()` handlers

events:
- add synthetic key events: QUIT CLOSE EXIT
- use synthetic events for GUI interaction (no longer simulate keystrokes)

tty:
- fix large OSC sequence support for terminal clipboard retrieval

Multicursor:
- use new `QECursor` for multicursor local states
- reallocate `multi_cursor` array in chunks

misc:
- add `eb_peekc(EditBuffer *b, int offset)`
- boolean cmdline options no longer require an argument, true if none provided
- int cmdline options either require an argument (CMD_LINE_INT_ARG) or take an
  optional argument, value is incremented if argument is not provided.
2024-11-10 00:44:20 +01:00
Charlie Gordon
ad69d01541 Add xterm clipbord support
- add `qe_encode64` and `qe_decode64` utility functions
- add command line option --clipboard to enable/disable tty clipboard support
- add `clipboard` trace option
2024-10-11 09:14:16 +02:00
Charlie Gordon
288eeb450e Improve modern terminal support
- improve ANSI tty and shell buffer escape sequence parser
- detect backspace/delete input setting from termios structure
- renumber special keys, remove redundant definitions
- handle shift state modifiers generically
- support tty `modifyOtherKeys` key encoding
- support tty `CSI u` key encoding
- simplify x11 key handling
- simplify haiku key handling (untested)
- bump VERSION to 6.3.1
- rename `insert-color` as `read-color`, insert code on `C-u C-c #`
- simplify string to key conversions
- improve CSI and OSC sequence support (ESC ] ... ^G or ST)
- `do_toggle_control_h()` should just toggle `ts->term_flags & KBS_CONTROL_H`
2024-09-25 01:02:14 +02:00
Charlie Gordon
16b6d8f1f6 Add StringArray functions
- add `sort_strings()` and `remove_duplicate_strings()`
2024-09-07 18:40:44 +02:00
oguillaumin
574cb4ac0f Add utility functions
- `canonicalize_path` returns destination array
  allow for destination to overlap source
- `qe_strcollate` compare directory name before contents
  this fixes the pathnames sorting
- add `get_relativename(filename, dirname)`
2024-08-31 13:49:00 +02:00
oguillaumin
17b0c4803d Add sreg_match(): simple regular expression matcher
Simple regexp patterns use a subset of POSIX regexp:
- only simple character classes, no escape sequences
- no assertions (except $), no backreferences
- embedded groups always generate maximal matches which
  may cause the outer expression to fail match
2024-08-31 13:49:00 +02:00
oguillaumin
e77e21bffd Select region on shifted cursor movement keys 2024-08-31 13:49:00 +02:00
oguillaumin
494ea38c33 Improve memory allocation APIs
- replace `qe_malloc_dup()` with `qe_malloc_dup_bytes()` and `qe_malloc_dup_array()`
- replace `qe_realloc()` with `qe_realloc_bytes()` and `qe_realloc_array()`
- pass numbers of objects to `qe_malloc_dup_array` and `qe_realloc_array`
- add `qe_strndup()`
2024-08-31 13:49:00 +02:00
Charlie Gordon
4be625f5c4 Improve macro handling
* add `macro-counter` variable
* add `QEState` fields `nb_macro_keys_run`, `macro_counter`, `macro_format`.
* add `int find_key_suffix(const char *str, char c)`
* pass `argval` to `do_call_last_kbd_macro` to handle early exit
* add `clear_macro`, `stop_macro`
* add `int check_format_string(const char *fmt, const char *template)`
* do not use `alloca` for `eb_vprintf`
* add `dbuf_str(db)`: null terminate the buffer and return a string pointer.
* add macro commands:
  `edit-last-kbd-macro`, `name-last-kbd-macro`, `insert-kbd-macro`,
  `read-kbd-macro`, `macro-add-counter`, `macro-set-counter`,
  `macro-insert-counter`, `macro-set-format`
* `start-keyboard-macro` restarts macro learning mode if learning already
* add documentation on macro commands
* stop macros upon errors (when ringing the bell)
* stop macros if prompting the user for confirmation
2024-07-28 00:00:03 +02:00
Charlie Gordon
af64810cb4 Add documentation on utility functions
* add `int ustr_get_identifier_x(dest, size, c, str, i, n, c1)`
* add `int cp_skip_blanks(const char32_t *str, int i, int n)`
2024-07-28 00:00:03 +02:00
Charlie Gordon
65e1bfcea7 Improve buf_t API and documentation
* rename `buf_encode_byte()` as `buf_quote_byte()`
* change `buf_printf` return value for consistency
* let `strquote` always return the length of the conversion like `snprintf`
2024-07-28 00:00:03 +02:00
Charlie Gordon
ceb6b3370f
Add *equivalents* for compare-windows (#27)
*equivalents* are strings that should compare equal in a `compare-windows`
session. You can define such strings in a **.qerc** file in the directory of
one of the files being compared.  This helps ignoring known changes such as
type of function renaming... Here is an example to help compare files between
the `bellard/quickjs` and the `quickjs-ng/quickjs` repositories:
```
define_equivalent("JS_DupValue(ctx, ", "js_dup(");
define_equivalent("JSValue", "JSValueConst");
define_equivalent("JS_NewInt32(ctx, ", "js_int32(");
define_equivalent("JS_NewInt32(ctx,\n", "js_int32(");
define_equivalent("JS_NewUint32(ctx, ", "js_uint32(");
define_equivalent("JS_NewUint32(ctx,\n", "js_uint32(");
define_equivalent("JS_NewBool(ctx, ", "js_bool(");
define_equivalent("JS_NewFloat64(ctx, ", "js_float64(");
define_equivalent("JS_EXTERN ", "");
define_equivalent("JS_EXTERN JS", "JS");
define_equivalent("JS_EXTERN JS_", "JS_");
ignore_equivalent = 1;
```
Other changes were necessary for proper utf8 skipping:
- add `utf8_prefix_len(str1, str2)` to compute the length of a common initial
  prefix not falling inside UTF-8 encoded codepoints.
- add `utf8_decode_prev` to get the previous codepoint
- add `eb_match_str_utf8_reverse`
2024-05-19 21:16:37 +02:00
Charlie Gordon
8994456e62 Fix clang compiler warnings
- add fallthrough pseudo keyword
- fix some macro issues
- fix compiler warnings
2024-02-10 20:29:26 +01:00
Charlie Gordon
d9633d761a Sundries
* update README.md and TODO.md
* study alternative key mapping scheme
* some constifications
2023-03-09 12:38:45 +01:00
oguillaumin
f36144d6a8 Change license to MIT
* bumped VERSION to 6.0.0
2023-03-05 02:04:02 +01:00
Charlie Gordon
d0f7b7a904 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
Charlie Gordon
216b3ff8b7 Fix gcc 12.2 insane optimisation issues fixes issue #11
* use memcpy and other value casts to avoid strict aliasing violations.
  gcc 12.2 was wrongly assuming that utf8_decode(&p) did not modify p
  because *pp was never explicitly set, albeit *(const u8 **)pp = p; was
  storing te updated value of p into it and the code generated for that
  was produced.  The code generator was miscompiling strtokey1 because
  the compiler relied on bogus code analysis at the call site.

  The gcc team is wasting many hours of valuable debugging time.
  They should at least issue a warning about aliasing rules violations.

* fix compiler warning on missing Xvideo header

* fix compiler warning on missing fallthrough

* bump version to 5.4.1c
2022-11-11 17:49:50 +01:00
Charlie Gordon
138be0a3ca Improvements in search functions
* eb_get_region_contents and eb_get_contents take an extra argument
  encode_null to encode embedded null bytes as "\xC0\x80"
* use steps instead of flags for isearch state array:
  max 256 code points, 512 steps and 768 search bytes
* add remove_string() to remove a string from a StringArray and pack the array
* rename get_history() as qe_get_history() and make it public
* prevent multiple registration of command tables in qe_register_commands()
* silence compiler warning on array size in charname_complete()
* remove last_search_u32 data, use search history list instead
* restrict search commands to the current region if highlighted

* bump version to 5.4.1b
2022-11-11 15:45:49 +01:00
Charlie Gordon
60390867ae Use wide char specific classification and case functions
* qe_toupper and qe_tolower handle only ASCII subset
* add qe_wtolower() and qe_wtoupper() for Unicode case conversions
  current implementation is partial
* handle accents in qe_wtolower() and qe_wtoupper() only
* add qe_iswalpha(), qe_iswlower() and qe_iswupper()
* restrict filename lowercasing kludge in reduce_filename()
* restrict qe_findchar() and qe_indexof() to ASCII subset
* rename functions:
   eb_match_str  => eb_match_str_utf8
   eb_match_istr => eb_match_istr_utf8
   strimatch_pat => utf8_strimatch_pat
   ustr_get_word => utf8_get_word
   wctoupper     => qe_wctoupper
   wctolower     => qe_wctolower
   strimatch_pat => utf8_strimatch_pat
   str_get_word  => str_get_word7
* handle accented letters in buffer casing functions
2022-11-01 01:19:32 +01:00
Charlie Gordon
9376e4be76 Handle accented letters in case functions
* add wctoupper() and wctolower()
* add qe_unaccent(c);
* use ligature functions for the above
* handle accents in qe_toupper() and qe_tolower()
* add convert_entry() method in CompletionDef
* pass CompletionDef pointer to minibuffer_edit callback
2022-10-31 10:59:11 +01:00
Charlie Gordon
47cc1d4052 Allow Unicode character names in insert-char, with completion
* add pattern matching in completion using *
* add `C-x 8 RET` binding for `insert-char`
* add charname completion
* add CT_GLOB and CT_IGLOB enumeration modes
* use CT_STRX for more completions
* add strmatch_pat() and strimatch_pat() utility functions
* add open_resource_file()
2022-10-30 21:18:39 +01:00
Charlie Gordon
7e70e611b6 Use char32_t for all code point variables and arrays
- char32_t is defined in cutils.h but may conflict with <uchar.h>
- all qe_isxxx functions take a char32_t
- add etf8x encoding for full range of char32_t type
- add utf8_decode_strict()
- add ustr_match_keyword()
- utf8_encode() / utf8_decode() handle up to 32 bits
- improve detect_charset():
  - detect utf8 and utf8x
  - avoid failure on partial utf8 sequence at end of buffer
  - detect overlong utf8 sequences
- fix display bugs for code points beyond MAX_UNICODE_DISPLAY
- simplify do_compare_windows(), avoid magic char values.
- rename functions:
    eb_encode_uchar -> eb_encode_char32
    eb_insert_uchar -> eb_insert_char32
    eb_insert_uchars -> eb_insert_char32_n
    eb_match_uchar -> eb_match_char32
    eb_delete_uchar -> eb_delete_char32
    eb_replace_uchar -> eb_replace_char32
    utf8_to_unicode -> utf8_to_char32
- use char32_t for all variables and arrays holding code-points
- fix some language syntax parsers.
- fix detect_eol_type_32bit(), used uint16_t instead of uint32_t
- bump VERSION to 5.4.0
2022-10-29 19:43:38 +02:00
Charlie Gordon
0099f138c9 Move UTF-8 utility functions to util.c
- simplify utf8_decode()
- simplify longest common prefix code in do_minibuffer_complete
- remove redundant include files
2022-10-17 18:38:21 +02:00
Charlie Gordon
c561a42273 Reduce header file dependencies
- remove redundant include files
- no longer include qe.h in charset.c, libqhtml
- add unicode_join.h for bidir definitions
- move QASSERT, MAX_WORD_SIZE, MAX_FILENAME_SIZE from qe.h to util.h
- move CompleteState and CompleteFunc to util.h
- bump VERSION to 5.3.4z
2022-10-15 19:32:59 +02:00
Charlie Gordon
1beb610d76 Update glyph width methodology
- rename unicode_tty_glyph_width() as qe_wcwidth()
- compute tables for qe_wcwidth() with tools/unicode_gen.c
  from the latest Unicode version
- add qe_wcwidth_variant() to determine if terminal may use
  incorrect width for a given glyph.
- reposition TTY cursor for glyphs with ambiguous width
- remove unicode_width.h
- add wcwidth.h and wcwidth.c generated by tools/unicode_gen.c
- update tools/unicode_gen.c and tools/unitable.c
- determine Unicode version support at start time
  displayed by describe-screen command
- display code point width and variant in what-cursor-position command (C-x ?)
- bumped VERSION to 5.3.4x
2022-09-27 22:30:05 +02:00
Charlie Gordon
d1fb4dde64 Add macros for block comparison, copy and move
After spending a few hours debugging a stupid memcpy size error, I
decided to use a typed version of memcpy, memcmp and memmove wherever
the array type size is greater than 1.

- add blockcmp(p1, p2, n), blockcpy(p1, p2, n), blockmove(p1, p2, n)
  for operation on typed arrays
- add max_uint() and min_uint()
- bumped VERSION to 5.3.4w
2022-09-27 09:32:41 +02:00
Charlie Gordon
298cd473e1 Small changes
- favor using cutils.h over util.h
- small improvement in bidi class lookup functions
- bumped VERSION to 5.3.4v
2022-09-20 13:15:53 +02:00
Charlie Gordon
bd50376780 Various improvements
- add charset.h
- add tools/unitable.c to compute unicode_width.h
- add tools/unicode_gen.c to compute more unicode tables
- use Unicode 15.0.0
- add rules to compute width tables from Unicode tables and TTY
- move basic definitions from util.h to cutils.h
- use CONFIG_SESSION for session support (undefined if CONFIG_TINY)
- define CompleteFunc and CT_xxx flags for completion functions
- pass CompleteFunc to xxx_complete() functions
  this allows more generic implemetation, without including qe.h
- rename fill_border() as fill_window_slack() for readability
- add QELEVEL environment variable to detect recursive invocation
- use stricter parser for load_ligatures()
- bump VERSION to 5.3.4u
2022-09-19 15:16:59 +02:00
Charlie Gordon
b8f81236cd Split util module
- split color/css functions from util.c into color.c
- add util.h and color.h for declarations
- util.c no longer includes qe.h
- move get_clock_ms() and get_clock_usec() to unix.c
- remove unused QString functions
- bump VERSION to 5.3.4s
2022-09-15 11:28:34 +02:00