This file is part of GNU Emacs.
-GNU Emacs is free software; you can redistribute it and/or modify
+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, 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
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
-along with GNU Emacs; see the file COPYING. If not, write to
-the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-Boston, MA 02110-1301, USA. */
+along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
/* New redisplay, TTY faces by Gerd Moellmann <gerd@gnu.org>. */
tty_set_terminal_modes (struct terminal *terminal)
{
struct tty_display_info *tty = terminal->display_info.tty;
-
+
if (tty->output)
{
if (tty->TS_termcap_modes)
struct coding_system *coding;
{
struct glyph *src_end = src + src_len;
- register GLYPH g;
unsigned char *buf;
int nchars, nbytes, required;
register int tlen = GLYPH_TABLE_LENGTH;
for (i = 0; i < cmp->glyph_len; i++)
{
int c = COMPOSITION_GLYPH (cmp, i);
-
+
if (! char_charset (c, charset_list, NULL))
break;
buf += CHAR_STRING (c, buf);
/* We must skip glyphs to be padded for a wide character. */
else if (! CHAR_GLYPH_PADDING_P (*src))
{
+ GLYPH g;
int c;
Lisp_Object string;
string = Qnil;
- g = GLYPH_FROM_CHAR_GLYPH (src[0]);
+ SET_GLYPH_FROM_CHAR_GLYPH (g, src[0]);
- if (g < 0 || g >= tlen)
+ if (GLYPH_INVALID_P (g) || GLYPH_SIMPLE_P (tbase, tlen, g))
{
/* This glyph doesn't has an entry in Vglyph_table. */
c = src->u.ch;
if (GLYPH_SIMPLE_P (tbase, tlen, g))
/* We set the multi-byte form of a character in G
(that should be an ASCII character) at WORKBUF. */
- c = FAST_GLYPH_CHAR (g);
+ c = GLYPH_CHAR (g);
else
/* We have a string in Vglyph_table. */
- string = tbase[g];
+ string = tbase[GLYPH_CHAR (g)];
}
if (NILP (string))
if (!FRAME_MEMORY_BELOW_FRAME (f)
&& vpos + i >= FRAME_LINES (f))
return;
-
+
if (multi)
{
raw_cursor_to (f, vpos, 0);
OUTPUTL (tty, scroll, tty->specified_window - vpos);
tty_set_scroll_region (f, 0, tty->specified_window);
}
-
+
if (!FRAME_SCROLL_REGION_OK (f)
&& FRAME_MEMORY_BELOW_FRAME (f)
&& n < 0)
char **address = term_get_fkeys_address;
KBOARD *kboard = term_get_fkeys_kboard;
-
+
/* This can happen if CANNOT_DUMP or with strange options. */
if (!KEYMAPP (kboard->Vinput_decode_map))
kboard->Vinput_decode_map = Fmake_sparse_keymap (Qnil);
enum display_element_type what;
{
struct it temp_it;
+ Lisp_Object gc;
GLYPH glyph;
temp_it = *it;
if (what == IT_CONTINUATION)
{
/* Continuation glyph. */
+ SET_GLYPH_FROM_CHAR (glyph, '\\');
if (it->dp
- && INTEGERP (DISP_CONTINUE_GLYPH (it->dp))
- && GLYPH_CHAR_VALID_P (XINT (DISP_CONTINUE_GLYPH (it->dp))))
+ && (gc = DISP_CONTINUE_GLYPH (it->dp), GLYPH_CODE_P (gc))
+ && GLYPH_CODE_CHAR_VALID_P (gc))
{
- glyph = XINT (DISP_CONTINUE_GLYPH (it->dp));
- glyph = spec_glyph_lookup_face (XWINDOW (it->window), glyph);
+ SET_GLYPH_FROM_GLYPH_CODE (glyph, gc);
+ spec_glyph_lookup_face (XWINDOW (it->window), &glyph);
}
- else
- glyph = '\\';
}
else if (what == IT_TRUNCATION)
{
/* Truncation glyph. */
+ SET_GLYPH_FROM_CHAR (glyph, '$');
if (it->dp
- && INTEGERP (DISP_TRUNC_GLYPH (it->dp))
- && GLYPH_CHAR_VALID_P (XINT (DISP_TRUNC_GLYPH (it->dp))))
+ && (gc = DISP_TRUNC_GLYPH (it->dp), GLYPH_CODE_P (gc))
+ && GLYPH_CODE_CHAR_VALID_P (gc))
{
- glyph = XINT (DISP_TRUNC_GLYPH (it->dp));
- glyph = spec_glyph_lookup_face (XWINDOW (it->window), glyph);
+ SET_GLYPH_FROM_GLYPH_CODE (glyph, gc);
+ spec_glyph_lookup_face (XWINDOW (it->window), &glyph);
}
- else
- glyph = '$';
}
else
abort ();
- temp_it.c = FAST_GLYPH_CHAR (glyph);
- temp_it.face_id = FAST_GLYPH_FACE (glyph);
+ temp_it.c = GLYPH_CHAR (glyph);
+ temp_it.face_id = GLYPH_FACE (glyph);
temp_it.len = CHAR_BYTES (temp_it.c);
produce_glyphs (&temp_it);
if (save)
{
- if (default_orig_pair)
- xfree (default_orig_pair);
+ xfree (default_orig_pair);
default_orig_pair = tty->TS_orig_pair ? xstrdup (tty->TS_orig_pair) : NULL;
- if (default_set_foreground)
- xfree (default_set_foreground);
+ xfree (default_set_foreground);
default_set_foreground = tty->TS_set_foreground ? xstrdup (tty->TS_set_foreground)
: NULL;
- if (default_set_background)
- xfree (default_set_background);
+ xfree (default_set_background);
default_set_background = tty->TS_set_background ? xstrdup (tty->TS_set_background)
: NULL;
}
void
-set_tty_color_mode (f, val)
+set_tty_color_mode (tty, f)
+ struct tty_display_info *tty;
struct frame *f;
- Lisp_Object val;
{
- Lisp_Object color_mode_spec, current_mode_spec;
- Lisp_Object color_mode, current_mode;
- int mode, old_mode;
+ Lisp_Object tem, val, color_mode_spec;
+ Lisp_Object color_mode;
+ int mode;
extern Lisp_Object Qtty_color_mode;
- Lisp_Object tty_color_mode_alist;
+ Lisp_Object tty_color_mode_alist
+ = Fintern_soft (build_string ("tty-color-mode-alist"), Qnil);
- tty_color_mode_alist = Fintern_soft (build_string ("tty-color-mode-alist"),
- Qnil);
+ tem = assq_no_quit (Qtty_color_mode, f->param_alist);
+ val = CONSP (tem) ? XCDR (tem) : Qnil;
if (INTEGERP (val))
color_mode = val;
else
{
- if (NILP (tty_color_mode_alist))
- color_mode_spec = Qnil;
- else
- color_mode_spec = Fassq (val, XSYMBOL (tty_color_mode_alist)->value);
-
- if (CONSP (color_mode_spec))
- color_mode = XCDR (color_mode_spec);
- else
- color_mode = Qnil;
+ tem = (NILP (tty_color_mode_alist) ? Qnil
+ : Fassq (val, XSYMBOL (tty_color_mode_alist)->value));
+ color_mode = CONSP (tem) ? XCDR (tem) : Qnil;
}
- current_mode_spec = assq_no_quit (Qtty_color_mode, f->param_alist);
-
- if (CONSP (current_mode_spec))
- current_mode = XCDR (current_mode_spec);
- else
- current_mode = Qnil;
- if (INTEGERP (color_mode))
- mode = XINT (color_mode);
- else
- mode = 0; /* meaning default */
- if (INTEGERP (current_mode))
- old_mode = XINT (current_mode);
- else
- old_mode = 0;
+ mode = INTEGERP (color_mode) ? XINT (color_mode) : 0;
- if (mode != old_mode)
+ if (mode != tty->previous_color_mode)
{
- tty_setup_colors (FRAME_TTY (f), mode);
- /* This recomputes all the faces given the new color
- definitions. */
- call0 (intern ("tty-set-up-initial-frame-faces"));
- redraw_frame (f);
+ Lisp_Object funsym = intern ("tty-set-up-initial-frame-faces");
+ tty->previous_color_mode = mode;
+ tty_setup_colors (tty , mode);
+ /* This recomputes all the faces given the new color definitions. */
+ safe_call (1, &funsym);
}
}
This function ignores suspended devices.
Returns NULL if the named terminal device is not opened. */
-
+
struct terminal *
get_named_tty (name)
char *name;
{
struct terminal *t = get_tty_terminal (tty, 1);
FILE *f;
-
+
if (!t)
error ("Unknown tty device");
f = t->display_info.tty->input;
-
+
if (f)
{
/* First run `suspend-tty-functions' and then clean up the tty
reset_sys_modes (t->display_info.tty);
delete_keyboard_wait_descriptor (fileno (f));
-
+
fclose (f);
if (f != t->display_info.tty->output)
fclose (t->display_info.tty->output);
-
+
t->display_info.tty->input = 0;
t->display_info.tty->output = 0;
if (FRAMEP (t->display_info.tty->top_frame))
FRAME_SET_VISIBLE (XFRAME (t->display_info.tty->top_frame), 0);
-
+
}
/* Clear display hooks to prevent further output. */
/* write_glyphs writes at cursor position, so we need to
temporarily move cursor coordinates to the beginning of
the highlight region. */
-
+
/* Save current cursor co-ordinates */
save_y = curY (tty);
save_x = curX (tty);
pos_y = row->y + WINDOW_TOP_EDGE_Y (w);
pos_x = row->used[LEFT_MARGIN_AREA] + start_hpos
+ WINDOW_LEFT_EDGE_X (w);
-
+
cursor_to (f, pos_y, pos_x);
if (draw == DRAW_MOUSE_FACE)
/* Find the range of text around this char that
should be active. */
Lisp_Object before, after;
- int ignore;
+ EMACS_INT ignore;
before = Foverlay_start (overlay);
/* Find the range of text around this char that
should be active. */
Lisp_Object before, after, beginning, end;
- int ignore;
+ EMACS_INT ignore;
beginning = Fmarker_position (w->start);
XSETINT (end, (BUF_Z (b) - XFASTINT (w->window_end_pos)));
result->modifiers = down_modifier;
else
result->modifiers = 0;
-
+
if (event->type & GPM_SINGLE)
result->modifiers |= click_modifier;
-
+
if (event->type & GPM_DOUBLE)
result->modifiers |= double_modifier;
return Qnil;
}
-int
+int
handle_one_term_event (struct tty_display_info *tty, Gpm_Event *event, struct input_event* hold_quit)
{
struct frame *f = XFRAME (tty->top_frame);
if (!tty || gpm_tty != tty)
return Qnil; /* Not activated on this terminal, nothing to do. */
-
+
if (gpm_fd >= 0)
delete_gpm_wait_descriptor (gpm_fd);
while (Gpm_Close()); /* close all the stack */
terminal->delete_glyphs_hook = &tty_delete_glyphs;
terminal->ring_bell_hook = &tty_ring_bell;
-
+
terminal->reset_terminal_modes_hook = &tty_reset_terminal_modes;
terminal->set_terminal_modes_hook = &tty_set_terminal_modes;
terminal->update_begin_hook = 0; /* Not needed. */
terminal->read_socket_hook = &tty_read_avail_input; /* keyboard.c */
terminal->frame_up_to_date_hook = 0; /* Not needed. */
-
+
terminal->delete_frame_hook = &delete_tty_output;
terminal->delete_terminal_hook = &delete_tty;
}
init_baud_rate (fileno (tty->input));
-#ifdef AIXHFT
- /* The HFT system on AIX doesn't optimize for scrolling, so it's
- really ugly at times. */
- terminal->line_ins_del_ok = 0;
- terminal->char_ins_del_ok = 0;
-#endif
-
/* Don't do this. I think termcap may still need the buffer. */
/* xfree (buffer); */
struct terminal *terminal;
char *str1, *str2, *arg1, *arg2;
{
- if (buffer)
- xfree (buffer);
+ xfree (buffer);
if (terminal)
delete_tty (terminal);
-
+
if (must_succeed)
fatal (str2, arg1, arg2);
else
struct tty_display_info *tty;
Lisp_Object tail, frame;
int last_terminal;
-
+
/* Protect against recursive calls. Fdelete_frame in
delete_terminal calls us back when it deletes our last frame. */
if (!terminal->name)
abort ();
tty = terminal->display_info.tty;
-
+
last_terminal = 1;
FOR_EACH_FRAME (tail, frame)
{
}
if (last_terminal)
error ("Attempt to delete the sole terminal device with live frames");
-
+
if (tty == tty_list)
tty_list = tty->next;
else
delete_terminal (terminal);
- if (tty->name)
- xfree (tty->name);
-
- if (tty->type)
- xfree (tty->type);
+ xfree (tty->name);
+ xfree (tty->type);
if (tty->input)
{
if (tty->termscript)
fclose (tty->termscript);
- if (tty->old_tty)
- xfree (tty->old_tty);
-
- if (tty->Wcm)
- xfree (tty->Wcm);
+ xfree (tty->old_tty);
+ xfree (tty->Wcm);
bzero (tty, sizeof (struct tty_display_info));
xfree (tty);