Commit graph

1,194 commits

Author SHA1 Message Date
Charlie Gordon
b321c1923a increase string lengths in script fragments
* bump buffer size from 256 to 2048 in format and variable retrieval
* number VERSION to 5.4.1g
2023-03-04 15:59:09 +01:00
Charlie Gordon
c223ed2760 small changes in unicode_join:
* use more consistent names
* use incl/excl range in binary searches
2023-03-03 20:10:10 +01:00
Charlie Gordon
e25667c577 Fix eval_region
* factorize evaluation result handling
* make QEValue.type signed to handle TOK_ERR and TOK_EOF
* extract buffer contents as UTF-8
* eval-region and eval-buffer take universal argument to insert expression
  result instead of showing as message
2023-02-24 12:14:40 +01:00
Charlie Gordon
bf0c938d19 Sundries
* bind `eval-region` to `M-C-z`
* fix configure and Makefile for arm64 target
* output selected target in configure

* bump version to 5.4.1f
2023-02-21 15:04:55 +01:00
Charlie Gordon
2231ae93f6 Improve qscript language and support
* add multi-line strings with """ syntax and escaped newlines
* call commands with allocated string arguments instead of local arena
* improve triple quoted string support in C like colorizers
* increase SEARCH_LENGTH to 2K (should use allocated arrays)
* fix kill-matching-lines definition
* fix utf8_to_char32 implementation inconsistency for empty destination
* fix buffering errors in eb_insert_utf8_buf() and eb_insert_char32_buf()

* bump version to 5.4.1e
2022-11-22 23:21:28 +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
6880277ec0 Improvements in search functions
* add search modes:
  copy-matching-lines, kill-matching-lines, list-matching-lines
  - add enum for search modes

* add search flag support in all search functions:
    search_forward, search_backward, count-matches, delete-matching-lines,
    delete-non-matching-lines, copy-matching-lines, kill-matching-lines,
    list-matching-lines, query-replace, replace-string
  - highlight matches during search string input
  - add search flag toggle functions in minibuffer_edit
    same code and bindings as for incremental search
  - add handlers in CompletionDef for minibuffer_edit session start and end
  - use generic search tag system to store flags in search string

* misc improvements and bug fixes:
  - test and set append-next-kill on kill-region
  - split `do_copy_region` from `do_kill_region`
  - remove argument in `do_kill_region` for `kill-region`
  - change immediate string argument code letter from 'S' to '@'
  - exit popup with do_popup_exit() in do_keyboard_quit
    remove popup_mode binding
  - add ESiii and ESsii command calling conventions
  - pass key and argval to:
    minibuffer_complete, do_minibuffer_complete_space,
    do_minibuffer_electric_key

* add default bindings:
    `next-error` on `M-g n`, `M-g M-n`
    `previous-error` on `M-g p`, `M-g M-p`
    `goto-line` on `M-g g`, `M-g M-g`, `C-x g`
    `goto-char` on `M-g c`

* bump version to 5.4.1a
2022-11-06 12:08:19 +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
7b6b5ed1e3 Disable Unicode terminal version detection
- disable Unicode version detection and reporting
- bump VERSION to 5.3.4y
2022-10-04 14:59:21 +02:00
Charlie Gordon
0a06b457ff Fixed crash bug on HTML files 2022-10-04 14:55:38 +02:00
Charlie Gordon
0be702e51b use UTF-8 in uppercase in comments 2022-10-04 14:53:25 +02:00
Charlie Gordon
d2c8ee3a9f fix bidir table size output 2022-10-01 16:02:52 +02:00
Charlie Gordon
ea9dd8ec90 Fix linux compilation problems
- remove unused variables
- create unidata directory when retrieving Unicode files
2022-10-01 15:57:59 +02:00
Charlie Gordon
fd76eae931 Small fixes
- fix warnings in tools/cptoqe.c
- fix signed char issue in tools/kmaptoqe.c
- fix optional argument parsing in tools/unicode_gen.c
- generate qe_bidir_get_type() and qe_bidir_get_type_test()
  functions for bidir_tables target
2022-10-01 15:35:23 +02:00
Charlie Gordon
490ebfbb0b Fix gcc warning. Fixes issue #9 2022-09-29 12:19:58 +02:00
Charlie Gordon
7e12eb51b2 add include guard in wcwidth.h 2022-09-27 22:38:29 +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
Charlie Gordon
a402c88341 Start a Quick Emacs Manual
- add tools/scandoc utility to extract doc comments from source code
- add qe-manual.c documentation framework
- add qe-manual.md target for convenient repository documentation
- document some utility functions
- add strtod_c(str, endp) for const strings
- add Makefile target qe-manual.md
- bump VERSION to 5.3.4r
2022-09-13 15:29:40 +02:00
Charlie Gordon
c7eaddf6dd Fix small isearch details
- remove opaque argument in exec_command()
- remove CMD_ISS and CMD_ISSi command signatures
- pass window pointer to isearch_xxx() functions
- isearch-exit() takes key, sets mark where search started;
  used for exiting incremental search on other commands.
- isearch-cancel() takes point back where search started;
  used for isearch-abort()
- handle prefix argument in query-replace (word match)
- add query_replace_help() on '?', C-h, f1
- remove dead code
- bump VERSION to 5.3.4q
2022-09-10 15:33:16 +02:00
Charlie Gordon
0bd17d54b4 Fix small esearch details
- remove opaque argument in exec_command()
- remove CMD_ISS and CMD_ISSi command signatures
- pass window pointer to isearch_xxx() functions
- isearch-exit() takes key, sets mark where search started;
  used for exiting incremental search on other commands.
- isearch-cancel() takes point back where search started;
  used for isearch-abort()
- handle prefix argument in query-replace (word match)
- add query_replace_help() on '?', C-h, f1
- remove dead code
- bump VERSION to 5.3.4q
2022-09-09 10:07:57 +02:00
Charlie Gordon
fc94bb5cab Fix compilation warning
- refuse empty string in describe_key_briefly()
2022-09-08 14:40:43 +02:00
Charlie Gordon
f8392d133b Improve describe-key-briefly, fix eb_printf
- fix prefix argument handling for describe-key
- echo prefix keys after "Describe key: " prompt
- move session commands to qe.c, remove them from tqe
- use byte_quote() in do_describe_buffer()
- use b->offset to track insertions in describe-xxx commands
- eb_putc(), eb_puts() and eb_printf() insert at `b->offset` instead of `b->total_size`
- do not use eb_write() in eb_trace_bytes()

- bump VERSION to 5.3.4p
2022-09-08 13:47:02 +02:00
Charlie Gordon
8c08dae0b0 Only report errors when evaluating configuration files
- fix has_linum_mode(), was reporting incorrect value
- put_error() messages are also reported as status messages
- qe_parse_script() reports parsing errors with put_error()
- prevent potential infinite loop in shell_mode_free()

- bump VERSION to 5.3.4o
2022-09-06 22:19:03 +02:00
Charlie Gordon
d3136a4d33 Fix line number display
Change the settings controlling the display of line and column numbers
to mimic the behavior of emacs linum-mode:

- add global states:
  - line-number-mode: control the display of line number in mode lines
  - column-number-mode: control the display of column number in mode lines
  - global-linum-mode: control the display of line numbers in the gutter
    space for all regular buffers.
- add a buffer state:
  - linum-mode: control the display of line numbers in the gutter space for
    this buffer (overrides global-linum-mode when set).

- add commands to toggle or set these states:
  - line-number-mode
  - column-number-mode
  - global-linum-mode
  - linum-mode

- rename filter-matching-lines as delete-non-matching-lines (emacs name)

- bump VERSION to 5.3.4n
2022-09-06 09:51:16 +02:00
Charlie Gordon
e7c7a14400 Improve qescript parser and evaluator
- improve operator lexer: produce token and precedence on 1 step
- merge parser.c and qescript.c

Fix other bugs
- close display before freeing memory in --free-all
- free TTYState in tty_dpy_close()
- free VarDef memory in --free-all
- fix crash bug on --free-all due to duplicating ModeDef structures

Improve variable handling:
- move do_describe_variable() to variable.c
- add var_alloc and str_alloc flags in VarDef to fix `end` hack
- remove ugly kludge to detect allocated strings
- type variables retrieved from environment
- free variable data on --free-all

- bump VERSION to 5.3.4m
2022-09-05 20:27:48 +02:00
Charlie Gordon
bfdc2717f4 Improve qescript parser and evaluator
- add QEValue utility functions:
  void qe_cfg_swap(QEValue *sp, QEValue *sp1);
  void qe_cfg_move(QEValue *sp, QEValue *sp1);
- add ds->start_line to restart parsing with correct line numbers
- add ds->newline_seen to handle automatic semicolon insertion
- implement skipping in qe_cfg_expr() and qe_cfg_stmt()
- implement comma and ternary operators
- upgrade tqe parser to token based
- fix lexer for multi character operators
- add qe_set_variable_offset() to control setting point and mark
- bump VERSION to 5.3.4l
2022-09-04 20:15:37 +02:00
Charlie Gordon
773df25f85 Fix crash bug (invalid free)
- bump VERSION to 5.3.4k
2022-09-02 23:39:37 +02:00
Charlie Gordon
5fd33711c3 fix crash bug on invalid free 2022-09-02 17:18:23 +02:00
Charlie Gordon
70132748b2 Try and merge config file parsers
- add utility function:
  char *file_load(const char *filename, int max_size, int *sizep);
- publish QEValue, selected TOK_xxx and value setters in qe.h
- add more common functions in parser.c
  qe_cfg_init(), qe_cfg_release()
- add generic argument parser qe_cfg_get_args()
- add conversion functions in qescript.c:
  char(v), int(v), string(v)
- add delim argument in qe_cfg_parse_string() in parse.c
- pass QEmacsDataSource pointer to has_token(), expect_token()

- bump VERSION to 5.3.4j
2022-09-01 22:27:04 +02:00
Charlie Gordon
893653c71d Merge branch 'master' of github.com:qemacs/qemacs 2022-08-31 23:33:42 +02:00
Quick Emacs project home
a464550de7
Merge pull request #7 from cmsigler/snprintf_chk
Eliminate gcc __builtin___snprintf_chk complaints (gcc version 12.1.1…
2022-08-31 23:33:00 +02:00
Charlie Gordon
a4b9a58d2d Try and merge config file parsers
- add byte_guote() to encode a single byte
- encode non ASCII bytes in strquote()
- split function call parse and evaluation into qe_cfg_call() in tqe's parser.c
- use has_token() in full parser
- fix bogus function name in config file parsing errors
- bump VERSION to 5.3.4i
2022-08-31 22:26:38 +02:00
Clemmitt Sigler
d26a43e5d7 Eliminate gcc __builtin___snprintf_chk complaints (gcc version 12.1.1 20220730 (GCC)) 2022-08-31 08:59:39 -04:00
Charlie Gordon
465d30bea7 Simplify prefix argument handling
- move code to do_prefix_argument()
- more qe_ungrab_keys() to isearch_key()
  ungrabing should be based on grab function return value
- an explicit 0 prefix argument prevents command execution
  unless the command explicitly receives the prefix argument
- use code_letter in exec_command(), qe_get_prototype()
- bump VERSION to 5.3.4h
2022-08-31 01:05:36 +02:00
Charlie Gordon
ed67e3a6f3 Fix compilation warnings
- avoid gratuitous C90 incompatibilities
2022-08-30 10:08:23 +02:00
Charlie Gordon
4475afab01 Use isearch pseudo mode for function dispatch
Extend command dispatch system:
- add CMD_ARG_OPAQUE argument type
- add ISS and ISSi command signatures for ISearchState
- add CMDx() macro for disabled and future commands
- restrict command set in parsers
- add opaque argument for exec_command()
- add sort-region command, same as sort-lines

Extend binding system:
- move do_unset_key() from extras.c to qe.c
- accept bindings lists in unset-key commands
- add exact argument for qe_find_binding()
- reorder xxx_bindings arrays

Improve emulation functions:
- improve set-emulation command:
  - add xxx_bindings arrays for emulations
  - add register_emulation_bindings()

Search system:
- use exec_command to dispatch isearch functions
  this allows easy redefinition of bindings, especially
  useful for emacs flavor emulations
- add isearch_commands[] with bindings and command descriptions

- bumped version to 5.3.4g
2022-08-30 10:00:42 +02:00
Charlie Gordon
fc698bd138 Fix compilation warnings
- use correct variable to expand TABs in corner case in VT100 emulator
  thanks to gcc who spotted a variable set but not used :)
2022-08-29 19:02:02 +02:00
Charlie Gordon
e5808368d0 Split isearch_key code into multiple functions
- next step is create non selectable isearch-mode with documented functions
- bumped version to 5.3.4f
2022-08-29 18:45:26 +02:00
Charlie Gordon
4939f6e927 Fix overwrite mode issues
- rename s->insert as s->overwrite with opposite semantics
- fix overwrite mode behavior:
   TABs are filled, then removed
   TABs and newlines are always inserted
   backspace removes TABS and newlines
   backspace overwrite previous glyph with 1 or 2 spaces except at EOL
   backspace only replaces with spaces before a TAB to preserve layout
   quoted-insert always inserts
- quoted-insert inserts special key as escape sequences
- make KEY_UNKNOWN and KEY_NONE special keys matched by KEY_IS_SPECIAL()
- eb_replace() returns the number of bytes written
- add text_screen_width() to compute the actual screen column
- add convenient bindings for laptops with limited special keys:
  - overwrite-mode: C-c o
  - insert-mode: C-c i
  - toggle-read-only: C-c %
  - not-modified: C-c ~
- document set-visited-file-name
- remove filename if set-visited-file-name with an empty string
- simplify eb_insert_uchars()
- bumped version to 5.3.4e
2022-08-29 18:41:29 +02:00