#include <sys/file.h>
#include <unistd.h>
#include <signal.h>
-#include <stdarg.h>
#include <setjmp.h>
#include "lisp.h"
static void tty_set_scroll_region (struct frame *f, int start, int stop);
static void turn_on_face (struct frame *, int face_id);
static void turn_off_face (struct frame *, int face_id);
+static void tty_turn_off_highlight (struct tty_display_info *);
static void tty_show_cursor (struct tty_display_info *);
static void tty_hide_cursor (struct tty_display_info *);
static void tty_background_highlight (struct tty_display_info *tty);
+static struct terminal *get_tty_terminal (Lisp_Object, int);
static void clear_tty_hooks (struct terminal *terminal);
static void set_tty_hooks (struct terminal *terminal);
static void dissociate_if_controlling_tty (int fd);
static void delete_tty (struct terminal *);
static void maybe_fatal (int must_succeed, struct terminal *terminal,
- const char *str1, const char *str2, ...) NO_RETURN;
-static void vfatal (const char *str, va_list ap) NO_RETURN;
+ const char *str1, const char *str2, ...)
+ NO_RETURN ATTRIBUTE_FORMAT_PRINTF (3, 5) ATTRIBUTE_FORMAT_PRINTF (4, 5);
+static void vfatal (const char *str, va_list ap)
+ NO_RETURN ATTRIBUTE_FORMAT_PRINTF (1, 0);
#define OUTPUT(tty, a) \
/* The largest frame width in any call to calculate_costs. */
-int max_frame_cols;
+static int max_frame_cols;
/* The largest frame height in any call to calculate_costs. */
-int max_frame_lines;
+static int max_frame_lines;
/* Non-zero if we have dropped our controlling tty and therefore
should not open a frame on stdout. */
/* Set up termcap modes for Emacs. */
-void
+static void
tty_set_terminal_modes (struct terminal *terminal)
{
struct tty_display_info *tty = terminal->display_info.tty;
/* Reset termcap modes before exiting Emacs. */
-void
+static void
tty_reset_terminal_modes (struct terminal *terminal)
{
struct tty_display_info *tty = terminal->display_info.tty;
\f
/* Handle highlighting. */
-void
+static void
tty_turn_off_highlight (struct tty_display_info *tty)
{
if (tty->standout_mode)
Set CODING->produced to the byte-length of the resulting byte
sequence, and return a pointer to that byte sequence. */
-static unsigned char *
+unsigned char *
encode_terminal_code (struct glyph *src, int src_len, struct coding_system *coding)
{
struct glyph *src_end = src + src_len;
{
if (src->type == COMPOSITE_GLYPH)
{
- struct composition *cmp;
- Lisp_Object gstring;
+ struct composition *cmp IF_LINT (= NULL);
+ Lisp_Object gstring IF_LINT (= Qnil);
int i;
nbytes = buf - encode_terminal_src;
else if (! CHAR_GLYPH_PADDING_P (*src))
{
GLYPH g;
- int c;
+ int c IF_LINT (= 0);
Lisp_Object string;
string = Qnil;
{
unsigned char *conversion_buffer;
struct coding_system *coding;
+ size_t n, stringlen;
struct tty_display_info *tty = FRAME_TTY (f);
the tail. */
coding->mode &= ~CODING_MODE_LAST_BLOCK;
- while (len > 0)
+ for (stringlen = len; stringlen != 0; stringlen -= n)
{
/* Identify a run of glyphs with the same face. */
int face_id = string->face_id;
- int n;
- for (n = 1; n < len; ++n)
+ for (n = 1; n < stringlen; ++n)
if (string[n].face_id != face_id)
break;
tty_highlight_if_desired (tty);
turn_on_face (f, face_id);
- if (n == len)
+ if (n == stringlen)
/* This is the last run. */
coding->mode |= CODING_MODE_LAST_BLOCK;
conversion_buffer = encode_terminal_code (string, n, coding);
fwrite (conversion_buffer, 1, coding->produced, tty->termscript);
UNBLOCK_INPUT;
}
- len -= n;
string += n;
/* Turn appearance modes off. */
static KBOARD *term_get_fkeys_kboard;
static Lisp_Object term_get_fkeys_1 (void);
-/* Rework termcap API to accept const pointer args. */
-static inline int my_tgetflag (const char *x) { return tgetflag ((char *) x); }
-static inline int my_tgetnum (const char *x) { return tgetnum ((char *) x); }
-static inline char *my_tgetstr (const char *x, char **a)
-{ return tgetstr ((char *) x, a); }
-#undef tgetflag
-#undef tgetnum
-#undef tgetstr
-#define tgetflag my_tgetflag
-#define tgetnum my_tgetnum
-#define tgetstr my_tgetstr
-
/* Find the escape codes sent by the function keys for Vinput_decode_map.
This function scans the termcap function key sequence entries, and
adds entries to Vinput_decode_map for each function key it finds. */
{
if (! STRINGP (acronym) && CHAR_TABLE_P (Vglyphless_char_display))
acronym = CHAR_TABLE_REF (Vglyphless_char_display, it->c);
+ if (CONSP (acronym))
+ acronym = XCDR (acronym);
buf[0] = '[';
str = STRINGP (acronym) ? SSDATA (acronym) : "";
for (len = 0; len < 6 && str[len] && ASCII_BYTE_P (str[len]); len++)
it->pixel_width = len;
it->nglyphs = len;
- if (len > 0 && it->glyph_row)
+ if (it->glyph_row)
append_glyphless_glyph (it, face_id, str);
}
/* Return the tty display object specified by TERMINAL. */
-struct terminal *
+static struct terminal *
get_tty_terminal (Lisp_Object terminal, int throw)
{
struct terminal *t = get_terminal (terminal, throw);
/* First run `suspend-tty-functions' and then clean up the tty
state because `suspend-tty-functions' might need to change
the tty state. */
- if (!NILP (Vrun_hooks))
- {
- Lisp_Object args[2];
- args[0] = intern ("suspend-tty-functions");
- XSETTERMINAL (args[1], t);
- Frun_hook_with_args (2, args);
- }
+ Lisp_Object args[2];
+ args[0] = intern ("suspend-tty-functions");
+ XSETTERMINAL (args[1], t);
+ Frun_hook_with_args (2, args);
reset_sys_modes (t->display_info.tty);
delete_keyboard_wait_descriptor (fileno (f));
FRAME_SET_VISIBLE (XFRAME (t->display_info.tty->top_frame), 1);
}
+ set_tty_hooks (t);
init_sys_modes (t->display_info.tty);
- /* Run `resume-tty-functions'. */
- if (!NILP (Vrun_hooks))
- {
- 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 args[2];
+ args[0] = intern ("resume-tty-functions");
+ XSETTERMINAL (args[1], t);
+ Frun_hook_with_args (2, args);
+ }
}
set_tty_hooks (t);
***********************************************************************/
#ifdef HAVE_GPM
+
+#ifndef HAVE_WINDOW_SYSTEM
void
term_mouse_moveto (int x, int y)
{
last_mouse_x = x;
last_mouse_y = y; */
}
+#endif /* HAVE_WINDOW_SYSTEM */
/* Implementation of draw_row_with_mouse_face for TTY/GPM. */
void
static void
term_mouse_position (FRAME_PTR *fp, int insist, Lisp_Object *bar_window,
enum scroll_bar_part *part, Lisp_Object *x,
- Lisp_Object *y, unsigned long *timeptr)
+ Lisp_Object *y, Time *timeptr)
{
struct timeval now;
+ Time sec, usec;
*fp = SELECTED_FRAME ();
(*fp)->mouse_moved = 0;
XSETINT (*x, last_mouse_x);
XSETINT (*y, last_mouse_y);
gettimeofday(&now, 0);
- *timeptr = (now.tv_sec * 1000) + (now.tv_usec / 1000);
+ sec = now.tv_sec;
+ usec = now.tv_usec;
+ *timeptr = (sec * 1000) + (usec / 1000);
}
/* Prepare a mouse-event in *RESULT for placement in the input queue.
terminal = create_terminal ();
#ifdef MSDOS
if (been_here > 0)
- maybe_fatal (1, 0, "Attempt to create another terminal %s", "",
+ maybe_fatal (0, 0, "Attempt to create another terminal %s", "",
name, "");
been_here = 1;
tty = &the_only_display_info;
if we don't have one at the moment. */
fd = emacs_open (name, O_RDWR | O_IGNORE_CTTY | O_NOCTTY, 0);
else
-#else
+#endif /* O_IGNORE_CTTY */
/* Alas, O_IGNORE_CTTY is a GNU extension that seems to be only
defined on Hurd. On other systems, we need to explicitly
dissociate ourselves from the controlling tty when we want to
open a frame on the same terminal. */
fd = emacs_open (name, O_RDWR | O_NOCTTY, 0);
-#endif /* O_IGNORE_CTTY */
tty->name = xstrdup (name);
terminal->name = xstrdup (name);
vfprintf (stderr, str, ap);
if (!(strlen (str) > 0 && str[strlen (str) - 1] == '\n'))
fprintf (stderr, "\n");
- va_end (ap);
fflush (stderr);
exit (1);
}
/* Auxiliary error-handling function for init_tty.
Delete TERMINAL, then call error or fatal with str1 or str2,
- respectively, according to MUST_SUCCEED. */
+ respectively, according to whether MUST_SUCCEED is zero or not. */
static void
maybe_fatal (int must_succeed, struct terminal *terminal,