Commit graph

142 commits

Author SHA1 Message Date
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
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
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
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
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
893653c71d Merge branch 'master' of github.com:qemacs/qemacs 2022-08-31 23:33:42 +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
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
Charlie Gordon
7aca319d3c Fix backspace behavior over wide glyphs
- add qe_iswide()
- add eb_next_glyph() / eb_prev_glyph()
- use a larger unicode_glyph_range_index[] array
- add s->cur_offset_hack to track when current position is in
  the middle of a wide glyph
- pass w to qe_term_overwrite(): erasing 1 or 2 positions
- erase partially overwritten wide glyphs
- remove qe_term_put_char()
- bumped version to 5.3.4d
2022-08-29 02:55:50 +02:00
Charlie Gordon
36d3644dbe Fix behavior on special glyphs
- add eb_skip_accents(), eb_skip_glyphs(), eb_delete_glyphs()
- overwriting a character with accents replaces it completely
- C-d deletes characters along with subsequent accents
- handle wide characters and accents in shell console
- handle repeated wide characters
- use Hex in trace_buffer for non-ASCII bytes
- bumped version to 5.3.4c
2022-08-28 20:28:40 +02:00
Charlie Gordon
0b61bbb0c5 fix gcc warning 2022-08-27 20:36:44 +02:00
Charlie Gordon
ee60fcd046 Improved TTY key decoding
- get_str() returns byte count
- add KEY_xxx definitions for SHIFT, CTRL and SHIFT+CTRL cursor keys
- allow KEY_META() for cursor and function keys
- add 'key' tracing option
- improve trace output readability
- add KEY_UNKNOWN for unrecognized TTY sequences
- add unknown-key command to display unknown key details
- add buf_encode_byte() to share code
- recognise M-ESC

Improve config file parsers:
- add full-version global variable for tests in config file
- no longer display configuration file errors in tqe
- recognise variable setting syntax in tqe
  handle tab-width, default-tab-width, indent-tabs-mode, indent-width

- bump VERSION to 5.3.4
2022-08-27 20:11:38 +02:00
Charlie Gordon
3bbee69742 Multiple improvements
improve command and bindings registration:
- simplify command and binding registration APIs
- add bindings member in ModeDef structures
- rename qe_register_cmd_table() as qe_register_commands(), change API
- add qe_register_bindings() taking mode, command-name and bindings string
- rename qe_mode_set_key() as qe_register_command_binding()

improve buffer listing:
- add BF_SHELL buffer flag for shell buffers
- show current directory of shell buffers in bufed

improve dired:
- add dired-hide-details-mode on "("
- use details_mask to control long listing

improve trace doctor:
- add EB_TRACE_DEBUG trace flag for debugging traces
- add do_set_trace_flags()
- change do_start_trace_mode() to do_toggle_trace_mode() with arg

misc:
- fix make_user_path() for pathnames without a trailing slash
- use separate commands for prefix_argument handling
- improve strstart(), strend(), pstrcpy(), pstrncpy(), get_dirname()
- add strmatchword() like strstart with check for word boundary
- bumped version to 5.3.3d
2022-08-22 17:13:26 +02:00
Charlie Gordon
4e5e42d2ea Colorize apropos window
- split eb_command_print_entry from command_print_entry
- split eb_variable_print_entry from variable_print_entry
- fix eb_sort_span to handle static styles
- match description strings in apropos
- use eb_xxx_print_entry in apropos to share code and colorization
- bumped version to 5.3.2d
2022-08-18 14:59:10 +02:00
Charlie Gordon
f7c1621ebb Improve paragraph handling
- simplify do_delete_blank_lines(), fix case of non blank line
- remove eb_start_paragraph()
- do_mark_paragraph() takes ARG_VAL, make emacs compatible
- simplify eb_prev_paragraph(), make emacs compatible
- improve fill_paragraph():
  compute actual indent size (handle TABs)
  compute actual word sizes (handle accents and double width glyphs)
- bumped version to 5.3.1j
2022-08-13 16:16:21 +02:00
Charlie Gordon
d052ab31ff Fix many compilation warnings for clang -Weverything
- made some local objects static
- fix many const cast issues
- fix comma operator warnings
- add const correct strtol_c(), strtoll_c(), strtold_c()
- add unconst(t) to override const removal warnings
- comment VLAs and flexible arrays
- use get_basename_offset() to enable const correct
  get_basename() and get_basename_nc()
