/* Terminal control module for terminals described by TERMCAP
- Copyright (C) 1985-1987, 1993-1995, 1998, 2000-2014 Free Software
+ Copyright (C) 1985-1987, 1993-1995, 1998, 2000-2016 Free Software
Foundation, Inc.
This file is part of GNU Emacs.
GNU Emacs is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
+the Free Software Foundation, either version 3 of the License, or (at
+your option) any later version.
GNU Emacs is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
#include "keymap.h"
#include "blockinput.h"
#include "syssignal.h"
-#include "systty.h"
-#include "intervals.h"
#ifdef MSDOS
#include "msdos.h"
static int been_here = -1;
#endif
#include "cm.h"
-#ifdef HAVE_X_WINDOWS
-#include "xterm.h"
-#endif
-
#include "menu.h"
/* The name of the default console device. */
static int max_frame_cols;
-static Lisp_Object Qtty_mode_set_strings;
-static Lisp_Object Qtty_mode_reset_strings;
-
\f
#ifdef HAVE_GPM
multibyte-form. But, it may be enlarged on demand if
Vglyph_table contains a string or a composite glyph is
encountered. */
- if (min (PTRDIFF_MAX, SIZE_MAX) / MAX_MULTIBYTE_LENGTH < src_len)
+ if (INT_MULTIPLY_WRAPV (src_len, MAX_MULTIBYTE_LENGTH, &required))
memory_full (SIZE_MAX);
- required = src_len;
- required *= MAX_MULTIBYTE_LENGTH;
if (encode_terminal_src_size < required)
- {
- encode_terminal_src = xrealloc (encode_terminal_src, required);
- encode_terminal_src_size = required;
- }
+ encode_terminal_src = xpalloc (encode_terminal_src,
+ &encode_terminal_src_size,
+ required - encode_terminal_src_size,
+ -1, sizeof *encode_terminal_src);
charset_list = coding_charset_list (coding);
glyph = it->glyph_row->glyphs[it->area];
}
glyph->type = COMPOSITE_GLYPH;
+ eassert (it->pixel_width <= SHRT_MAX);
glyph->pixel_width = it->pixel_width;
glyph->u.cmp.id = it->cmp_it.id;
if (it->cmp_it.ch < 0)
else
{
eassert (it->glyphless_method == GLYPHLESS_DISPLAY_HEX_CODE);
- len = (it->c < 0x10000 ? sprintf (buf, "\\u%04X", it->c)
- : it->c <= MAX_UNICODE_CHAR ? sprintf (buf, "\\U%06X", it->c)
- : sprintf (buf, "\\x%06X", it->c));
+ len = sprintf (buf,
+ (it->c < 0x10000 ? "\\u%04X"
+ : it->c <= MAX_UNICODE_CHAR ? "\\U%06X"
+ : "\\x%06X"),
+ it->c + 0u);
}
str = buf;
}
/* First run `suspend-tty-functions' and then clean up the tty
state because `suspend-tty-functions' might need to change
the tty state. */
- Lisp_Object args[2];
- args[0] = intern ("suspend-tty-functions");
- XSETTERMINAL (args[1], t);
- Frun_hook_with_args (2, args);
+ Lisp_Object term;
+ XSETTERMINAL (term, t);
+ CALLN (Frun_hook_with_args, intern ("suspend-tty-functions"), term);
reset_sys_modes (t->display_info.tty);
delete_keyboard_wait_descriptor (fileno (f));
set_tty_hooks (t);
init_sys_modes (t->display_info.tty);
- {
- /* Run `resume-tty-functions'. */
- Lisp_Object args[2];
- args[0] = intern ("resume-tty-functions");
- XSETTERMINAL (args[1], t);
- Frun_hook_with_args (2, args);
- }
+ /* Run `resume-tty-functions'. */
+ Lisp_Object term;
+ XSETTERMINAL (term, t);
+ CALLN (Frun_hook_with_args, intern ("resume-tty-functions"), term);
}
set_tty_hooks (t);
last menu help message. */
static int menu_help_paneno, menu_help_itemno;
-static Lisp_Object Qtty_menu_navigation_map, Qtty_menu_exit;
-static Lisp_Object Qtty_menu_prev_item, Qtty_menu_next_item;
-static Lisp_Object Qtty_menu_next_menu, Qtty_menu_prev_menu;
-static Lisp_Object Qtty_menu_select, Qtty_menu_ignore;
-static Lisp_Object Qtty_menu_mouse_movement;
-
typedef struct tty_menu_struct
{
int count;
Lisp_Object selectface;
int first_item = 0;
int col, row;
+ Lisp_Object prev_inhibit_redisplay = Vinhibit_redisplay;
USE_SAFE_ALLOCA;
/* Don't allow non-positive x0 and y0, lest the menu will wrap
buffers_num_deleted = 1;
}
+ /* Inhibit redisplay for as long as the menu is active, to avoid
+ messing the screen if some timer calls sit-for or a similar
+ function. */
+ Vinhibit_redisplay = Qt;
+
/* Force update of the current frame, so that the desired and the
current matrices are identical. */
update_frame_with_menu (sf, -1, -1);
if (!kbd_buffer_events_waiting ())
clear_input_pending ();
SAFE_FREE ();
+ Vinhibit_redisplay = prev_inhibit_redisplay;
return result;
}
tty_pop_down_menu (Lisp_Object arg)
{
tty_menu *menu = XSAVE_POINTER (arg, 0);
+ struct buffer *orig_buffer = XSAVE_POINTER (arg, 1);
block_input ();
tty_menu_destroy (menu);
+ set_buffer_internal (orig_buffer);
unblock_input ();
}
pane = selidx = 0;
- record_unwind_protect (tty_pop_down_menu, make_save_ptr (menu));
+ /* We save and restore the current buffer because tty_menu_activate
+ triggers redisplay, which switches buffers at will. */
+ record_unwind_protect (tty_pop_down_menu,
+ make_save_ptr_ptr (menu, current_buffer));
specbind (Qoverriding_terminal_local_map,
Fsymbol_value (Qtty_menu_navigation_map));
"Terminal type %s is not defined",
"Terminal type %s is not defined.\n\
If that is not the actual type of terminal you have,\n\
-use the Bourne shell command `TERM=... export TERM' (C-shell:\n\
-`setenv TERM ...') to specify the correct type. It may be necessary\n"
+use the Bourne shell command 'TERM=...; export TERM' (C-shell:\n\
+'setenv TERM ...') to specify the correct type. It may be necessary\n"
#ifdef TERMINFO
-"to do `unset TERMINFO' (C-shell: `unsetenv TERMINFO') as well.",
+"to do 'unset TERMINFO' (C-shell: 'unsetenv TERMINFO') as well.",
#else
-"to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.",
+"to do 'unset TERMCAP' (C-shell: 'unsetenv TERMCAP') as well.",
#endif
terminal_type);
}
"Terminal type \"%s\" is not powerful enough to run Emacs.\n\
It lacks the ability to position the cursor.\n\
If that is not the actual type of terminal you have,\n\
-use the Bourne shell command `TERM=... export TERM' (C-shell:\n\
-`setenv TERM ...') to specify the correct type. It may be necessary\n"
+use the Bourne shell command 'TERM=...; export TERM' (C-shell:\n\
+'setenv TERM ...') to specify the correct type. It may be necessary\n"
# ifdef TERMINFO
-"to do `unset TERMINFO' (C-shell: `unsetenv TERMINFO') as well.",
+"to do 'unset TERMINFO' (C-shell: 'unsetenv TERMINFO') as well.",
# else /* TERMCAP */
-"to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.",
+"to do 'unset TERMCAP' (C-shell: 'unsetenv TERMCAP') as well.",
# endif /* TERMINFO */
terminal_type);
}