Commit graph

86 commits

Author SHA1 Message Date
Charlie Gordon
6fb16e1cc2 Simplify and improve qe_check_buffer_file
* pass `QEmacsState` to key grab functions
* clear `grab_key_opaque` when freeing windows, buffers, mode_data
* add checks on window and buffer pointers in key grab functions
* this should fix a crash bug when deleting unsynched buffers from bufed
* fix `reload_buffer` to update buffer `file_size` and `mtime` fields
* check buffer file before invoking commands that modify the buffer
* check buffer file after command that changes the current window
  or the current window's buffer
2026-06-24 00:44:18 +02:00
Charlie Gordon
eda70b4576 Fix compilation warning 2026-06-23 10:14:28 +02:00
huwwa
f71fc6f25b shell: improve shell mode
* add `BF_ERROR` to identify error source buffers and use it with `next-error`.
* show `HELP` and `ERROR` buffer flags in `describe-buffer`.

* add a dedicated compilation mode with the following bindings:
  * `next-error` on `n`, `M-n`
  * `previous-error` on `p`, `M-p`
  * `scroll-up` on `SPC`
  * `scroll-down` on `DEL`
  * `search-forward` on `/`

  and the following new commands:
  * `goto-error` on `RET`, `LF`
  * `kill-compilation` on `C-c C-k`

* use `compilation` mode instead of `pager` mode for
  `do-compile`, and switch interactive shell buffers to
  `compilation` mode when the shell exits (if `shell_buffer_read_only` is set)

* refine popup/sidepane closing in `next-error`:
  * remove unnecessary popup check, as the command cannot
    be invoked if a popup window is present.
  * use `do_delete_window` to close side pane to avoid
    screen gap bug with `edit_close`.
2026-06-23 09:12:37 +02:00
Charlie Gordon
18755e7e09 Popup handling: add generic approach to disable commands
* add `#` at the beginning of the comand argument description
  to disable command when current window is a popup or the minibuf
* update command definitions
2026-06-14 23:30:50 +02:00
huwwa
c5e09df466 fix target window selection logic for next-error 2026-06-13 23:46:28 +02:00
Charlie Gordon
0cb68d2d74 Shell: improve current directory traking
* parse process output for shell prompts with current directory
* parse `make -w -C` output for temporary subdirectory excursions
* handle property type and flags separately
* add `QE_PROP_MARK` to prevent offset update at range boundary
* use `QE_PROP_DUP` to optimize buffer properties with single allocation
* use mask in `eb_delete_properties` to delete tags selectively
* fix `eb_find_property` range glitch
* fix offset tracking for CWD properties
* simplify default directory selection for shell commands
* fix compiler warnings on variable shadow definitions
* optimize `next_error()`: no lookback needed anymore
* display buffer properties in `describe-buffer`
* update TODO.md
2026-06-13 18:12:57 +02:00
huwwa
4f3c4dcd60 improve colors and styles
* add error-location style and colorize error locations.
2026-06-12 15:41:07 +02:00
huwwa
6e647fd6cb Add documentation for OSC 7 support 2026-06-12 15:41:07 +02:00
huwwa
f8a0b51d20 shell: improve current directory handling
* track the shell's current working directory using OSC 7.
* add `QE_PROP_CWD` buffer property, associate it with shell's cwd.
2026-06-12 15:41:07 +02:00
huwwa
32ecc2c050 shell: improve next-error
* remove popups, sidepanes, helppanes.
* verify file existence before opening.
* refine error/source windows:
    * find window showing the error source buffer,
      split a new one if none are found.
    * if current window is showing error source buffer,
      find file in next window, split a new one if none are found.
    * center cursor after going to error.
* show error line on window's first line.
* center cursor after going to error.
2026-06-12 15:41:07 +02:00
huwwa
073f6c005b shell: follow caption message on interactive shell
* remove unnecessary check.
* minor cosmetics.
2026-06-12 15:41:07 +02:00
huwwa
68d50fc88d shell: avoid silent exit for commands starting in popup/minibuf 2026-06-12 15:41:07 +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
3da74c964b Buffer/file: add diff-buffer-file
* add command to compare buffer with its file in a popup
* add [d] for diff when prompting for buffer/file synching
* add default behavior for buffer/file synching
* add CONFIG_LINUX, CONFIG_FREEBSD, CONFIG_OPENBSD, CONFIG_NETBSD
* add diff styles
2026-06-04 15:08:24 +02:00
Charlie Gordon
eff66d1e8c Buffer/File: check for file changes
* keep track of original file size and time in buffer data
* check for file changes upon window change, buffer modification and save
* prompt for reloading buffer contents and other options
2026-06-04 15:08:24 +02:00
Charlie Gordon
8977efa8a4 Shell: small improvements
* use `closefrom` if available
* use recommended approach to update tty winsize
2026-05-26 10:36:48 +02:00
huwwa
f91d04168b shell: refine non-interactive commands
* replace pty usage with pipes for non-interactive commands.
* remove `SF_INFINITE` flag.
2026-05-26 09:34:58 +02:00
Charlie Gordon
d6b37ca511 Sundries: bug fixes
* fix crash bug on `delete_equivalent()`: qe_free takes a double pointer
* remove unused ShellState variables
* initialize term structures
2026-05-18 01:15:21 +02:00
Charlie Gordon
dc4eb3efb6 man: ensure full manual page is formatted and uses hightlighting
- set `MAN_KEEP_FORMATTING=1` and `MANPAGER=cat` for the man
  command and handle overstriking in the terminal emulation.
