diff --git a/layers/+spacemacs/spacemacs-ui-visual/funcs.el b/layers/+spacemacs/spacemacs-ui-visual/funcs.el index 4edc96a3b..655b09958 100644 --- a/layers/+spacemacs/spacemacs-ui-visual/funcs.el +++ b/layers/+spacemacs/spacemacs-ui-visual/funcs.el @@ -10,17 +10,16 @@ ;;; License: GPLv3 -;; smooth scrolling +;; golden ratio -(defun spacemacs/enable-smooth-scrolling () - "Enable smooth scrolling." - (interactive) - (setq scroll-conservatively 101)) +(defun spacemacs/no-golden-ratio-for-buffers (bufname) + "Disable golden-ratio if BUFNAME is the name of a visible buffer." + (and (get-buffer bufname) (get-buffer-window bufname 'visible))) -(defun spacemacs/disable-smooth-scrolling () - "Enable smooth scrolling." - (interactive) - (setq scroll-conservatively 0)) +(defun spacemacs/no-golden-ratio-guide-key () + "Disable golden-ratio for guide-key popwin buffer." + (or (spacemacs/no-golden-ratio-for-buffers " *guide-key*") + (spacemacs/no-golden-ratio-for-buffers " *popwin-dummy*"))) ;; neotree @@ -73,6 +72,71 @@ (when (get-buffer-window (neo-global--get-buffer)) (neo-global--attach))) + +;; popwin + +(defun spacemacs/remove-popwin-display-config (str) + "Removes the popwin display configurations that matches the passed STR" + (setq popwin:special-display-config + (-remove (lambda (x) (if (and (listp x) (stringp (car x))) + (string-match str (car x)))) + popwin:special-display-config))) + + +;; smooth scrolling + +(defun spacemacs/enable-smooth-scrolling () + "Enable smooth scrolling." + (interactive) + (setq scroll-conservatively 101)) + +(defun spacemacs/disable-smooth-scrolling () + "Enable smooth scrolling." + (interactive) + (setq scroll-conservatively 0)) + + +;; spaceline + +(defun spacemacs/customize-powerline-faces () + "Alter powerline face to make them work with more themes." + (set-face-attribute 'powerline-inactive2 nil + :inherit 'font-lock-comment-face)) + +(defun spacemacs//evil-state-face () + (let ((state (if (eq 'operator evil-state) evil-previous-state evil-state))) + (intern (format "spacemacs-%S-face" state)))) + +(defun spacemacs//restore-powerline (buffer) + "Restore the powerline in buffer" + (with-current-buffer buffer + (setq-local mode-line-format (default-value 'mode-line-format)) + (powerline-set-selected-window) + (powerline-reset))) + +(defun spacemacs//set-powerline-for-startup-buffers () + "Set the powerline for buffers created when Emacs starts." + (dolist (buffer '("*Messages*" "*spacemacs*" "*Compile-Log*")) + (when (and (get-buffer buffer) + (configuration-layer/package-usedp 'spaceline)) + (spacemacs//restore-powerline buffer)))) + +(defun spacemacs//prepare-diminish () + (when spaceline-minor-modes-p + (let ((unicodep (dotspacemacs|symbol-value + dotspacemacs-mode-line-unicode-symbols))) + (setq spaceline-minor-modes-separator + (if unicodep (if (display-graphic-p) "" " ") "|")) + (dolist (mm spacemacs--diminished-minor-modes) + (let ((mode (car mm))) + (when (and (boundp mode) (symbol-value mode)) + (let* ((unicode (cadr mm)) + (ascii (caddr mm)) + (dim (if unicodep + unicode + (if ascii ascii unicode)))) + (diminish mode dim)))))))) + ;; vi-tilde-fringe @@ -84,3 +148,44 @@ "Disable `vi-tilde-fringe' in the current buffer if it is read only." (when buffer-read-only (spacemacs/disable-vi-tilde-fringe))) + + +;; zoom + +(defun spacemacs//zoom-frm-powerline-reset () + (when (fboundp 'powerline-reset) + (setq-default powerline-height (spacemacs/compute-powerline-height)) + (powerline-reset))) + +(defun spacemacs//zoom-frm-do (arg) + "Perform a zoom action depending on ARG value." + (let ((zoom-action (cond ((eq arg 0) 'zoom-frm-unzoom) + ((< arg 0) 'zoom-frm-out) + ((> arg 0) 'zoom-frm-in))) + (fm (cdr (assoc 'fullscreen (frame-parameters)))) + (fwp (* (frame-char-width) (frame-width))) + (fhp (* (frame-char-height) (frame-height)))) + (when (equal fm 'maximized) + (toggle-frame-maximized)) + (funcall zoom-action) + (set-frame-size nil fwp fhp t) + (when (equal fm 'maximized) + (toggle-frame-maximized)))) + +(defun spacemacs/zoom-frm-in () + "zoom in frame, but keep the same pixel size" + (interactive) + (spacemacs//zoom-frm-do 1) + (spacemacs//zoom-frm-powerline-reset)) + +(defun spacemacs/zoom-frm-out () + "zoom out frame, but keep the same pixel size" + (interactive) + (spacemacs//zoom-frm-do -1) + (spacemacs//zoom-frm-powerline-reset)) + +(defun spacemacs/zoom-frm-unzoom () + "Unzoom current frame, keeping the same pixel size" + (interactive) + (spacemacs//zoom-frm-do 0) + (spacemacs//zoom-frm-powerline-reset)) diff --git a/layers/+spacemacs/spacemacs-ui-visual/packages.el b/layers/+spacemacs/spacemacs-ui-visual/packages.el index bf2f1d381..f7b60d251 100644 --- a/layers/+spacemacs/spacemacs-ui-visual/packages.el +++ b/layers/+spacemacs/spacemacs-ui-visual/packages.el @@ -134,19 +134,14 @@ windmove-down)) (add-to-list 'golden-ratio-extra-commands f)) - ;; Disable auto-resizing for some buffers - (defun spacemacs/no-golden-ratio-for-buffers (bufname) - "Disable golden-ratio if BUFNAME is the name of a visible buffer." - (and (get-buffer bufname) (get-buffer-window bufname 'visible))) - (defun spacemacs/no-golden-ratio-guide-key () - "Disable golden-ratio for guide-key popwin buffer." - (or (spacemacs/no-golden-ratio-for-buffers " *guide-key*") - (spacemacs/no-golden-ratio-for-buffers " *popwin-dummy*"))) + ;; golden-ratio-exclude-buffer-names + (dolist (n '(" *NeoTree*" + "*LV*" + " *which-key*")) + (add-to-list 'golden-ratio-exclude-buffer-names n)) + (add-to-list 'golden-ratio-inhibit-functions 'spacemacs/no-golden-ratio-guide-key) - (add-to-list 'golden-ratio-exclude-buffer-names " *NeoTree*") - (add-to-list 'golden-ratio-exclude-buffer-names "*LV*") - (add-to-list 'golden-ratio-exclude-buffer-names " *which-key*") (spacemacs|diminish golden-ratio-mode " ⓖ" " g")))) @@ -232,14 +227,7 @@ (push '("*ert*" :dedicated t :position bottom :stick t :noselect nil ) popwin:special-display-config) (push '("*grep*" :dedicated t :position bottom :stick t :noselect nil ) popwin:special-display-config) (push '("*nosetests*" :dedicated t :position bottom :stick t :noselect nil ) popwin:special-display-config) - (push '("^\*WoMan.+\*$" :regexp t :position bottom ) popwin:special-display-config) - - (defun spacemacs/remove-popwin-display-config (str) - "Removes the popwin display configurations that matches the passed STR" - (setq popwin:special-display-config - (-remove (lambda (x) (if (and (listp x) (stringp (car x))) - (string-match str (car x)))) - popwin:special-display-config)))))) + (push '("^\*WoMan.+\*$" :regexp t :position bottom ) popwin:special-display-config)))) (defun spacemacs-ui-visual/init-smooth-scrolling () (setq scroll-preserve-screen-position t @@ -267,10 +255,6 @@ (spaceline-compile))) :config (progn - (defun spacemacs/customize-powerline-faces () - "Alter powerline face to make them work with more themes." - (set-face-attribute 'powerline-inactive2 nil - :inherit 'font-lock-comment-face)) (spacemacs/customize-powerline-faces) (dolist (spec '((minor-modes "tmm") @@ -290,10 +274,7 @@ "-" " " (format "%S" segment))) :evil-leader ,(cadr spec))))) (setq spaceline-org-clock-p nil) - - (defun spacemacs//evil-state-face () - (let ((state (if (eq 'operator evil-state) evil-previous-state evil-state))) - (intern (format "spacemacs-%S-face" state)))) + (setq spaceline-highlight-face-func 'spacemacs//evil-state-face) (let ((unicodep (dotspacemacs|symbol-value @@ -331,35 +312,6 @@ (when (configuration-layer/package-usedp 'info+) (spaceline-info-mode t)) - (defun spacemacs//restore-powerline (buffer) - "Restore the powerline in buffer" - (with-current-buffer buffer - (setq-local mode-line-format (default-value 'mode-line-format)) - (powerline-set-selected-window) - (powerline-reset))) - - (defun spacemacs//set-powerline-for-startup-buffers () - "Set the powerline for buffers created when Emacs starts." - (dolist (buffer '("*Messages*" "*spacemacs*" "*Compile-Log*")) - (when (and (get-buffer buffer) - (configuration-layer/package-usedp 'spaceline)) - (spacemacs//restore-powerline buffer)))) - - (defun spacemacs//prepare-diminish () - (when spaceline-minor-modes-p - (let ((unicodep (dotspacemacs|symbol-value - dotspacemacs-mode-line-unicode-symbols))) - (setq spaceline-minor-modes-separator - (if unicodep (if (display-graphic-p) "" " ") "|")) - (dolist (mm spacemacs--diminished-minor-modes) - (let ((mode (car mm))) - (when (and (boundp mode) (symbol-value mode)) - (let* ((unicode (cadr mm)) - (ascii (caddr mm)) - (dim (if unicodep - unicode - (if ascii ascii unicode)))) - (diminish mode dim)))))))) (add-hook 'spaceline-pre-hook 'spacemacs//prepare-diminish) (spacemacs//set-powerline-for-startup-buffers)))) @@ -382,44 +334,6 @@ ("q" nil :exit t)) (spacemacs/set-leader-keys "zf" 'spacemacs/zoom-frm-transient-state/body) - (defun spacemacs//zoom-frm-powerline-reset () - (when (fboundp 'powerline-reset) - (setq-default powerline-height (spacemacs/compute-powerline-height)) - (powerline-reset))) - - (defun spacemacs//zoom-frm-do (arg) - "Perform a zoom action depending on ARG value." - (let ((zoom-action (cond ((eq arg 0) 'zoom-frm-unzoom) - ((< arg 0) 'zoom-frm-out) - ((> arg 0) 'zoom-frm-in))) - (fm (cdr (assoc 'fullscreen (frame-parameters)))) - (fwp (* (frame-char-width) (frame-width))) - (fhp (* (frame-char-height) (frame-height)))) - (when (equal fm 'maximized) - (toggle-frame-maximized)) - (funcall zoom-action) - (set-frame-size nil fwp fhp t) - (when (equal fm 'maximized) - (toggle-frame-maximized)))) - - (defun spacemacs/zoom-frm-in () - "zoom in frame, but keep the same pixel size" - (interactive) - (spacemacs//zoom-frm-do 1) - (spacemacs//zoom-frm-powerline-reset)) - - (defun spacemacs/zoom-frm-out () - "zoom out frame, but keep the same pixel size" - (interactive) - (spacemacs//zoom-frm-do -1) - (spacemacs//zoom-frm-powerline-reset)) - - (defun spacemacs/zoom-frm-unzoom () - "Unzoom current frame, keeping the same pixel size" - (interactive) - (spacemacs//zoom-frm-do 0) - (spacemacs//zoom-frm-powerline-reset)) - ;; Font size, either with ctrl + mouse wheel (global-set-key (kbd "") 'spacemacs/zoom-frm-in) (global-set-key (kbd "") 'spacemacs/zoom-frm-out))))