summaryrefslogtreecommitdiff
path: root/src/term.c
AgeCommit message (Collapse)Author
2026-05-28Fix the MSDOS buildPo Lu
* msdos/sedlibmk.inp (GL_GNULIB_STDC_[^ =] &c.): Rename from GL_STDC_... and define to 1 before other variables prefixed GL_GNULIB_ are defined to 0. (NEXT_AS_FIRST_DIRECTIVE_STDBIT_H) (NEXT_AS_FIRST_DIRECTIVE_STDCOUNTOF_H, STDCOUNTOF_H): Define. (GL_HAVE_STDBIT_H_CONDITION): Replace GL_GENERATE_STDBIT_H_CONDITION. (CXX_HAVE_STDCOUNTOF_H, GL_GNULIB_STREQ, GL_GNULIB_MEMEQ) (GL_GNULIB_STRNUL, GL_GENERATE_STDCOUNTOF_H_CONDITION): Substitute "1". * src/conf_post.h (_REGEX_AVOID_UCHAR_H) [MSDOS]: Define to 1. * src/term.c (init_tty) [MSDOS]: Set TN_max_colors to 16, which was deleted inadvertently with recent MS Windows modifications. * config.bat: Rename stdcountof.in.h appropriately.
2026-05-26ARRAYELTS → countofPaul Eggert
C2y will standardize countof as the macro that Emacs uses the name ARRAYELTS for. Switch to the standard name, which is supported by GCC 16+, by Clang 21, and by the Gnulib stdcountof-h module already in use for compilers that do not support countof. Also, use countof in a few places where we missed using ARRAYELTS. * admin/coccinelle/arrayelts.cocci: Suggest countof, not ARRAYELTS. * admin/merge-gnulib (GNULIB_MODULES): Add stdcountof-h, as it is now a direct rather than an indirect dependency. * exec/trace.c, src/lisp.h, src/sfnt.c: Include <stdcountof.h>. (ARRAYELTS): Remove. All uses replaced by countof. * lib-src/ebrowse.c, lib-src/etags.c, lib-src/make-docfile.c: * lib-src/seccomp-filter.c, lwlib/lwlib-Xaw.c: Prefer <stdcountof.h> and countof to doing things by hand.
2026-05-26Omit useless casts found by GCC 16Paul Eggert
GCC 16’s -Wuseless-cast warning can be useful. Fix the useless casts it identifies, and also fix false positives by using compound literals, which are safer anyway than casts. * src/composite.c (composition_adjust_point) (Ffind_composition_internal): * lwlib/xlwmenu.c (xlwMenuResources, xlwMenuClassRec) (resource_widget_value, XlwMenuDestroy, Select): * src/alloc.c (process_mark_stack): * src/data.c (Faref): * src/emacs-module.c (module_extract_big_integer): * src/fileio.c (Finsert_file_contents): * src/frame.h (FRAME_MESSAGE_BUF_SIZE): * src/gtkutil.c (xg_tool_item_stale_p, update_frame_tool_bar): * src/image.c (pbm_load, png_load_body, jpeg_load_body) (tiff_load, gif_load): * src/pdumper.c (ptrdiff_t_to_dump_off, dump_queue_dequeue) (field_relpos, dump_field_emacs_ptr) (dump_object_start_pseudovector, pdumper_remember_scalar_impl) (pdumper_load, syms_of_pdumper): * src/regex-emacs.c (BUF_PUSH, BUF_PUSH_2, POINTER_TO_OFFSET): * src/xdisp.c (remember_mouse_glyph, pint2str): * src/xterm.c (cvt_string_to_pixel, handle_one_xevent): Omit useless casts. Perhaps they were formerly needed, but they should not be needed now. * src/alloc.c (Fmemory_info): * src/category.c (Fdefine_category, Fmodify_category_entry): * src/data.c (Fash): * src/dispextern.h (GLYPH_CODE_P): * src/emacs.c (load_seccomp): * src/fns.c (Flocale_info, maybe_resize_hash_table): * src/indent.c (check_display_width): * src/json.c (symset_size): * src/lisp.h (XUNTAG, BOOL_VECTOR_LENGTH_MAX, obarray_size) (hash_table_index_size): * src/lread.c (make_obarray, grow_obarray, Fobarray_clear): * src/menu.c (digest_single_submenu, x_popup_menu_1): * src/term.c (init_tty): * src/widget.c (update_wm_hints): * src/xdisp.c (truncate_echo_area): * src/xfns.c (x_set_border_pixel): * src/xfont.c (xfont_match, xfont_open): * src/xmenu.c (set_frame_menubar): * test/src/emacs-module-resources/mod-test.c (emacs_module_init): Use compound literal instead of a cast that is useless in some platforms but not others. * src/dispextern.h, src/haikugui.h, src/w32gui.h: (WINDOW_HANDLE_UINTPTR): New macro. * src/frame.c (gui_report_frame_params): * src/xterm.c (x_try_cr_xlib_drawable): Use it. * src/lisp.h (XUNTAG): And tag with UINTPTR_MAX to pacify gcc warning about a constant out of range. (hash_idx_t): Make it int_least32_t, as it need not be exactly 32 bits. (PRIdHASH_IDX): New macro. * src/pdumper.c (dump_queue_dequeue): Use it. * src/profiler.c (setup_cpu_timer): Make a local EMACS_INT rather than int, to avoid need for casting later. * src/syntax.c (uninitialized_interval): Use 1u rather than 1 so the cast is always useful. A compound literal wouldn’t do here, as this macro needs to be an integer constant expression. * src/xfns.c (XICCallback, XICProc): Remove macros. (Xxic_preedit_start_callback): Use a cleaner way to specify it, avoiding the need for type macros, and for a cast if HAVE_XICCALLBACK_CALLBACK. * src/xterm.c (handle_one_xevent): 2nd arg is now XEvent * on all platforms, as there is no need to diverge, and diverging meant we needed lots of unnecessary casts.
2026-05-23Prefer ptrdiff_t to size_t when either will doPaul Eggert
Signed types are a bit safer, as they avoid some comparison confusion and -fsanitize=undefined can check more misuses of them. * src/alloc.c (lisp_malloc, lisp_align_malloc) (allocate_string_data, allocate_vector_from_block, object_bytes): * src/coding.c (from_unicode_buffer): * src/decompress.c (acc_size, accumulate_and_process_md5): * src/emacs.c (load_seccomp, shut_down_emacs): * src/fns.c (sxhash_bignum): * src/ftfont.c (get_adstyle_property): * src/image.c (lookup_image, xpm_init_color_cache) (xpm_cache_color): * src/json.c (json_out_str, struct json_parser) (json_make_object_workspace_for_slow_path) (json_make_object_workspace_for, json_parse_array) (json_parse_object): * src/sysdep.c (get_current_dir_name_or_unreachable) (init_sys_modes, convert_speed): * src/termchar.h (struct tty_display_info): * src/textconv.h (struct textconv_conversion_text): * src/xfns.c (struct x_xim_text_conversion_data) (x_encode_xim_text): * src/xselect.c (struct transfer, c_size_for_format) (x_size_for_format, selection_data_for_offset) (selection_data_size, x_start_selection_transfer) (x_continue_selection_transfer): Prefer ptrdiff_t to size_t when either will do. * src/term.c (Ftty__set_output_buffer_size): Limit output buffer size to PTRDIFF_MAX as well as to SIZE_MAX.
2026-05-23New function memory_full_upPaul Eggert
* src/alloc.c (memory_full_up): New function. Replace all callers of memory_full (SIZE_MAX) with callers to this function. This simplifies callers and should make future changes easier. It also saves a whopping 296 bytes in executable size with gcc 16.1.1 20260515 (Red Hat 16.1.1-2) x86-64.
2026-04-25Fix line-truncation on horizontally-split TTY framesEli Zaretskii
* src/term.c (append_glyph, append_composite_glyph) (append_glyphless_glyph): Account for the right-border glyph when computing the end glyph of TEXT_AREA. (Bug#80900)
2026-04-23Simplify Tc/COLORTERM=truecolor escape sequencePeter Oliver
This should be more readable to most people, since C is more widely familiar than the terminfo language. * src/term.c (init_tty): Do the conversion from a single integer 24-bit color value to three 8-bit RGB values up-front. (Bug#70941)
2026-04-23Support setrgbb/setrgbf for setting 24-bit colorTim Ruffing
* src/term.c (turn_on_face): Account for TF_rgb_separate. (init_tty): Support setrgbf/setrrgbb and set TF_rgb_separate accordingly. * src/termchar.h: Update commentary. (Bug#70941)
2026-04-23Use expected escape sequence for terminfo Tc and COLORTERM=truecolorPeter Oliver
When the non-standard terminfo capability Tc is present, or the environment variable COLORTERM is set to truecolor, use a hard-coded escape sequence that addresses all colors directly by their RGB values. Previously we used escape sequences cribbed from terminfo's setaf/setab for direct color, that expect that we will only try to use colors 000000 to 000007 for the first eight indexed colors. This isn't something we currently handle. * doc/misc/efaq.texi (Colors on a TTY): Fix off-by-one error in list of indexed colors for terminfo RGB terminals. * src/term.c (init_tty): Don’t use any indexed colors with terminfo Tc capability or COLORTERM=truecolor environment variable (bug#70941).
2026-04-08Support 24-bit TrueColor on MS-Windows consoleewantown
* src/w32console.c (DEFAULTP, SSPRINTF, w32con_write_vt_seq) (w32con_get_cursor_coords): New functions and macros. (w32con_write_glyphs): Hide cursor before writing to the console. Add code for writing in virtual-terminal mode when 'w32_use_virtual_terminal' is non-zero. (w32con_write_glyphs_with_face): Add code for writing in virtual-terminal mode when 'w32_use_virtual_terminal' is non-zero. (w32con_setup_virtual_terminal): New function. (w32con_set_terminal_modes): Call it. (turn_on_face, turn_off_face): New functions. (initialize_w32_display): Save background and foreground, and the current TTY. (Fset_screen_color): Accept an additional optional argument VTP; if non-nil, arrange for 24-bit display to use the specified colors. (Fget_screen_color): Accept an additional optional argument VTP; if non-nil, return colors used by 24-bit display. (Fw32_use_virtual_terminal, Fw32_use_virtual_terminal_p): New functions. * src/term.c (tty_setup_colors) [WINDOWSNT]: Set up virtual-terminal sequences for colors. (init_tty) [WINDOWSNT]: Set up terminfo capabilities for Windows virtual-terminal. * src/xdisp.c (redisplay_internal): Don't call set_tty_color_mode for WINDOWSNT. * lisp/term/w32console.el (w32-tty-set-base-colors) (w32-tty-define-base-colors, w32-tty-define-8bit-colors) (w32-tty-define-24bit-colors, w32-tty-get-pixel): New functions. (terminal-init-w32console): Remove color setup. (w32-tty-setup-colors): New function. * lisp/term/tty-colors.el (tty-color-mode-alist): Add --color modes for 256 and 24-bit color modes. * lisp/startup.el (tty-handle-args): Fix --color handling. * lisp/faces.el (tty-set-up-initial-frame-faces): Set up colors for MS-Windows consoles. * etc/NEWS: * doc/emacs/msdos.texi (Windows Misc): * doc/emacs/cmdargs.texi (Colors X): Document 24-bit color support on MS-Windows. (Bug#79298)
2026-03-26Simplify some struct frame.output_method checksBasil L. Contovounesios
* src/lisp.h (inhibit_window_system): Fix typo in commentary. * src/dispnew.c (Fopen_termscript): (init_display_interactive) [!HAVE_ANDROID, !MSDOS]: * src/dosfns.c [MSDOS] (dos_cleanup): * src/frame.c (frame_inhibit_resize, frame_windows_min_size) (do_switch_frame, delete_frame): (make_terminal_frame) [MSDOS]: (Fmake_terminal_frame) [MSDOS, WINDOWSNT]: * src/keyboard.c (read_decoded_event_from_main_queue) [!WINDOWSNT]: (Fcurrent_input_mode): * src/menu.c (single_menu_item): * src/msdos.c [MSDOS] (internal_terminal_init): * src/sysdep.c (init_sys_modes): * src/term.c: [HAVE_GPM] (Fgpm_mouse_start, Fgpm_mouse_stop): [MSDOS] (tty_free_frame_resources): * src/w32xfns.c (get_frame_dc): * src/xdisp.c (clear_garbaged_frames, hscroll_window_tree) (redisplay_internal): * src/xfaces.c (Fdisplay_supports_face_attributes_p) (realize_default_face, realize_face, realize_tty_face): Use is_tty_frame, FRAME_INITIAL_P, FRAME_MSDOS_P, FRAME_TERMCAP_P, FRAME_W32_P, and FRAME_TTY as appropriate instead of open-coding them (bug#80629).
2026-03-15Avoid segfaults in TTY menu-item selectionEli Zaretskii
* src/term.c (tty_menu_show): Don't allow "selection" of items in a bogus menu. (Bug#80603)
2026-03-14Avoid another assertion violation in TTY menusEli Zaretskii
* src/term.c (tty_menu_show): Reject bogus menus whose 'menu_items' is nil. (Bug#80603)
2026-03-14Avoid assertion violations in tty menus in rare casesEli Zaretskii
* src/term.c (mouse_get_xy): Restore the lost protection against 'mouse_position' returning nil as mouse coordinates. (Bug#80603)
2026-01-01; Add 2026 to copyright years.Sean Whitton
2025-08-09Variable to control overshoot and backup for TTY cursor motionManuel Giraud
* src/term.c (syms_of_term): New variable. * src/cm.c (calccost): Control overshooting with new variable. * etc/NEWS: Document new variable. * lisp/term/rxvt.el (terminal-init-rxvt): Force no TAB+BS for rxvt. (Bug#78474)
2025-03-27Don't write to bottom-right cell on ttys with AutoWrap (bug#77233)Gerd Möllmann
* src/term.c (tty_write_glyphs): Handle case of writing only one character in the last column.
2025-03-25Fix the DJGPP buildPo Lu
* msdos/emacs.djl (.bss): Guarantee that lread.o is 8-byte aligned. * msdos/sed2v2.inp (ALIGNOF_INT, ALIGNOF_LONG) (ALIGNOF_LONG_LONG): Correct typos. * src/term.c (tty_free_frame_resources): Synchronize with non-DOS variant.
2025-03-23Avoid rare crashes due to "C-g C-g" on TTY framesEli Zaretskii
* src/term.c (tty_send_additional_strings): Don't use SBYTES, as this function could be called in the middle of GC. (Bug#77205)
2025-03-17Implement dragging and resizing of tty child framesMartin Rudalics
* lisp/faces.el (face-spec-recalc): Don't set scroll-bar-foreground and scroll-bar-background parameters on ttys. * lisp/mouse.el (mouse-drag-frame-resize) (mouse-drag-frame-move): On ttys call 'mouse-position-in-root-frame' to get position of child frame to resize or drag. * lisp/xt-mouse.el (xterm-mouse-event): Handle events on child frame decorations as if they happened on the internal border to find out whether a user wants to drag or resize a child frame. * src/frame.c (frame_internal_border_part): Define for ttys too. (Fmouse_position_in_root_frame): New function. * src/frame.h (internal_border_part): Define for ttys too. * src/keyboard.c (internal_border_parts): Define for ttys too. (frame_border_side): New enum. (make_lispy_position): Handle events on tty child frames. (Fposn_at_x_y): Accept -1 for Y so we can handle a position on the top decoration of a tty child frame. * src/term.c (tty_frame_at): Handle case where X and Y denote a position on a tty child frame's decoration. * src/window.c (Fwindow_at): Handle case where X and Y denote a position on the decoration of a tty child frame which we pretend as belonging to that child frame (and not to its root).
2025-03-09Fix drawing to the bottom-right corner of terminalsGerd Möllmann
* src/term.c (tty_write_glyphs_1): Renamed from tty_write_glyphs. Don't check if writing the bottom-right corner. (tty_write_glyphs): New function handling case of writing to the bottom-right corner, and otherwise calling tty_write_glyphs_1.
2025-03-04Fix 'etc/DOC' for a few functions/variablesEli Zaretskii
* src/term.c (Ftty_frame_at): * src/menu.c (syms_of_menu) <x-popup-menu-function>: * src/dispnew.c (Fredisplay): Fix "doc:". The extra blank was preventing 'make-docfile' from recognizing the functions and variables and extracting their documentation to 'etc/DOC'. (Bug#76722)
2025-02-26; Whitespace fixes to silence git hooksStefan Kangas
2025-02-23Enforce redisplay when deleting a child frame (bug#76406)Gerd Möllmann
* src/term.c (tty_free_frame_resources): When deleting a child mark its root frame to garbaged. * src/dispnew.c (prepare_desired_root_row): Add a check for GLYPH_DEBUG.
2025-02-03Handle mouse highlighting in the presence of tty child framesGerd Möllmann
* src/term.c (tty_draw_row_with_mouse_face): Draw only parts of the highlighted text that are not covered by other frames.
2025-01-31Don’t use garbage after tty_frame_at returns nilPaul Eggert
* src/term.c (handle_one_term_event): Don’t access possibly uninitialized storage if frame is nil. This fixes an issue introduced in commit 5eae7f5227c7789dea45cef26fec17c057024670 dated 2025-01-26 14:43:51 -0800. Issue caught by --enable-gcc-warnings, which enables -Wanalyzer-use-of-uninitialized-value with gcc (GCC) 14.2.1 20250110 (Red Hat 14.2.1-7).
2025-01-27Fix clicking in child frames with GPMjared
* src/term.c (handle_one_term_event): Store child frame coordinates in event.
2025-01-27Fix the Android portPo Lu
* src/term.c (tty_frame_at) [HAVE_ANDROID]: Always return nil. * src/terminal.c (cursor_to, raw_cursor_to) [HAVE_ANDROID]: Don't call root_xy.
2025-01-25Replace is_frame_ancestor with frame_ancestor_pGerd Möllmann
* src/dispnew.c (is_frame_ancestor): Removed. (frame_z_order_cmp): Use frame_ancestor_p. (copy_child_glyphs): Ditto. * src/dispextern.h: Declaration removed. * src/term.c (mouse_get_xy): Use frame_ancestor_p.
2025-01-25; * src/term.c (handle_one_term_event): Fix last change.Eli Zaretskii
2025-01-25Reapply "Fix mouse position handling for nested tty child frames"Gerd Möllmann
This reverts commit e2cc52dbcd196f95cc79c6c6d899b9e86e696fe5.
2025-01-25Reapply "Fix tty-frame-at for nested tty child frames"Gerd Möllmann
This reverts commit 9ad28959d6895720865c0718bf60f4b7b0b144f3.
2025-01-25Reapply "Simplify absolute (x, y) computation on ttys"Gerd Möllmann
This reverts commit 13fdcd730ff63bf79caace9a6e46aff5f944b1b7.
2025-01-25Revert "Simplify absolute (x, y) computation on ttys"Gerd Möllmann
This reverts commit 5e132835ad320be1d5c45ffbf83d67d16fc7bf96.
2025-01-25Revert "Fix tty-frame-at for nested tty child frames"Gerd Möllmann
This reverts commit 9693f2a95ad14bf0caa34e60d72722d4dd4d85c9.
2025-01-25Revert "Fix mouse position handling for nested tty child frames"Gerd Möllmann
This reverts commit f37559a1ee035d184bc4db6e4f597281d3ac6879.
2025-01-25Fix mouse position handling for nested tty child framesGerd Möllmann
* src/dispnew.c (child_xy): New function. * src/dispextern.h: Declare it. * src/term.c (tty_frame_at): Return child-relative (x, y) in output parameters. (Ftty_frame_at): Return a list (FRAME CHILD-X CHILD-Y). (handle_one_term_event): Adapt use of tty_frame_at. * lisp/xt-mouse.el (xterm-mouse-event): Use new tty-frame-at.
2025-01-25Fix tty-frame-at for nested tty child framesGerd Möllmann
* src/term.c (tty_frame_at): Translate child frame origin to absolute coordinates.
2025-01-25Simplify absolute (x, y) computation on ttysGerd Möllmann
* src/dispnew.c (root_xy): New function. (frame_pos_abs): Removed. (frame_rect_abs, abs_cursor_pos): Use root_xy. * src/dispextern.h: Declare root_xy. * src/term.c (mouse_get_xy): Use it.
2025-01-23Handle tty menus overlapping child framesGerd Möllmann
* src/dispnew.c (frame_pos_abs, is_frame_ancestor): Make externally visible. * src/dispextern.h: Declare above functions. * src/term.c (mouse_get_xy): Handle mouse movement over child frames.
2025-01-11; * src/term.c (term_mouse_position): Fix 'fp' pointer.Juri Linkov
2025-01-11; * src/term.c (tty_frame_at, term_mouse_position): Fix last change.Eli Zaretskii
2025-01-11Support TTY child frames with GPM mouseJared Finder
* lisp/frame.el (x-list-fonts): Delete `frame-at', to move to C implementation. * lisp/xt-mouse.el (xterm-mouse-event): Call new `tty-frame-at'. * src/term.c (tty_frame_at, Ftty_frame_at): New C function, replacing `frame-at' only for TTYs. (term_mouse_position): Use last_mouse_frame when it is set. (handle_one_term_event): Call tty_frame_at to get frame under mouse, store it in last_mouse_frame. Alter event coordinates based on mouse frame. (syms_of_term): Add tty-frame-at, last_mouse_frame. * src/termhooks.h: Make Gpm_Event parameter const.
2025-01-01Update copyright year to 2025Paul Eggert
Run "TZ=UTC0 admin/update-copyright".
2024-12-19; Fix compilation warnings in term.cEli Zaretskii
* src/term.c (Ftty_frame_geometry, Ftty_frame_edges) (Ftty_frame_list_z_order, Ftty_frame_restack) (Ftty_display_pixel_width, Ftty_display_pixel_height): Doc fixes. (Ftty_frame_restack): Make it "noreturn".
2024-12-12Signal errors for unimplemented featuresGerd Möllmann
* src/frame.c (make_terminal_frame): Error for minibuffer-only frames. * src/term.c (Ftty_frame_restack): Signal error.
2024-11-05TTY menus: handle saved state referencing dead framesGerd Möllmann
* src/term.c (restore_desired_matrix): If a tty menu saves a current matrix that contains glyphs from a child frame, handle the case that that child frame dies before the saved state is restored.
2024-10-28Don't work around a corner case once observedGerd Möllmann
* src/term.c (tty_write_glyphs): Refactor a bit. Don't check for null glyph frame.
2024-10-22* src/term.c (tty_display_dimension): Avoid warnings.Eli Zaretskii
2024-10-22Fix commenting conventions.Eli Zaretskii