1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-04-21 12:16:54 +02:00

43 Commits

Author SHA1 Message Date
Stefan Haller
1f2cb35cc9 Refactor: move wrapMessageToWidth to utils/lines.go
to make it more generally usable by clients other than ConfirmationHelper, which
we will do later in this branch. Rename it to WrapViewLinesToWidth while we're
at it.

Add tests; in particular, add a sanity check that we wrap lines the same way as
gocui does. The tests that are added here are the same ones as in gocui for its
lineWrap function, but we'll extend them a bit in later commits in this branch.
2024-12-23 12:24:09 +01:00
Stefan Haller
3610f13418 Fix several bugs in wrapMessageToWidth
This corresponds to the following fixes in gocui's lineWrap function:
- https://github.com/jesseduffield/gocui/pull/67/commits/86cf561ef493
- https://github.com/jesseduffield/gocui/pull/67/commits/24746d5cd6ee
- https://github.com/jesseduffield/gocui/pull/67/commits/4b97941c4ec6
2024-12-23 12:24:09 +01:00
Stefan Haller
f6f2a52dee Bump gocui and adapt lazygit code
Original commit message of the gocui change:

This fixes View.Size, Width and Height to be the correct (outer) size of a view
including its frame, and InnerSize/InnerWidth/InnerHeight to be the usable
client area exluding the frame. Previously, Size was actually the InnerSize (and
a lot of client code used it as such, so these need to be changed to InnerSize).
InnerSize, on the other hand, was *one* less than Size (not two, as you would
have expected), and in many cases this was made up for at call sites by adding 1
(e.g. in calcRealScrollbarStartEnd, parseInput, and many other places in the
lazygit code).

There are still some weird things left that I didn't address here:
- a view's lower-right coordinates (x1/y1) are one less than you would expect.
  For example, a view with a 2x2 client area like this:
    ╭──╮
    │ab│
    │cd│
    ╰──╯
  in the top-left corner of the screen (x0 and y0 both zero) has x1/xy at 3, not
  4 as would be more natural.
- a view without a frame has its coordinates extended by 1 on all sides; to
  illustrate, the same 2x2 view as before but without a frame, sitting in the
  top-left corder of the screen, has coordinates x0=-1, y0=-1, x1=2, y1=2. This
  is highly confusing and unexpected.

I left these as they are because they would be even more of a breaking change,
and also because they don't have quite as much of an impact on general app code.
2024-12-01 10:40:08 +01:00
Stefan Haller
825f5c0a91 Use AutoRenderHyperLinks in confirmation view
This allows us to get rid of the underlineLinks function.
2024-09-28 12:04:51 +02:00
Stefan Haller
b15a1c7ae7 Remove return value of CreatePopupPanel 2024-09-06 08:45:48 +02:00
Stefan Haller
371998e635 Remove return value of IContextMgr.Push/Pop et. al. 2024-09-06 08:45:48 +02:00
Stefan Haller
8302575078 Remove return value of Focus-related functions 2024-09-06 08:45:48 +02:00
Stefan Haller
b91beb68e1 Remove return value of HandleRender 2024-09-06 08:45:48 +02:00
Stefan Haller
5659f1f3e9 Bump gocui
And adapt client code.
2024-09-06 08:45:48 +02:00
Yaroslav Halchenko
4bbfe7b3cc [DATALAD RUNCMD] run codespell throughout fixing typos automagically
=== Do not change lines below ===
{
 "chain": [],
 "cmd": "codespell -w",
 "exit": 0,
 "extra_inputs": [],
 "inputs": [],
 "outputs": [],
 "pwd": "."
}
^^^ Do not change lines above ^^^

Signed-off-by: Yaroslav Halchenko <debian@onerussian.com>
2024-08-27 18:03:00 +02:00
Stefan Haller
a709caf138 Remove error return value from functions that always return nil 2024-08-27 10:33:06 +02:00
Stefan Haller
61b59837bb Use our new hyperlink support in confirmations 2024-08-24 10:36:01 +02:00
Stefan Haller
f98b57aa5e Change direct access to Common.UserConfig to a getter
This will allow us to turn the field into an atomic.Value for safe concurrent
access.
2024-08-18 10:24:52 +02:00
Stefan Haller
f30387e7f5 Replace CurrentPopupContexts() with Context().CurrentPopup() 2024-08-17 11:14:51 +02:00
Stefan Haller
7ed94c0410 Replace CurrentContext() with Context().Current() 2024-08-17 11:14:51 +02:00
Stefan Haller
98335361fd Replace PopContext() with Context().Pop() 2024-08-17 11:14:50 +02:00
Stefan Haller
bd36b8a95e Replace PushContext() with Context().Push() 2024-08-17 11:14:50 +02:00
Stefan Haller
4b6479b25f Stagger popup panels
When opening a popup panel on top of another one, offset the new one a little
bit down and to the right.
2024-06-28 08:14:07 +02:00
Stefan Haller
1ab1fb3599 Resize all open popup panels in layout, not just the topmost one
Probably not the most import feature in the world, but when resizing the
terminal window while multiple popup panels were open at the same time, we would
only resize the topmost one.