- use get_extension_offset() to enable const correct
  get_extension() and get_extension_nc()
- always include config.h
- use size_t for some size arguments:
  umemmove(), umemcpy(), umemcmp(), qe_memicmp()
- add qe-doc.info and qe-doc.pdf targets
- fix shadowing bug in buf_write: used tor return 0 instead of byte count
- bumped version to 5.3.1e
2022-08-10 18:50:19 +02:00
Charlie Gordon
e08de03499 updated credits and copyrights 2022-08-03 17:00:38 +02:00
Charlie Gordon
b72b1773db Fix gcc compilation
- be more careful about snprintf target arrays
- fix bug in qe_load_file(): was testing local array instead of argument
- remove unused indent variable in clang.c
- pass pointer to CSSFile in css_close()
2022-08-03 16:47:12 +02:00
Charlie Gordon
e13fcfb543 remove trailing blanks 2020-10-21 15:01:52 +00:00
Charlie Gordon
d0b9f3dad4 bumped copyrights on modified files 2020-10-17 21:09:49 +00:00
Charlie Gordon
6e0564d4ed Improve completion system
- pass CompleteState to print_entry() handler
- remove list_get_colorized_line()
- remove get_colorized_line() window handler
- add colorize_mode along with colorize_func
- add list_display_hook() to fix list mode navigation
- rename generic_get_colorized_line() as get_colorized_line()
- fix memory leak in eb_add_property()
- pretty print tags in tag_complete() and list_tags()
2020-10-17 20:55:47 +00:00
Charlie Gordon
9d967ad29c Improve completion system
- rename and extend CompletionEntry as CompletionDef
- create xxx_completion CompletionDef structures
- rename xxx_completion() functions to xxx_complete()
- register CompletionDef structs with qe_register_completion()
- add (start, end) range in CompleteState
- use eb_puts() and eb_putc() instead of eb_printf()
- simplify eb_delete_chars()
- ignore left pane in compare-windows()
- simplify qe_list_bindings()
- improve command and variable completion popup
2020-10-17 15:41:31 +00:00
Charlie Gordon
128d0c28dd build: use CONFIG_MMAP when unmapping buffer data in eb_clear() (F.Revol) 2017-05-07 06:08:57 +00:00
Charlie Gordon
d329669530 buffer: new APIs
- int eb_insert_uchars(EditBuffer *b, int offset, int c, int n);
- int eb_replace_uchar(EditBuffer *b, int offset, int c);
- inline eb_insert_spaces() using eb_insert_uchars() instead
- add minp(), maxp() and clampp() with side effect on first argument
- publish ucs2 and ucs4 charsets
2017-04-25 16:46:41 +00:00
Charlie Gordon
eacb2ad6e0 shell: major improvements in tty emulator
terminal emulator:
- add EditState.cols and EditState.rows: window dimensions in characters
- pass target window to new_shell_buffer()
- use window size for shell terminal emulator initial screen size
- set COLUMNS and LINES environment variables for child processes
- factorize emulator character output
- increase number of CSI arguments
- simplify and improve CSI m argument processing including
  multiple argument sequences
