gpt4 book ai didi

emacs - 在退出全屏时在 Emacs 中设置帧大小

转载 作者:行者123 更新时间:2023-12-02 02:31:04 25 4
gpt4 key购买 nike

我正在使用 Carbon Emacs 23,并试图在切换出全屏框架(由函数设置)后将框架宽度设置为某个值。实际上,奇怪的是,不仅没有设置宽度,而且如果你反复退出全屏,框架会变得越来越小,就像一个消失的窗口。感谢任何想法,我尝试了一些不同的想法。这是代码:

    (defun set-frame-size-according-to-resolution ()                                                                                                     
(interactive)
(if window-system
(progn
;; use 120 char wide window for largeish displays
;; and smaller 80 column windows for smaller displays
;; pick whatever numbers make sense for you
(if (> (x-display-pixel-width) 1280)
(add-to-list 'default-frame-alist (cons 'width 140))
(add-to-list 'default-frame-alist (cons 'width 100)))
;; for the height, subtract a couple hundred pixels
;; from the screen height (for panels, menubars and
;; whatnot), then divide by the height of a char to
;; get the height we want
(add-to-list 'default-frame-alist
(cons 'height (/ (- (x-display-pixel-height) 200) (frame-char-height)))))))


;;; This used to be in Carbon Emacs, puttin' it back in with my own twist
(defun mac-toggle-max-window ()
(interactive)
(set-frame-parameter nil 'fullscreen
(if (frame-parameter nil 'fullscreen)
(progn
(scroll-bar-mode 1) ;; turn on scrollbars when not in fullscreen mode
(set-frame-size-according-to-resolution)
nil)
(progn
(scroll-bar-mode -1) ;; turn off scrollbars when in fullscreen mode
'fullboth))))

;;; Toggle full screen via CMD-Return (my meta key is mapped to command on OS X
(define-key global-map [(meta return)]
'mac-toggle-max-window)

最佳答案

没关系,几分钟后我就弄明白了。

这里是答案:

;;; Set frame width - used on toggle out of fullscreen mode
(defun default-frame-width ()
"Set width of selected frame."
(modify-frame-parameters
(selected-frame)
(list (cons 'width 140))))

;;; This used to be in Carbon Emacs, puttin' it back in with my own twist
(defun mac-toggle-max-window ()
(interactive)
(set-frame-parameter nil 'fullscreen
(if (frame-parameter nil 'fullscreen)
(progn
(scroll-bar-mode 1) ;; turn on scrollbars when not in fullscreen mode
(default-frame-width)
nil)
(progn
(scroll-bar-mode -1) ;; turn off scrollbars when in fullscreen mode
'fullboth))))

;;; Toggle full screen via CMD-Return (my meta key is mapped to command on OS X
(define-key global-map [(meta return)]
'mac-toggle-max-window)

关于emacs - 在退出全屏时在 Emacs 中设置帧大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3766296/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com