-
Notifications
You must be signed in to change notification settings - Fork 438
Buffers panel: highlight current button/buffer #3199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Buffers panel: highlight current button/buffer #3199
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the idea! I've left some comments, mostly cosmetic and helping with Spinneret and our custom tags, like :nbutton
.
collect (:raw (buffer-markup buffer))))))) | ||
collect (:raw (buffer-markup buffer (eq buffer (current-buffer))))))))) | ||
|
||
(defun reload-panel-buffer (panel-buffer) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might go into the body of the panel command as:
(reload-buffer panel-buffer)
So no need for a separate function that works out of context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your comments! Would this be a flet
expression? This function is to be called by the window-set-buffer-hook
. I guess I need a free-standing function for the hook!?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, right. I haven't taken the window hook into account. For that, a separate function might be necessary. But here, in buttons, you can benefit from the panel buffer accessibility.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added the window hook in commit bec09b2. Now I call reload-panel-buffer
in the hook. Is it correct to call this top-level function also in the buffers panel? Or should I create a flet
expression nevertheless?
I have tried this. It works for `:class "action"` but not for `:class "success"`. Where is the according CSS defined?
It's buffer.lisp, line 167 on master.
|
be7ca1c
to
6ebccfc
Compare
So far, my best try to add (defun buffers-panel-handler (window buffer)
(reload-panel-buffer (first (nyxt::panel-buffers (current-window)))))
(define-configuration window
((window-set-buffer-hook
(hooks:add-hook %slot-default% 'buffers-panel-handler)))) AFAIU, this warning lets the compilation fail:
When I remove the function arguments Update: I think I should use (defun buffers-panel-handler (window buffer)
(print buffer)
(reload-panel-buffer (first (nyxt::panel-buffers window)))) But this causes a crash on startup. Update 2: Fixed in commit bec09b2. |
Compilation warning: The variable WINDOW is defined but never used
It's just a compiler being picky. Add (declare (ignore window)) to the handler right after argument list and it'll work.
|
4d57254
to
2fdbc9c
Compare
@aadcg, take a look. Most of my programming-related questions are resolved, so what's left is the feature assessment.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @MaxGyver83. I've left some comments.
When all of conversations are closed I'll give this feature a try.
I'll take a final look tomorrow and merge. |
@MaxGyver83, while this is a very welcomed feature, the PR doesn't seem ready. When opening a new buffer, see how the panel buffer gets updated. Steps to reproduce:
If we have a mechanism that updates the panel buffer automatically, then we can rid of the update button. Thanks! |
62559ce
to
923936a
Compare
True. It looks like my testing was too narrow. I have committed two changes:
I'm still trying to add the EDIT:
I'm wondering if it's correct at all that one window's buffers panel shows all windows' buffers. If this is intended, I might need a third hook. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MaxGyver83 I'm mostly happy with this PR. In terms of the UI, I'd suggest doing the change below.
:text-overflow ellipsis))
(:body
- (:nbutton :text "Update ↺"
- :buffer panel-buffer
- :class "success"
- `(reload-panel-buffer ,panel-buffer))
(:h1 "Buffers")
(loop for buffer in (buffer-list)
- collect (:raw (buffer-markup buffer (eq buffer (current-buffer)))))))))
+ collect (:raw (buffer-markup buffer (eq buffer (current-buffer)))))
+ (:nbutton :text "↺"
+ :buffer panel-buffer
+ :style "position: absolute; bottom: 10px; right: 10px;"
+ :class "success"
+ `(reload-panel-buffer ,panel-buffer))))))
Which results in:
I'm still trying to add the window-set-buffer-hook directly in window.lisp in initialize-instance.
I think the way you did is good enough for now.
Another possible bug: When the buffers panel shows three buffers (...) I'm wondering if it's correct at all that one window's buffers panel shows all windows' buffers. If this is intended, I might need a third hook.
Let's discuss that topic on a separate issue.
@MaxGyver83 would you like to make the changes yourself or shall I do it? Thanks.
Co-authored-by: Andre A. Gomes <andremegafone@gmail.com>
923936a
to
b8ea2f0
Compare
I have committed your suggested change, updated the changelog and rebased. |
@MaxGyver83 I've merged your work via commits f9361ad and 772c844. Thanks for this important contribution! |
Description
While
switch-buffer
is very efficient for finding a specific buffer among many, it requires that you remember what to search for. Having a list of open buffers always visible (as p.e. in Firefox) helps to keep an overview. Nyxt's buffer panel is very similar to a tab bar in other browsers.In this pull request, I try to make the buffer panel even a bit more useful.
Changes:
currently only updated when the buffer is changed using the buffer panel).window-set-buffer-hook
.buffer-loaded-hook
.Before:
After:
Discussion
Please tell me if such a changed is welcome at all. If yes, you might prefer a different design.
I actually want to use the defaultprompt-buffer
highlight color instead of a simple blue but I couldn't manage to select this theme color. I also don't yet understand how to set a hook.One detail: In line 100, I create either a regular or a blue
:nbutton
depending on thehighlight
argument. Actually, I would prefer to write less duplicate code but this does not work:I don't know why.Probably easy to solve but I'm a Common Lisp beginner. → @aartaka showed me how to fix this.Checklist:
Everything in this checklist is required for each PR. Please do not approve a PR that does not have all of these items.
:documentation
s written in the aforementioned style. (It's OK to skip the docstring for really trivial parts.)changelog.lisp
with my changes if it's anything user-facing (new features, important bug fix, compatibility breakage).migration.lisp
entry for all compatibility-breaking changes.(asdf:test-system :nyxt)
and(asdf:test-system :nyxt/gi-gtk)
) and they pass.