|
| 1 | +(in-package #:nyxt-user) |
| 2 | + |
| 3 | +(load-after-system :slynk (nyxt-init-file "slynk.lisp")) |
| 4 | + |
| 5 | +(define-configuration browser |
| 6 | + ((session-restore-prompt :always-ask))) |
| 7 | + |
| 8 | +(defun format-short-status-modes (&optional (buffer (current-buffer))) |
| 9 | + (str:replace-using |
| 10 | + '("-mode" "" |
| 11 | + "base" "" |
| 12 | + "emacs" "ξ" ; Xi looks like Emacs logo... |
| 13 | + "force-https" "ϕ" |
| 14 | + "auto" "α" |
| 15 | + "blocker" "β" |
| 16 | + "proxy" "π" |
| 17 | + "reduce-tracking" "τ" |
| 18 | + "certificate-exception" "χ" |
| 19 | + "style" "σ" |
| 20 | + "web" "ω" |
| 21 | + "help" "?") |
| 22 | + (format nil "~{~a~^ ~}" |
| 23 | + (mapcar (alexandria:compose #'str:downcase #'mode-name) |
| 24 | + (modes buffer))))) |
| 25 | + |
| 26 | +(defun format-short-status-load-status (&optional (buffer (current-buffer))) |
| 27 | + (when (web-buffer-p buffer) |
| 28 | + (case (slot-value buffer 'nyxt::load-status) |
| 29 | + (:unloaded "∅") |
| 30 | + (:loading "∞") |
| 31 | + (:finished "")))) |
| 32 | + |
| 33 | +(defun format-short-status-url (&optional (buffer (current-buffer))) |
| 34 | + (markup:markup |
| 35 | + (:a :class "button" |
| 36 | + :href (lisp-url '(nyxt:set-url-from-current-url)) |
| 37 | + (str:concat |
| 38 | + (format-short-status-load-status buffer) |
| 39 | + (format nil " ~a — ~a" |
| 40 | + (ppcre:regex-replace-all |
| 41 | + "(https://|www\\.|/$)" |
| 42 | + (object-display (url buffer)) |
| 43 | + "") |
| 44 | + (title buffer)))))) |
| 45 | + |
| 46 | +(defun short-format-status (window) |
| 47 | + (let ((buffer (current-buffer window))) |
| 48 | + (markup:markup |
| 49 | + (:div :id "container" |
| 50 | + (:div :id "controls" (markup:raw "")) |
| 51 | + (:div :class "arrow arrow-right" |
| 52 | + :style "background-color:rgb(80,80,80)" "") |
| 53 | + (:div :id "url" (markup:raw (format-short-status-url buffer))) |
| 54 | + (:div :class "arrow arrow-right" |
| 55 | + :style "background-color:rgb(120,120,120)" "") |
| 56 | + (:div :id "tabs" (markup:raw (format-status-tabs))) |
| 57 | + (:div :class "arrow arrow-left" |
| 58 | + :style "background-color:rgb(120,120,120)" "") |
| 59 | + (:div :id "modes" (format-short-status-modes buffer)))))) |
| 60 | + |
| 61 | +(define-configuration window |
| 62 | + ((status-formatter #'short-format-status) |
| 63 | + (message-buffer-style |
| 64 | + (str:concat |
| 65 | + %slot-default |
| 66 | + (cl-css:css |
| 67 | + '((body |
| 68 | + :background-color "black" |
| 69 | + :color "white"))))))) |
| 70 | + |
| 71 | +;; ;; An experimental setting for transition to a bigger screen. |
| 72 | +;; (define-configuration status-buffer |
| 73 | +;; ((height 30) |
| 74 | +;; (style (str:concat %slot-default |
| 75 | +;; (cl-css:css |
| 76 | +;; '((body |
| 77 | +;; :font-size "20px" |
| 78 | +;; :line-height "30px") |
| 79 | +;; (".arrow" |
| 80 | +;; :height "30px"))))))) |
| 81 | + |
| 82 | +(define-configuration minibuffer |
| 83 | + ((style |
| 84 | + (str:concat |
| 85 | + %slot-default |
| 86 | + (cl-css:css |
| 87 | + '((body |
| 88 | + :background-color "black" |
| 89 | + :color "#808080"))))))) |
| 90 | + |
| 91 | +(define-configuration buffer |
| 92 | + ((default-modes `(emacs-mode ,@%slot-default)) |
| 93 | + (conservative-word-move t) |
| 94 | + ;; QWERTY home row. |
| 95 | + (hints-alphabet "DSJKHLFAGNMXCWEIO"))) |
| 96 | + |
| 97 | +(define-configuration web-buffer |
| 98 | + ((default-modes `(emacs-mode auto-mode blocker-mode force-https-mode |
| 99 | + ,@%slot-default)))) |
| 100 | + |
| 101 | +(define-configuration internal-buffer |
| 102 | + ((style |
| 103 | + (str:concat |
| 104 | + %slot-default |
| 105 | + (cl-css:css |
| 106 | + '((body |
| 107 | + :background-color "black" |
| 108 | + :color "lightgray") |
| 109 | + (hr |
| 110 | + :color "darkgray") |
| 111 | + (.button |
| 112 | + :color "#333333"))))))) |
| 113 | + |
| 114 | +(define-configuration nyxt/auto-mode:auto-mode |
| 115 | + ((nyxt/auto-mode:prompt-on-mode-toggle t))) |
0 commit comments