Mercurial > emacs
comparison src/dispnew.c @ 554:e14686fb979e
*** empty log message ***
author | Jim Blandy <jimb@redhat.com> |
---|---|
date | Thu, 20 Feb 1992 04:15:20 +0000 |
parents | 937bccff8155 |
children | 1c2d1836941a |
comparison
equal
deleted
inserted
replaced
553:e16b0df74717 | 554:e14686fb979e |
---|---|
21 #include <signal.h> | 21 #include <signal.h> |
22 | 22 |
23 #include "config.h" | 23 #include "config.h" |
24 #include <stdio.h> | 24 #include <stdio.h> |
25 #include <ctype.h> | 25 #include <ctype.h> |
26 | |
27 #ifdef NEED_TIME_H | |
28 #include <time.h> | |
29 #else /* not NEED_TIME_H */ | |
30 #ifdef HAVE_TIMEVAL | |
31 #include <sys/time.h> | |
32 #endif /* HAVE_TIMEVAL */ | |
33 #endif /* not NEED_TIME_H */ | |
34 | |
35 #ifdef HAVE_TERMIO | |
36 #include <termio.h> | |
37 #ifdef TCOUTQ | |
38 #undef TIOCOUTQ | |
39 #define TIOCOUTQ TCOUTQ | |
40 #endif /* TCOUTQ defined */ | |
41 #include <fcntl.h> | |
42 #else | |
43 #ifndef VMS | |
44 #include <sys/ioctl.h> | |
45 #endif /* not VMS */ | |
46 #endif /* not HAVE_TERMIO */ | |
47 | |
48 /* Allow m- file to inhibit use of FIONREAD. */ | |
49 #ifdef BROKEN_FIONREAD | |
50 #undef FIONREAD | |
51 #endif | |
52 | |
53 /* Interupt input is not used if there is no FIONREAD. */ | |
54 #ifndef FIONREAD | |
55 #undef SIGIO | |
56 #endif | |
57 | 26 |
58 #include "termchar.h" | 27 #include "termchar.h" |
59 #include "termopts.h" | 28 #include "termopts.h" |
60 #include "cm.h" | 29 #include "cm.h" |
61 #include "lisp.h" | 30 #include "lisp.h" |
65 #include "window.h" | 34 #include "window.h" |
66 #include "commands.h" | 35 #include "commands.h" |
67 #include "disptab.h" | 36 #include "disptab.h" |
68 #include "indent.h" | 37 #include "indent.h" |
69 | 38 |
39 #include "systerm.h" | |
40 #include "systime.h" | |
41 | |
70 #ifdef HAVE_X_WINDOWS | 42 #ifdef HAVE_X_WINDOWS |
71 #include "xterm.h" | 43 #include "xterm.h" |
72 #endif /* HAVE_X_WINDOWS */ | 44 #endif /* HAVE_X_WINDOWS */ |
73 | 45 |
74 #define max(a, b) ((a) > (b) ? (a) : (b)) | 46 #define max(a, b) ((a) > (b) ? (a) : (b)) |
79 This ought to be built in in stdio, but it isn't. | 51 This ought to be built in in stdio, but it isn't. |
80 Some s- files override this because their stdio internals differ. */ | 52 Some s- files override this because their stdio internals differ. */ |
81 #define PENDING_OUTPUT_COUNT(FILE) ((FILE)->_ptr - (FILE)->_base) | 53 #define PENDING_OUTPUT_COUNT(FILE) ((FILE)->_ptr - (FILE)->_base) |
82 #endif | 54 #endif |
83 | 55 |
84 /* Nonzero means do not assume anything about current | 56 /* Nonzero upon entry to redisplay means do not assume anything about |
85 contents of actual terminal screen */ | 57 current contents of actual terminal screen; clear and redraw it. */ |
86 | 58 |
87 int screen_garbaged; | 59 int screen_garbaged; |
88 | 60 |
89 /* Nonzero means last display completed. Zero means it was preempted. */ | 61 /* Nonzero means last display completed. Zero means it was preempted. */ |
90 | 62 |
1050 || (outq > 20 && ((i - 1) % preempt_count == 0))) | 1022 || (outq > 20 && ((i - 1) % preempt_count == 0))) |
1051 { | 1023 { |
1052 fflush (stdout); | 1024 fflush (stdout); |
1053 if (preempt_count == 1) | 1025 if (preempt_count == 1) |
1054 { | 1026 { |
1055 #ifdef TIOCOUTQ | 1027 #ifdef EMACS_OUTQSIZE |
1056 if (ioctl (0, TIOCOUTQ, &outq) < 0) | 1028 if (EMACS_OUTQSIZE (0, &outq) < 0) |
1057 /* Probably not a tty. Ignore the error and reset | 1029 /* Probably not a tty. Ignore the error and reset |
1058 * the outq count. */ | 1030 * the outq count. */ |
1059 outq = PENDING_OUTPUT_COUNT (stdout); | 1031 outq = PENDING_OUTPUT_COUNT (stdout); |
1060 #endif | 1032 #endif |
1061 outq *= 10; | 1033 outq *= 10; |
1807 \(Not all operating systems support milliseconds.)") | 1779 \(Not all operating systems support milliseconds.)") |
1808 (n, millisec) | 1780 (n, millisec) |
1809 Lisp_Object n, millisec; | 1781 Lisp_Object n, millisec; |
1810 { | 1782 { |
1811 #ifndef subprocesses | 1783 #ifndef subprocesses |
1812 #ifdef HAVE_TIMEVAL | 1784 EMACS_TIME timeout, end_time; |
1813 struct timeval timeout, end_time, garbage1; | |
1814 #endif /* HAVE_TIMEVAL */ | |
1815 #endif /* no subprocesses */ | 1785 #endif /* no subprocesses */ |
1816 int usec = 0; | 1786 int usec = 0; |
1817 int sec; | 1787 int sec; |
1818 | 1788 |
1819 CHECK_NUMBER (n, 0); | 1789 CHECK_NUMBER (n, 0); |
1821 if (sec <= 0) | 1791 if (sec <= 0) |
1822 return Qnil; | 1792 return Qnil; |
1823 | 1793 |
1824 if (!NILP (millisec)) | 1794 if (!NILP (millisec)) |
1825 { | 1795 { |
1826 #ifndef HAVE_TIMEVAL | 1796 #ifndef EMACS_HAS_USECS |
1827 error ("millisecond sit-for not supported on %s", SYSTEM_TYPE); | 1797 error ("millisecond sit-for not supported on %s", SYSTEM_TYPE); |
1828 #else | 1798 #else |
1829 usec = sec % 1000 * 1000; | 1799 usec = sec % 1000 * 1000; |
1830 sec /= 1000; | 1800 sec /= 1000; |
1831 #endif | 1801 #endif |
1842 #else /* not VMS */ | 1812 #else /* not VMS */ |
1843 /* The reason this is done this way | 1813 /* The reason this is done this way |
1844 (rather than defined (H_S) && defined (H_T)) | 1814 (rather than defined (H_S) && defined (H_T)) |
1845 is because the VMS preprocessor doesn't grok `defined' */ | 1815 is because the VMS preprocessor doesn't grok `defined' */ |
1846 #ifdef HAVE_SELECT | 1816 #ifdef HAVE_SELECT |
1847 #ifdef HAVE_TIMEVAL | 1817 EMACS_GET_TIME (end_time); |
1848 gettimeofday (&end_time, &garbage1); | 1818 EMACS_SET_SECS_USECS (timeout, sec, usec); |
1849 end_time.tv_sec += sec; | 1819 EMACS_ADD_TIME (end_time, timeout); |
1850 end_time.tv_usec += usec; | 1820 |
1851 if (end_time.tv_usec >= 1000000) | |
1852 end_time.tv_sec++, end_time.tv_usec -= 1000000; | |
1853 | |
1854 while (1) | 1821 while (1) |
1855 { | 1822 { |
1856 gettimeofday (&timeout, &garbage1); | 1823 EMACS_GET_TIME (timeout); |
1857 timeout.tv_sec = end_time.tv_sec - timeout.tv_sec; | 1824 EMACS_SUB_TIME (timeout, end_time, timeout); |
1858 timeout.tv_usec = end_time.tv_usec - timeout.tv_usec; | 1825 if (EMACS_TIME_NEG_P (timeout) |
1859 if (timeout.tv_usec < 0) | 1826 || !select (1, 0, 0, 0, &timeout)) |
1860 timeout.tv_usec += 1000000, timeout.tv_sec--; | |
1861 if (timeout.tv_sec < 0) | |
1862 break; | 1827 break; |
1863 if (!select (1, 0, 0, 0, &timeout)) | 1828 } |
1864 break; | |
1865 } | |
1866 #else /* not HAVE_TIMEVAL */ | |
1867 /* Is it safe to quit out of `sleep'? I'm afraid to trust it. */ | |
1868 sleep (sec); | |
1869 #endif /* HAVE_TIMEVAL */ | |
1870 #else /* not HAVE_SELECT */ | 1829 #else /* not HAVE_SELECT */ |
1871 sleep (sec); | 1830 sleep (sec); |
1872 #endif /* HAVE_SELECT */ | 1831 #endif /* HAVE_SELECT */ |
1873 #endif /* not VMS */ | 1832 #endif /* not VMS */ |
1874 | 1833 |
1887 Value is t if waited the full time with no input arriving.") | 1846 Value is t if waited the full time with no input arriving.") |
1888 (n, millisec, nodisp) | 1847 (n, millisec, nodisp) |
1889 Lisp_Object n, millisec, nodisp; | 1848 Lisp_Object n, millisec, nodisp; |
1890 { | 1849 { |
1891 #ifndef subprocesses | 1850 #ifndef subprocesses |
1892 #ifdef HAVE_TIMEVAL | 1851 EMACS_TIME timeout; |
1893 struct timeval timeout; | |
1894 #else | |
1895 int timeout_sec; | |
1896 #endif | |
1897 int waitchannels; | 1852 int waitchannels; |
1898 #endif /* no subprocesses */ | 1853 #endif /* no subprocesses */ |
1899 int usec = 0; | 1854 int usec = 0; |
1900 int sec; | 1855 int sec; |
1901 | 1856 |
1911 if (sec <= 0) | 1866 if (sec <= 0) |
1912 return Qt; | 1867 return Qt; |
1913 | 1868 |
1914 if (!NILP (millisec)) | 1869 if (!NILP (millisec)) |
1915 { | 1870 { |
1916 #ifndef HAVE_TIMEVAL | 1871 #ifndef EMACS_HAS_USECS |
1917 error ("millisecond sleep-for not supported on %s", SYSTEM_TYPE); | 1872 error ("millisecond sleep-for not supported on %s", SYSTEM_TYPE); |
1918 #else | 1873 #else |
1919 usec = sec % 1000 * 1000; | 1874 usec = sec % 1000 * 1000; |
1920 sec /= 1000; | 1875 sec /= 1000; |
1921 #endif | 1876 #endif |
1932 | 1887 |
1933 waitchannels = 1; | 1888 waitchannels = 1; |
1934 #ifdef VMS | 1889 #ifdef VMS |
1935 input_wait_timeout (XINT (n)); | 1890 input_wait_timeout (XINT (n)); |
1936 #else /* not VMS */ | 1891 #else /* not VMS */ |
1937 #ifndef HAVE_TIMEVAL | 1892 EMACS_SET_SECS_USECS (timeout, sec, usec); |
1938 timeout_sec = sec; | |
1939 select (1, &waitchannels, 0, 0, &timeout_sec); | |
1940 #else /* HAVE_TIMEVAL */ | |
1941 timeout.tv_sec = sec; | |
1942 timeout.tv_usec = usec; | |
1943 select (1, &waitchannels, 0, 0, &timeout); | 1893 select (1, &waitchannels, 0, 0, &timeout); |
1944 #endif /* HAVE_TIMEVAL */ | |
1945 #endif /* not VMS */ | 1894 #endif /* not VMS */ |
1946 | 1895 |
1947 immediate_quit = 0; | 1896 immediate_quit = 0; |
1948 #endif /* no subprocesses */ | 1897 #endif /* no subprocesses */ |
1949 | 1898 |
1954 1, 1, 0, | 1903 1, 1, 0, |
1955 "Pause, without updating display, for ARG milliseconds.") | 1904 "Pause, without updating display, for ARG milliseconds.") |
1956 (n) | 1905 (n) |
1957 Lisp_Object n; | 1906 Lisp_Object n; |
1958 { | 1907 { |
1959 #ifndef HAVE_TIMEVAL | 1908 #ifndef EMACS_HAS_USECS |
1960 error ("sleep-for-millisecs not supported on %s", SYSTEM_TYPE); | 1909 error ("sleep-for-millisecs not supported on %s", SYSTEM_TYPE); |
1961 #else | 1910 #else |
1962 CHECK_NUMBER (n, 0); | 1911 CHECK_NUMBER (n, 0); |
1963 wait_reading_process_input (XINT (n) / 1000, XINT (n) % 1000 * 1000, | 1912 wait_reading_process_input (XINT (n) / 1000, XINT (n) % 1000 * 1000, |
1964 0, 0); | 1913 0, 0); |
1965 return Qnil; | 1914 return Qnil; |
1966 #endif /* HAVE_TIMEVAL */ | 1915 #endif /* EMACS_HAS_USECS */ |
1967 } | 1916 } |
1968 | 1917 |
1969 char *terminal_type; | 1918 char *terminal_type; |
1970 | 1919 |
1971 /* Initialization done when Emacs fork is started, before doing stty. */ | 1920 /* Initialization done when Emacs fork is started, before doing stty. */ |