Mercurial > emacs
comparison src/w32console.c @ 24938:a4c871b96d4b
(w32_use_full_screen_buffer): New variable.
(syms_of_ntterm): Register it.
(initialize_w32_display): Set initial frame size accordingly,
respecting the LINES and COLUMNS environment variables if set.
author | Andrew Innes <andrewi@gnu.org> |
---|---|
date | Fri, 09 Jul 1999 13:38:11 +0000 |
parents | 3bb855a40bf6 |
children | fe54558f20d8 |
comparison
equal
deleted
inserted
replaced
24937:42f29912dc46 | 24938:a4c871b96d4b |
---|---|
73 DWORD prev_console_mode; | 73 DWORD prev_console_mode; |
74 | 74 |
75 #ifndef USE_SEPARATE_SCREEN | 75 #ifndef USE_SEPARATE_SCREEN |
76 CONSOLE_CURSOR_INFO prev_console_cursor; | 76 CONSOLE_CURSOR_INFO prev_console_cursor; |
77 #endif | 77 #endif |
78 | |
79 /* Determine whether to make frame dimensions match the screen buffer, | |
80 or the current window size. The former is desirable when running | |
81 over telnet, while the latter is more useful when working directly at | |
82 the console with a large scroll-back buffer. */ | |
83 int w32_use_full_screen_buffer; | |
78 | 84 |
79 | 85 |
80 /* Setting this as the ctrl handler prevents emacs from being killed when | 86 /* Setting this as the ctrl handler prevents emacs from being killed when |
81 someone hits ^C in a 'suspended' session (child shell). | 87 someone hits ^C in a 'suspended' session (child shell). |
82 Also ignore Ctrl-Break signals. */ | 88 Also ignore Ctrl-Break signals. */ |
561 #else | 567 #else |
562 cur_screen = prev_screen; | 568 cur_screen = prev_screen; |
563 GetConsoleCursorInfo (prev_screen, &prev_console_cursor); | 569 GetConsoleCursorInfo (prev_screen, &prev_console_cursor); |
564 #endif | 570 #endif |
565 | 571 |
572 /* Respect setting of LINES and COLUMNS environment variables. */ | |
573 { | |
574 char * lines = getenv("LINES"); | |
575 char * columns = getenv("COLUMNS"); | |
576 | |
577 if (lines != NULL && columns != NULL) | |
578 { | |
579 SMALL_RECT new_win_dims; | |
580 COORD new_size; | |
581 | |
582 new_size.X = atoi (columns); | |
583 new_size.Y = atoi (lines); | |
584 | |
585 GetConsoleScreenBufferInfo (cur_screen, &info); | |
586 | |
587 /* Shrink the window first, so the buffer dimensions can be | |
588 reduced if necessary. */ | |
589 new_win_dims.Top = 0; | |
590 new_win_dims.Left = 0; | |
591 new_win_dims.Bottom = min (new_size.Y, info.dwSize.Y) - 1; | |
592 new_win_dims.Right = min (new_size.X, info.dwSize.X) - 1; | |
593 SetConsoleWindowInfo (cur_screen, TRUE, &new_win_dims); | |
594 | |
595 SetConsoleScreenBufferSize (cur_screen, new_size); | |
596 | |
597 /* Set the window size to match the buffer dimension. */ | |
598 new_win_dims.Top = 0; | |
599 new_win_dims.Left = 0; | |
600 new_win_dims.Bottom = new_size.Y - 1; | |
601 new_win_dims.Right = new_size.X - 1; | |
602 SetConsoleWindowInfo (cur_screen, TRUE, &new_win_dims); | |
603 } | |
604 } | |
605 | |
566 GetConsoleScreenBufferInfo (cur_screen, &info); | 606 GetConsoleScreenBufferInfo (cur_screen, &info); |
567 | 607 |
568 meta_key = 1; | 608 meta_key = 1; |
569 char_attr = info.wAttributes & 0xFF; | 609 char_attr = info.wAttributes & 0xFF; |
570 char_attr_normal = char_attr; | 610 char_attr_normal = char_attr; |
571 char_attr_reverse = ((char_attr & 0xf) << 4) + ((char_attr & 0xf0) >> 4); | 611 char_attr_reverse = ((char_attr & 0xf) << 4) + ((char_attr & 0xf0) >> 4); |
572 | 612 |
573 /* Lines per page. Use buffer coords instead of buffer size. */ | 613 if (w32_use_full_screen_buffer) |
574 FRAME_HEIGHT (selected_frame) = 1 + info.srWindow.Bottom - | 614 { |
575 info.srWindow.Top; | 615 FRAME_HEIGHT (selected_frame) = info.dwSize.Y; /* lines per page */ |
576 /* Characters per line. Use buffer coords instead of buffer size. */ | 616 SET_FRAME_WIDTH (selected_frame, info.dwSize.X); /* characters per line */ |
577 SET_FRAME_WIDTH (selected_frame, 1 + info.srWindow.Right - | 617 } |
578 info.srWindow.Left); | 618 else |
619 { | |
620 /* Lines per page. Use buffer coords instead of buffer size. */ | |
621 FRAME_HEIGHT (selected_frame) = 1 + info.srWindow.Bottom - | |
622 info.srWindow.Top; | |
623 /* Characters per line. Use buffer coords instead of buffer size. */ | |
624 SET_FRAME_WIDTH (selected_frame, 1 + info.srWindow.Right - | |
625 info.srWindow.Left); | |
626 } | |
579 } | 627 } |
580 | 628 |
581 DEFUN ("set-screen-color", Fset_screen_color, Sset_screen_color, 2, 2, 0, | 629 DEFUN ("set-screen-color", Fset_screen_color, Sset_screen_color, 2, 2, 0, |
582 "Set screen colors.") | 630 "Set screen colors.") |
583 (foreground, background) | 631 (foreground, background) |
622 #endif /* !HAVE_NTGUI */ | 670 #endif /* !HAVE_NTGUI */ |
623 | 671 |
624 void | 672 void |
625 syms_of_ntterm () | 673 syms_of_ntterm () |
626 { | 674 { |
675 DEFVAR_BOOL ("w32-use-full-screen-buffer", | |
676 &w32_use_full_screen_buffer, | |
677 "Non-nil means make terminal frames use the full screen buffer dimensions.\n\ | |
678 This is desirable when running Emacs over telnet, and is the default.\n\ | |
679 A value of nil means use the current console window dimensions; this\n\ | |
680 may be preferrable when working directly at the console with a large\n\ | |
681 scroll-back buffer."); | |
682 w32_use_full_screen_buffer = 1; | |
683 | |
627 defsubr (&Sset_screen_color); | 684 defsubr (&Sset_screen_color); |
628 defsubr (&Sset_cursor_size); | 685 defsubr (&Sset_cursor_size); |
629 defsubr (&Sset_message_beep); | 686 defsubr (&Sset_message_beep); |
630 } | 687 } |