- minimal support for `:` as argument separator eg:
  \033[38;5;128:128:128m
- support erase line vt100 command:
  \033[K, \033[0K erase end of line
  \033[1K         erase beginning of line
  \033[2K         erase complete line
debugging:
- pass string argument to set-trace: on, off or list of trace indicators
- remove doctor command
- add QE_TRACE_EMULATE for emulator trace messages
- fix incorrect uses of eb_delete()
2017-04-21 14:44:14 +00:00
Charlie Gordon
e71273f3af syntax: improve tag display
- increase identifier buffer lengths
- fix some bugs in buffer property handling
2017-04-17 09:16:24 +00:00
Charlie Gordon
84547c6209 build: fix compile time warning
- fix some warnings on unused variables and variables potentially
  used before set
- force definition of va_copy() and atomic_get_and_set() for haiku
2017-04-15 09:39:02 +00:00
Charlie Gordon
b39607410e fixed compilation warnings 2017-04-14 06:59:17 +00:00
Charlie Gordon
6c595c1f2c colors: extend color system
- add 8K color modes and 64-bit QETermStyle values
- add 64-bit buffer style support
- reduce colored character system used in syntax handlers to 8-bit style
  and 24-bit code point
- use QETermStyle type instead of int wherever a composite style is used
- force color system used by the terminal with environment variables:
  USE_16_COLORS=1, USE_256_COLORS=1 or USE_TRUE_COLORS=1
2017-04-12 07:33:20 +00:00
Charlie Gordon
799b1489bc display: full support for 256 color virtual terminal
- add various utilities for color escape sequence testing:
  tests/16colors.pl
  tests/256colors2.pl
  tests/color-spaces.pl
  tests/truecolors.sh
  tests/xterm-colortest.sh
  tests/xterm-colour-chart.py
- use colored code-points only for syntax highlighting
- use QETermStyle and QEStyleDef internally
- convert to TTYChar attributes only for text terminal output.
- remove most CHAR_MASK and STYLE_SHIFT handling
- pass QETermStyle array to get_colorized_line mode handlers
- pass QETermStyle array to isearch_colorize_matches
- remove combine_static_colorized_line
- move color matching functions to util.c
- rename get_tty_color as qe_map_color
- improve local variable naming consistency:
  DisplayState *ds, QEStyleDef *stp, QEStyleDef styledef.
2017-04-03 08:33:57 +00:00
Charlie Gordon
35d2610146 clang: add primitive tag support
- add buffer properties with offset tracking
- use buffer properties for type, macro, function and object definitions.
- display current function or type name on mode line
- add list-tags command to show the tags detected for the current buffer
- add goto-tag on C-X , and M-F1 to jump to the definition of the current word
- add find-tag on C-X . to search for a given tag with completion
2017-03-31 07:51:56 +00:00
Charlie Gordon
d06fdbfd14 basic: changed API for popup windows
- pass current window to show_popup()
- remove show_ptr argument from new_help_buffer()
- call show_popup() unconditionally
- add int eb_vprintf(EditBuffer *b, const char *fmt, va_list ap);
2017-03-26 15:57:24 +00:00
Charlie Gordon
c5a3bb8ecb updated heading 2017-03-25 18:14:59 +00:00
Charlie Gordon
6a7ac743a4 shell: fix crash on large process output
- fix `eb_fgets()`: used to return out of bound length.
2017-01-03 04:55:24 +00:00
Charlie Gordon
79bf90c8d6 basic: simplifications
- remove `eb_nextc_style()`
- `eb_nextc()` does not modify `b->cur_style`
- add `eb_get_style()` to retrieve style for given offset in full-style buffers
- add `eb_next()` and `eb_prev()` to skip chars
- pass `offset` to `eb_get_line()` and `generic_get_colorized_line()`...
- use `eb_skip_chars()` in `do_delete_char()` and `text_write_char()`
- replaced `eb_get_strline()` with `eb_fgets()` with similar semantics
  except return value is number of bytes before the newline or end of line
- no longer pass end offset to `isearch_colorize_matches()`
- just pass number of code points to `combine_static_colorized_line()`
- no longer call `isearch_colorize_matches` from `generic_get_colorized_line`
2016-12-23 19:51:48 +00:00
Charlie Gordon
71ab83a208 display: optimize low level buffer content read functions
- remove style handling from eb_nextc()
- add eb_nextc_style()
2016-12-13 17:20:51 +00:00
Charlie Gordon
31f4362ce2 shell: improve shell editing, yank kill buffer at shell prompt
- add mode specific `delete_bytes()` method
- reorder `write_char()` and `mouse_goto()` mode methods
- pass `keep` argument to `do_kill()`
- pass `argval` to `do_kill_line()`
- add `do_kill_beginning_of_line()` command
- allow kill commands in read-only buffers, copies contents to kill-ring and
  moves point.
- change `do_kill_line()` semantics when invoked with numeric argument
- add `cur_prompt` and `last_char` in ShellState to track start of
  shell input line
- C-a moves to start of shell input, exits interactive mode if there already
- force interactive mode on shell-end-of-line and shell-end-of-buffer
- simplify shell_write_char(), remove hard coded dispatcher
- add `shell_delete_bytes()` to delete contents in shell input line
- change shell-kill-word and shell-kill-line to not rely on mode specific
  cursor movement commands because of asynchronous behavior.  This is also
  a problem for macros
- make shell-yank insert data via shell input.
- pause for 1ms after each CR sent to the process
2016-06-07 08:56:39 +00:00
Charlie Gordon
b962e33ade updated copyrights 2016-03-06 19:53:06 +00:00
Charlie Gordon
bb96ec15af shell: fixed colors for libcaca output
- increase number of ANSI escape arguments to 6
- added debug traces for unhandled escape sequences
- wrap traces before 80 columns in *trace* buffer
2016-03-06 17:42:26 +00:00
Charlie Gordon
1f5a77a784 portability: stop defining symbols starting with __ 2015-09-16 22:18:22 +00:00
Charlie Gordon
9b433ae687 sessions: implement session saving/restoring
- add qe_save_variables(s, b)
- add use_session_file global variable
- add VarDef::modified flag to detect customized variables
- set modified flag upon variable modifications
- dired: set modified flag when changing in dired variables
- fix BUG in qe_register_variables, did not set set_value handler
  on last VarDef element
- make qe_save_variables() public
- remove do_save_variables(), move save_session() to parser.c
- add eb_puts() and eb_putc() for consistency
- add WF_HIDDEN window flag to temporarily flag windows to be deleted
- add do_hide_window(), do_delete_all_windows() and do_delete_hidden_windows()
- add qe_save_window_layout() to save window layout to session file
- add do_create_window(s, filename, layout) to restore window layout
- add qe_save_macros() to save keyboard macros to session file
- detect keyboard macro redefinitions and avoid duplicates
- add qe_save_open_files() to save list of open files and directories
- pass `all` flag to do_delete_other_windows() to force complete deletion
- add qe_load_session() and do_save_session():
  * qe_load_session() is invoked before parsing the command line if
    use_session_file is set, via the config file or command line option (-s)
  * do_save_session() is invoked just before closing qemacs.  It can also
    be invoked as a command and shows a popup window with the contents of
    the session file produced instead of saving it.
- fix CRASH BUG in command definitions, missing argument specifier caused
  spurious crashes when invoking commands from script files. This affected:
  find-file(), find-file-other-window(), find-alternate-file(), kill-buffer()
  load-file-from-path().
- insert newly created windows in list in top-down left-right order
- update WF_RSEPARATOR flag upon deletion of vertically split window
2015-09-10 00:25:23 +00:00
Charlie Gordon
f0aa3a4bd8 cosmetics: untabify, remove trailing spaces 2015-08-27 23:03:39 +00:00
Charlie Gordon
581eef3b5d buffers: fix improbable bugs
- make kill buffers system buffers (not displayed in buffer-list)
- only create *scratch* buffer in qe_kill_buffer() if needed
- prevent crash if killing style, log or kill buffers
- display \n as ^J in minibuf
2015-08-27 22:51:56 +00:00
Charlie Gordon
060f860756 fix more linux compilation warnings 2015-08-27 18:59:56 +00:00
Charlie Gordon
9ab179d048 fix linux compile warnings 2015-08-27 18:52:30 +00:00
Charlie Gordon
9331372a54 modes: upgrade mode selection and handling
- separate buffer and window specific mode data management, new API:
   QEModeData *qe_create_buffer_mode_data(EditBuffer *b, ModeDef *m);
   void *qe_get_buffer_mode_data(EditBuffer *b, ModeDef *m, EditState *e);
   QEModeData *qe_create_window_mode_data(EditState *s, ModeDef *m);
   void *qe_get_window_mode_data(EditState *e, ModeDef *m, int status);
   int qe_free_mode_data(QEModeData *md);
- make a list of buffer specific mode data areas so multiple major modes
  can co-exist in different windows for the same buffer
- add mode.mode_free callback to release buffer specific resources
- remove buffer.close callback
- shell state is now buffer specific shell_mode data
- clean up compress and archive mode
- show more buffer modes in buffer-list
- simplify edit_set_mode(), display error message on failure
2015-08-27 15:31:59 +00:00