Skip to content

Commit

Permalink
Merge pull request #3320 from atlas-engineer/refactor-buffers
Browse files Browse the repository at this point in the history
  • Loading branch information
aadcg committed Jan 29, 2024
2 parents cc1c12f + 204b3c4 commit 1512527
Show file tree
Hide file tree
Showing 10 changed files with 394 additions and 401 deletions.
2 changes: 1 addition & 1 deletion nyxt.asd
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@
(:file "inspector")
(:file "dom")
(:file "buffer")
(:file "window")
(:file "panel")
(:file "window")
(:file "mode")
(:file "history")
(:file "auto-rules")
Expand Down
369 changes: 0 additions & 369 deletions source/buffer.lisp

Large diffs are not rendered by default.

8 changes: 6 additions & 2 deletions source/changelog.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,8 @@ auto-configuration (which probably wouldn't work anyways).")
(:li "Prompt buffer updated for intuitive matching with new algorithms and settings.")
(:li "Revamp status buffer design for increased readability and aesthetics. Make it
fully customizable with " (:nxref :function 'format-status) " framework.")
(:li "Status buffer placement can be changed with "
(:nxref :slot 'status-buffer-position :class-name 'window) " (thanks to @mianmoreno)")
(:li "Status buffer placement can be changed with " (:code "status-buffer-position")
" (thanks to @mianmoreno)")
(:li "Most help pages, including " (:a :href (nyxt-url 'manual) "the manual")
" are more readable and interactive.")
(:li "Add support for the Gopher and Gemini protocols.")
Expand Down Expand Up @@ -995,6 +995,10 @@ allows access to common functions that are defined within the mode."))))

(define-version "4.0.0"
(:ul
(:li "Deprecate slot " (:code "status-buffer-position") "in favour of"
(:nxref :slot 'placement :class-name 'status-buffer) ".")
(:li "Deprecate slot " (:code "prompt-buffer-open-height") " since "
(:nxref :slot 'height :class-name 'prompt-buffer) "suffices.")
(:li "Add slot "
(:nxref :slot 'nyxt/mode/hint:x-placement :class-name 'nyxt/mode/hint:hint-mode)
" to draw hints on the right of the hinted element. By default, they
Expand Down
50 changes: 50 additions & 0 deletions source/message.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,56 @@

(in-package :nyxt)

(define-class message-buffer (input-buffer)
((window
nil
:type (maybe window)
:documentation "The `window' to which the message buffer is attached.")
(height
16
:type integer
:writer nil
:reader height
:export t
:documentation "The height of the message buffer in pixels.")
(style (theme:themed-css (theme *browser*)
`(:font-face :font-family "public sans" :font-style "normal" :font-weight "400" :src ,(format nil "url('nyxt-resource:~a')" "PublicSans-Regular.woff") "format('woff')")
`(:font-face :font-family "public sans" :font-style "italic" :font-weight "400" :src ,(format nil "url('nyxt-resource:~a')" "PublicSans-Italic.woff") "format('woff')")
`(:font-face :font-family "public sans" :font-style "normal" :font-weight "100" :src ,(format nil "url('nyxt-resource:~a')" "PublicSans-Thin.woff") "format('woff')")
`(:font-face :font-family "public sans" :font-style "italic" :font-weight "100" :src ,(format nil "url('nyxt-resource:~a')" "PublicSans-ThinItalic.woff") "format('woff')")
`(:font-face :font-family "public sans" :font-style "normal" :font-weight "200" :src ,(format nil "url('nyxt-resource:~a')" "PublicSans-ExtraLight.woff") "format('woff')")
`(:font-face :font-family "public sans" :font-style "italic" :font-weight "200" :src ,(format nil "url('nyxt-resource:~a')" "PublicSans-ExtraLightItalic.woff") "format('woff')")
`(:font-face :font-family "public sans" :font-style "normal" :font-weight "300" :src ,(format nil "url('nyxt-resource:~a')" "PublicSans-Light.woff") "format('woff')")
`(:font-face :font-family "public sans" :font-style "italic" :font-weight "300" :src ,(format nil "url('nyxt-resource:~a')" "PublicSans-LightItalic.woff") "format('woff')")
`(:font-face :font-family "public sans" :font-style "normal" :font-weight "500" :src ,(format nil "url('nyxt-resource:~a')" "PublicSans-Medium.woff") "format('woff')")
`(:font-face :font-family "public sans" :font-style "italic" :font-weight "500" :src ,(format nil "url('nyxt-resource:~a')" "PublicSans-MediumItalic.woff") "format('woff')")
`(:font-face :font-family "public sans" :font-style "normal" :font-weight "600" :src ,(format nil "url('nyxt-resource:~a')" "PublicSans-SemiBold.woff") "format('woff')")
`(:font-face :font-family "public sans" :font-style "italic" :font-weight "600" :src ,(format nil "url('nyxt-resource:~a')" "PublicSans-SemiBoldItalic.woff") "format('woff')")
`(:font-face :font-family "public sans" :font-style "normal" :font-weight "700" :src ,(format nil "url('nyxt-resource:~a')" "PublicSans-Bold.woff") "format('woff')")
`(:font-face :font-family "public sans" :font-style "italic" :font-weight "700" :src ,(format nil "url('nyxt-resource:~a')" "PublicSans-BoldItalic.woff") "format('woff')")
`(:font-face :font-family "public sans" :font-style "normal" :font-weight "800" :src ,(format nil "url('nyxt-resource:~a')" "PublicSans-ExtraBold.woff") "format('woff')")
`(:font-face :font-family "public sans" :font-style "italic" :font-weight "800" :src ,(format nil "url('nyxt-resource:~a')" "PublicSans-ExtraBoldItalic.woff") "format('woff')")
`(:font-face :font-family "public sans" :font-style "normal" :font-weight "900" :src ,(format nil "url('nyxt-resource:~a')" "PublicSans-Black.woff") "format('woff')")
`(:font-face :font-family "public sans" :font-style "italic" :font-weight "900" :src ,(format nil "url('nyxt-resource:~a')" "PublicSans-BlackItalic.woff") "format('woff')")
`(:font-face :font-family "dejavu sans mono" :src ,(format nil "url('nyxt-resource:~a')" "DejaVuSansMono.ttf") "format('ttf')")
`(body
:background-color ,theme:background-alt
:color ,theme:on-background-alt
:font-family ,theme:font-family
:font-size "75vh"
:line-height "100vh"
:padding 0
:padding-left "4px"
:margin 0))))
(:export-class-name-p t)
(:export-accessor-names-p t)
(:export-predicate-name-p t)
(:metaclass user-class))

(defmethod (setf height) (value (message-buffer message-buffer))
(setf (ffi-height message-buffer) value)
(setf (slot-value message-buffer 'height) value))

(defclass messages-appender (log4cl-impl:appender) ())

(defmethod log4cl-impl:appender-do-append ((appender messages-appender) logger level log-func)
Expand Down
6 changes: 6 additions & 0 deletions source/migration.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,12 @@ major versions."
result)))))

(define-migration "4"
(prompt-buffer-open-height)
(:p "Deprecated since " (:nxref :slot 'height :class-name 'prompt-buffer) " suffices.")

(status-buffer-position)
(:p "Deprecated in favor of " (:nxref :slot 'placement :class-name 'status-buffer) ".")

(hints-offset-x)
(:p "Deprecated in favor of "
(:nxref :slot 'nyxt/mode/hint:x-translation :class-name 'nyxt/mode/hint:hint-mode) ".")
Expand Down
155 changes: 148 additions & 7 deletions source/panel.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,159 @@

(in-package :nyxt)

;; TODO: Quite some code could be factored with `internal-page'.
(define-class panel-buffer (input-buffer modable-buffer document-buffer network-buffer)
((width
256
:documentation "The width in pixels.")
(style (theme:themed-css (theme *browser*)
`(:font-face :font-family "public sans" :font-style "normal" :font-weight "400" :src ,(format nil "url('nyxt-resource:~a')" "PublicSans-Regular.woff") "format('woff')")
`(:font-face :font-family "public sans" :font-style "italic" :font-weight "400" :src ,(format nil "url('nyxt-resource:~a')" "PublicSans-Italic.woff") "format('woff')")
`(:font-face :font-family "public sans" :font-style "normal" :font-weight "100" :src ,(format nil "url('nyxt-resource:~a')" "PublicSans-Thin.woff") "format('woff')")
`(:font-face :font-family "public sans" :font-style "italic" :font-weight "100" :src ,(format nil "url('nyxt-resource:~a')" "PublicSans-ThinItalic.woff") "format('woff')")
`(:font-face :font-family "public sans" :font-style "normal" :font-weight "200" :src ,(format nil "url('nyxt-resource:~a')" "PublicSans-ExtraLight.woff") "format('woff')")
`(:font-face :font-family "public sans" :font-style "italic" :font-weight "200" :src ,(format nil "url('nyxt-resource:~a')" "PublicSans-ExtraLightItalic.woff") "format('woff')")
`(:font-face :font-family "public sans" :font-style "normal" :font-weight "300" :src ,(format nil "url('nyxt-resource:~a')" "PublicSans-Light.woff") "format('woff')")
`(:font-face :font-family "public sans" :font-style "italic" :font-weight "300" :src ,(format nil "url('nyxt-resource:~a')" "PublicSans-LightItalic.woff") "format('woff')")
`(:font-face :font-family "public sans" :font-style "normal" :font-weight "500" :src ,(format nil "url('nyxt-resource:~a')" "PublicSans-Medium.woff") "format('woff')")
`(:font-face :font-family "public sans" :font-style "italic" :font-weight "500" :src ,(format nil "url('nyxt-resource:~a')" "PublicSans-MediumItalic.woff") "format('woff')")
`(:font-face :font-family "public sans" :font-style "normal" :font-weight "600" :src ,(format nil "url('nyxt-resource:~a')" "PublicSans-SemiBold.woff") "format('woff')")
`(:font-face :font-family "public sans" :font-style "italic" :font-weight "600" :src ,(format nil "url('nyxt-resource:~a')" "PublicSans-SemiBoldItalic.woff") "format('woff')")
`(:font-face :font-family "public sans" :font-style "normal" :font-weight "700" :src ,(format nil "url('nyxt-resource:~a')" "PublicSans-Bold.woff") "format('woff')")
`(:font-face :font-family "public sans" :font-style "italic" :font-weight "700" :src ,(format nil "url('nyxt-resource:~a')" "PublicSans-BoldItalic.woff") "format('woff')")
`(:font-face :font-family "public sans" :font-style "normal" :font-weight "800" :src ,(format nil "url('nyxt-resource:~a')" "PublicSans-ExtraBold.woff") "format('woff')")
`(:font-face :font-family "public sans" :font-style "italic" :font-weight "800" :src ,(format nil "url('nyxt-resource:~a')" "PublicSans-ExtraBoldItalic.woff") "format('woff')")
`(:font-face :font-family "public sans" :font-style "normal" :font-weight "900" :src ,(format nil "url('nyxt-resource:~a')" "PublicSans-Black.woff") "format('woff')")
`(:font-face :font-family "public sans" :font-style "italic" :font-weight "900" :src ,(format nil "url('nyxt-resource:~a')" "PublicSans-BlackItalic.woff") "format('woff')")
`(:font-face :font-family "dejavu sans mono" :src ,(format nil "url('nyxt-resource:~a')" "DejaVuSansMono.ttf") "format('ttf')")
`(body
:background-color ,theme:background-alt
:color ,theme:on-background-alt
:font-family ,theme:font-family
:margin "0"
:padding "10px"
:padding-top "24px"
:border-style "solid"
:border-width "0px 1px"
:border-color ,theme:secondary)
`("h1,h2,h3,h4,h5,h6"
:font-family ,theme:font-family
:font-weight 500)
`(a
:color ,theme:primary)
`("details summary"
:margin-left "inherit"
:margin-bottom "8px"
:cursor "pointer")
`("summary::-webkit-details-marker"
:padding-bottom "4px")
'("details > summary"
:list-style-type "none")
'("details > summary::-webkit-details-marker"
:display "none")
'("details > summary::before"
:font-weight "bold"
:content "+"
:margin-right "5px"
:display "inline-block")
'("details[open] > summary::before"
:content "")
`(pre
:font-family ,theme:monospace-font-family
:font-size "0.9rem")
`(code
:font-family ,theme:monospace-font-family
:font-size "0.9rem")
`(dt
:font-weight bold)
`(dd
:margin-inline-start 1em
:font-size xx-small)
`((:and a :hover)
:cursor "pointer"
:text-decoration "underline")
`((:and a :active)
:opacity 0.6)
`("#close"
:position "fixed"
:top "4px"
:right "4px"
:line-height "12px")
`(button
:background "transparent"
:max-width "100%"
:color "inherit"
:border "none"
:padding 0
:font "inherit"
:outline "inherit")
`(.button
:background-color ,theme:primary
:color ,theme:on-primary
:display "inline-block"
:text-decoration "none"
:border-radius "2px"
:padding "6px"
:margin "2px")
`(.action
:color ,theme:action)
`(.button.action
:background-color ,theme:action
:color ,theme:on-action
:border-color ,theme:action+)
`(.warning
:color ,theme:warning)
`(.button.warning
:background-color ,theme:warning
:color ,theme:on-warning
:border-color ,theme:warning+)
`(.success
:color ,theme:success)
`(.button.success
:background-color ,theme:success
:color ,theme:on-success
:border-color ,theme:success+)
`(.highlight
:color ,theme:highlight)
`(.button.highlight
:background-color ,theme:highlight
:color ,theme:on-highlight
:border-color ,theme:highlight+)
`((:and .button :hover)
:cursor "pointer"
:opacity 0.8)
`((:and .button (:or :visited :active))
:color ,theme:background)
`("a:visited"
:color ,theme:secondary)
`(".progress-bar-container"
:border-radius "3px"
:height "20px"
:width "100%")
`(".progress-bar-base"
:border-radius "3px"
:background-color ,theme:secondary
:height "100%")
`(".progress-bar-fill"
:border-radius "3px"
:background-color ,theme:primary
:height "100%"))))
(:export-class-name-p t)
(:export-accessor-names-p t)
(:export-predicate-name-p t)
(:metaclass user-class)
(:documentation "Panel buffer (also known as sidebar): small view on the side of the screen.
Panels (pages openable in panel buffer with respective commands) are defined
with `define-panel-command' and `define-panel-command-global'.
Also see `panel-page'."))

(define-class panel-buffer-source (prompter:source)
((prompter:name "Panel buffers")
(window :accessor window :initarg :window)
(window nil)
(prompter:filter-preprocessor #'prompter:filter-exact-matches)
(prompter:enable-marks-p t)
(prompter:constructor (lambda (source)
(panel-buffers (window source))))))
(prompter:constructor (lambda (source) (panel-buffers (window source))))))

(define-command-global delete-panel-buffer (&key (window (current-window))
(panels (prompt
Expand Down Expand Up @@ -62,7 +206,6 @@ panel."))
:buffer (make-instance 'panel-buffer))
(side ,page))))))))

;; FIXME: Better way to compose HTML wrappers?
(defmethod (setf form) :after (lambda-expression (page panel-page))
(declare (ignore lambda-expression))
(let ((original-form (slot-value page 'form)))
Expand All @@ -87,8 +230,6 @@ panel."))
"×")))))
(values contents type status headers reason))))))

;; TODO: Add define-panel?

(export-always 'define-panel-command)
(defmacro define-panel-command (name (&rest arglist)
(buffer-var title &optional (side :left))
Expand Down
5 changes: 3 additions & 2 deletions source/prompt-buffer.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
:export t
:documentation "The height occupied by the prompt buffer.
The options are:
- `:default', which sets it to the value of `prompt-buffer-open-height';
- `:default', which sets it to a third of the window's height;
- `:fit-to-prompt', which shrinks the height to fit the input area;
- an integer, which corresponds to the height in pixels.")
(prompter:history (prompt-buffer-generic-history *browser*)
Expand Down Expand Up @@ -279,7 +279,8 @@ See `prompt' for how to invoke prompts.")
(setf (ffi-height prompt-buffer)
(case value
(:default
(prompt-buffer-open-height (window prompt-buffer)))
(round (/ (ffi-height (window prompt-buffer))
3)))
(:fit-to-prompt
(ps-eval :buffer prompt-buffer
(+ (ps:chain (nyxt/ps:qs document "#prompt-area") offset-height)
Expand Down
4 changes: 2 additions & 2 deletions source/renderer/gtk.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ response. The BODY is wrapped with `with-protect'."
;; receive input, for instance to create a new buffer.
(setf nyxt::active-buffer (make-instance 'input-buffer))

(when (eq (status-buffer-position window) :top)
(when (eq (placement status-buffer) :top)
(gtk:gtk-box-pack-start root-box-layout status-container :expand nil))

;; Add the views to the box layout and to the window
Expand All @@ -496,7 +496,7 @@ response. The BODY is wrapped with `with-protect'."
(setf (gtk:gtk-widget-size-request message-container)
(list -1 (height message-buffer)))

(when (eq (status-buffer-position window) :bottom)
(when (eq (placement status-buffer) :bottom)
(gtk:gtk-box-pack-end root-box-layout status-container :expand nil))

(gtk:gtk-box-pack-start status-container (gtk-object status-buffer) :expand t)
Expand Down
Loading

0 comments on commit 1512527

Please sign in to comment.