The main reason for changing this is because it makes the next commit easier to
implement.
2024-06-28 08:14:07 +02:00
Stefan Haller
1d502d3245 Remove return value from ResizeCurrentPopupPanel
It always returned nil, so there's no point in returning an error.
2024-06-28 08:14:07 +02:00
Stefan Haller
bb01648521 Remove redundant calls to resize editable panels at creating time
The only purpose of this was to scroll the editable text correctly (see
https://github.com/jesseduffield/lazygit/pull/2146); now that gocui takes care
of that, we no longer need to do this.
2024-06-28 08:14:07 +02:00
Stefan Haller
b795d91fa8 Remove redundant resizeConfirmationPanel() call at panel creating time
We resize the panel in layout, so there's no need to do that after creation.
2024-06-27 10:18:12 +02:00
Stefan Haller
ccc620e5fc Remove duplicate function
ResizeConfirmationPanel and resizeConfirmationPanel were identical, get rid of
one of them.
2024-06-27 10:14:00 +02:00
Stefan Haller
34d7afc0e9 Remove unused functions 2024-06-27 10:14:00 +02:00
Stefan Haller
c3d1a79a89 Fix clicking outside of the commit description panel or suggestions panel
We forgot to handle the "suggestions" and "commitDescription" view names.

Instead of listing all the names of views that can appear in popups though,
let's use the context kind for this, which feels more robust.

This is a change in behavior: previously, clicking outside of the search or
filter prompt would close the prompt, now it no longer does (because search has
a persistent popup kind, but it wasn't listed in the list of view names before).
2024-06-27 09:36:50 +02:00
Stefan Haller
7e92dbfd3d Add menu prompt
This makes it possible to add a prompt to a menu. It will be shown above the
menu items, separated from them by a blank line.
2024-06-23 12:33:16 +02:00
Stefan Haller
dbc21af3b1 Extract function wrapMessageToWidth
This steals even more code from `gocui.lineWrap`.

We'll make use of this in the next commit.
2024-06-23 12:33:15 +02:00
Stefan Haller
2d0c96466a Fix calculation of tooltip height
For tooltips that are just one or two characters longer than the available
width, the last word would be cut off. On my screen this happened for the
tooltip for the fixup command.
2024-05-26 19:26:27 +02:00
Stefan Haller
010b0ae923 Show delete/edit keybindings in suggestions subtitle if available 2024-05-19 07:06:18 +02:00
Stefan Haller
a7041cf492 Allow editing a custom command from the suggestions list by pressing 'e'
For custom commands it is useful to select an earlier command and have it copied
to the prompt for further editing. This can be done by hitting 'e' now.

For other types of suggestion panels we don't enable this behavior, as you can't
create arbitrary new items there that don't already exist as a suggestion.
2024-05-19 07:06:18 +02:00
Stefan Haller
da3e0f7147 Support deleting items from the custom commands history
In the custom commands panel you can now tab to the suggestions and hit 'd' to
delete items from there. Useful if you mistyped a command and don't want it to
appear in your history any more.
2024-05-19 07:06:18 +02:00
Stefan Haller
82a3d33ce3 Remove calls to Error()
Now that we have an error handler set, we can simply let them bubble up all the
way to gocui.
2024-04-18 10:10:30 +02:00
Stefan Haller
5d509efe19 Underline links in confirmation panels 2024-03-29 10:55:33 +01:00
Stefan Haller
84e1d15079 Make DisabledReason a struct
This is a pure refactoring, no change in behavior yet. We'll add another field
to the struct in the next commit.
2024-01-14 17:45:35 +01:00
Stefan Haller
864a9ada57 Remove unused WithLoaderPanel code 2023-09-20 13:30:49 +02:00
Stefan Haller
7f9818cfa2 Add DisabledReason field to MenuItem
This is useful to disable items that are not applicable right now because of
some condition (e.g. the "delete branch" menu item when the currently
checked-out branch is selected).

When a DisabledReason is set on a menu item, we
- show it in a tooltip (below the regular tooltip of the item, if it has one)
- strike through the item's key, if it has one
- show an error message with the DisabledReason if the user tries to invoke the
  command
2023-09-18 10:15:11 +02:00
Jesse Duffield
ec7e9f9228 Fix confirmation view sizing
The proper fix is to actually have these two functions share code,
or for views to be able to manage their own heights based on their contents.

But I want to get this out for the sake of a Lazygit Anniversary release.
2023-08-05 16:09:02 +10:00
Jesse Duffield
373f24c80f Fix crash on empty menu
When a menu is empty (e.g. due to filtering) we shouldn't crash on focus or selection
2023-07-20 21:05:52 +10:00
Jesse Duffield
a9e2c8129f Introduce filtered list view model
We're going to start supporting filtering of list views
2023-07-03 12:54:13 +10:00
Sean
9d68b287db Split commit message panel into commit summary and commit description panel
When we use the one panel for the entire commit message, its tricky to have a keybinding both for adding a newline and submitting.
By having two panels: one for the summary line and one for the description, we allow for 'enter' to submit the message when done from the summary panel,
and 'enter' to add a newline when done from the description panel. Alt-enter, for those who can use that key combo, also works for submitting the message
from the description panel. For those who can't use that key combo, and don't want to remap the keybinding, they can hit tab to go back to the summary panel
and then 'enter' to submit the message.

We have some awkwardness in that both contexts (i.e. panels) need to appear and disappear in tandem and we don't have a great way of handling that concept,
so we just push both contexts one after the other, and likewise remove both contexts when we escape.
2023-04-30 13:19:53 +10:00
Jesse Duffield
fc91ef6a59 standardise helper args 2023-04-30 13:19:53 +10:00
Jesse Duffield
43251e7275 split context common from helper common 2023-04-30 13:19:53 +10:00
Jesse Duffield
509e3efa70 lots more refactoring 2023-04-30 13:19:53 +10:00