- this approach works on macOS, linux, FreeBSD and OpenBSD
2026-05-17 16:12:36 +02:00
huwwa
cbeb5d4acd Shell: prevent man command from paging
- apply infinite-height prior to winsize initialization.
- use `LESS_LINES` environment variable.
- use `PAGER=less -F` to make less quit at the end of the man page
2026-05-17 12:49:56 +02:00
huwwa
053871bec7 Pager: verify existance of last buffer on abort 2026-05-17 00:03:01 +02:00
huwwa
34488a2ed4 Shell: use window width and height fields directly 2026-05-17 00:03:01 +02:00
huwwa
eefc007d60 Pager: add pager-abort command 2026-05-16 22:32:06 +02:00
huwwa
c654f504e5 Shell: refine target window selection logic
The behavior follows this priority order:

1. reuse an existing window already displaying the buffer,
2. if shell-command-other-window is not set, use the current
   window, otherwise
3. select the largest available non-active window.
4. split a new window if no sutiable window is found.
5. fall back to the current window if splitting fails.
2026-05-16 22:32:06 +02:00
huwwa
a927d093ab Shell: improve shell_close/shell_read_cb
- add check when process is signaled.
- put appropriate status message when non-interactive.
- follow output stream when non-interactive.
2026-05-16 22:32:06 +02:00
huwwa
ec1aee59a4 Shell: cosmetic changes
- add interactive shell process caption.
- rearrange lines.
2026-05-16 22:32:06 +02:00
Charlie Gordon
7f3b31d8d4 Shell: add optional shell modes
- `shell_buffer_read_only` controls if the shell buffer should become
  read-only and use pager-mode when not interactive
- `shell_mode_auto_interactive` controls if the shell interactive mode is
  switched to and from automatically based on cursor movement commands
- disable auto interactive if region is highlighted
- fix crash bug in qe_register_emulation_bindings for "emacs" emulation
2026-05-11 00:21:56 +02:00
huwwa
880aa115cd shell: sync interactive state between windows sharing the same shell buffer 2026-05-11 00:21:56 +02:00
huwwa
7d7a7d0fac shell: update toggle input status message 2026-05-11 00:21:56 +02:00
huwwa
2af3c40706 shell: split interactive and non-interactive shell commands 2026-05-11 00:21:56 +02:00
huwwa
5b87d2e4ff shell: manage interactive mode and readonly state
* decouple interactive mode from cursor position.
* clear readonly when entering interactive mode and
  restore when leaving it.
* simplify navigation logic by removing offset-based toggling.
* set pager mode on interactive shell exit.
2026-05-11 00:21:56 +02:00
huwwa
8a9c4412ed shell: check process termination before closing 2026-05-06 14:23:14 +02:00
huwwa
668a4be142 shell: avoid leaving stray processes when reusing a shell buffer
* check for active processes in shell buffers before reusing them,
  and prompt the user to kill the running process to avoid leaving
  it detached and unreachable.
2026-05-06 14:23:14 +02:00
huwwa
640ad15e4d shell: try to split window for shell commands 2026-05-06 14:23:14 +02:00
huwwa
db2bbc4c71 remove extra new line with caption
* `ctime` format ends with a new line.
2026-05-06 14:23:14 +02:00
huwwa
4d3e1e0810 shell: encapsulate error variables in a global ShellError structure 2026-05-06 14:23:14 +02:00
huwwa
b3f37b7b23 check for active process associated with the buffer before killing it
* killing a shell buffer while its process is still running can leave the
  process alive but no longer accessible.
2026-05-06 14:23:14 +02:00
huwwa
42c88b10ca default exit status to -1 if not launched 2026-05-06 14:23:14 +02:00
huwwa
aeb0767a3c fix: defer pty closure until buffer is fully drained
fixes a race condition where pty data was lost on process exit.
The pid callback now flags the exit status, while `shell_read_cb`
handles the final teardown. This prevents truncation for
high-throughput processes.
2026-05-06 14:23:14 +02:00
huwwa
adc72a8b0a set readonly flag for compilation buffer 2026-05-06 14:23:14 +02:00
huwwa
9502e20d52 fix: use appropriate buffer flag 2026-05-06 14:23:14 +02:00
Charlie Gordon
d2db97217c disable transient bindings on next-error and previous-error 2026-02-06 13:02:09 +01:00
huwwa
93539ead18 replace depricated getdtablesize with sysconf 2026-02-06 12:45:28 +01:00
Charlie Gordon
e4fb8c8428
Improve language colorizers (#54)
* fix detection of javascript partial comments in diff output
* colorize python annotations
* add simplistic yaml colorizer
* colorize .gitignore files
* improve shell buffer diff output colorization
2024-12-14 23:56:54 +01:00
Charlie Gordon
e0ba872d77
Improve error reporting (#50)
- rename `edit_new` as `qe_new_window`
- report error in `qe_new_buffer` and `qe_new_window` upon failure
- rename `qe_find_buffer_file` as `qe_find_buffer_filename`
- rename `read_charset` as `qe_parse_charset`
- reset yank buffer references in `eb_clear()`
- make `qe_init()` return error code and abort upon error
2024-12-08 19:43:26 +01:00
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
ab86598e29 Automate modifyOtherKeys, mouse and clipboard support detection
- intialize `tty_mk`, `tty_mouse` and `tty_clipboard` to `-1` for automatic
- command line options force setting
- otherwise, configure support from environment variables (for now)
2024-10-11 09:14:16 +02:00
Charlie Gordon
9815df4c68 Fix shell buffer CSI parameter parsing 2024-09-25 01:02:14 +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