aboutsummaryrefslogtreecommitdiffstats
path: root/src/msdos.c
diff options
context:
space:
mode:
authorEli Zaretskii2013-09-05 11:01:04 +0300
committerEli Zaretskii2013-09-05 11:01:04 +0300
commit41306318777a942420bc4feadbfacf662ea179dc (patch)
tree669e5cca02f95d6064ce73c0d3fbbf91b8c8b563 /src/msdos.c
parent141f1ff7a40cda10f0558e891dd196a943a5082e (diff)
parent257b3b03cb1cff917e0b3b7832ad3eab5b59f257 (diff)
downloademacs-41306318777a942420bc4feadbfacf662ea179dc.tar.gz
emacs-41306318777a942420bc4feadbfacf662ea179dc.zip
Merge from trunk after a lot of time.
Diffstat (limited to 'src/msdos.c')
-rw-r--r--src/msdos.c285
1 files changed, 106 insertions, 179 deletions
diff --git a/src/msdos.c b/src/msdos.c
index 95d16438005..5ad227bd67c 100644
--- a/src/msdos.c
+++ b/src/msdos.c
@@ -1,6 +1,6 @@
1/* MS-DOS specific C utilities. -*- coding: raw-text -*- 1/* MS-DOS specific C utilities. -*- coding: cp850 -*-
2 2
3Copyright (C) 1993-1997, 1999-2012 Free Software Foundation, Inc. 3Copyright (C) 1993-1997, 1999-2013 Free Software Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
6 6
@@ -20,6 +20,13 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
20/* Contributed by Morten Welinder */ 20/* Contributed by Morten Welinder */
21/* New display, keyboard, and mouse control by Kim F. Storm */ 21/* New display, keyboard, and mouse control by Kim F. Storm */
22 22
23/* Note: This file MUST use a unibyte encoding, to both display the
24 keys on the non-US keyboard layout as their respective labels, and
25 provide the correct byte values for the keyboard input to inject
26 into Emacs. See 'struct dos_keyboard_map' below. As long as there
27 are only European keyboard layouts here, we are OK with DOS
28 codepage 850 encoding. */
29
23/* Note: some of the stuff here was taken from end of sysdep.c in demacs. */ 30/* Note: some of the stuff here was taken from end of sysdep.c in demacs. */
24 31
25#include <config.h> 32#include <config.h>
@@ -31,7 +38,13 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
31#include <time.h> 38#include <time.h>
32#include <sys/param.h> 39#include <sys/param.h>
33#include <sys/time.h> 40#include <sys/time.h>
41/* gettime and settime in dos.h clash with their namesakes from
42 gnulib, so we move out of our way the prototypes in dos.h. */
43#define gettime dos_h_gettime_
44#define settime dos_h_settime_
34#include <dos.h> 45#include <dos.h>
46#undef gettime
47#undef settime
35#include <errno.h> 48#include <errno.h>
36#include <sys/stat.h> /* for _fixpath */ 49#include <sys/stat.h> /* for _fixpath */
37#include <unistd.h> /* for chdir, dup, dup2, etc. */ 50#include <unistd.h> /* for chdir, dup, dup2, etc. */
@@ -103,18 +116,18 @@ int _crt0_startup_flags = (_CRT0_FLAG_UNIX_SBRK | _CRT0_FLAG_FILL_SBRK_MEMORY);
103 116
104#endif /* not SYSTEM_MALLOC */ 117#endif /* not SYSTEM_MALLOC */
105 118
119/* Return the current timestamp in milliseconds since midnight. */
106static unsigned long 120static unsigned long
107event_timestamp (void) 121event_timestamp (void)
108{ 122{
109 struct time t; 123 struct timespec t;
110 unsigned long s; 124 unsigned long s;
111 125
112 gettime (&t); 126 gettime (&t);
113 s = t.ti_min; 127 s = t.tv_sec;
114 s *= 60; 128 s %= 86400;
115 s += t.ti_sec;
116 s *= 1000; 129 s *= 1000;
117 s += t.ti_hund * 10; 130 s += t.tv_nsec * 1000000;
118 131
119 return s; 132 return s;
120} 133}
@@ -285,7 +298,7 @@ mouse_button_depressed (int b, int *xp, int *yp)
285} 298}
286 299
287void 300void
288mouse_get_pos (FRAME_PTR *f, int insist, Lisp_Object *bar_window, 301mouse_get_pos (struct frame **f, int insist, Lisp_Object *bar_window,
289 enum scroll_bar_part *part, Lisp_Object *x, Lisp_Object *y, 302 enum scroll_bar_part *part, Lisp_Object *x, Lisp_Object *y,
290 Time *time) 303 Time *time)
291{ 304{
@@ -514,8 +527,10 @@ dos_set_window_size (int *rows, int *cols)
514 527
515 /* If the user specified a special video mode for these dimensions, 528 /* If the user specified a special video mode for these dimensions,
516 use that mode. */ 529 use that mode. */
517 sprintf (video_name, "screen-dimensions-%dx%d", *rows, *cols); 530 video_mode
518 video_mode = Fsymbol_value (Fintern_soft (build_string (video_name), Qnil)); 531 = Fsymbol_value (Fintern_soft (make_formatted_string
532 (video_name, "screen-dimensions-%dx%d",
533 *rows, *cols), Qnil));
519 534
520 if (INTEGERP (video_mode) 535 if (INTEGERP (video_mode)
521 && (video_mode_value = XINT (video_mode)) > 0) 536 && (video_mode_value = XINT (video_mode)) > 0)
@@ -587,11 +602,7 @@ dos_set_window_size (int *rows, int *cols)
587 Lisp_Object window = hlinfo->mouse_face_window; 602 Lisp_Object window = hlinfo->mouse_face_window;
588 603
589 if (! NILP (window) && XFRAME (XWINDOW (window)->frame) == f) 604 if (! NILP (window) && XFRAME (XWINDOW (window)->frame) == f)
590 { 605 reset_mouse_highlight (hlinfo);
591 hlinfo->mouse_face_beg_row = hlinfo->mouse_face_beg_col = -1;
592 hlinfo->mouse_face_end_row = hlinfo->mouse_face_end_col = -1;
593 hlinfo->mouse_face_window = Qnil;
594 }
595 } 606 }
596 607
597 /* Enable bright background colors. */ 608 /* Enable bright background colors. */
@@ -788,7 +799,7 @@ IT_set_face (int face)
788 /* The default face for the frame should always be realized and 799 /* The default face for the frame should always be realized and
789 cached. */ 800 cached. */
790 if (!fp) 801 if (!fp)
791 abort (); 802 emacs_abort ();
792 } 803 }
793 screen_face = face; 804 screen_face = face;
794 fg = fp->foreground; 805 fg = fp->foreground;
@@ -935,9 +946,6 @@ IT_write_glyphs (struct frame *f, struct glyph *str, int str_len)
935 Mouse Highlight (and friends..) 946 Mouse Highlight (and friends..)
936 ************************************************************************/ 947 ************************************************************************/
937 948
938/* Last window where we saw the mouse. Used by mouse-autoselect-window. */
939static Lisp_Object last_mouse_window;
940
941static int mouse_preempted = 0; /* non-zero when XMenu gobbles mouse events */ 949static int mouse_preempted = 0; /* non-zero when XMenu gobbles mouse events */
942 950
943int 951int
@@ -1021,7 +1029,6 @@ IT_clear_end_of_line (struct frame *f, int first_unused)
1021{ 1029{
1022 char *spaces, *sp; 1030 char *spaces, *sp;
1023 int i, j, offset = 2 * (new_pos_X + screen_size_X * new_pos_Y); 1031 int i, j, offset = 2 * (new_pos_X + screen_size_X * new_pos_Y);
1024 extern int fatal_error_in_progress;
1025 struct tty_display_info *tty = FRAME_TTY (f); 1032 struct tty_display_info *tty = FRAME_TTY (f);
1026 1033
1027 if (new_pos_X >= first_unused || fatal_error_in_progress) 1034 if (new_pos_X >= first_unused || fatal_error_in_progress)
@@ -1144,7 +1151,7 @@ IT_display_cursor (int on)
1144 to put the cursor at the end of the text displayed there. */ 1151 to put the cursor at the end of the text displayed there. */
1145 1152
1146static void 1153static void
1147IT_cmgoto (FRAME_PTR f) 1154IT_cmgoto (struct frame *f)
1148{ 1155{
1149 /* Only set the cursor to where it should be if the display is 1156 /* Only set the cursor to where it should be if the display is
1150 already in sync with the window contents. */ 1157 already in sync with the window contents. */
@@ -1222,7 +1229,7 @@ IT_update_begin (struct frame *f)
1222 if (display_info->termscript) 1229 if (display_info->termscript)
1223 fprintf (display_info->termscript, "\n\n<UPDATE_BEGIN"); 1230 fprintf (display_info->termscript, "\n\n<UPDATE_BEGIN");
1224 1231
1225 BLOCK_INPUT; 1232 block_input ();
1226 1233
1227 if (f && f == mouse_face_frame) 1234 if (f && f == mouse_face_frame)
1228 { 1235 {
@@ -1247,7 +1254,7 @@ IT_update_begin (struct frame *f)
1247 /* If the mouse highlight is in the window that was deleted 1254 /* If the mouse highlight is in the window that was deleted
1248 (e.g., if it was popped by completion), clear highlight 1255 (e.g., if it was popped by completion), clear highlight
1249 unconditionally. */ 1256 unconditionally. */
1250 if (NILP (w->buffer)) 1257 if (NILP (w->contents))
1251 hlinfo->mouse_face_window = Qnil; 1258 hlinfo->mouse_face_window = Qnil;
1252 else 1259 else
1253 { 1260 {
@@ -1257,22 +1264,16 @@ IT_update_begin (struct frame *f)
1257 break; 1264 break;
1258 } 1265 }
1259 1266
1260 if (NILP (w->buffer) || i < w->desired_matrix->nrows) 1267 if (NILP (w->contents) || i < w->desired_matrix->nrows)
1261 clear_mouse_face (hlinfo); 1268 clear_mouse_face (hlinfo);
1262 } 1269 }
1263 } 1270 }
1264 else if (mouse_face_frame && !FRAME_LIVE_P (mouse_face_frame)) 1271 else if (mouse_face_frame && !FRAME_LIVE_P (mouse_face_frame))
1265 { 1272 /* If the frame with mouse highlight was deleted, invalidate the
1266 /* If the frame with mouse highlight was deleted, invalidate the 1273 highlight info. */
1267 highlight info. */ 1274 reset_mouse_highlight (hlinfo);
1268 hlinfo->mouse_face_beg_row = hlinfo->mouse_face_beg_col = -1;
1269 hlinfo->mouse_face_end_row = hlinfo->mouse_face_end_col = -1;
1270 hlinfo->mouse_face_window = Qnil;
1271 hlinfo->mouse_face_deferred_gc = 0;
1272 hlinfo->mouse_face_mouse_frame = NULL;
1273 }
1274 1275
1275 UNBLOCK_INPUT; 1276 unblock_input ();
1276} 1277}
1277 1278
1278static void 1279static void
@@ -1288,21 +1289,10 @@ IT_update_end (struct frame *f)
1288static void 1289static void
1289IT_frame_up_to_date (struct frame *f) 1290IT_frame_up_to_date (struct frame *f)
1290{ 1291{
1291 Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f);
1292 Lisp_Object new_cursor, frame_desired_cursor; 1292 Lisp_Object new_cursor, frame_desired_cursor;
1293 struct window *sw; 1293 struct window *sw;
1294 1294
1295 if (hlinfo->mouse_face_deferred_gc 1295 FRAME_MOUSE_UPDATE (f);
1296 || (f && f == hlinfo->mouse_face_mouse_frame))
1297 {
1298 BLOCK_INPUT;
1299 if (hlinfo->mouse_face_mouse_frame)
1300 note_mouse_highlight (hlinfo->mouse_face_mouse_frame,
1301 hlinfo->mouse_face_mouse_x,
1302 hlinfo->mouse_face_mouse_y);
1303 hlinfo->mouse_face_deferred_gc = 0;
1304 UNBLOCK_INPUT;
1305 }
1306 1296
1307 /* Set the cursor type to whatever they wanted. In a minibuffer 1297 /* Set the cursor type to whatever they wanted. In a minibuffer
1308 window, we want the cursor to appear only if we are reading input 1298 window, we want the cursor to appear only if we are reading input
@@ -1319,7 +1309,7 @@ IT_frame_up_to_date (struct frame *f)
1319 new_cursor = frame_desired_cursor; 1309 new_cursor = frame_desired_cursor;
1320 else 1310 else
1321 { 1311 {
1322 struct buffer *b = XBUFFER (sw->buffer); 1312 struct buffer *b = XBUFFER (sw->contents);
1323 1313
1324 if (EQ (BVAR (b,cursor_type), Qt)) 1314 if (EQ (BVAR (b,cursor_type), Qt))
1325 new_cursor = frame_desired_cursor; 1315 new_cursor = frame_desired_cursor;
@@ -1386,7 +1376,7 @@ IT_insert_glyphs (struct frame *f, struct glyph *start, int len)
1386static void 1376static void
1387IT_delete_glyphs (struct frame *f, int n) 1377IT_delete_glyphs (struct frame *f, int n)
1388{ 1378{
1389 abort (); 1379 emacs_abort ();
1390} 1380}
1391 1381
1392/* This was copied from xfaces.c */ 1382/* This was copied from xfaces.c */
@@ -1546,11 +1536,6 @@ IT_reset_terminal_modes (struct terminal *term)
1546 term_setup_done = 0; 1536 term_setup_done = 0;
1547} 1537}
1548 1538
1549static void
1550IT_set_terminal_window (struct frame *f, int foo)
1551{
1552}
1553
1554/* Remember the screen colors of the current frame, to serve as the 1539/* Remember the screen colors of the current frame, to serve as the
1555 default colors for newly-created frames. */ 1540 default colors for newly-created frames. */
1556DEFUN ("msdos-remember-default-colors", Fmsdos_remember_default_colors, 1541DEFUN ("msdos-remember-default-colors", Fmsdos_remember_default_colors,
@@ -1579,9 +1564,9 @@ IT_set_frame_parameters (struct frame *f, Lisp_Object alist)
1579 Lisp_Object tail; 1564 Lisp_Object tail;
1580 int i, j, length = XINT (Flength (alist)); 1565 int i, j, length = XINT (Flength (alist));
1581 Lisp_Object *parms 1566 Lisp_Object *parms
1582 = (Lisp_Object *) alloca (length * sizeof (Lisp_Object)); 1567 = (Lisp_Object *) alloca (length * word_size);
1583 Lisp_Object *values 1568 Lisp_Object *values
1584 = (Lisp_Object *) alloca (length * sizeof (Lisp_Object)); 1569 = (Lisp_Object *) alloca (length * word_size);
1585 /* Do we have to reverse the foreground and background colors? */ 1570 /* Do we have to reverse the foreground and background colors? */
1586 int reverse = EQ (Fcdr (Fassq (Qreverse, f->param_alist)), Qt); 1571 int reverse = EQ (Fcdr (Fassq (Qreverse, f->param_alist)), Qt);
1587 int redraw = 0, fg_set = 0, bg_set = 0; 1572 int redraw = 0, fg_set = 0, bg_set = 0;
@@ -1603,11 +1588,9 @@ IT_set_frame_parameters (struct frame *f, Lisp_Object alist)
1603 1588
1604 /* Extract parm names and values into those vectors. */ 1589 /* Extract parm names and values into those vectors. */
1605 i = 0; 1590 i = 0;
1606 for (tail = alist; CONSP (tail); tail = Fcdr (tail)) 1591 for (tail = alist; CONSP (tail); tail = XCDR (tail))
1607 { 1592 {
1608 Lisp_Object elt; 1593 Lisp_Object elt = XCAR (tail);
1609
1610 elt = Fcar (tail);
1611 parms[i] = Fcar (elt); 1594 parms[i] = Fcar (elt);
1612 CHECK_SYMBOL (parms[i]); 1595 CHECK_SYMBOL (parms[i]);
1613 values[i] = Fcdr (elt); 1596 values[i] = Fcdr (elt);
@@ -1753,7 +1736,7 @@ IT_set_frame_parameters (struct frame *f, Lisp_Object alist)
1753 } 1736 }
1754} 1737}
1755 1738
1756extern void init_frame_faces (FRAME_PTR); 1739extern void init_frame_faces (struct frame *);
1757 1740
1758#endif /* !HAVE_X_WINDOWS */ 1741#endif /* !HAVE_X_WINDOWS */
1759 1742
@@ -1788,7 +1771,7 @@ internal_terminal_init (void)
1788 } 1771 }
1789 1772
1790 tty = FRAME_TTY (sf); 1773 tty = FRAME_TTY (sf);
1791 KVAR (current_kboard, Vwindow_system) = Qpc; 1774 kset_window_system (current_kboard, Qpc);
1792 sf->output_method = output_msdos_raw; 1775 sf->output_method = output_msdos_raw;
1793 if (init_needed) 1776 if (init_needed)
1794 { 1777 {
@@ -1836,18 +1819,8 @@ internal_terminal_init (void)
1836 if (colors[1] >= 0 && colors[1] < 16) 1819 if (colors[1] >= 0 && colors[1] < 16)
1837 FRAME_BACKGROUND_PIXEL (SELECTED_FRAME ()) = colors[1]; 1820 FRAME_BACKGROUND_PIXEL (SELECTED_FRAME ()) = colors[1];
1838 } 1821 }
1839 the_only_display_info.mouse_highlight.mouse_face_mouse_frame = NULL; 1822
1840 the_only_display_info.mouse_highlight.mouse_face_deferred_gc = 0; 1823 reset_mouse_highlight (&the_only_display_info.mouse_highlight);
1841 the_only_display_info.mouse_highlight.mouse_face_beg_row =
1842 the_only_display_info.mouse_highlight.mouse_face_beg_col = -1;
1843 the_only_display_info.mouse_highlight.mouse_face_end_row =
1844 the_only_display_info.mouse_highlight.mouse_face_end_col = -1;
1845 the_only_display_info.mouse_highlight.mouse_face_face_id = DEFAULT_FACE_ID;
1846 the_only_display_info.mouse_highlight.mouse_face_window = Qnil;
1847 the_only_display_info.mouse_highlight.mouse_face_mouse_x =
1848 the_only_display_info.mouse_highlight.mouse_face_mouse_y = 0;
1849 the_only_display_info.mouse_highlight.mouse_face_defer = 0;
1850 the_only_display_info.mouse_highlight.mouse_face_hidden = 0;
1851 1824
1852 if (have_mouse) /* detected in dos_ttraw, which see */ 1825 if (have_mouse) /* detected in dos_ttraw, which see */
1853 { 1826 {
@@ -1883,7 +1856,7 @@ initialize_msdos_display (struct terminal *term)
1883 term->ring_bell_hook = IT_ring_bell; 1856 term->ring_bell_hook = IT_ring_bell;
1884 term->reset_terminal_modes_hook = IT_reset_terminal_modes; 1857 term->reset_terminal_modes_hook = IT_reset_terminal_modes;
1885 term->set_terminal_modes_hook = IT_set_terminal_modes; 1858 term->set_terminal_modes_hook = IT_set_terminal_modes;
1886 term->set_terminal_window_hook = IT_set_terminal_window; 1859 term->set_terminal_window_hook = NULL;
1887 term->update_begin_hook = IT_update_begin; 1860 term->update_begin_hook = IT_update_begin;
1888 term->update_end_hook = IT_update_end; 1861 term->update_end_hook = IT_update_end;
1889 term->frame_up_to_date_hook = IT_frame_up_to_date; 1862 term->frame_up_to_date_hook = IT_frame_up_to_date;
@@ -1914,7 +1887,7 @@ dos_get_saved_screen (char **screen, int *rows, int *cols)
1914 1887
1915/* We are not X, but we can emulate it well enough for our needs... */ 1888/* We are not X, but we can emulate it well enough for our needs... */
1916void 1889void
1917check_x (void) 1890check_window_system (void)
1918{ 1891{
1919 if (! FRAME_MSDOS_P (SELECTED_FRAME ())) 1892 if (! FRAME_MSDOS_P (SELECTED_FRAME ()))
1920 error ("Not running under a window system"); 1893 error ("Not running under a window system");
@@ -1966,10 +1939,10 @@ struct dos_keyboard_map
1966 1939
1967static struct dos_keyboard_map us_keyboard = { 1940static struct dos_keyboard_map us_keyboard = {
1968/* 0 1 2 3 4 5 */ 1941/* 0 1 2 3 4 5 */
1969/* 01234567890123456789012345678901234567890 12345678901234 */ 1942/* 01234567890123456789012345678901234567890 123 45678901234 */
1970 "`1234567890-= qwertyuiop[] asdfghjkl;'\\ zxcvbnm,./ ", 1943 "`1234567890-= qwertyuiop[] asdfghjkl;'\\ \\zxcvbnm,./ ",
1971/* 0123456789012345678901234567890123456789 012345678901234 */ 1944/* 0123456789012345678901234567890123456789 012345678901234 */
1972 "~!@#$%^&*()_+ QWERTYUIOP{} ASDFGHJKL:\"| ZXCVBNM<>? ", 1945 "~!@#$%^&*()_+ QWERTYUIOP{} ASDFGHJKL:\"| |ZXCVBNM<>? ",
1973 0, /* no Alt-Gr key */ 1946 0, /* no Alt-Gr key */
1974 0 /* no translate table */ 1947 0 /* no translate table */
1975}; 1948};
@@ -1977,9 +1950,9 @@ static struct dos_keyboard_map us_keyboard = {
1977static struct dos_keyboard_map fr_keyboard = { 1950static struct dos_keyboard_map fr_keyboard = {
1978/* 0 1 2 3 4 5 */ 1951/* 0 1 2 3 4 5 */
1979/* 012 3456789012345678901234567890123456789012345678901234 */ 1952/* 012 3456789012345678901234567890123456789012345678901234 */
1980 "ý&‚\",(-Š_€…)= azertyuiop^$ qsdfghjklm—* wxcvbnm;:! ", 1953 "ý&‚\"'(-Š_€…)= azertyuiop^$ qsdfghjklm—* <wxcvbn,;:! ",
1981/* 0123456789012345678901234567890123456789012345678901234 */ 1954/* 0123456789012345678901234567890123456789012345678901234 */
1982 " 1234567890ø+ AZERTYUIOPùœ QSDFGHJKLM%æ WXCVBN?./õ ", 1955 " 1234567890ø+ AZERTYUIOPùœ QSDFGHJKLM%æ >WXCVBN?./õ ",
1983/* 01234567 89012345678901234567890123456789012345678901234 */ 1956/* 01234567 89012345678901234567890123456789012345678901234 */
1984 " ~#{[|`\\^@]} Ï ", 1957 " ~#{[|`\\^@]} Ï ",
1985 0 /* no translate table */ 1958 0 /* no translate table */
@@ -2001,9 +1974,9 @@ static struct kbd_translate it_kbd_translate_table[] = {
2001static struct dos_keyboard_map it_keyboard = { 1974static struct dos_keyboard_map it_keyboard = {
2002/* 0 1 2 3 4 5 */ 1975/* 0 1 2 3 4 5 */
2003/* 0 123456789012345678901234567890123456789012345678901234 */ 1976/* 0 123456789012345678901234567890123456789012345678901234 */
2004 "\\1234567890'< qwertyuiopŠ+> asdfghjkl•…— zxcvbnm,.- ", 1977 "\\1234567890'< qwertyuiopŠ+> asdfghjkl•…— <zxcvbnm,.- ",
2005/* 01 23456789012345678901234567890123456789012345678901234 */ 1978/* 01 23456789012345678901234567890123456789012345678901234 */
2006 "|!\"œ$%&/()=?^> QWERTYUIOP‚* ASDFGHJKL‡øõ ZXCVBNM;:_ ", 1979 "|!\"œ$%&/()=?^> QWERTYUIOP‚* ASDFGHJKL‡øõ >ZXCVBNM;:_ ",
2007/* 0123456789012345678901234567890123456789012345678901234 */ 1980/* 0123456789012345678901234567890123456789012345678901234 */
2008 " {}~` [] @# ", 1981 " {}~` [] @# ",
2009 it_kbd_translate_table 1982 it_kbd_translate_table
@@ -2012,9 +1985,9 @@ static struct dos_keyboard_map it_keyboard = {
2012static struct dos_keyboard_map dk_keyboard = { 1985static struct dos_keyboard_map dk_keyboard = {
2013/* 0 1 2 3 4 5 */ 1986/* 0 1 2 3 4 5 */
2014/* 0123456789012345678901234567890123456789012345678901234 */ 1987/* 0123456789012345678901234567890123456789012345678901234 */
2015 "«1234567890+| qwertyuiop†~ asdfghjkl‘›' zxcvbnm,.- ", 1988 "«1234567890+| qwertyuiop†~ asdfghjkl‘›' <zxcvbnm,.- ",
2016/* 01 23456789012345678901234567890123456789012345678901234 */ 1989/* 01 23456789012345678901234567890123456789012345678901234 */
2017 "õ!\"#$%&/()=?` QWERTYUIOP^ ASDFGHJKL’* ZXCVBNM;:_ ", 1990 "õ!\"#$%&/()=?` QWERTYUIOP^ ASDFGHJKL’* >ZXCVBNM;:_ ",
2018/* 0123456789012345678901234567890123456789012345678901234 */ 1991/* 0123456789012345678901234567890123456789012345678901234 */
2019 " @œ$ {[]} | ", 1992 " @œ$ {[]} | ",
2020 0 /* no translate table */ 1993 0 /* no translate table */
@@ -2421,10 +2394,10 @@ and then the scan code. */)
2421 else 2394 else
2422 { 2395 {
2423 val = Fvector (NUM_RECENT_DOSKEYS, keys); 2396 val = Fvector (NUM_RECENT_DOSKEYS, keys);
2424 memcpy (XVECTOR (val)->contents, keys + recent_doskeys_index, 2397 vcopy (val, 0, keys + recent_doskeys_index,
2425 (NUM_RECENT_DOSKEYS - recent_doskeys_index) * sizeof (Lisp_Object)); 2398 NUM_RECENT_DOSKEYS - recent_doskeys_index);
2426 memcpy (XVECTOR (val)->contents + NUM_RECENT_DOSKEYS - recent_doskeys_index, 2399 vcopy (val, NUM_RECENT_DOSKEYS - recent_doskeys_index,
2427 keys, recent_doskeys_index * sizeof (Lisp_Object)); 2400 keys, recent_doskeys_index);
2428 return val; 2401 return val;
2429 } 2402 }
2430} 2403}
@@ -2459,12 +2432,12 @@ dos_rawgetc (void)
2459 sc = regs.h.ah; 2432 sc = regs.h.ah;
2460 2433
2461 total_doskeys += 2; 2434 total_doskeys += 2;
2462 XVECTOR (recent_doskeys)->contents[recent_doskeys_index++] 2435 ASET (recent_doskeys, recent_doskeys_index, make_number (c));
2463 = make_number (c); 2436 recent_doskeys_index++;
2464 if (recent_doskeys_index == NUM_RECENT_DOSKEYS) 2437 if (recent_doskeys_index == NUM_RECENT_DOSKEYS)
2465 recent_doskeys_index = 0; 2438 recent_doskeys_index = 0;
2466 XVECTOR (recent_doskeys)->contents[recent_doskeys_index++] 2439 ASET (recent_doskeys, recent_doskeys_index, make_number (sc));
2467 = make_number (sc); 2440 recent_doskeys_index++;
2468 if (recent_doskeys_index == NUM_RECENT_DOSKEYS) 2441 if (recent_doskeys_index == NUM_RECENT_DOSKEYS)
2469 recent_doskeys_index = 0; 2442 recent_doskeys_index = 0;
2470 2443
@@ -2685,10 +2658,10 @@ dos_rawgetc (void)
2685 /* Generate SELECT_WINDOW_EVENTs when needed. */ 2658 /* Generate SELECT_WINDOW_EVENTs when needed. */
2686 if (!NILP (Vmouse_autoselect_window)) 2659 if (!NILP (Vmouse_autoselect_window))
2687 { 2660 {
2688 mouse_window = window_from_coordinates (SELECTED_FRAME (), 2661 static Lisp_Object last_mouse_window;
2689 mouse_last_x, 2662
2690 mouse_last_y, 2663 mouse_window = window_from_coordinates
2691 0, 0); 2664 (SELECTED_FRAME (), mouse_last_x, mouse_last_y, 0, 0);
2692 /* A window will be selected only when it is not 2665 /* A window will be selected only when it is not
2693 selected now, and the last mouse movement event was 2666 selected now, and the last mouse movement event was
2694 not in it. A minibuffer window will be selected iff 2667 not in it. A minibuffer window will be selected iff
@@ -2703,10 +2676,9 @@ dos_rawgetc (void)
2703 event.timestamp = event_timestamp (); 2676 event.timestamp = event_timestamp ();
2704 kbd_buffer_store_event (&event); 2677 kbd_buffer_store_event (&event);
2705 } 2678 }
2679 /* Remember the last window where we saw the mouse. */
2706 last_mouse_window = mouse_window; 2680 last_mouse_window = mouse_window;
2707 } 2681 }
2708 else
2709 last_mouse_window = Qnil;
2710 2682
2711 previous_help_echo_string = help_echo_string; 2683 previous_help_echo_string = help_echo_string;
2712 help_echo_string = help_echo_object = help_echo_window = Qnil; 2684 help_echo_string = help_echo_object = help_echo_window = Qnil;
@@ -2815,7 +2787,7 @@ IT_menu_create (void)
2815{ 2787{
2816 XMenu *menu; 2788 XMenu *menu;
2817 2789
2818 menu = (XMenu *) xmalloc (sizeof (XMenu)); 2790 menu = xmalloc (sizeof (XMenu));
2819 menu->allocated = menu->count = menu->panecount = menu->width = 0; 2791 menu->allocated = menu->count = menu->panecount = menu->width = 0;
2820 return menu; 2792 return menu;
2821} 2793}
@@ -2829,10 +2801,10 @@ IT_menu_make_room (XMenu *menu)
2829 if (menu->allocated == 0) 2801 if (menu->allocated == 0)
2830 { 2802 {
2831 int count = menu->allocated = 10; 2803 int count = menu->allocated = 10;
2832 menu->text = (char **) xmalloc (count * sizeof (char *)); 2804 menu->text = xmalloc (count * sizeof (char *));
2833 menu->submenu = (XMenu **) xmalloc (count * sizeof (XMenu *)); 2805 menu->submenu = xmalloc (count * sizeof (XMenu *));
2834 menu->panenumber = (int *) xmalloc (count * sizeof (int)); 2806 menu->panenumber = xmalloc (count * sizeof (int));
2835 menu->help_text = (const char **) xmalloc (count * sizeof (char *)); 2807 menu->help_text = xmalloc (count * sizeof (char *));
2836 } 2808 }
2837 else if (menu->allocated == menu->count) 2809 else if (menu->allocated == menu->count)
2838 { 2810 {
@@ -2913,7 +2885,7 @@ IT_menu_display (XMenu *menu, int y, int x, int pn, int *faces, int disp_help)
2913 width = menu->width; 2885 width = menu->width;
2914 /* We multiply width by 2 to account for possible control characters. 2886 /* We multiply width by 2 to account for possible control characters.
2915 FIXME: cater to non-ASCII characters in menus. */ 2887 FIXME: cater to non-ASCII characters in menus. */
2916 text = (struct glyph *) xmalloc ((width * 2 + 2) * sizeof (struct glyph)); 2888 text = xmalloc ((width * 2 + 2) * sizeof (struct glyph));
2917 ScreenGetCursor (&row, &col); 2889 ScreenGetCursor (&row, &col);
2918 mouse_get_xy (&mx, &my); 2890 mouse_get_xy (&mx, &my);
2919 IT_update_begin (sf); 2891 IT_update_begin (sf);
@@ -2977,11 +2949,6 @@ IT_menu_display (XMenu *menu, int y, int x, int pn, int *faces, int disp_help)
2977 2949
2978/* --------------------------- X Menu emulation ---------------------- */ 2950/* --------------------------- X Menu emulation ---------------------- */
2979 2951
2980/* Report availability of menus. */
2981
2982int
2983have_menus_p (void) { return 1; }
2984
2985/* Create a brand new menu structure. */ 2952/* Create a brand new menu structure. */
2986 2953
2987XMenu * 2954XMenu *
@@ -3001,7 +2968,7 @@ XMenuAddPane (Display *foo, XMenu *menu, const char *txt, int enable)
3001 const char *p; 2968 const char *p;
3002 2969
3003 if (!enable) 2970 if (!enable)
3004 abort (); 2971 emacs_abort ();
3005 2972
3006 IT_menu_make_room (menu); 2973 IT_menu_make_room (menu);
3007 menu->submenu[menu->count] = IT_menu_create (); 2974 menu->submenu[menu->count] = IT_menu_create ();
@@ -3282,10 +3249,10 @@ XMenuActivate (Display *foo, XMenu *menu, int *pane, int *selidx,
3282 erasing it works correctly... */ 3249 erasing it works correctly... */
3283 if (! NILP (saved_echo_area_message)) 3250 if (! NILP (saved_echo_area_message))
3284 message_with_string ("%s", saved_echo_area_message, 0); 3251 message_with_string ("%s", saved_echo_area_message, 0);
3285 message (0); 3252 message1 (0);
3286 while (statecount--) 3253 while (statecount--)
3287 xfree (state[statecount].screen_behind); 3254 xfree (state[statecount].screen_behind);
3288 IT_display_cursor (1); /* turn cursor back on */ 3255 IT_display_cursor (1); /* Turn cursor back on. */
3289 /* Clean up any mouse events that are waiting inside Emacs event queue. 3256 /* Clean up any mouse events that are waiting inside Emacs event queue.
3290 These events are likely to be generated before the menu was even 3257 These events are likely to be generated before the menu was even
3291 displayed, probably because the user pressed and released the button 3258 displayed, probably because the user pressed and released the button
@@ -3293,7 +3260,7 @@ XMenuActivate (Display *foo, XMenu *menu, int *pane, int *selidx,
3293 Emacs will process them after we return and surprise the user. */ 3260 Emacs will process them after we return and surprise the user. */
3294 discard_mouse_events (); 3261 discard_mouse_events ();
3295 mouse_clear_clicks (); 3262 mouse_clear_clicks ();
3296 if (!kbd_buffer_events_waiting (1)) 3263 if (!kbd_buffer_events_waiting ())
3297 clear_input_pending (); 3264 clear_input_pending ();
3298 /* Allow mouse events generation by dos_rawgetc. */ 3265 /* Allow mouse events generation by dos_rawgetc. */
3299 mouse_preempted--; 3266 mouse_preempted--;
@@ -3319,18 +3286,6 @@ XMenuDestroy (Display *foo, XMenu *menu)
3319 xfree (menu); 3286 xfree (menu);
3320 menu_help_message = prev_menu_help_message = NULL; 3287 menu_help_message = prev_menu_help_message = NULL;
3321} 3288}
3322
3323int
3324x_pixel_width (struct frame *f)
3325{
3326 return FRAME_COLS (f);
3327}
3328
3329int
3330x_pixel_height (struct frame *f)
3331{
3332 return FRAME_LINES (f);
3333}
3334#endif /* !HAVE_X_WINDOWS */ 3289#endif /* !HAVE_X_WINDOWS */
3335 3290
3336/* ----------------------- DOS / UNIX conversion --------------------- */ 3291/* ----------------------- DOS / UNIX conversion --------------------- */
@@ -3340,7 +3295,7 @@ void msdos_downcase_filename (unsigned char *);
3340/* Destructively turn backslashes into slashes. */ 3295/* Destructively turn backslashes into slashes. */
3341 3296
3342void 3297void
3343dostounix_filename (char *p) 3298dostounix_filename (char *p, int ignore)
3344{ 3299{
3345 msdos_downcase_filename (p); 3300 msdos_downcase_filename (p);
3346 3301
@@ -3604,7 +3559,7 @@ init_environment (int argc, char **argv, int skip_args)
3604 if (!s) s = "c:/command.com"; 3559 if (!s) s = "c:/command.com";
3605 t = alloca (strlen (s) + 1); 3560 t = alloca (strlen (s) + 1);
3606 strcpy (t, s); 3561 strcpy (t, s);
3607 dostounix_filename (t); 3562 dostounix_filename (t, 0);
3608 setenv ("SHELL", t, 0); 3563 setenv ("SHELL", t, 0);
3609 3564
3610 /* PATH is also downcased and backslashes mirrored. */ 3565 /* PATH is also downcased and backslashes mirrored. */
@@ -3614,7 +3569,7 @@ init_environment (int argc, char **argv, int skip_args)
3614 /* Current directory is always considered part of MsDos's path but it is 3569 /* Current directory is always considered part of MsDos's path but it is
3615 not normally mentioned. Now it is. */ 3570 not normally mentioned. Now it is. */
3616 strcat (strcpy (t, ".;"), s); 3571 strcat (strcpy (t, ".;"), s);
3617 dostounix_filename (t); /* Not a single file name, but this should work. */ 3572 dostounix_filename (t, 0); /* Not a single file name, but this should work. */
3618 setenv ("PATH", t, 1); 3573 setenv ("PATH", t, 1);
3619 3574
3620 /* In some sense all dos users have root privileges, so... */ 3575 /* In some sense all dos users have root privileges, so... */
@@ -3915,8 +3870,10 @@ croak (char *badfunc)
3915/* 3870/*
3916 * A few unimplemented functions that we silently ignore. 3871 * A few unimplemented functions that we silently ignore.
3917 */ 3872 */
3918int setpgrp (void) {return 0; } 3873pid_t tcgetpgrp (int fd) { return 0; }
3874int setpgid (int pid, int pgid) { return 0; }
3919int setpriority (int x, int y, int z) { return 0; } 3875int setpriority (int x, int y, int z) { return 0; }
3876pid_t setsid (void) { return 0; }
3920 3877
3921#if __DJGPP__ == 2 && __DJGPP_MINOR__ < 4 3878#if __DJGPP__ == 2 && __DJGPP_MINOR__ < 4
3922ssize_t 3879ssize_t
@@ -3956,14 +3913,6 @@ careadlinkat (int fd, char const *filename,
3956 return buffer; 3913 return buffer;
3957} 3914}
3958 3915
3959ssize_t
3960careadlinkatcwd (int fd, char const *filename, char *buffer,
3961 size_t buffer_size)
3962{
3963 (void) fd;
3964 return readlink (filename, buffer, buffer_size);
3965}
3966
3967 3916
3968#if __DJGPP__ == 2 && __DJGPP_MINOR__ < 2 3917#if __DJGPP__ == 2 && __DJGPP_MINOR__ < 2
3969 3918
@@ -4065,13 +4014,6 @@ sigprocmask (int how, const sigset_t *new_set, sigset_t *old_set)
4065#ifndef HAVE_SELECT 4014#ifndef HAVE_SELECT
4066#include "sysselect.h" 4015#include "sysselect.h"
4067 4016
4068#ifndef EMACS_TIME_ZERO_OR_NEG_P
4069#define EMACS_TIME_ZERO_OR_NEG_P(time) \
4070 ((long)(time).tv_sec < 0 \
4071 || ((time).tv_sec == 0 \
4072 && (long)(time).tv_usec <= 0))
4073#endif
4074
4075/* This yields the rest of the current time slice to the task manager. 4017/* This yields the rest of the current time slice to the task manager.
4076 It should be called by any code which knows that it has nothing 4018 It should be called by any code which knows that it has nothing
4077 useful to do except idle. 4019 useful to do except idle.
@@ -4097,10 +4039,10 @@ dos_yield_time_slice (void)
4097 because wait_reading_process_output takes care of that. */ 4039 because wait_reading_process_output takes care of that. */
4098int 4040int
4099sys_select (int nfds, SELECT_TYPE *rfds, SELECT_TYPE *wfds, SELECT_TYPE *efds, 4041sys_select (int nfds, SELECT_TYPE *rfds, SELECT_TYPE *wfds, SELECT_TYPE *efds,
4100 EMACS_TIME *timeout) 4042 struct timespec *timeout, void *ignored)
4101{ 4043{
4102 int check_input; 4044 int check_input;
4103 struct time t; 4045 struct timespec t;
4104 4046
4105 check_input = 0; 4047 check_input = 0;
4106 if (rfds) 4048 if (rfds)
@@ -4114,7 +4056,7 @@ sys_select (int nfds, SELECT_TYPE *rfds, SELECT_TYPE *wfds, SELECT_TYPE *efds,
4114 FD_ZERO (efds); 4056 FD_ZERO (efds);
4115 4057
4116 if (nfds != 1) 4058 if (nfds != 1)
4117 abort (); 4059 emacs_abort ();
4118 4060
4119 /* If we are looking only for the terminal, with no timeout, 4061 /* If we are looking only for the terminal, with no timeout,
4120 just read it and wait -- that's more efficient. */ 4062 just read it and wait -- that's more efficient. */
@@ -4127,25 +4069,20 @@ sys_select (int nfds, SELECT_TYPE *rfds, SELECT_TYPE *wfds, SELECT_TYPE *efds,
4127 } 4069 }
4128 else 4070 else
4129 { 4071 {
4130 EMACS_TIME clnow, cllast, cldiff; 4072 struct timespec clnow, cllast, cldiff;
4131 4073
4132 gettime (&t); 4074 gettime (&t);
4133 EMACS_SET_SECS_USECS (cllast, t.ti_sec, t.ti_hund * 10000L); 4075 cllast = make_timespec (t.tv_sec, t.tv_nsec);
4134 4076
4135 while (!check_input || !detect_input_pending ()) 4077 while (!check_input || !detect_input_pending ())
4136 { 4078 {
4137 gettime (&t); 4079 gettime (&t);
4138 EMACS_SET_SECS_USECS (clnow, t.ti_sec, t.ti_hund * 10000L); 4080 clnow = make_timespec (t.tv_sec, t.tv_nsec);
4139 EMACS_SUB_TIME (cldiff, clnow, cllast); 4081 cldiff = timespec_sub (clnow, cllast);
4140 4082 *timeout = timespec_sub (*timeout, cldiff);
4141 /* When seconds wrap around, we assume that no more than
4142 1 minute passed since last `gettime'. */
4143 if (EMACS_TIME_NEG_P (cldiff))
4144 EMACS_SET_SECS (cldiff, EMACS_SECS (cldiff) + 60);
4145 EMACS_SUB_TIME (*timeout, *timeout, cldiff);
4146 4083
4147 /* Stop when timeout value crosses zero. */ 4084 /* Stop when timeout value crosses zero. */
4148 if (EMACS_TIME_ZERO_OR_NEG_P (*timeout)) 4085 if (timespec_sign (*timeout) <= 0)
4149 return 0; 4086 return 0;
4150 cllast = clnow; 4087 cllast = clnow;
4151 dos_yield_time_slice (); 4088 dos_yield_time_slice ();
@@ -4214,26 +4151,8 @@ init_gettimeofday (void)
4214} 4151}
4215#endif 4152#endif
4216 4153
4217#ifdef abort 4154static void
4218#undef abort 4155msdos_abort (void)
4219void
4220dos_abort (char *file, int line)
4221{
4222 char buffer1[200], buffer2[400];
4223 int i, j;
4224
4225 sprintf (buffer1, "<EMACS FATAL ERROR IN %s LINE %d>", file, line);
4226 for (i = j = 0; buffer1[i]; i++) {
4227 buffer2[j++] = buffer1[i];
4228 buffer2[j++] = 0x70;
4229 }
4230 dosmemput (buffer2, j, (int)ScreenPrimary);
4231 ScreenSetCursor (2, 0);
4232 abort ();
4233}
4234#else
4235void
4236abort (void)
4237{ 4156{
4238 dos_ttcooked (); 4157 dos_ttcooked ();
4239 ScreenSetCursor (10, 0); 4158 ScreenSetCursor (10, 0);
@@ -4249,7 +4168,15 @@ abort (void)
4249#endif /* __DJGPP_MINOR__ >= 2 */ 4168#endif /* __DJGPP_MINOR__ >= 2 */
4250 exit (2); 4169 exit (2);
4251} 4170}
4252#endif 4171
4172void
4173msdos_fatal_signal (int sig)
4174{
4175 if (sig == SIGABRT)
4176 msdos_abort ();
4177 else
4178 raise (sig);
4179}
4253 4180
4254void 4181void
4255syms_of_msdos (void) 4182syms_of_msdos (void)