diff options
| author | Eli Zaretskii | 1999-04-04 11:43:57 +0000 |
|---|---|---|
| committer | Eli Zaretskii | 1999-04-04 11:43:57 +0000 |
| commit | d1d5dc1954b919bea8e276aa0deda511fa583992 (patch) | |
| tree | 1bad21e2acd13b41639849c06494f723c38d2345 | |
| parent | 01c504479b801c46c5963b42f213820193ad388b (diff) | |
| download | emacs-d1d5dc1954b919bea8e276aa0deda511fa583992.tar.gz emacs-d1d5dc1954b919bea8e276aa0deda511fa583992.zip | |
(struct kbd_translate): New struct, for key translation
tables private to certain national keyboard layouts.
(struct dos_keyboard_map): Add a pointer to a private translation
table.
(jp_kbd_translate_table): Private table for the Japanese
keyboard.
(jp_keyboard): Japanese keyboard layout.
(it_kbd_translate_table): Private table for the Italian keyboard.
(it_keyboard): Use it_kbd_translate_table.
(keyboard_layout_list): Add the Japanese keyboard.
(dos_rawgetc): Use the keyboard-private translation table, if
available.
(abort) [__DJGPP_MINOR__ >= 2]: Raise SIGABRT.
| -rw-r--r-- | src/msdos.c | 124 |
1 files changed, 93 insertions, 31 deletions
diff --git a/src/msdos.c b/src/msdos.c index 7abe41a6124..4a9aacc9432 100644 --- a/src/msdos.c +++ b/src/msdos.c | |||
| @@ -378,7 +378,7 @@ dosv_refresh_virtual_screen (int offset, int count) | |||
| 378 | } | 378 | } |
| 379 | #endif | 379 | #endif |
| 380 | 380 | ||
| 381 | static | 381 | static void |
| 382 | dos_direct_output (y, x, buf, len) | 382 | dos_direct_output (y, x, buf, len) |
| 383 | int y; | 383 | int y; |
| 384 | int x; | 384 | int x; |
| @@ -952,7 +952,7 @@ IT_cursor_to (int y, int x) | |||
| 952 | 952 | ||
| 953 | static int cursor_cleared; | 953 | static int cursor_cleared; |
| 954 | 954 | ||
| 955 | static | 955 | static void |
| 956 | IT_display_cursor (int on) | 956 | IT_display_cursor (int on) |
| 957 | { | 957 | { |
| 958 | if (on && cursor_cleared) | 958 | if (on && cursor_cleared) |
| @@ -1152,9 +1152,14 @@ IT_set_terminal_modes (void) | |||
| 1152 | es_value = regs.x.es; | 1152 | es_value = regs.x.es; |
| 1153 | __dpmi_int (0x10, ®s); | 1153 | __dpmi_int (0x10, ®s); |
| 1154 | 1154 | ||
| 1155 | if (regs.x.es != es_value && regs.x.es != (ScreenPrimary >> 4) & 0xffff) | 1155 | if (regs.x.es != es_value) |
| 1156 | { | 1156 | { |
| 1157 | screen_old_address = ScreenPrimary; | 1157 | /* screen_old_address is only set if ScreenPrimary does NOT |
| 1158 | already point to the relocated buffer address returned by | ||
| 1159 | the Int 10h/AX=FEh call above. DJGPP v2.02 and later sets | ||
| 1160 | ScreenPrimary to that address at startup under DOS/V. */ | ||
| 1161 | if (regs.x.es != (ScreenPrimary >> 4) & 0xffff) | ||
| 1162 | screen_old_address = ScreenPrimary; | ||
| 1158 | screen_virtual_segment = regs.x.es; | 1163 | screen_virtual_segment = regs.x.es; |
| 1159 | screen_virtual_offset = regs.x.di; | 1164 | screen_virtual_offset = regs.x.di; |
| 1160 | ScreenPrimary = (screen_virtual_segment << 4) + screen_virtual_offset; | 1165 | ScreenPrimary = (screen_virtual_segment << 4) + screen_virtual_offset; |
| @@ -1473,13 +1478,33 @@ check_x (void) | |||
| 1473 | * SPACE | 1478 | * SPACE |
| 1474 | */ | 1479 | */ |
| 1475 | 1480 | ||
| 1481 | #define Ignore 0x0000 | ||
| 1482 | #define Normal 0x0000 /* normal key - alt changes scan-code */ | ||
| 1483 | #define FctKey 0x1000 /* func key if c == 0, else c */ | ||
| 1484 | #define Special 0x2000 /* func key even if c != 0 */ | ||
| 1485 | #define ModFct 0x3000 /* special if mod-keys, else 'c' */ | ||
| 1486 | #define Map 0x4000 /* alt scan-code, map to unshift/shift key */ | ||
| 1487 | #define KeyPad 0x5000 /* map to insert/kp-0 depending on c == 0xe0 */ | ||
| 1488 | #define Grey 0x6000 /* Grey keypad key */ | ||
| 1489 | |||
| 1490 | #define Alt 0x0100 /* alt scan-code */ | ||
| 1491 | #define Ctrl 0x0200 /* ctrl scan-code */ | ||
| 1492 | #define Shift 0x0400 /* shift scan-code */ | ||
| 1493 | |||
| 1476 | static int extended_kbd; /* 101 (102) keyboard present. */ | 1494 | static int extended_kbd; /* 101 (102) keyboard present. */ |
| 1477 | 1495 | ||
| 1496 | struct kbd_translate { | ||
| 1497 | unsigned char sc; | ||
| 1498 | unsigned char ch; | ||
| 1499 | unsigned short code; | ||
| 1500 | }; | ||
| 1501 | |||
| 1478 | struct dos_keyboard_map | 1502 | struct dos_keyboard_map |
| 1479 | { | 1503 | { |
| 1480 | char *unshifted; | 1504 | char *unshifted; |
| 1481 | char *shifted; | 1505 | char *shifted; |
| 1482 | char *alt_gr; | 1506 | char *alt_gr; |
| 1507 | struct kbd_translate *translate_table; | ||
| 1483 | }; | 1508 | }; |
| 1484 | 1509 | ||
| 1485 | 1510 | ||
| @@ -1489,7 +1514,8 @@ static struct dos_keyboard_map us_keyboard = { | |||
| 1489 | "`1234567890-= qwertyuiop[] asdfghjkl;'\\ zxcvbnm,./ ", | 1514 | "`1234567890-= qwertyuiop[] asdfghjkl;'\\ zxcvbnm,./ ", |
| 1490 | /* 0123456789012345678901234567890123456789 012345678901234 */ | 1515 | /* 0123456789012345678901234567890123456789 012345678901234 */ |
| 1491 | "~!@#$%^&*()_+ QWERTYUIOP{} ASDFGHJKL:\"| ZXCVBNM<>? ", | 1516 | "~!@#$%^&*()_+ QWERTYUIOP{} ASDFGHJKL:\"| ZXCVBNM<>? ", |
| 1492 | 0 /* no Alt-Gr key */ | 1517 | 0, /* no Alt-Gr key */ |
| 1518 | 0 /* no translate table */ | ||
| 1493 | }; | 1519 | }; |
| 1494 | 1520 | ||
| 1495 | static struct dos_keyboard_map fr_keyboard = { | 1521 | static struct dos_keyboard_map fr_keyboard = { |
| @@ -1499,7 +1525,8 @@ static struct dos_keyboard_map fr_keyboard = { | |||
| 1499 | /* 0123456789012345678901234567890123456789012345678901234 */ | 1525 | /* 0123456789012345678901234567890123456789012345678901234 */ |
| 1500 | " 1234567890+ AZERTYUIOP QSDFGHJKLM% WXCVBN?./ ", | 1526 | " 1234567890+ AZERTYUIOP QSDFGHJKLM% WXCVBN?./ ", |
| 1501 | /* 01234567 89012345678901234567890123456789012345678901234 */ | 1527 | /* 01234567 89012345678901234567890123456789012345678901234 */ |
| 1502 | " ~#{[|`\\^@]} " | 1528 | " ~#{[|`\\^@]} ", |
| 1529 | 0 /* no translate table */ | ||
| 1503 | }; | 1530 | }; |
| 1504 | 1531 | ||
| 1505 | /* | 1532 | /* |
| @@ -1509,14 +1536,21 @@ static struct dos_keyboard_map fr_keyboard = { | |||
| 1509 | * added also {,},` as, respectively, AltGr-8, AltGr-9, AltGr-' | 1536 | * added also {,},` as, respectively, AltGr-8, AltGr-9, AltGr-' |
| 1510 | * Donated by Stefano Brozzi <brozzis@mag00.cedi.unipr.it> | 1537 | * Donated by Stefano Brozzi <brozzis@mag00.cedi.unipr.it> |
| 1511 | */ | 1538 | */ |
| 1539 | |||
| 1540 | static struct kbd_translate it_kbd_translate_table[] = { | ||
| 1541 | { 0x56, 0x3c, Map | 13 }, | ||
| 1542 | { 0x56, 0x3e, Map | 13 }, | ||
| 1543 | { 0, 0, 0 } | ||
| 1544 | }; | ||
| 1512 | static struct dos_keyboard_map it_keyboard = { | 1545 | static struct dos_keyboard_map it_keyboard = { |
| 1513 | /* 0 1 2 3 4 5 */ | 1546 | /* 0 1 2 3 4 5 */ |
| 1514 | /* 0 123456789012345678901234567890123456789012345678901234 */ | 1547 | /* 0 123456789012345678901234567890123456789012345678901234 */ |
| 1515 | "\\1234567890' qwertyuiop+ asdfghjkl zxcvbnm,.- ", | 1548 | "\\1234567890'< qwertyuiop+ asdfghjkl zxcvbnm,.- ", |
| 1516 | /* 01 23456789012345678901234567890123456789012345678901234 */ | 1549 | /* 01 23456789012345678901234567890123456789012345678901234 */ |
| 1517 | "|!\"$%&/()=?^ QWERTYUIOP* ASDFGHJKL ZXCVBNM;:_ ", | 1550 | "|!\"$%&/()=?^> QWERTYUIOP* ASDFGHJKL ZXCVBNM;:_ ", |
| 1518 | /* 0123456789012345678901234567890123456789012345678901234 */ | 1551 | /* 0123456789012345678901234567890123456789012345678901234 */ |
| 1519 | " {}~` [] @# " | 1552 | " {}~` [] @# ", |
| 1553 | it_kbd_translate_table | ||
| 1520 | }; | 1554 | }; |
| 1521 | 1555 | ||
| 1522 | static struct dos_keyboard_map dk_keyboard = { | 1556 | static struct dos_keyboard_map dk_keyboard = { |
| @@ -1526,7 +1560,23 @@ static struct dos_keyboard_map dk_keyboard = { | |||
| 1526 | /* 01 23456789012345678901234567890123456789012345678901234 */ | 1560 | /* 01 23456789012345678901234567890123456789012345678901234 */ |
| 1527 | "!\"#$%&/()=?` QWERTYUIOP^ ASDFGHJKL* ZXCVBNM;:_ ", | 1561 | "!\"#$%&/()=?` QWERTYUIOP^ ASDFGHJKL* ZXCVBNM;:_ ", |
| 1528 | /* 0123456789012345678901234567890123456789012345678901234 */ | 1562 | /* 0123456789012345678901234567890123456789012345678901234 */ |
| 1529 | " @$ {[]} | " | 1563 | " @$ {[]} | ", |
| 1564 | 0 /* no translate table */ | ||
| 1565 | }; | ||
| 1566 | |||
| 1567 | static struct kbd_translate jp_kbd_translate_table[] = { | ||
| 1568 | { 0x73, 0x5c, Map | 0 }, | ||
| 1569 | { 0x7d, 0x5c, Map | 13 }, | ||
| 1570 | { 0, 0, 0 } | ||
| 1571 | }; | ||
| 1572 | static struct dos_keyboard_map jp_keyboard = { | ||
| 1573 | /* 0 1 2 3 4 5 */ | ||
| 1574 | /* 0123456789012 345678901234567890123456789012345678901234 */ | ||
| 1575 | "\\1234567890-^\\ qwertyuiop@[ asdfghjkl;:] zxcvbnm,./ ", | ||
| 1576 | /* 01 23456789012345678901234567890123456789012345678901234 */ | ||
| 1577 | "_!\"#$%&'()~=~| QWERTYUIOP`{ ASDFGHJKL+*} ZXCVBNM<>? ", | ||
| 1578 | 0, /* no Alt-Gr key */ | ||
| 1579 | jp_kbd_translate_table | ||
| 1530 | }; | 1580 | }; |
| 1531 | 1581 | ||
| 1532 | static struct keyboard_layout_list | 1582 | static struct keyboard_layout_list |
| @@ -1538,7 +1588,8 @@ static struct keyboard_layout_list | |||
| 1538 | 1, &us_keyboard, | 1588 | 1, &us_keyboard, |
| 1539 | 33, &fr_keyboard, | 1589 | 33, &fr_keyboard, |
| 1540 | 39, &it_keyboard, | 1590 | 39, &it_keyboard, |
| 1541 | 45, &dk_keyboard | 1591 | 45, &dk_keyboard, |
| 1592 | 81, &jp_keyboard | ||
| 1542 | }; | 1593 | }; |
| 1543 | 1594 | ||
| 1544 | static struct dos_keyboard_map *keyboard; | 1595 | static struct dos_keyboard_map *keyboard; |
| @@ -1578,19 +1629,6 @@ dos_set_keyboard (code, always) | |||
| 1578 | return 0; | 1629 | return 0; |
| 1579 | } | 1630 | } |
| 1580 | 1631 | ||
| 1581 | #define Ignore 0x0000 | ||
| 1582 | #define Normal 0x0000 /* normal key - alt changes scan-code */ | ||
| 1583 | #define FctKey 0x1000 /* func key if c == 0, else c */ | ||
| 1584 | #define Special 0x2000 /* func key even if c != 0 */ | ||
| 1585 | #define ModFct 0x3000 /* special if mod-keys, else 'c' */ | ||
| 1586 | #define Map 0x4000 /* alt scan-code, map to unshift/shift key */ | ||
| 1587 | #define KeyPad 0x5000 /* map to insert/kp-0 depending on c == 0xe0 */ | ||
| 1588 | #define Grey 0x6000 /* Grey keypad key */ | ||
| 1589 | |||
| 1590 | #define Alt 0x0100 /* alt scan-code */ | ||
| 1591 | #define Ctrl 0x0200 /* ctrl scan-code */ | ||
| 1592 | #define Shift 0x0400 /* shift scan-code */ | ||
| 1593 | |||
| 1594 | static struct | 1632 | static struct |
| 1595 | { | 1633 | { |
| 1596 | unsigned char char_code; /* normal code */ | 1634 | unsigned char char_code; /* normal code */ |
| @@ -1690,7 +1728,7 @@ ibmpc_translate_map[] = | |||
| 1690 | Ignore, /* Right shift */ | 1728 | Ignore, /* Right shift */ |
| 1691 | Grey | 1, /* Grey * */ | 1729 | Grey | 1, /* Grey * */ |
| 1692 | Ignore, /* Alt */ | 1730 | Ignore, /* Alt */ |
| 1693 | Normal | ' ', /* ' ' */ | 1731 | Normal | 55, /* ' ' */ |
| 1694 | Ignore, /* Caps Lock */ | 1732 | Ignore, /* Caps Lock */ |
| 1695 | FctKey | 0xbe, /* F1 */ | 1733 | FctKey | 0xbe, /* F1 */ |
| 1696 | FctKey | 0xbf, /* F2 */ | 1734 | FctKey | 0xbf, /* F2 */ |
| @@ -1962,7 +2000,7 @@ dos_rawgetc () | |||
| 1962 | { | 2000 | { |
| 1963 | union REGS regs; | 2001 | union REGS regs; |
| 1964 | register unsigned char c; | 2002 | register unsigned char c; |
| 1965 | int sc, code, mask, kp_mode; | 2003 | int sc, code = -1, mask, kp_mode; |
| 1966 | int modifiers; | 2004 | int modifiers; |
| 1967 | 2005 | ||
| 1968 | regs.h.ah = extended_kbd ? 0x10 : 0x00; | 2006 | regs.h.ah = extended_kbd ? 0x10 : 0x00; |
| @@ -2012,10 +2050,30 @@ dos_rawgetc () | |||
| 2012 | } | 2050 | } |
| 2013 | else | 2051 | else |
| 2014 | { | 2052 | { |
| 2015 | if (sc >= (sizeof (ibmpc_translate_map) / sizeof (short))) | 2053 | /* Try the keyboard-private translation table first. */ |
| 2016 | continue; | 2054 | if (keyboard->translate_table) |
| 2017 | if ((code = ibmpc_translate_map[sc]) == Ignore) | 2055 | { |
| 2018 | continue; | 2056 | struct kbd_translate *p = keyboard->translate_table; |
| 2057 | |||
| 2058 | while (p->sc) | ||
| 2059 | { | ||
| 2060 | if (p->sc == sc && p->ch == c) | ||
| 2061 | { | ||
| 2062 | code = p->code; | ||
| 2063 | break; | ||
| 2064 | } | ||
| 2065 | p++; | ||
| 2066 | } | ||
| 2067 | } | ||
| 2068 | /* If the private table didn't translate it, use the general | ||
| 2069 | one. */ | ||
| 2070 | if (code == -1) | ||
| 2071 | { | ||
| 2072 | if (sc >= (sizeof (ibmpc_translate_map) / sizeof (short))) | ||
| 2073 | continue; | ||
| 2074 | if ((code = ibmpc_translate_map[sc]) == Ignore) | ||
| 2075 | continue; | ||
| 2076 | } | ||
| 2019 | } | 2077 | } |
| 2020 | 2078 | ||
| 2021 | if (c == 0) | 2079 | if (c == 0) |
| @@ -2071,6 +2129,8 @@ dos_rawgetc () | |||
| 2071 | } | 2129 | } |
| 2072 | 2130 | ||
| 2073 | case Map: | 2131 | case Map: |
| 2132 | if (keyboard->translate_table) | ||
| 2133 | c = 0; /* so key gets mapped through country-specific kbd */ | ||
| 2074 | if (c && !(mask & ALT_P) && !((mask & SHIFT_P) && (mask & CTRL_P))) | 2134 | if (c && !(mask & ALT_P) && !((mask & SHIFT_P) && (mask & CTRL_P))) |
| 2075 | if (!keyboard_map_all) | 2135 | if (!keyboard_map_all) |
| 2076 | return c; | 2136 | return c; |
| @@ -3908,10 +3968,12 @@ abort () | |||
| 3908 | #if __DJGPP__ == 2 && __DJGPP_MINOR__ < 2 | 3968 | #if __DJGPP__ == 2 && __DJGPP_MINOR__ < 2 |
| 3909 | if (screen_virtual_segment) | 3969 | if (screen_virtual_segment) |
| 3910 | dosv_refresh_virtual_screen (2 * 10 * screen_size_X, 4 * screen_size_X); | 3970 | dosv_refresh_virtual_screen (2 * 10 * screen_size_X, 4 * screen_size_X); |
| 3911 | #endif /* __DJGPP_MINOR__ < 2 */ | ||
| 3912 | /* Generate traceback, so we could tell whodunit. */ | 3971 | /* Generate traceback, so we could tell whodunit. */ |
| 3913 | signal (SIGINT, SIG_DFL); | 3972 | signal (SIGINT, SIG_DFL); |
| 3914 | __asm__ __volatile__ ("movb $0x1b,%al;call ___djgpp_hw_exception"); | 3973 | __asm__ __volatile__ ("movb $0x1b,%al;call ___djgpp_hw_exception"); |
| 3974 | #else /* __DJGPP_MINOR__ >= 2 */ | ||
| 3975 | raise (SIGABRT); | ||
| 3976 | #endif /* __DJGPP_MINOR__ >= 2 */ | ||
| 3915 | #endif | 3977 | #endif |
| 3916 | exit (2); | 3978 | exit (2); |
| 3917 | } | 3979 | } |