Commit cbcc5ad4 authored by Eli Zaretskii's avatar Eli Zaretskii
Browse files

(msdos-create-frame-with-faces): Renamed from make-msdos-frame.

(terminal-init-internal): New function, errors out if called.
(msdos-initialize-window-system): New function.
(msdos-create-frame-with-faces): Set the terminal's `terminal-initted' (sic!)
(frame-creation-function-alist): Add msdos-create-frame-with-faces.
(window-system-initialization-alist): Add msdos-initialize-window-system.
(handle-args-function-alist): Use tty-handle-args for `pc' ``window system''
as well.
(pc-win): Provide.
parent d8dbc0d0
......@@ -23,15 +23,30 @@
;;; Commentary:
;; This file is preloaded into Emacs by loadup.el. The functions in
;; this file are then called during startup from startup.el. This
;; means that just loading this file should not have any side effects
;; besides defining functions and variables, and in particular should
;; NOT initialize any window systems.
;; The main entry points to this file's features are msdos-handle-args,
;; msdos-create-frame-with-faces, msdos-initialize-window-system,
;; terminal-init-internal. The last one is not supposed to be called,
;; so it just errors out.
;;; Code:
(if (not (fboundp 'msdos-remember-default-colors))
(error "%s: Loading pc-win.el but not compiled for MS-DOS"
(load "term/internal" nil t)
(declare-function msdos-remember-default-colors "msdos.c")
(declare-function w16-set-clipboard-data "w16select.c")
(declare-function w16-get-clipboard-data "w16select.c")
;;; This is copied from etc/rgb.txt, except that some values were changed
;;; This was copied from etc/rgb.txt, except that some values were changed
;;; a bit to make them consistent with DOS console colors, and the RGB
;;; values were scaled up to 16 bits, as `tty-define-color' requires.
......@@ -67,10 +82,10 @@
;; ---------------------------------------------------------------------------
;; We want to delay setting frame parameters until the faces are setup
(defvar default-frame-alist nil)
(modify-frame-parameters terminal-frame default-frame-alist)
;(modify-frame-parameters terminal-frame default-frame-alist)
(defun msdos-face-setup ()
"Set up initial faces for the MS-DOS display."
(set-face-foreground 'bold "yellow" terminal-frame)
(set-face-foreground 'italic "red" terminal-frame)
(set-face-foreground 'bold-italic "lightred" terminal-frame)
......@@ -85,8 +100,6 @@
(set-face-background 'msdos-menu-passive-face "blue" terminal-frame)
(set-face-background 'msdos-menu-select-face "red" terminal-frame))
(add-hook 'before-init-hook 'msdos-face-setup)
(defun msdos-handle-reverse-video (frame parameters)
"Handle the reverse-video frame parameter on MS-DOS frames."
(when (cdr (or (assq 'reverse parameters)
......@@ -103,8 +116,7 @@
;; This must run after all the default colors are inserted into
;; tty-color-alist, since msdos-handle-reverse-video needs to know the
;; actual frame colors. tty-color-alist is set up by startup.el, but
;; only after it runs before-init-hook and after-init-hook.
;; actual frame colors.
(defun msdos-setup-initial-frame ()
(modify-frame-parameters terminal-frame default-frame-alist)
;; This remembers the screen colors after applying default-frame-alist,
......@@ -117,23 +129,29 @@
(frame-set-background-mode terminal-frame)
(face-set-after-frame-default terminal-frame))
(add-hook 'term-setup-hook 'msdos-setup-initial-frame)
;; We create frames as if we were a terminal, but with a twist.
(defun make-msdos-frame (&optional parameters)
;; We create frames as if we were a terminal, but without invoking the
;; terminal-initialization function. Also, our handling of reverse
;; video is slightly different.
(defun msdos-create-frame-with-faces (&optional parameters)
"Create an frame on MS-DOS display.
Optional frame parameters PARAMETERS specify the frame parameters.
Parameters not specified by PARAMETERS are taken from
`default-frame-alist'. If either PARAMETERS or `default-frame-alist'
contains a `reverse' parameter, handle that. Value is the new frame
(let ((frame (make-terminal-frame parameters))
(with-selected-frame frame
(msdos-handle-reverse-video frame (frame-parameters frame))
(unless (terminal-parameter frame 'terminal-initted)
(set-terminal-parameter frame 'terminal-initted t))
(frame-set-background-mode frame)
(face-set-after-frame-default frame)
(setq success t))
(unless success (delete-frame frame)))
(add-to-list 'frame-creation-function-alist '(pc . make-msdos-frame))
;; ---------------------------------------------------------------------------
;; More or less useful imitations of certain X-functions. A lot of the
;; values returned are questionable, but usually only the form of the
......@@ -163,7 +181,6 @@
;; From lisp/term/x-win.el
(defvar x-display-name "pc"
"The display name specifying the MS-DOS display and frame type.")
(setq split-window-keep-point t)
(defvar x-colors (mapcar 'car msdos-color-values)
"The list of colors available on a PC display under MS-DOS.")
......@@ -209,10 +226,6 @@ support other types of selections."
(setq x-last-selected-text text))))))
;;; Arrange for the kill and yank functions to set and check the clipboard.
(setq interprogram-cut-function 'x-select-text)
(setq interprogram-paste-function 'x-get-selection-value)
;; From lisp/faces.el: we only have one font, so always return
;; it, no matter which variety they've asked for.
(defun x-frob-font-slant (font which)
......@@ -241,7 +254,81 @@ are fixed-pitch."
(fset 'set-cursor-color 'ignore) ; Hardware determined by char under.
(fset 'set-border-color 'ignore) ; Not useful.
;; Initialization.
;; ---------------------------------------------------------------------------
;; This function is run, by faces.el:tty-create-frame-with-faces, only
;; for the initial frame (on each terminal, but we have only one).
;; This works by setting the `terminal-initted' terminal parameter to
;; this function, the first time `tty-create-frame-with-faces' is
;; called on that terminal. `tty-create-frame-with-faces' is called
;; directly from startup.el and also by `make-frame' through
;; `frame-creation-function-alist'. `make-frame' will call this
;; function if `msdos-create-frame-with-faces' (see below) is not
;; found in `frame-creation-function-alist', which means something is
;; _very_ wrong, because "internal" terminal emulator should not be
;; turned on if our window-system is not `pc'. Therefore, the only
;; Right Thing for us to do here is scream bloody murder.
(defun terminal-init-internal ()
"Terminal initialization function for the MS-DOS \"internal\" terminal.
Errors out because it is not supposed to be called, ever."
(error "terminal-init-internal called for window-system `%s'"
(defun msdos-initialize-window-system ()
"Initialization function for the `pc' \"window system\"."
(or (eq (window-system) 'pc)
"`msdos-initialize-window-system' called, but window-system is `%s'"
;; First, the keyboard.
(msdos-setup-keyboard terminal-frame) ; see internal.el
;; Next, register the default colors.
(let* ((colors msdos-color-values)
(color (car colors)))
(while colors
(tty-color-define (car color) (cadr color) (cddr color))
(setq colors (cdr colors) color (car colors))))
;; Modifying color mappings means realized faces don't
;; use the right colors, so clear them.
;; Now set up some additional faces.
;; Set up the initial frame.
;; We want to delay the codepage-related setup until after user's
;; .emacs is processed, because people might define their
;; `dos-codepage-setup-hook' there.
(add-hook 'after-init-hook 'dos-codepage-setup)
;; In multibyte mode, we want unibyte buffers to be displayed
;; using the terminal coding system, so that they display
;; correctly on the DOS terminal; in unibyte mode we want to see
;; all 8-bit characters verbatim. In both cases, we want the
;; entire range of 8-bit characters to arrive at our display code
;; verbatim.
(standard-display-8bit 127 255)
;; We are fast enough to make this optimization unnecessary.
(setq split-window-keep-point t)
;; Arrange for the kill and yank functions to set and check the
;; clipboard.
(setq interprogram-cut-function 'x-select-text)
(setq interprogram-paste-function 'x-get-selection-value)
(run-hooks 'terminal-init-msdos-hook))
;; frame-creation-function-alist is examined by frame.el:make-frame.
(add-to-list 'frame-creation-function-alist
'(pc . msdos-create-frame-with-faces))
;; window-system-initialization-alist is examined by startup.el:command-line.
(add-to-list 'window-system-initialization-alist
'(pc . msdos-initialize-window-system))
;; We don't need anything beyond tty-handle-args for handling
;; command-line argument; see startup.el.
(add-to-list 'handle-args-function-alist '(pc . tty-handle-args))
;; ---------------------------------------------------------------------------
(provide 'pc-win)
;; arch-tag: 5cbdb455-b495-427b-95d0-e417d77d00b4
;;; pc-win.el ends here
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment