Commit graph

37 commits

Author SHA1 Message Date
Charlie Gordon
f674419e75
Fix put_status/put_error behavior (#47)
* Fix `put_status`/`put_error` behavior

- use `put_error` instead of `put_status` for command errors
- prevent status message output to console during initialization
- use `put_error` for side effects in command errors
- add `&` prefix in status messages to force screen flush
- flush screen in `qe_display()`, remove redundant calls to `dpy_flush`
- fix gcc compilation errors and warnings
- remove most references to `global_screen`
- free font cache before closing the screen
- prevent mouse handling upon focus detection

* drop CI on macos-12
2024-12-03 22:52:55 +01:00
Charlie Gordon
e3c5bfd457
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
Charlie Gordon
0e90c18107 Add support for suspending qemacs
- add `suspend-qemacs` command
- add `dpy_suspend` QEDisplay method to handle suspending qemacs appropriately
- catch `SIGTSTP` and `SIGCONT` to adjust terminal state.
- add `qemacs-version` command
- bump VERSION to 6.3.2
2024-09-25 01:02:14 +02:00
Charlie Gordon
3852fb9c19 Update copyrights 2024-07-28 00:00:03 +02:00
Charlie Gordon
84393d6c4f Add bell sounds
* add `QEDisplay::dpy_sound_bell`
* add `\007` prefix in `put_status` to sound bell
2024-07-28 00:00:03 +02:00
oguillaumin
f36144d6a8 Change license to MIT
* bumped VERSION to 6.0.0
2023-03-05 02:04:02 +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
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
40ba28b979 x11: fix toggle-full-screen (bound to C-c f) 2017-05-21 08:10:37 +00:00
Charlie Gordon
7d7103ca70 graphics: add device and generic picture display functions
- add bitmap formats for 4BPP and BGR combinations
- add color palette in QEPicture
- add xfactor and yfactor in QEDisplay for preferred pixel granularity
  yfactor is typically 2 for text mode display
- add dpy_draw_picture() device function
- add bitmap drawing functions:
    qe_create_picture(int width, int height, QEBitmapFormat format, int flags);
    int qe_picture_lock(QEPicture *ip);
    void qe_picture_unlock(QEPicture *ip);
    qe_free_picture(QEPicture **ipp);
    QE_PAL_MODE(r, g, b, incr)
    int qe_picture_set_palette(QEPicture *ip, int mode,
                    unsigned char *p, int count, int tcolor);
    int qe_picture_copy(QEPicture *dst, int dst_x, int dst_y, int dst_w, int dst_h,
                    const QEPicture *src, int src_x, int src_y, int src_w, int src_h,
                    int flags);
    int qe_draw_picture(QEditScreen *s, int dst_x, int dst_y, int dst_w, int dst_h,
                    const QEPicture *ip,
                    int src_x, int src_y, int src_w, int src_h,
                    int flags, QEColor col);
- add 3 compile time selectable image interfaces in flactal.c benchmark
2017-05-15 09:44:21 +00:00
Charlie Gordon
634d3c9165 graphics: add 1 and 8 bit bitmap formats 2017-05-05 20:07:52 +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
c57a7c6233 display: small fixes for consistency
- add wrappers in display.h
- renamed tty dpy_xxx handlers for consistency
- separate tty_term_resize called on signal and tty_dpy_invalidate
- add dpy_xor_rectangle for software cursor, remove QECOLOR_XOR
2017-04-18 09:14:55 +00:00
Charlie Gordon
5d463eb5ad styles: improve consistency
- rename font styles QE_STYLE_xxx to QE_FONT_STYLE_xxx
- rename font family QE_FAMILY_xxx to QE_FONT_FAMILY_xxx
- improve tests/16colors.pl: display bold italics combination
- improve tests/color-spaces.pl: compare true color and palette dumps
- add colortest target in Makefile to produce various color patterns
2017-04-11 06:46:13 +00:00
Charlie Gordon
4104ab568b display: improve color and style handling
- add support for 256 and true color terminals
- fix color handling for defined styles
- fix bold, italic and underline handling for terminals
- use more explicit symbols for qe-term emulator in shell.c
- shell buffer terminal emulator still uses 16 colors
- display buffer style in C-X =
- bumped version to 0.5.0dev
2017-04-02 01:12:01 +00:00
Charlie Gordon
38fdd559f5 display: improve display structure handling
- add QEDisplay.dpy_describe handler
- rename dpy_init as screen_init
- allocate TTYState instead of using static struct in tty.c
2017-03-15 07:24:31 +00:00
Charlie Gordon
1f5a77a784 portability: stop defining symbols starting with __ 2015-09-16 22:18:22 +00:00
Charlie Gordon
4f47d8b945 portability: avoid using or pseudo-keyword 2015-09-16 21:43:22 +00:00
Charlie Gordon
c5f56a0d5b Fix memory leaks and bad references detected by valgrind
* add free_font_cache()
* add css_free_colors()
* add unload_ligatures()
* add --free-all cmd line option to free memory upon exit for valgrind
* tty.c: fix off by 3 size in qe_realloc. Should be typed
* qe.c: fix invalid pointer reference upon destroying transient buffer
2014-01-24 00:46:26 +00:00
Charlie Gordon
e967914b5a improve consistency in new/delete methodology
* use qe_mallocz for all structures
* prevent spurious uses of malloc/free/realloc
* pass pointers to pointers to all deletion functions
* use consistent patterns for list deletions
* add more dependencies in Makefiles
2014-01-23 12:56:22 +00:00
Charlie Gordon
02da1bb7a1 add generic styles buffer from shell color mode
* styles_buffer hold static style info for each character in the buffer
* new buffer flags to create styles buffers with 1, 2 or 4 bytes per char
* copy static styles to the kill_ring and pasted them style enabled buffers
* preserve static styles in convert-buffer-file-coding-system
* display style bytes in bufed list
* add commands set-region-color, set-region-style, drop-styles
2014-01-15 19:44:24 +00:00
Charlie Gordon
68b4ba44ab fix for C++ compile (needed for Haiku)
renamed private structure members to priv_data
added casts on assignents from void* (OK in C, not in C++)
2013-12-17 16:06:35 +00:00
Charlie Gordon
28397f424f moved input_methods to QEmacsState
qe_register_binding takes ModeDef* and returns status
cosmetic changes in QEDisplay API
added int dpy_init(QEditScreen *s, QEDisplay *dpy, int w, int h);
  copies *dpy (or dummy_dpy if NULL) to QEditScreen and calls method
simplified dpy_init methods and calls
inlined 5 more methods
moved dummy_dpy to display.c and simplified
simplified to_hex
simplified qe_colors array handling
2008-01-11 11:29:28 +00:00
Charlie Gordon
4743fa1308 added remove_slash and append_slash path utilities
renamed canonize to canonicalize
added crude support for ~user -> /home/user
added win32 specific stuff in basename
added C-/ as an alias for C-_
some cosmetics, moved code
create files with mode 0644 in raw_save_buffer
untabified, removed redundant spaces
modified code generators to the same effect
2008-01-03 09:51:29 +00:00
Charlie Gordon
26ea3f69a0 added wrappers and utilities for safer memory allocation:
type *qe_malloc(type);
type *qe_mallocz(type);
type *qe_malloc_array(type, count);
type *qe_mallocz_array(type, count);
type *qe_malloc_hack(type, extra_bytes);
type *qe_mallocz_hack(type, extra_bytes);
void qe_free(&ptr);
void *qe_realloc(&ptr, new_size);
char *qe_strdup(const char *str);
void *qe_malloc_bytes(size_t size);
void *qe_mallocz_bytes(size_t size);
void *qe_malloc_dup(const void *src, size_t size);

pass pointer address to bmp_free()
2007-12-12 11:49:02 +00:00
Charlie Gordon
6c65411200 added missing headings, cosmetics 2007-12-03 16:10:38 +00:00
Charlie Gordon
494e9f7866 include cflags.mk for extra gcc warnings if present
utf8_encode now returns the number of characters copied,
  simplified code accordingly
made local functions static
tagged unused function arguments
fixed shadowing issues
added support for GCC attributes for unused arguments and format strings
use snprintf() instead of sprintf()
moved scattered declarations to qe.h
removed duplicate declarations in header files
eb_write() payload argument is now const
fixed crash bug: reset trace_buffer upon deletion
improved trace_buffer readability: trace all pseudo tty streams separately
added missing structure initializers
removed buffered string handling from cutils.h
added new buffered string API for statically allocated buffers (should unify)
small improvements in X11 initialization
improved consistency in tty.c (function names...)
  added STDIN and STDOUT streams in QEditScreen to stop using stdin and stdout
  use unlocked stream I/O if available (faster)
  changed and documented terminal setup and exit sequences
  improved charset handling
mode_line functions now return the character count (like snprintf)
2006-12-31 19:34:00 +00:00
Charlie Gordon
ade489eba5 msg 2005-07-08 09:30:43 +00:00
Charlie Gordon
f6867f8b51 - Added font locking to fix crash bugs in html/css.
- select_font() now locks the font, which must be unlocked with
  release_font().  Extra locks can be added with lock_font().
- Added release_font() wherever needed.
- Added put_error() to store errors in *errors* system buffer.
- Make put_status() store messages in *messages* system buffer.
2005-05-13 10:05:23 +00:00
Charlie Gordon
e27c83422d extended MAX_SCREEN_WIDTH to 1024 2005-05-11 11:59:03 +00:00
Charlie Gordon
8fac0ab42e reordered KEY_xxx definitions
added KEY_DEL=127 (formerly KEY_BACKSPACE)
added KEY_BS=8  C-H  to handle control-h as backspace on some ttys
fixed KEY_F6 thru KEY_F12 (were off by one)
added strtokeys() to convert a string with key names to a key buffer
added define-kbd-macro() from key string
added execute-macro-keys() to execute commands from a key string
improved qe_key_process().
changed method to update shell cursor : tty_update_cursor disabled
  shell_display_hook() used instead
greatly improved shell buffer behaviour, charset handling.
much improved tty input handling : support more key combinations and modes.
added missing charset declarations in qe.h
added borders_invalid and complete_refresh window flags
made C-L completely refresh display
moved window border display to separate function
changed edit_display() to allow complete redisplay even with popups
fixed window delete crash bugs by improving consistency with
  edit_attach and edit_detach.
2005-05-09 02:17:47 +00:00
Charlie Gordon
f4649fc080 added dummy_font so select_font never returns NULL
do not free system fonts
changed scroll command to support half window and one line modes
added commands to navigate window layout
2005-05-05 17:21:54 +00:00
Charlie Gordon
3dd0f5660c Initial revision 2004-05-29 10:17:37 +00:00