Fix the modeline view to reposition on resize

This commit is contained in:
Sameer Rahmani 2024-04-11 15:39:22 +01:00
parent dc949d26c4
commit f27b43c3d0
Signed by: lxsameer
GPG Key ID: 8741FACBF412FFA5
6 changed files with 42 additions and 22 deletions

View File

@ -253,15 +253,16 @@
"nixpkgs": "nixpkgs_4"
},
"locked": {
"lastModified": 1712776989,
"narHash": "sha256-DiZoTYM8FptB4DkyrzdFDMDIMECNCdYpnthjhi0NaRs=",
"rev": "5241f9f243cb6099a185db12552a32f70509ada6",
"revCount": 48,
"lastModified": 1712846008,
"narHash": "sha256-0739q1QSpprLrlqdmQeSM9ynqmuqHagmRLnyMEy47Xc=",
"ref": "refs/tags/v0.1.8",
"rev": "e53688bcc79e5e3142bb2c912d59965c086dafe4",
"revCount": 49,
"type": "git",
"url": "https://devheroes.codes/lxsameer/noether"
},
"original": {
"rev": "5241f9f243cb6099a185db12552a32f70509ada6",
"ref": "refs/tags/v0.1.8",
"type": "git",
"url": "https://devheroes.codes/lxsameer/noether"
}

View File

@ -17,7 +17,8 @@
description = "FG42 - Emacs Editor for advance users";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/442d407992384ed9c0e6d352de75b69079904e4e";
inputs.noether.url = "git+https://devheroes.codes/lxsameer/noether?rev=5241f9f243cb6099a185db12552a32f70509ada6";
inputs.noether.url = "git+https://devheroes.codes/lxsameer/noether?ref=refs/tags/v0.1.8";
inputs.emacs-overlay.url = "github:nix-community/emacs-overlay/0f7f3b39157419f3035a2dad39fbaf8a4ba0448d";
inputs.flake-parts.url = "github:hercules-ci/flake-parts";
@ -50,6 +51,7 @@
gtk3 = (factory { emacsParams.withGTK3 = true; }).fg42;
pgtk = (factory { emacsParams.withPgtk = true; }).fg42;
gtk2 = (factory { emacsParams.withGTK2 = true; }).fg42;
none = (factory { emacsParams.toolkit = "no"; }).fg42;
});
devShells.default = pkgs.mkShell {

View File

@ -256,6 +256,9 @@ shipped with Emacs."
(add-hook
'emacs-startup-hook
(lambda ()
;; It only applies to toolkit=no
(set-mouse-color (get-base16-color-or :base07 "#eeeeec"))
;; Switch from `dabbrev-expand' to `hippie-expand'
(global-set-key [remap dabbrev-expand] 'hippie-expand)

View File

@ -67,7 +67,7 @@
(setq user-emacs-directory emacsd)
(setq user-init-file
(or (getenv "FG42_CONFIG_FILE")
(format "%s/.fg42.el"
(format "%s/.fg42.v4.el"
(getenv "HOME")))))

View File

@ -39,13 +39,13 @@
(defun fg42/-format-mode-icon (_ v _ _)
"Format the icon V."
(nerd-icons-icon-for-mode v))
(format " %s " (nerd-icons-icon-for-mode v)))
(noether-defunit fg42/mode-icon
"Draws an icon for the current major mode."
:label ""
:len 1
:len 3
:init (lambda ()
(add-hook 'post-command-hook #'fg42/-update-mode-icon))

View File

@ -26,33 +26,47 @@
(require 'fg42/modeline/units)
(defun fg42/--bottom-right (info)
"Keep the modeline at bottom right by using the data from INFO."
(cons -1 -1))
(defun fg42/adjust-modeline (view)
"Adjust the VIEW after parent frame resize."
(noether-show view))
(noether-defview fg42/modeline
"A simple and minimalist mode-line like status bar"
:managed? t
:binding (kbd "C-c 0")
:buffer "*modeline"
:buffer "*modeline*"
:visible? t
:timeout 0
:on-parent-resize #'fg42/adjust-modeline
:frame
(list
:position
(cons (- (frame-inner-width) 690)
(- (frame-outer-height) 20))
:right-fringe 5
:poshandler #'fg42/--bottom-right
:border-width 0
:font (format "%s %s" (car fg42/font) (- (cadr fg42/font) 1))
:border-color "#bd93f9")
:units
(list
(buffer-name-unit :label (format "%s " (nerd-icons-codicon "nf-cod-layers"))
:len 20)
(buffer-name-unit
:label (format "%s " (nerd-icons-codicon "nf-cod-layers"))
:len 20)
;; (mode-name-unit :label " " :len 4)
(projectile-project-unit :label (format "%s " (nerd-icons-octicon "nf-oct-project"))
:len 20)
(git-branch-unit :label (format "%s " (nerd-icons-devicon "nf-dev-git_branch"))
:len 20)
(projectile-project-unit
:label (format "%s " (nerd-icons-octicon "nf-oct-project"))
:len 20)
(git-branch-unit
:label (format "%s " (nerd-icons-devicon "nf-dev-git_branch"))
:len 20)
(fg42/mode-icon)
(line-unit :label "")))
(line-unit :label (format "%s " (nerd-icons-codicon "nf-cod-location")))))
(when-wm
@ -67,7 +81,7 @@ Appears on the center of the current window."
(list
;; Such a big numbers for X and Y will cause the frame to appear on the
;; bottom right corner and covering the minibuffer
:position '(10000 . 10000)
:position '(-30 . -1)
:border-width 0
:timeout 5
:border-color "#bd93f9")