⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 w32-win.el

📁 windows版本的emacs
💻 EL
📖 第 1 页 / 共 3 页
字号:
;;; w32-win.el --- parse switches controlling interface with W32 window system;; Copyright (C) 1993, 1994 Free Software Foundation, Inc.;; Author: Kevin Gallo;; Keywords: terminals;; This file is part of GNU Emacs.;; GNU Emacs is free software; you can redistribute it and/or modify;; it under the terms of the GNU General Public License as published by;; the Free Software Foundation; either version 2, or (at your option);; any later version.;; GNU Emacs is distributed in the hope that it will be useful,;; but WITHOUT ANY WARRANTY; without even the implied warranty of;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the;; GNU General Public License for more details.;; You should have received a copy of the GNU General Public License;; along with GNU Emacs; see the file COPYING.  If not, write to the;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,;; Boston, MA 02111-1307, USA.;;; Commentary:;; w32-win.el:  this file is loaded from ../lisp/startup.el when it recognizes;; that W32 windows are to be used.  Command line switches are parsed and those;; pertaining to W32 are processed and removed from the command line.  The;; W32 display is opened and hooks are set for popping up the initial window.;; startup.el will then examine startup files, and eventually call the hooks;; which create the first window (s).;;; Code:;; These are the standard X switches from the Xt Initialize.c file of;; Release 4.;; Command line		Resource Manager string;; +rv			*reverseVideo;; +synchronous		*synchronous;; -background		*background;; -bd			*borderColor;; -bg			*background;; -bordercolor		*borderColor;; -borderwidth		.borderWidth;; -bw			.borderWidth;; -display		.display;; -fg			*foreground;; -fn			*font;; -font		*font;; -foreground		*foreground;; -geometry		.geometry;; -i			.iconType;; -itype		.iconType;; -iconic		.iconic;; -name		.name;; -reverse		*reverseVideo;; -rv			*reverseVideo;; -selectionTimeout    .selectionTimeout;; -synchronous		*synchronous;; -xrm;; An alist of X options and the function which handles them.  See;; ../startup.el.(if (not (eq window-system 'w32))    (error "%s: Loading w32-win.el but not compiled for w32" (invocation-name)))	 (require 'frame)(require 'mouse)(require 'scroll-bar)(require 'faces)(require 'select)(require 'menu-bar)(if (fboundp 'new-fontset)    (require 'fontset));; Because Windows scrollbars look and act quite differently compared;; with the standard X scroll-bars, we don't try to use the normal;; scroll bar routines.(defun w32-handle-scroll-bar-event (event)  "Handle W32 scroll bar EVENT to do normal Window style scrolling."  (interactive "e")  (let ((old-window (selected-window)))    (unwind-protect	(let* ((position (event-start event))	       (window (nth 0 position))	       (portion-whole (nth 2 position))	       (bar-part (nth 4 position)))	  (save-excursion	    (select-window window)	    (cond	     ((eq bar-part 'up)	      (goto-char (window-start window))	      (scroll-down 1))	     ((eq bar-part 'above-handle)	      (scroll-down))	     ((eq bar-part 'handle)	      (scroll-bar-maybe-set-window-start event))	     ((eq bar-part 'below-handle)	      (scroll-up))	     ((eq bar-part 'down)	      (goto-char (window-start window))	      (scroll-up 1))	     )))      (select-window old-window))));; The following definition is used for debugging.;(defun w32-handle-scroll-bar-event (event) (interactive "e") (princ event))(global-set-key [vertical-scroll-bar mouse-1] 'w32-handle-scroll-bar-event);; (scroll-bar-mode nil)(defvar mouse-wheel-scroll-amount 4  "*Number of lines to scroll per click of the mouse wheel.")(defun mouse-wheel-scroll-line (event)  "Scroll the window in which EVENT occurred by `mouse-wheel-scroll-amount'."  (interactive "e")  (condition-case nil      (if (< (car (cdr (cdr event))) 0)	  (scroll-up mouse-wheel-scroll-amount)	(scroll-down mouse-wheel-scroll-amount))    (error nil)));; for scroll-in-place.el, this way the -scroll-line and -scroll-screen;; commands won't interact(setq scroll-command-groups (list '(mouse-wheel-scroll-line)))(defun mouse-wheel-scroll-screen (event)  "Scroll the window in which EVENT occurred by `mouse-wheel-scroll-amount'."  (interactive "e")  (condition-case nil      (if (< (car (cdr (cdr event))) 0)          (scroll-up)        (scroll-down))    (error nil)));; Bind the mouse-wheel event:(global-set-key [mouse-wheel] 'mouse-wheel-scroll-line)(global-set-key [C-mouse-wheel] 'mouse-wheel-scroll-screen)(defun w32-drag-n-drop-debug (event)  "Print the drag-n-drop EVENT in a readable form."  (interactive "e")  (princ event))(defun w32-drag-n-drop (event)  "Edit the files listed in the drag-n-drop EVENT.Switch to a buffer editing the last file dropped."  (interactive "e")  (save-excursion    ;; Make sure the drop target has positive co-ords    ;; before setting the selected frame - otherwise it    ;; won't work.  <skx@tardis.ed.ac.uk>    (let* ((window (posn-window (event-start event)))	   (coords (posn-x-y (event-start event)))	   (x (car coords))	   (y (cdr coords)))      (if (and (> x 0) (> y 0))	  (set-frame-selected-window nil window))    (mapcar 'find-file (car (cdr (cdr event)))))  (raise-frame)))(defun w32-drag-n-drop-other-frame (event)  "Edit the files listed in the drag-n-drop EVENT, in other frames.May create new frames, or reuse existing ones.  The frame editingthe last file dropped is selected."  (interactive "e")  (mapcar 'find-file-other-frame (car (cdr (cdr event)))));; Bind the drag-n-drop event.(global-set-key [drag-n-drop] 'w32-drag-n-drop)(global-set-key [C-drag-n-drop] 'w32-drag-n-drop-other-frame);; Keyboard layout/language change events;; For now ignore language-change events; in the future;; we should switch the Emacs Input Method to match the;; new layout/language selected by the user.(global-set-key [language-change] 'ignore)(defvar x-invocation-args)(defvar x-command-line-resources nil)(defconst x-option-alist  '(("-bw" .	x-handle-numeric-switch)    ("-d" .		x-handle-display)    ("-display" .	x-handle-display)    ("-name" .	x-handle-name-rn-switch)    ("-rn" .	x-handle-name-rn-switch)    ("-T" .		x-handle-switch)    ("-r" .		x-handle-switch)    ("-rv" .	x-handle-switch)    ("-reverse" .	x-handle-switch)    ("-fn" .	x-handle-switch)    ("-font" .	x-handle-switch)    ("-ib" .	x-handle-numeric-switch)    ("-g" .		x-handle-geometry)    ("-geometry" .	x-handle-geometry)    ("-fg" .	x-handle-switch)    ("-foreground".	x-handle-switch)    ("-bg" .	x-handle-switch)    ("-background".	x-handle-switch)    ("-ms" .	x-handle-switch)    ("-itype" .	x-handle-switch)    ("-i" 	.	x-handle-switch)    ("-iconic" .	x-handle-iconic)    ("-xrm" .       x-handle-xrm-switch)    ("-cr" .	x-handle-switch)    ("-vb" .	x-handle-switch)    ("-hb" .	x-handle-switch)    ("-bd" .	x-handle-switch)))(defconst x-long-option-alist  '(("--border-width" .	"-bw")    ("--display" .	"-d")    ("--name" .		"-name")    ("--title" .	"-T")    ("--reverse-video" . "-reverse")    ("--font" .		"-font")    ("--internal-border" . "-ib")    ("--geometry" .	"-geometry")    ("--foreground-color" . "-fg")    ("--background-color" . "-bg")    ("--mouse-color" .	"-ms")    ("--icon-type" .	"-itype")    ("--iconic" .	"-iconic")    ("--xrm" .		"-xrm")    ("--cursor-color" .	"-cr")    ("--vertical-scroll-bars" . "-vb")    ("--border-color" .	"-bd")))(defconst x-switch-definitions  '(("-name" name)    ("-T" name)    ("-r" reverse t)    ("-rv" reverse t)    ("-reverse" reverse t)    ("-fn" font)    ("-font" font)    ("-ib" internal-border-width)    ("-fg" foreground-color)    ("-foreground" foreground-color)    ("-bg" background-color)    ("-background" background-color)    ("-ms" mouse-color)    ("-cr" cursor-color)    ("-itype" icon-type t)    ("-i" icon-type t)    ("-vb" vertical-scroll-bars t)    ("-hb" horizontal-scroll-bars t)    ("-bd" border-color)    ("-bw" border-width)))(defun x-handle-switch (switch)  "Handle SWITCH of the form \"-switch value\" or \"-switch\"."  (let ((aelt (assoc switch x-switch-definitions)))    (if aelt	(if (nth 2 aelt)	    (setq default-frame-alist		  (cons (cons (nth 1 aelt) (nth 2 aelt))			default-frame-alist))	  (setq default-frame-alist		(cons (cons (nth 1 aelt)			    (car x-invocation-args))		      default-frame-alist)		x-invocation-args (cdr x-invocation-args))))))(defun x-handle-iconic (switch)  "Make \"-iconic\" SWITCH apply only to the initial frame."  (setq initial-frame-alist	(cons '(visibility . icon) initial-frame-alist)))(defun x-handle-numeric-switch (switch)  "Handle SWITCH of the form \"-switch n\"."  (let ((aelt (assoc switch x-switch-definitions)))    (if aelt	(setq default-frame-alist	      (cons (cons (nth 1 aelt)			  (string-to-int (car x-invocation-args)))		    default-frame-alist)	      x-invocation-args	      (cdr x-invocation-args)))))(defun x-handle-xrm-switch (switch)  "Handle the \"-xrm\" SWITCH."  (or (consp x-invocation-args)      (error "%s: missing argument to `%s' option" (invocation-name) switch))  (setq x-command-line-resources (car x-invocation-args))  (setq x-invocation-args (cdr x-invocation-args)))(defun x-handle-geometry (switch)  "Handle the \"-geometry\" SWITCH."  (let ((geo (x-parse-geometry (car x-invocation-args))))    (setq initial-frame-alist	  (append initial-frame-alist		  (if (or (assq 'left geo) (assq 'top geo))		      '((user-position . t)))		  (if (or (assq 'height geo) (assq 'width geo))		      '((user-size . t)))		  geo)	  x-invocation-args (cdr x-invocation-args))))(defun x-handle-name-rn-switch (switch)  "Handle a \"-name\" or \"-rn\" SWITCH.";; Handle the -name and -rn options.  Set the variable x-resource-name;; to the option's operand; if the switch was `-name', set the name of;; the initial frame, too.  (or (consp x-invocation-args)      (error "%s: missing argument to `%s' option" (invocation-name) switch))  (setq x-resource-name (car x-invocation-args)	x-invocation-args (cdr x-invocation-args))  (if (string= switch "-name")      (setq initial-frame-alist (cons (cons 'name x-resource-name)				      initial-frame-alist))))(defvar x-display-name nil  "The display name specifying server and frame.")(defun x-handle-display (switch)  "Handle the \"-display\" SWITCH."  (setq x-display-name (car x-invocation-args)	x-invocation-args (cdr x-invocation-args)))(defvar x-invocation-args nil)(defun x-handle-args (args)  "Process the X-related command line options in ARGS.This is done before the user's startup file is loaded.  They are copied tox-invocation args from which the X-related things are extracted, firstthe switch (e.g., \"-fg\") in the following code, and possible values\(e.g., \"black\") in the option handler code (e.g., x-handle-switch).This returns ARGS with the arguments that have been processed removed."  (setq x-invocation-args args	args nil)  (while x-invocation-args    (let* ((this-switch (car x-invocation-args))	   (orig-this-switch this-switch)	   completion argval aelt)      (setq x-invocation-args (cdr x-invocation-args))      ;; Check for long options with attached arguments      ;; and separate out the attached option argument into argval.      (if (string-match "^--[^=]*=" this-switch)	  (setq argval (substring this-switch (match-end 0))		this-switch (substring this-switch 0 (1- (match-end 0)))))      (setq completion (try-completion this-switch x-long-option-alist))      (if (eq completion t)	  ;; Exact match for long option.	  (setq this-switch (cdr (assoc this-switch x-long-option-alist)))	(if (stringp completion)	    (let ((elt (assoc completion x-long-option-alist)))	      ;; Check for abbreviated long option.	      (or elt		  (error "Option `%s' is ambiguous" this-switch))	      (setq this-switch (cdr elt)))	  ;; Check for a short option.	  (setq argval nil this-switch orig-this-switch)))      (setq aelt (assoc this-switch x-option-alist))      (if aelt	  (if argval	      (let ((x-invocation-args		     (cons argval x-invocation-args)))		(funcall (cdr aelt) this-switch))	    (funcall (cdr aelt) this-switch))	(setq args (cons this-switch args)))))  (setq args (nreverse args)));;;; Available colors;;(defvar x-colors '("LightGreen"		   "light green"		   "DarkRed"		   "dark red"		   "DarkMagenta"		   "dark magenta"		   "DarkCyan"		   "dark cyan"		   "DarkBlue"		   "dark blue"		   "DarkGray"		   "dark gray"		   "DarkGrey"		   "dark grey"		   "grey100"		   "gray100"		   "grey99"		   "gray99"		   "grey98"		   "gray98"		   "grey97"		   "gray97"		   "grey96"		   "gray96"		   "grey95"		   "gray95"		   "grey94"		   "gray94"		   "grey93"		   "gray93"		   "grey92"		   "gray92"		   "grey91"		   "gray91"		   "grey90"		   "gray90"		   "grey89"		   "gray89"		   "grey88"		   "gray88"		   "grey87"		   "gray87"		   "grey86"		   "gray86"		   "grey85"		   "gray85"		   "grey84"		   "gray84"		   "grey83"		   "gray83"		   "grey82"		   "gray82"		   "grey81"		   "gray81"		   "grey80"		   "gray80"		   "grey79"		   "gray79"		   "grey78"		   "gray78"		   "grey77"		   "gray77"		   "grey76"		   "gray76"		   "grey75"		   "gray75"		   "grey74"		   "gray74"		   "grey73"		   "gray73"		   "grey72"		   "gray72"		   "grey71"		   "gray71"		   "grey70"		   "gray70"		   "grey69"		   "gray69"		   "grey68"		   "gray68"		   "grey67"		   "gray67"		   "grey66"		   "gray66"		   "grey65"		   "gray65"		   "grey64"		   "gray64"		   "grey63"		   "gray63"		   "grey62"		   "gray62"		   "grey61"		   "gray61"		   "grey60"		   "gray60"		   "grey59"		   "gray59"		   "grey58"

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -