From 196e0a3c17291fe8191ea880072ed08e6a87f513 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Mon, 6 Apr 2026 19:59:32 +0200 Subject: [PATCH 1/6] Copy gocui files into lazygit repo under pkg/gocui I copied all files except dot files (.github and .gitignore), the _examples folder, and go.mod/go.sum. At some point we may want to copy the files back to the gocui repo when other clients (e.g. lazydocker) want to use the newer versions of them. --- go.mod | 1 - go.sum | 2 - pkg/commands/git_commands/remote.go | 2 +- pkg/commands/git_commands/sync.go | 2 +- pkg/commands/git_commands/sync_test.go | 2 +- pkg/commands/git_commands/tag.go | 2 +- pkg/commands/oscommands/cmd_obj.go | 2 +- .../oscommands/cmd_obj_runner_test.go | 2 +- pkg/commands/oscommands/cmd_obj_test.go | 2 +- pkg/config/keynames.go | 2 +- .../jesseduffield => pkg}/gocui/AUTHORS | 0 .../gocui/CHANGES_tcell.md | 0 .../gocui/CODE_OF_CONDUCT.md | 0 .../gocui/CONTRIBUTING.md | 0 .../jesseduffield => pkg}/gocui/LICENSE | 0 .../jesseduffield => pkg}/gocui/README.md | 0 .../jesseduffield => pkg}/gocui/attribute.go | 0 .../jesseduffield => pkg}/gocui/doc.go | 0 .../jesseduffield => pkg}/gocui/edit.go | 0 .../jesseduffield => pkg}/gocui/escape.go | 0 pkg/gocui/escape_test.go | 159 +++ .../jesseduffield => pkg}/gocui/gui.go | 44 - .../jesseduffield => pkg}/gocui/gui_others.go | 0 .../gocui/gui_windows.go | 0 .../jesseduffield => pkg}/gocui/keybinding.go | 0 .../jesseduffield => pkg}/gocui/loader.go | 0 .../jesseduffield => pkg}/gocui/scrollbar.go | 0 pkg/gocui/scrollbar_test.go | 114 ++ .../jesseduffield => pkg}/gocui/task.go | 0 .../gocui/task_manager.go | 0 .../gocui/tcell_driver.go | 0 .../jesseduffield => pkg}/gocui/text_area.go | 0 pkg/gocui/text_area_test.go | 1043 +++++++++++++++++ .../jesseduffield => pkg}/gocui/view.go | 0 pkg/gocui/view_test.go | 415 +++++++ pkg/gui/background.go | 2 +- pkg/gui/context/base_context.go | 2 +- pkg/gui/context/local_commits_context.go | 2 +- pkg/gui/context/main_context.go | 2 +- pkg/gui/context/patch_explorer_context.go | 2 +- pkg/gui/context/simple_context.go | 2 +- pkg/gui/context/sub_commits_context.go | 2 +- pkg/gui/context/view_trait.go | 2 +- pkg/gui/controllers.go | 2 +- pkg/gui/controllers/base_controller.go | 2 +- pkg/gui/controllers/branches_controller.go | 2 +- .../commit_description_controller.go | 2 +- .../controllers/commit_message_controller.go | 2 +- .../controllers/commits_files_controller.go | 2 +- .../custom_patch_options_menu_action.go | 2 +- pkg/gui/controllers/files_controller.go | 2 +- pkg/gui/controllers/global_controller.go | 2 +- .../controllers/helpers/app_status_helper.go | 2 +- .../controllers/helpers/branches_helper.go | 2 +- pkg/gui/controllers/helpers/commits_helper.go | 2 +- pkg/gui/controllers/helpers/gpg_helper.go | 2 +- .../helpers/inline_status_helper.go | 2 +- .../helpers/merge_and_rebase_helper.go | 2 +- pkg/gui/controllers/helpers/refresh_helper.go | 2 +- pkg/gui/controllers/helpers/refs_helper.go | 2 +- pkg/gui/controllers/helpers/repos_helper.go | 2 +- pkg/gui/controllers/helpers/search_helper.go | 2 +- .../controllers/helpers/suggestions_helper.go | 2 +- pkg/gui/controllers/helpers/update_helper.go | 2 +- pkg/gui/controllers/helpers/window_helper.go | 2 +- .../controllers/helpers/worktree_helper.go | 2 +- .../jump_to_side_window_controller.go | 2 +- pkg/gui/controllers/list_controller.go | 2 +- .../controllers/local_commits_controller.go | 2 +- pkg/gui/controllers/main_view_controller.go | 2 +- .../controllers/merge_conflicts_controller.go | 2 +- .../controllers/patch_building_controller.go | 2 +- .../controllers/patch_explorer_controller.go | 2 +- pkg/gui/controllers/prompt_controller.go | 2 +- pkg/gui/controllers/quit_actions.go | 2 +- pkg/gui/controllers/remotes_controller.go | 2 +- pkg/gui/controllers/screen_mode_actions.go | 2 +- .../controllers/search_prompt_controller.go | 2 +- pkg/gui/controllers/side_window_controller.go | 2 +- pkg/gui/controllers/staging_controller.go | 2 +- pkg/gui/controllers/status_controller.go | 2 +- pkg/gui/controllers/submodules_controller.go | 2 +- pkg/gui/controllers/suggestions_controller.go | 2 +- .../switch_to_focused_main_view_controller.go | 2 +- pkg/gui/controllers/sync_controller.go | 2 +- pkg/gui/controllers/tags_controller.go | 2 +- pkg/gui/controllers/undo_controller.go | 2 +- .../controllers/vertical_scroll_controller.go | 2 +- .../controllers/view_selection_controller.go | 2 +- .../controllers/workspace_reset_controller.go | 2 +- pkg/gui/editors.go | 2 +- pkg/gui/global_handlers.go | 2 +- pkg/gui/gui.go | 2 +- pkg/gui/gui_common.go | 2 +- pkg/gui/gui_driver.go | 2 +- pkg/gui/keybindings.go | 2 +- pkg/gui/keybindings/keybindings.go | 2 +- pkg/gui/layout.go | 2 +- pkg/gui/main_panels.go | 2 +- pkg/gui/patch_exploring/state.go | 2 +- pkg/gui/popup/popup_handler.go | 2 +- pkg/gui/pty.go | 2 +- pkg/gui/pty_windows.go | 2 +- pkg/gui/services/custom_commands/client.go | 2 +- .../custom_commands/handler_creator.go | 2 +- .../custom_commands/keybinding_creator.go | 2 +- pkg/gui/status/status_manager.go | 2 +- pkg/gui/tasks_adapter.go | 2 +- pkg/gui/test_mode.go | 2 +- pkg/gui/types/common.go | 2 +- pkg/gui/types/context.go | 2 +- pkg/gui/types/keybindings.go | 2 +- pkg/gui/types/views.go | 2 +- pkg/gui/view_helpers.go | 2 +- pkg/gui/views.go | 2 +- pkg/integration/clients/tui.go | 2 +- pkg/integration/components/test_test.go | 2 +- pkg/integration/components/view_driver.go | 2 +- pkg/integration/components/views.go | 2 +- pkg/integration/types/types.go | 2 +- pkg/tasks/async_handler.go | 2 +- pkg/tasks/async_handler_test.go | 2 +- pkg/tasks/tasks.go | 2 +- pkg/tasks/tasks_test.go | 2 +- pkg/theme/gocui.go | 2 +- pkg/theme/theme.go | 2 +- pkg/utils/lines_test.go | 2 +- pkg/utils/utils.go | 2 +- .../github.com/jesseduffield/gocui/.gitignore | 1 - vendor/modules.txt | 3 - 130 files changed, 1832 insertions(+), 152 deletions(-) rename {vendor/github.com/jesseduffield => pkg}/gocui/AUTHORS (100%) rename {vendor/github.com/jesseduffield => pkg}/gocui/CHANGES_tcell.md (100%) rename {vendor/github.com/jesseduffield => pkg}/gocui/CODE_OF_CONDUCT.md (100%) rename {vendor/github.com/jesseduffield => pkg}/gocui/CONTRIBUTING.md (100%) rename {vendor/github.com/jesseduffield => pkg}/gocui/LICENSE (100%) rename {vendor/github.com/jesseduffield => pkg}/gocui/README.md (100%) rename {vendor/github.com/jesseduffield => pkg}/gocui/attribute.go (100%) rename {vendor/github.com/jesseduffield => pkg}/gocui/doc.go (100%) rename {vendor/github.com/jesseduffield => pkg}/gocui/edit.go (100%) rename {vendor/github.com/jesseduffield => pkg}/gocui/escape.go (100%) create mode 100644 pkg/gocui/escape_test.go rename {vendor/github.com/jesseduffield => pkg}/gocui/gui.go (97%) rename {vendor/github.com/jesseduffield => pkg}/gocui/gui_others.go (100%) rename {vendor/github.com/jesseduffield => pkg}/gocui/gui_windows.go (100%) rename {vendor/github.com/jesseduffield => pkg}/gocui/keybinding.go (100%) rename {vendor/github.com/jesseduffield => pkg}/gocui/loader.go (100%) rename {vendor/github.com/jesseduffield => pkg}/gocui/scrollbar.go (100%) create mode 100644 pkg/gocui/scrollbar_test.go rename {vendor/github.com/jesseduffield => pkg}/gocui/task.go (100%) rename {vendor/github.com/jesseduffield => pkg}/gocui/task_manager.go (100%) rename {vendor/github.com/jesseduffield => pkg}/gocui/tcell_driver.go (100%) rename {vendor/github.com/jesseduffield => pkg}/gocui/text_area.go (100%) create mode 100644 pkg/gocui/text_area_test.go rename {vendor/github.com/jesseduffield => pkg}/gocui/view.go (100%) create mode 100644 pkg/gocui/view_test.go delete mode 100644 vendor/github.com/jesseduffield/gocui/.gitignore diff --git a/go.mod b/go.mod index 0af18042a..37b26b83f 100644 --- a/go.mod +++ b/go.mod @@ -18,7 +18,6 @@ require ( github.com/gookit/color v1.6.0 github.com/integrii/flaggy v1.8.0 github.com/jesseduffield/generics v0.0.0-20250517122708-b0b4a53a6f5c - github.com/jesseduffield/gocui v0.3.1-0.20260327132312-944dab3bc980 github.com/jesseduffield/lazycore v0.0.0-20221012050358-03d2e40243c5 github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 github.com/karimkhaleel/jsonschema v0.0.0-20231001195015-d933f0d94ea3 diff --git a/go.sum b/go.sum index 1eca13f8b..e108704c1 100644 --- a/go.sum +++ b/go.sum @@ -50,8 +50,6 @@ github.com/invopop/jsonschema v0.10.0 h1:c1ktzNLBun3LyQQhyty5WE3lulbOdIIyOVlkmDL github.com/invopop/jsonschema v0.10.0/go.mod h1:ffZ5Km5SWWRAIN6wbDXItl95euhFz2uON45H2qjYt+0= github.com/jesseduffield/generics v0.0.0-20250517122708-b0b4a53a6f5c h1:tC2PaiisXAC5sOjDPfMArSnbswDObtCssx+xn28edX4= github.com/jesseduffield/generics v0.0.0-20250517122708-b0b4a53a6f5c/go.mod h1:F2fEBk0ddf6ixrBrJjY7phfQ3hL9rXG0uSjvwYe50bE= -github.com/jesseduffield/gocui v0.3.1-0.20260327132312-944dab3bc980 h1:LEZwOrBm9S+4lRlXpoz+RSzSvhOVE+6v/Rk+A7Kg00Q= -github.com/jesseduffield/gocui v0.3.1-0.20260327132312-944dab3bc980/go.mod h1:lQCd2TvvNXVKFBowy4A7xxZbUp+1KEiGs4j0Q5Zt9gQ= github.com/jesseduffield/lazycore v0.0.0-20221012050358-03d2e40243c5 h1:CDuQmfOjAtb1Gms6a1p5L2P8RhbLUq5t8aL7PiQd2uY= github.com/jesseduffield/lazycore v0.0.0-20221012050358-03d2e40243c5/go.mod h1:qxN4mHOAyeIDLP7IK7defgPClM/z1Kze8VVQiaEjzsQ= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= diff --git a/pkg/commands/git_commands/remote.go b/pkg/commands/git_commands/remote.go index cfcb85091..3b27730fc 100644 --- a/pkg/commands/git_commands/remote.go +++ b/pkg/commands/git_commands/remote.go @@ -4,7 +4,7 @@ import ( "fmt" "strings" - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/samber/lo" ) diff --git a/pkg/commands/git_commands/sync.go b/pkg/commands/git_commands/sync.go index d64a0910c..0400b4e26 100644 --- a/pkg/commands/git_commands/sync.go +++ b/pkg/commands/git_commands/sync.go @@ -4,8 +4,8 @@ import ( "fmt" "github.com/go-errors/errors" - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands/oscommands" + "github.com/jesseduffield/lazygit/pkg/gocui" ) type SyncCommands struct { diff --git a/pkg/commands/git_commands/sync_test.go b/pkg/commands/git_commands/sync_test.go index fdc44a6b9..6a7702586 100644 --- a/pkg/commands/git_commands/sync_test.go +++ b/pkg/commands/git_commands/sync_test.go @@ -3,8 +3,8 @@ package git_commands import ( "testing" - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands/oscommands" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/stretchr/testify/assert" ) diff --git a/pkg/commands/git_commands/tag.go b/pkg/commands/git_commands/tag.go index 1e9b449b1..4d15027e1 100644 --- a/pkg/commands/git_commands/tag.go +++ b/pkg/commands/git_commands/tag.go @@ -3,8 +3,8 @@ package git_commands import ( "strings" - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands/oscommands" + "github.com/jesseduffield/lazygit/pkg/gocui" ) type TagCommands struct { diff --git a/pkg/commands/oscommands/cmd_obj.go b/pkg/commands/oscommands/cmd_obj.go index 24d2ca511..0df6ed43c 100644 --- a/pkg/commands/oscommands/cmd_obj.go +++ b/pkg/commands/oscommands/cmd_obj.go @@ -4,7 +4,7 @@ import ( "os/exec" "strings" - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/samber/lo" "github.com/sasha-s/go-deadlock" ) diff --git a/pkg/commands/oscommands/cmd_obj_runner_test.go b/pkg/commands/oscommands/cmd_obj_runner_test.go index 74e3a1985..ffddfaad1 100644 --- a/pkg/commands/oscommands/cmd_obj_runner_test.go +++ b/pkg/commands/oscommands/cmd_obj_runner_test.go @@ -4,7 +4,7 @@ import ( "strings" "testing" - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/utils" ) diff --git a/pkg/commands/oscommands/cmd_obj_test.go b/pkg/commands/oscommands/cmd_obj_test.go index b135f1b74..269b5dac2 100644 --- a/pkg/commands/oscommands/cmd_obj_test.go +++ b/pkg/commands/oscommands/cmd_obj_test.go @@ -4,7 +4,7 @@ import ( "os/exec" "testing" - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" ) func TestCmdObjToString(t *testing.T) { diff --git a/pkg/config/keynames.go b/pkg/config/keynames.go index bb9756b43..00dc158fc 100644 --- a/pkg/config/keynames.go +++ b/pkg/config/keynames.go @@ -4,7 +4,7 @@ import ( "strings" "unicode/utf8" - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/samber/lo" ) diff --git a/vendor/github.com/jesseduffield/gocui/AUTHORS b/pkg/gocui/AUTHORS similarity index 100% rename from vendor/github.com/jesseduffield/gocui/AUTHORS rename to pkg/gocui/AUTHORS diff --git a/vendor/github.com/jesseduffield/gocui/CHANGES_tcell.md b/pkg/gocui/CHANGES_tcell.md similarity index 100% rename from vendor/github.com/jesseduffield/gocui/CHANGES_tcell.md rename to pkg/gocui/CHANGES_tcell.md diff --git a/vendor/github.com/jesseduffield/gocui/CODE_OF_CONDUCT.md b/pkg/gocui/CODE_OF_CONDUCT.md similarity index 100% rename from vendor/github.com/jesseduffield/gocui/CODE_OF_CONDUCT.md rename to pkg/gocui/CODE_OF_CONDUCT.md diff --git a/vendor/github.com/jesseduffield/gocui/CONTRIBUTING.md b/pkg/gocui/CONTRIBUTING.md similarity index 100% rename from vendor/github.com/jesseduffield/gocui/CONTRIBUTING.md rename to pkg/gocui/CONTRIBUTING.md diff --git a/vendor/github.com/jesseduffield/gocui/LICENSE b/pkg/gocui/LICENSE similarity index 100% rename from vendor/github.com/jesseduffield/gocui/LICENSE rename to pkg/gocui/LICENSE diff --git a/vendor/github.com/jesseduffield/gocui/README.md b/pkg/gocui/README.md similarity index 100% rename from vendor/github.com/jesseduffield/gocui/README.md rename to pkg/gocui/README.md diff --git a/vendor/github.com/jesseduffield/gocui/attribute.go b/pkg/gocui/attribute.go similarity index 100% rename from vendor/github.com/jesseduffield/gocui/attribute.go rename to pkg/gocui/attribute.go diff --git a/vendor/github.com/jesseduffield/gocui/doc.go b/pkg/gocui/doc.go similarity index 100% rename from vendor/github.com/jesseduffield/gocui/doc.go rename to pkg/gocui/doc.go diff --git a/vendor/github.com/jesseduffield/gocui/edit.go b/pkg/gocui/edit.go similarity index 100% rename from vendor/github.com/jesseduffield/gocui/edit.go rename to pkg/gocui/edit.go diff --git a/vendor/github.com/jesseduffield/gocui/escape.go b/pkg/gocui/escape.go similarity index 100% rename from vendor/github.com/jesseduffield/gocui/escape.go rename to pkg/gocui/escape.go diff --git a/pkg/gocui/escape_test.go b/pkg/gocui/escape_test.go new file mode 100644 index 000000000..0073463c4 --- /dev/null +++ b/pkg/gocui/escape_test.go @@ -0,0 +1,159 @@ +package gocui + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestParseOne(t *testing.T) { + var ei *escapeInterpreter + + ei = newEscapeInterpreter(OutputNormal) + isEscape, err := ei.parseOne([]byte{'a'}) + assert.Equal(t, false, isEscape) + assert.NoError(t, err) + + ei = newEscapeInterpreter(OutputNormal) + parseEscRunes(t, ei, "\x1b[0K") + _, ok := ei.instruction.(eraseInLineFromCursor) + assert.Equal(t, true, ok) + + ei = newEscapeInterpreter(OutputNormal) + parseEscRunes(t, ei, "\x1b[K") + _, ok = ei.instruction.(eraseInLineFromCursor) + assert.Equal(t, true, ok) + + ei = newEscapeInterpreter(OutputNormal) + parseEscRunes(t, ei, "\x1b[1K") + _, ok = ei.instruction.(noInstruction) + assert.Equal(t, true, ok) + + ei = newEscapeInterpreter(OutputNormal) + parseEscRunes(t, ei, "\x1b(B") + _, ok = ei.instruction.(noInstruction) + assert.Equal(t, true, ok) + + ei = newEscapeInterpreter(OutputNormal) + parseEscRunes(t, ei, "\x1b)0") + _, ok = ei.instruction.(noInstruction) + assert.Equal(t, true, ok) + + ei = newEscapeInterpreter(OutputNormal) + parseEscRunes(t, ei, "\x1b*A") + _, ok = ei.instruction.(noInstruction) + assert.Equal(t, true, ok) + + ei = newEscapeInterpreter(OutputNormal) + parseEscRunes(t, ei, "\x1b+K") + _, ok = ei.instruction.(noInstruction) + assert.Equal(t, true, ok) +} + +func TestParseOneColours(t *testing.T) { + scenarios := []struct { + outputMode OutputMode + input string + expectedFg Attribute + expectedBg Attribute + }{ + {OutputNormal, "\x1b[30m", ColorBlack, ColorDefault}, + {OutputNormal, "\x1b[31m", ColorRed, ColorDefault}, + {OutputNormal, "\x1b[32m", ColorGreen, ColorDefault}, + {OutputNormal, "\x1b[33m", ColorYellow, ColorDefault}, + {OutputNormal, "\x1b[34m", ColorBlue, ColorDefault}, + {OutputNormal, "\x1b[35m", ColorMagenta, ColorDefault}, + {OutputNormal, "\x1b[36m", ColorCyan, ColorDefault}, + {OutputNormal, "\x1b[37m", ColorWhite, ColorDefault}, + {OutputNormal, "\x1b[40m", ColorDefault, ColorBlack}, + {OutputNormal, "\x1b[41m", ColorDefault, ColorRed}, + {OutputNormal, "\x1b[42m", ColorDefault, ColorGreen}, + {OutputNormal, "\x1b[43m", ColorDefault, ColorYellow}, + {OutputNormal, "\x1b[44m", ColorDefault, ColorBlue}, + {OutputNormal, "\x1b[45m", ColorDefault, ColorMagenta}, + {OutputNormal, "\x1b[46m", ColorDefault, ColorCyan}, + {OutputNormal, "\x1b[47m", ColorDefault, ColorWhite}, + {OutputNormal, "\x1b[47;31m", ColorRed, ColorWhite}, + {OutputNormal, "\x1b[90m", Get256Color(8), ColorDefault}, + {OutputNormal, "\x1b[91m", Get256Color(9), ColorDefault}, + {OutputNormal, "\x1b[92m", Get256Color(10), ColorDefault}, + {OutputNormal, "\x1b[93m", Get256Color(11), ColorDefault}, + {OutputNormal, "\x1b[94m", Get256Color(12), ColorDefault}, + {OutputNormal, "\x1b[95m", Get256Color(13), ColorDefault}, + {OutputNormal, "\x1b[96m", Get256Color(14), ColorDefault}, + {OutputNormal, "\x1b[97m", Get256Color(15), ColorDefault}, + {OutputNormal, "\x1b[100m", ColorDefault, Get256Color(8)}, + {OutputNormal, "\x1b[101m", ColorDefault, Get256Color(9)}, + {OutputNormal, "\x1b[102m", ColorDefault, Get256Color(10)}, + {OutputNormal, "\x1b[103m", ColorDefault, Get256Color(11)}, + {OutputNormal, "\x1b[104m", ColorDefault, Get256Color(12)}, + {OutputNormal, "\x1b[105m", ColorDefault, Get256Color(13)}, + {OutputNormal, "\x1b[106m", ColorDefault, Get256Color(14)}, + {OutputNormal, "\x1b[107m", ColorDefault, Get256Color(15)}, + {Output256, "\x1b[38;5;32m", Get256Color(32), ColorDefault}, + {OutputTrue, "\x1b[38;5;32m", Get256Color(32), ColorDefault}, + {OutputTrue, "\x1b[38;2;50;103;205m", NewRGBColor(50, 103, 205), ColorDefault}, + {Output256, "\x1b[48;5;32m", ColorDefault, Get256Color(32)}, + {OutputTrue, "\x1b[48;5;32m", ColorDefault, Get256Color(32)}, + {OutputTrue, "\x1b[48;2;50;103;205m", ColorDefault, NewRGBColor(50, 103, 205)}, + {OutputTrue, "\x1b[1;95;48;2;255;224;224m", Get256Color(13), NewRGBColor(255, 224, 224)}, + } + + for _, scenario := range scenarios { + ei := newEscapeInterpreter(scenario.outputMode) + parseEscRunes(t, ei, scenario.input) + assert.Equal(t, scenario.expectedFg, ei.curFgColor&AttrColorBits) + assert.Equal(t, scenario.expectedBg, ei.curBgColor) + } + + // resetting colours + scenarios = []struct { + outputMode OutputMode + input string + expectedFg Attribute + expectedBg Attribute + }{ + {OutputNormal, "\x1b[39m", ColorDefault, ColorRed}, + {OutputNormal, "\x1b[49m", ColorRed, ColorDefault}, + {OutputNormal, "\x1b[0m", ColorDefault, ColorDefault}, + } + + for _, scenario := range scenarios { + ei := newEscapeInterpreter(scenario.outputMode) + ei.curFgColor = ColorRed + ei.curBgColor = ColorRed + parseEscRunes(t, ei, scenario.input) + assert.Equal(t, scenario.expectedFg, ei.curFgColor) + assert.Equal(t, scenario.expectedBg, ei.curBgColor) + } + + // setting attributes + attrScenarios := []struct { + outputMode OutputMode + input string + expectedAttr Attribute + }{ + {OutputNormal, "\x1b[1m", AttrBold}, + {OutputNormal, "\x1b[2m", AttrDim}, + {OutputNormal, "\x1b[3m", AttrItalic}, + {OutputNormal, "\x1b[4m", AttrUnderline}, + {OutputNormal, "\x1b[5m", AttrBlink}, + {OutputNormal, "\x1b[7m", AttrReverse}, + {OutputNormal, "\x1b[9m", AttrStrikeThrough}, + } + + for _, scenario := range attrScenarios { + ei := newEscapeInterpreter(scenario.outputMode) + parseEscRunes(t, ei, scenario.input) + style := ei.curFgColor & AttrStyleBits + assert.Equal(t, scenario.expectedAttr, style) + } +} + +func parseEscRunes(t *testing.T, ei *escapeInterpreter, runes string) { + for _, b := range []byte(runes) { + isEscape, err := ei.parseOne([]byte{b}) + assert.Equal(t, true, isEscape) + assert.NoError(t, err) + } +} diff --git a/vendor/github.com/jesseduffield/gocui/gui.go b/pkg/gocui/gui.go similarity index 97% rename from vendor/github.com/jesseduffield/gocui/gui.go rename to pkg/gocui/gui.go index 0d97e280b..0db418c67 100644 --- a/vendor/github.com/jesseduffield/gocui/gui.go +++ b/pkg/gocui/gui.go @@ -8,7 +8,6 @@ import ( "context" standardErrors "errors" "runtime" - "slices" "strings" "sync" "time" @@ -25,15 +24,6 @@ type OutputMode int const DOUBLE_CLICK_THRESHOLD = 500 * time.Millisecond var ( - // ErrAlreadyBlacklisted is returned when the keybinding is already blacklisted. - ErrAlreadyBlacklisted = standardErrors.New("keybind already blacklisted") - - // ErrBlacklisted is returned when the keybinding being parsed / used is blacklisted. - ErrBlacklisted = standardErrors.New("keybind blacklisted") - - // ErrNotBlacklisted is returned when a keybinding being whitelisted is not blacklisted. - ErrNotBlacklisted = standardErrors.New("keybind not blacklisted") - // ErrNoSuchKeybind is returned when the keybinding being parsed does not exist. ErrNoSuchKeybind = standardErrors.New("no such keybind") @@ -155,7 +145,6 @@ type Gui struct { maxX, maxY int outputMode OutputMode stop chan struct{} - blacklist []Key // BgColor and FgColor allow to configure the background and foreground // colors of the GUI. @@ -573,10 +562,6 @@ func (g *Gui) SetKeybinding(viewname string, key any, mod Modifier, handler func return err } - if g.isBlacklisted(k) { - return ErrBlacklisted - } - kb = newKeybinding(viewname, k, ch, mod, handler) g.keybindings = append(g.keybindings, kb) return nil @@ -632,26 +617,6 @@ func (g *Gui) SetViewClickBinding(binding *ViewMouseBinding) error { return nil } -// BlackListKeybinding adds a keybinding to the blacklist -func (g *Gui) BlacklistKeybinding(k Key) error { - if slices.Contains(g.blacklist, k) { - return ErrAlreadyBlacklisted - } - g.blacklist = append(g.blacklist, k) - return nil -} - -// WhiteListKeybinding removes a keybinding from the blacklist -func (g *Gui) WhitelistKeybinding(k Key) error { - for i, j := range g.blacklist { - if j == k { - g.blacklist = append(g.blacklist[:i], g.blacklist[i+1:]...) - return nil - } - } - return ErrNotBlacklisted -} - func (g *Gui) SetFocusHandler(handler func(bool) error) { g.focusHandler = handler } @@ -1616,10 +1581,6 @@ func (g *Gui) execKeybindings(v *View, ev *GocuiEvent) error { // execKeybinding executes a given keybinding func (g *Gui) execKeybinding(v *View, kb *keybinding) error { - if g.isBlacklisted(kb.key) { - return nil - } - if err := kb.handler(g, v); err != nil { return err } @@ -1665,11 +1626,6 @@ func (g *Gui) StartTicking(ctx context.Context) { }() } -// isBlacklisted reports whether the key is blacklisted -func (g *Gui) isBlacklisted(k Key) bool { - return slices.Contains(g.blacklist, k) -} - func (g *Gui) Suspend() error { g.suspendedMutex.Lock() defer g.suspendedMutex.Unlock() diff --git a/vendor/github.com/jesseduffield/gocui/gui_others.go b/pkg/gocui/gui_others.go similarity index 100% rename from vendor/github.com/jesseduffield/gocui/gui_others.go rename to pkg/gocui/gui_others.go diff --git a/vendor/github.com/jesseduffield/gocui/gui_windows.go b/pkg/gocui/gui_windows.go similarity index 100% rename from vendor/github.com/jesseduffield/gocui/gui_windows.go rename to pkg/gocui/gui_windows.go diff --git a/vendor/github.com/jesseduffield/gocui/keybinding.go b/pkg/gocui/keybinding.go similarity index 100% rename from vendor/github.com/jesseduffield/gocui/keybinding.go rename to pkg/gocui/keybinding.go diff --git a/vendor/github.com/jesseduffield/gocui/loader.go b/pkg/gocui/loader.go similarity index 100% rename from vendor/github.com/jesseduffield/gocui/loader.go rename to pkg/gocui/loader.go diff --git a/vendor/github.com/jesseduffield/gocui/scrollbar.go b/pkg/gocui/scrollbar.go similarity index 100% rename from vendor/github.com/jesseduffield/gocui/scrollbar.go rename to pkg/gocui/scrollbar.go diff --git a/pkg/gocui/scrollbar_test.go b/pkg/gocui/scrollbar_test.go new file mode 100644 index 000000000..63db4bb9a --- /dev/null +++ b/pkg/gocui/scrollbar_test.go @@ -0,0 +1,114 @@ +package gocui + +import "testing" + +func TestCalcScrollbar(t *testing.T) { + tests := []struct { + testName string + listSize int + pageSize int + position int + scrollAreaSize int + + expectedStart int + expectedHeight int + }{ + { + testName: "page size greater than list size", + listSize: 5, + pageSize: 10, + position: 0, + scrollAreaSize: 20, + + expectedStart: 0, + expectedHeight: 20, + }, + { + testName: "page size matches list size", + listSize: 10, + pageSize: 10, + position: 0, + scrollAreaSize: 20, + + expectedStart: 0, + expectedHeight: 20, + }, + { + testName: "page size half of list size", + listSize: 10, + pageSize: 5, + position: 0, + scrollAreaSize: 20, + + expectedStart: 0, + expectedHeight: 10, + }, + { + testName: "page size half of list size at scroll end", + listSize: 10, + pageSize: 5, + position: 5, + scrollAreaSize: 20, + + expectedStart: 10, + expectedHeight: 10, + }, + { + testName: "page size third of list size having scrolled half the way", + listSize: 15, + // Recall that my max position is listSize - pageSize i.e 15 - 5 i.e. 10. + // So if I've scrolled to position 5 that means I've done one page and I've got + // one page to go which means by scrollbar should take up a third of the available + // space and appear in the centre of the scrollbar area + pageSize: 5, + position: 5, + scrollAreaSize: 21, + + expectedStart: 7, + expectedHeight: 7, + }, + { + testName: "page size third of list size having scrolled the full way", + listSize: 15, + pageSize: 5, + position: 10, + scrollAreaSize: 21, + + expectedStart: 14, + expectedHeight: 7, + }, + { + testName: "page size third of list size having scrolled by one", + listSize: 15, + pageSize: 5, + position: 1, + scrollAreaSize: 21, + + expectedStart: 2, + expectedHeight: 7, + }, + { + testName: "page size third of list size having scrolled up from the bottom by one", + listSize: 15, + pageSize: 5, + position: 9, + scrollAreaSize: 21, + + expectedStart: 12, + expectedHeight: 7, + }, + } + + for _, test := range tests { + t.Run(test.testName, func(t *testing.T) { + start, height := calcScrollbar(test.listSize, test.pageSize, test.position, test.scrollAreaSize) + if start != test.expectedStart { + t.Errorf("expected start to be %d, got %d", test.expectedStart, start) + } + + if height != test.expectedHeight { + t.Errorf("expected height to be %d, got %d", test.expectedHeight, height) + } + }) + } +} diff --git a/vendor/github.com/jesseduffield/gocui/task.go b/pkg/gocui/task.go similarity index 100% rename from vendor/github.com/jesseduffield/gocui/task.go rename to pkg/gocui/task.go diff --git a/vendor/github.com/jesseduffield/gocui/task_manager.go b/pkg/gocui/task_manager.go similarity index 100% rename from vendor/github.com/jesseduffield/gocui/task_manager.go rename to pkg/gocui/task_manager.go diff --git a/vendor/github.com/jesseduffield/gocui/tcell_driver.go b/pkg/gocui/tcell_driver.go similarity index 100% rename from vendor/github.com/jesseduffield/gocui/tcell_driver.go rename to pkg/gocui/tcell_driver.go diff --git a/vendor/github.com/jesseduffield/gocui/text_area.go b/pkg/gocui/text_area.go similarity index 100% rename from vendor/github.com/jesseduffield/gocui/text_area.go rename to pkg/gocui/text_area.go diff --git a/pkg/gocui/text_area_test.go b/pkg/gocui/text_area_test.go new file mode 100644 index 000000000..618e1a02e --- /dev/null +++ b/pkg/gocui/text_area_test.go @@ -0,0 +1,1043 @@ +package gocui + +import ( + "reflect" + "strconv" + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestTextArea(t *testing.T) { + tests := []struct { + actions func(*TextArea) + wrapWidth int + expectedContent string + expectedCursor int + expectedClipboard string + }{ + { + actions: func(textarea *TextArea) { + textarea.TypeCharacter("a") + textarea.TypeCharacter("b") + textarea.TypeCharacter("c") + }, + expectedContent: "abc", + expectedCursor: 3, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeCharacter("a") + textarea.TypeCharacter("\n") + textarea.TypeCharacter("c") + }, + expectedContent: "a\nc", + expectedCursor: 3, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString("abcd") + }, + expectedContent: "abcd", + expectedCursor: 4, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString("a字cd") + }, + expectedContent: "a字cd", + expectedCursor: 6, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.BackSpaceChar() + }, + expectedContent: "", + expectedCursor: 0, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeCharacter("a") + textarea.BackSpaceChar() + }, + expectedContent: "", + expectedCursor: 0, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeCharacter("a") + textarea.TypeCharacter("b") + textarea.BackSpaceChar() + }, + expectedContent: "a", + expectedCursor: 1, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.DeleteChar() + }, + expectedContent: "", + expectedCursor: 0, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeCharacter("a") + textarea.DeleteChar() + }, + expectedContent: "a", + expectedCursor: 1, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeCharacter("a") + textarea.MoveCursorLeft() + textarea.DeleteChar() + }, + expectedContent: "", + expectedCursor: 0, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeCharacter("a") + textarea.TypeCharacter("b") + textarea.TypeCharacter("c") + textarea.MoveCursorLeft() + textarea.MoveCursorLeft() + textarea.DeleteChar() + }, + expectedContent: "ac", + expectedCursor: 1, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.MoveCursorLeft() + }, + expectedContent: "", + expectedCursor: 0, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeCharacter("a") + textarea.MoveCursorLeft() + }, + expectedContent: "a", + expectedCursor: 0, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeCharacter("a") + textarea.TypeCharacter("b") + textarea.MoveCursorLeft() + }, + expectedContent: "ab", + expectedCursor: 1, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.MoveCursorRight() + }, + expectedContent: "", + expectedCursor: 0, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeCharacter("a") + textarea.MoveCursorRight() + }, + expectedContent: "a", + expectedCursor: 1, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeCharacter("a") + textarea.TypeCharacter("b") + textarea.MoveCursorLeft() + textarea.MoveCursorRight() + }, + expectedContent: "ab", + expectedCursor: 2, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeCharacter("漢") + textarea.TypeCharacter("字") + textarea.MoveCursorLeft() + }, + expectedContent: "漢字", + expectedCursor: 3, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.ToggleOverwrite() + textarea.TypeCharacter("a") + textarea.TypeCharacter("b") + }, + expectedContent: "ab", + expectedCursor: 2, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeCharacter("a") + textarea.TypeCharacter("b") + textarea.TypeCharacter("c") + textarea.MoveCursorLeft() + textarea.MoveCursorLeft() + textarea.ToggleOverwrite() + textarea.TypeCharacter("d") + }, + expectedContent: "adc", + expectedCursor: 2, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString("aaa bbb") + textarea.MoveLeftWord() + }, + expectedContent: "aaa bbb", + expectedCursor: 4, + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString("aaa\nbbb") + textarea.MoveLeftWord() + }, + expectedContent: "aaa\nbbb", + expectedCursor: 4, + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString("aaa bbb") + textarea.GoToStartOfLine() + textarea.MoveLeftWord() + }, + wrapWidth: 4, + expectedContent: "aaa bbb", + expectedCursor: 0, + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString("aaa bbb\n") + textarea.MoveLeftWord() + }, + expectedContent: "aaa bbb\n", + expectedCursor: 7, + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString("aaa bbb") + textarea.MoveLeftWord() + textarea.MoveLeftWord() + }, + expectedContent: "aaa bbb", + expectedCursor: 0, + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString("aaa") + textarea.GoToStartOfLine() + textarea.MoveLeftWord() + }, + expectedContent: "aaa", + expectedCursor: 0, + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString("aaa bbb") + textarea.MoveRightWord() + }, + expectedContent: "aaa bbb", + expectedCursor: 7, + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString("aaa\nbbb") + textarea.GoToStartOfLine() + textarea.MoveCursorLeft() + textarea.MoveRightWord() + }, + expectedContent: "aaa\nbbb", + expectedCursor: 4, + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString("aaa bbb") + textarea.GoToStartOfLine() + textarea.MoveCursorLeft() + textarea.MoveRightWord() + }, + wrapWidth: 4, + expectedContent: "aaa bbb", + expectedCursor: 7, + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString("aaa bbb") + textarea.GoToStartOfLine() + textarea.MoveRightWord() + }, + expectedContent: "aaa bbb", + expectedCursor: 3, + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString("aaa bbb\n") + textarea.MoveCursorLeft() + textarea.GoToStartOfLine() + textarea.MoveRightWord() + textarea.MoveRightWord() + }, + expectedContent: "aaa bbb\n", + expectedCursor: 7, + }, + { + actions: func(textarea *TextArea) { + // overwrite mode acts same as normal mode when cursor is at the end + textarea.TypeCharacter("a") + textarea.TypeCharacter("b") + textarea.TypeCharacter("c") + textarea.ToggleOverwrite() + textarea.TypeCharacter("d") + }, + expectedContent: "abcd", + expectedCursor: 4, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.DeleteToStartOfLine() + }, + expectedContent: "", + expectedCursor: 0, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeCharacter("a") + textarea.TypeCharacter("b") + textarea.DeleteToStartOfLine() + }, + expectedContent: "", + expectedCursor: 0, + expectedClipboard: "ab", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeCharacter("a") + textarea.TypeCharacter("b") + textarea.MoveCursorLeft() + textarea.MoveCursorLeft() + textarea.DeleteToStartOfLine() + }, + expectedContent: "ab", + expectedCursor: 0, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeCharacter("a") + textarea.TypeCharacter("b") + textarea.TypeCharacter("\n") + textarea.DeleteToStartOfLine() + }, + expectedContent: "ab", + expectedCursor: 2, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeCharacter("a") + textarea.TypeCharacter("b") + textarea.TypeCharacter("\n") + textarea.TypeCharacter("c") + textarea.TypeCharacter("d") + textarea.DeleteToStartOfLine() + }, + expectedContent: "ab\n", + expectedCursor: 3, + expectedClipboard: "cd", + }, + { + actions: func(textarea *TextArea) { + textarea.GoToStartOfLine() + }, + expectedContent: "", + expectedCursor: 0, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeCharacter("a") + textarea.MoveCursorLeft() + textarea.GoToStartOfLine() + }, + expectedContent: "a", + expectedCursor: 0, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeCharacter("a") + textarea.TypeCharacter("b") + textarea.TypeCharacter("\n") + textarea.TypeCharacter("c") + textarea.TypeCharacter("d") + textarea.MoveCursorLeft() + textarea.MoveCursorLeft() + textarea.MoveCursorLeft() + textarea.GoToStartOfLine() + }, + expectedContent: "ab\ncd", + expectedCursor: 0, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeCharacter("a") + textarea.TypeCharacter("b") + textarea.TypeCharacter("\n") + textarea.TypeCharacter("c") + textarea.TypeCharacter("d") + textarea.GoToStartOfLine() + }, + expectedContent: "ab\ncd", + expectedCursor: 3, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeCharacter("a") + textarea.TypeCharacter("b") + textarea.TypeCharacter("\n") + textarea.TypeCharacter("c") + textarea.TypeCharacter("d") + textarea.MoveCursorLeft() + textarea.MoveCursorLeft() + textarea.GoToStartOfLine() + }, + expectedContent: "ab\ncd", + expectedCursor: 3, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.GoToEndOfLine() + }, + expectedContent: "", + expectedCursor: 0, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeCharacter("a") + textarea.TypeCharacter("b") + textarea.TypeCharacter("\n") + textarea.TypeCharacter("c") + textarea.TypeCharacter("d") + textarea.MoveCursorLeft() + textarea.MoveCursorLeft() + textarea.GoToEndOfLine() + }, + expectedContent: "ab\ncd", + expectedCursor: 5, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.SetCursor2D(10, 10) + }, + expectedContent: "", + expectedCursor: 0, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.SetCursor2D(-1, -1) + }, + expectedContent: "", + expectedCursor: 0, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString("ab\ncd") + textarea.SetCursor2D(0, 0) + }, + expectedContent: "ab\ncd", + expectedCursor: 0, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString("ab\ncd") + textarea.SetCursor2D(2, 0) + }, + expectedContent: "ab\ncd", + expectedCursor: 2, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString("ab\ncd\nef") + textarea.SetCursor2D(2, 1) + }, + expectedContent: "ab\ncd\nef", + expectedCursor: 5, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString("abcd\n\nijkl") + textarea.MoveCursorUp() + }, + expectedContent: "abcd\n\nijkl", + expectedCursor: 5, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString("abcdef\n老老老") + textarea.MoveCursorLeft() + textarea.MoveCursorUp() + }, + expectedContent: "abcdef\n老老老", + expectedCursor: 4, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString("abcdef\n老老老") + textarea.MoveCursorUp() + textarea.MoveCursorLeft() + textarea.MoveCursorLeft() + textarea.MoveCursorLeft() + textarea.MoveCursorDown() + }, + expectedContent: "abcdef\n老老老", + expectedCursor: 13, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString("abcd\nef") + textarea.MoveCursorUp() + textarea.GoToEndOfLine() + textarea.MoveCursorDown() + }, + expectedContent: "abcd\nef", + expectedCursor: 7, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString("abcd") + textarea.MoveCursorUp() + }, + expectedContent: "abcd", + expectedCursor: 4, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString(`abcdefg`) + textarea.Clear() + }, + expectedContent: "", + expectedCursor: 0, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString(`abcdefg`) + textarea.Clear() + }, + expectedContent: "", + expectedCursor: 0, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString(`abc def`) + textarea.MoveCursorLeft() + textarea.BackSpaceWord() + }, + expectedContent: "abc f", + expectedCursor: 4, + expectedClipboard: "de", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString(`abc def `) + textarea.BackSpaceWord() + }, + expectedContent: "abc ", + expectedCursor: 5, + expectedClipboard: "def ", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString("abc def\nghi") + textarea.BackSpaceWord() + }, + expectedContent: "abc def\n", + expectedCursor: 8, + expectedClipboard: "ghi", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString("abc def\nghi") + textarea.MoveCursorLeft() + textarea.MoveCursorLeft() + textarea.MoveCursorLeft() + textarea.BackSpaceWord() + }, + expectedContent: "abc defghi", + expectedCursor: 7, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString(`abc(def)`) + textarea.BackSpaceWord() + }, + expectedContent: "abc(def", + expectedCursor: 7, + expectedClipboard: ")", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString(`abc(def`) + textarea.BackSpaceWord() + }, + expectedContent: "abc(", + expectedCursor: 4, + expectedClipboard: "def", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString(`abc`) + textarea.GoToStartOfLine() + textarea.BackSpaceWord() + }, + expectedContent: "abc", + expectedCursor: 0, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString(`abc`) + textarea.Yank() + }, + expectedContent: "abc", + expectedCursor: 3, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString(`abc def`) + textarea.DeleteToStartOfLine() + textarea.Yank() + textarea.Yank() + }, + expectedContent: "abc defabc def", + expectedCursor: 14, + expectedClipboard: "abc def", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString("abc\ndef") + textarea.MoveCursorLeft() + textarea.MoveCursorLeft() + textarea.MoveCursorUp() + textarea.DeleteToEndOfLine() + }, + expectedContent: "a\ndef", + expectedCursor: 1, + expectedClipboard: "bc", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString("abc\ndef") + textarea.MoveCursorUp() + textarea.DeleteToEndOfLine() + }, + expectedContent: "abcdef", + expectedCursor: 3, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString(`abc def`) + textarea.BackSpaceWord() + textarea.Yank() + textarea.Yank() + }, + expectedContent: "abc defdef", + expectedCursor: 10, + expectedClipboard: "def", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString(`abc def`) + textarea.MoveCursorLeft() + textarea.MoveCursorLeft() + textarea.DeleteToEndOfLine() + textarea.Yank() + textarea.Yank() + }, + expectedContent: "abc defef", + expectedCursor: 9, + expectedClipboard: "ef", + }, + } + + for i, test := range tests { + t.Run(strconv.Itoa(i+1), func(t *testing.T) { + textarea := &TextArea{} + if test.wrapWidth > 0 { + textarea.AutoWrap = true + textarea.AutoWrapWidth = test.wrapWidth + } + test.actions(textarea) + assert.EqualValues(t, test.expectedContent, textarea.GetUnwrappedContent()) + assert.EqualValues(t, test.expectedCursor, textarea.cursor) + assert.EqualValues(t, test.expectedClipboard, textarea.clipboard) + }) + } +} + +func TestGetCursorXY(t *testing.T) { + tests := []struct { + actions func(*TextArea) + wrapWidth int + expectedX int + expectedY int + }{ + { + actions: func(textarea *TextArea) { + // do nothing + }, + expectedX: 0, + expectedY: 0, + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString("\n") + }, + expectedX: 0, + expectedY: 1, + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString("\na") + }, + expectedX: 1, + expectedY: 1, + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString("\n") + textarea.MoveCursorUp() + }, + expectedX: 0, + expectedY: 0, + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString("\n\n") + textarea.MoveCursorUp() + }, + expectedX: 0, + expectedY: 1, + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString("ab\ncd") + }, + expectedX: 2, + expectedY: 1, + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString("ab\n") + }, + expectedX: 0, + expectedY: 1, + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString("ab\n") + textarea.MoveCursorLeft() + }, + expectedX: 2, + expectedY: 0, + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString("ab\n\n") + }, + expectedX: 0, + expectedY: 2, + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString("ab\n\n") + textarea.MoveCursorLeft() + }, + expectedX: 0, + expectedY: 1, + }, + { + actions: func(textarea *TextArea) { + textarea.TypeCharacter("漢") + textarea.TypeCharacter("字") + }, + expectedX: 4, + expectedY: 0, + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString("abc de") + textarea.MoveCursorLeft() + }, + wrapWidth: 4, + expectedX: 1, + expectedY: 1, + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString("abc de") + textarea.MoveCursorLeft() + textarea.MoveCursorLeft() + }, + wrapWidth: 4, + expectedX: 0, + expectedY: 1, + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString("abc de") + textarea.MoveCursorLeft() + textarea.MoveCursorLeft() + textarea.MoveCursorLeft() + }, + wrapWidth: 4, + expectedX: 3, + expectedY: 0, + }, + } + + for i, test := range tests { + t.Run(strconv.Itoa(i+1), func(t *testing.T) { + textarea := &TextArea{} + if test.wrapWidth > 0 { + textarea.AutoWrap = true + textarea.AutoWrapWidth = test.wrapWidth + } + test.actions(textarea) + x, y := textarea.GetCursorXY() + assert.EqualValues(t, test.expectedX, x) + assert.EqualValues(t, test.expectedY, y) + + // As a sanity check, test that setting the cursor back to (x, y) results in the same cursor position: + cursor := textarea.cursor + textarea.SetCursor2D(x, y) + assert.EqualValues(t, cursor, textarea.cursor) + }) + } +} + +func Test_AutoWrapContent(t *testing.T) { + tests := []struct { + name string + content string + autoWrapWidth int + expectedWrappedContent string + expectedSoftLineBreaks []int + }{ + { + name: "empty content", + content: "", + autoWrapWidth: 7, + expectedWrappedContent: "", + expectedSoftLineBreaks: []int{}, + }, + { + name: "no wrapping necessary", + content: "abcde", + autoWrapWidth: 7, + expectedWrappedContent: "abcde", + expectedSoftLineBreaks: []int{}, + }, + { + name: "wrap at whitespace", + content: "abcde xyz", + autoWrapWidth: 7, + expectedWrappedContent: "abcde \nxyz", + expectedSoftLineBreaks: []int{6}, + }, + { + name: "take wide characters into account", + content: "🏴󠁧󠁢󠁥󠁮󠁧󠁿 🏴󠁧󠁢󠁥󠁮󠁧󠁿 x y", // the flag has a width of 2 + autoWrapWidth: 7, + expectedWrappedContent: "🏴󠁧󠁢󠁥󠁮󠁧󠁿 🏴󠁧󠁢󠁥󠁮󠁧󠁿 x \ny", + expectedSoftLineBreaks: []int{60}, + }, + { + name: "take wide characters into account at line end", + content: "🏴󠁧󠁢󠁥󠁮󠁧󠁿 🏴󠁧󠁢󠁥󠁮󠁧󠁿 🏴󠁧󠁢󠁥󠁮󠁧󠁿", // the flag has a width of 2 + autoWrapWidth: 7, + expectedWrappedContent: "🏴󠁧󠁢󠁥󠁮󠁧󠁿 🏴󠁧󠁢󠁥󠁮󠁧󠁿 \n🏴󠁧󠁢󠁥󠁮󠁧󠁿", + expectedSoftLineBreaks: []int{58}, + }, + { + name: "lots of whitespace is preserved at end of line", + content: "abcde xyz", + autoWrapWidth: 7, + expectedWrappedContent: "abcde \nxyz", + expectedSoftLineBreaks: []int{11}, + }, + { + name: "don't wrap inside long word when there's no whitespace", + content: "abc defghijklmn opq", + autoWrapWidth: 7, + expectedWrappedContent: "abc \ndefghijklmn \nopq", + expectedSoftLineBreaks: []int{4, 16}, + }, + { + name: "don't break at space after footnote symbol", + content: "abc\n[1]: https://long/link\ndef", + autoWrapWidth: 7, + expectedWrappedContent: "abc\n[1]: https://long/link\ndef", + expectedSoftLineBreaks: []int{}, + }, + { + name: "don't break at space after footnote symbol at soft line start", + content: "abc def [1]: https://long/link\nghi", + autoWrapWidth: 7, + expectedWrappedContent: "abc def \n[1]: https://long/link\nghi", + expectedSoftLineBreaks: []int{8}, + }, + { + name: "do break at subsequent space after footnote symbol", + content: "abc\n[1]: normal text follows\ndef", + autoWrapWidth: 7, + expectedWrappedContent: "abc\n[1]: normal \ntext \nfollows\ndef", + expectedSoftLineBreaks: []int{16, 21}, + }, + { + name: "don't break at space after trailer", + content: "abc\nSigned-off-by: John Doe \nCo-authored-by: Jane Smith \n", + autoWrapWidth: 10, + expectedWrappedContent: "abc\nSigned-off-by: John Doe \nCo-authored-by: Jane Smith \n", + expectedSoftLineBreaks: []int{}, + }, + { + name: "do break at space after trailer if there is no space after the colon", + content: "abc\nSigned-off-by:John Doe \n", + autoWrapWidth: 10, + expectedWrappedContent: "abc\nSigned-off-by:John \nDoe \n\n", + expectedSoftLineBreaks: []int{23, 27}, + }, + { + name: "hard line breaks", + content: "abc\ndef\n", + autoWrapWidth: 7, + expectedWrappedContent: "abc\ndef\n", + expectedSoftLineBreaks: []int{}, + }, + { + name: "mixture of hard and soft line breaks", + content: "abc def ghi jkl mno\npqr stu vwx yz\n", + autoWrapWidth: 7, + expectedWrappedContent: "abc def \nghi jkl \nmno\npqr stu \nvwx yz\n", + expectedSoftLineBreaks: []int{8, 16, 28}, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + textArea := &TextArea{content: tt.content, AutoWrapWidth: tt.autoWrapWidth, AutoWrap: true} + cells, softLineBreakIndices := contentToCells(tt.content, tt.autoWrapWidth) + textArea.cells = cells + if !reflect.DeepEqual(textArea.GetContent(), tt.expectedWrappedContent) { + t.Errorf("autoWrapContentImpl() wrappedContent = %v, expected %v", textArea.GetContent(), tt.expectedWrappedContent) + } + if !reflect.DeepEqual(softLineBreakIndices, tt.expectedSoftLineBreaks) { + t.Errorf("autoWrapContentImpl() softLineBreakIndices = %v, expected %v", softLineBreakIndices, tt.expectedSoftLineBreaks) + } + + // As a sanity check, run through all characters of the original content, + // convert the cursor to the wrapped cursor, and check that the character + // in the wrapped content at that position is the same: + origCursor := 0 + for _, chr := range stringToGraphemes(tt.content) { + wrappedIndex := textArea.contentCursorToCellCursor(origCursor) + if chr != textArea.cells[wrappedIndex].char { + t.Errorf("Runes in orig content and wrapped content don't match at %d: expected %v, got %v", origCursor, chr, textArea.cells[wrappedIndex].char) + } + + // Also, check that converting the wrapped position back to the + // orig position yields the original value again: + origIndexAgain := textArea.cellCursorToContentCursor(wrappedIndex) + if origCursor != origIndexAgain { + t.Errorf("wrappedCursorToOrigCursor doesn't yield original position: expected %d, got %d", origCursor, origIndexAgain) + } + + origCursor += len(chr) + } + }) + } +} + +var testContent string = `Lorem ipsum dolor sit amet, consectetur adipiscing elit. +Quisque vehicula mi at elit pellentesque, eu pulvinar ligula molestie. +In vitae orci vitae elit fermentum lobortis sed in nisi. +Nam non odio nisi. +Donec vitae elit enim. +Pellentesque faucibus dolor at metus elementum sollicitudin. +Mauris eu orci vel odio ornare feugiat eget ac nisl. +Nam at dolor erat. +Integer sit amet rutrum lectus, mollis pretium sapien. +Maecenas ligula ipsum, congue vitae rhoncus eget, volutpat at quam. +Donec ac ultricies tortor, sit amet sollicitudin urna. +Integer porta ornare diam a imperdiet. +Praesent vulputate mi turpis, in porttitor diam commodo a. +Donec ut enim ligula. + +[Thïs-is-not-à-fôôtnöte]: https://example.com/footnote + +Sïgned-öff-by: This is not a trailer + +[1]: This is a footnote + +Signed-off-by: John Doe +` + +func BenchmarkTypeCharacter(b *testing.B) { + textArea := &TextArea{content: testContent, AutoWrapWidth: 72, AutoWrap: true} + textArea.SetCursor2D(0, 0) + + b.ResetTimer() + for b.Loop() { + textArea.TypeCharacter("a") + } +} diff --git a/vendor/github.com/jesseduffield/gocui/view.go b/pkg/gocui/view.go similarity index 100% rename from vendor/github.com/jesseduffield/gocui/view.go rename to pkg/gocui/view.go diff --git a/pkg/gocui/view_test.go b/pkg/gocui/view_test.go new file mode 100644 index 000000000..a7023be43 --- /dev/null +++ b/pkg/gocui/view_test.go @@ -0,0 +1,415 @@ +// Copyright 2014 The gocui Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package gocui + +import ( + "strings" + "testing" + + "github.com/rivo/uniseg" + "github.com/stretchr/testify/assert" +) + +func TestWriteString(t *testing.T) { + tests := []struct { + existingLines []string + stringsToWrite []string + expectedLines [][]string + }{ + { + []string{}, + []string{""}, + [][]string{{}}, + }, + { + []string{}, + []string{"1\n"}, + [][]string{{"1", ""}}, + }, + { + []string{}, + []string{"1\n", "2\n"}, + [][]string{{"1", ""}, {"2", ""}}, + }, + { + []string{"a"}, + []string{"1\n"}, + [][]string{{"1", ""}}, + }, + { + []string{"a\x00"}, + []string{"1\n"}, + [][]string{{"1", "\x00"}}, + }, + { + []string{"ab"}, + []string{"1\n"}, + [][]string{{"1", "b"}}, + }, + { + []string{"abc"}, + []string{"1\n"}, + [][]string{{"1", "b", "c"}}, + }, + { + []string{}, + []string{"1\r"}, + [][]string{{"1", ""}}, + }, + { + []string{"a"}, + []string{"1\r"}, + [][]string{{"1", ""}}, + }, + { + []string{"a\x00"}, + []string{"1\r"}, + [][]string{{"1", "\x00"}}, + }, + { + []string{"ab"}, + []string{"1\r"}, + [][]string{{"1", "b"}}, + }, + { + []string{"abc"}, + []string{"1\r"}, + [][]string{{"1", "b", "c"}}, + }, + } + + for _, test := range tests { + v := NewView("name", 0, 0, 10, 10, OutputNormal) + for _, l := range test.existingLines { + v.lines = append(v.lines, stringToCells(l)) + } + for _, s := range test.stringsToWrite { + v.writeString(s) + } + var resultingLines [][]string + for _, l := range v.lines { + resultingLines = append(resultingLines, cellsToStrings(l)) + } + assert.Equal(t, test.expectedLines, resultingLines) + } +} + +func TestUpdatedCursorAndOrigin(t *testing.T) { + tests := []struct { + prevOrigin int + size int + cursor int + expectedCursor int + expectedOrigin int + }{ + {0, 10, 0, 0, 0}, + {0, 10, 9, 9, 0}, + {0, 10, 10, 9, 1}, + {0, 10, 19, 9, 10}, + {0, 10, 20, 9, 11}, + {20, 10, 19, 0, 19}, + {20, 10, 25, 5, 20}, + } + + for _, test := range tests { + cursor, origin := updatedCursorAndOrigin(test.prevOrigin, test.size, test.cursor) + assert.EqualValues(t, test.expectedCursor, cursor, "Cursor is wrong") + assert.EqualValues(t, test.expectedOrigin, origin, "Origin in wrong") + } +} + +func TestAutoRenderingHyperlinks(t *testing.T) { + v := NewView("name", 0, 0, 10, 10, OutputNormal) + v.AutoRenderHyperLinks = true + + v.writeString("htt") + // No hyperlinks are generated for incomplete URLs + assert.Equal(t, "", v.lines[0][0].hyperlink) + // Writing more characters to the same line makes the link complete (even + // though we didn't see a newline yet) + v.writeString("ps://example.com") + assert.Equal(t, "https://example.com", v.lines[0][0].hyperlink) + + v.Clear() + // Valid but incomplete URL + v.writeString("https://exa") + assert.Equal(t, "https://exa", v.lines[0][0].hyperlink) + // Writing more characters to the same fixes the link + v.writeString("mple.com") + assert.Equal(t, "https://example.com", v.lines[0][0].hyperlink) +} + +func TestContainsColoredText(t *testing.T) { + hexColor := func(text string, hexStr string) []cell { + cells := make([]cell, len(text)) + hex := GetColor(hexStr) + for i, chr := range text { + cells[i] = cell{fgColor: hex, chr: string(chr)} + } + return cells + } + red := "#ff0000" + green := "#00ff00" + redStr := func(text string) []cell { return hexColor(text, red) } + greenStr := func(text string) []cell { return hexColor(text, green) } + + concat := func(lines ...[]cell) []cell { + var cells []cell + for _, line := range lines { + cells = append(cells, line...) + } + return cells + } + + tests := []struct { + lines [][]cell + fgColorStr string + text string + expected bool + }{ + { + lines: [][]cell{concat(redStr("a"))}, + fgColorStr: red, + text: "a", + expected: true, + }, + { + lines: [][]cell{concat(redStr("a"))}, + fgColorStr: red, + text: "b", + expected: false, + }, + { + lines: [][]cell{concat(redStr("a"))}, + fgColorStr: green, + text: "b", + expected: false, + }, + { + lines: [][]cell{concat(redStr("hel"), greenStr("lo"), redStr(" World!"))}, + fgColorStr: red, + text: "hello", + expected: false, + }, + { + lines: [][]cell{concat(redStr("hel"), greenStr("lo"), redStr(" World!"))}, + fgColorStr: green, + text: "lo", + expected: true, + }, + { + lines: [][]cell{ + redStr("hel"), + redStr("lo"), + }, + fgColorStr: red, + text: "hello", + expected: false, + }, + } + + for i, test := range tests { + v := &View{lines: test.lines} + assert.Equal(t, test.expected, v.ContainsColoredText(test.fgColorStr, test.text), "Test %d failed", i) + } +} + +func stringToCells(s string) []cell { + var cells []cell + state := -1 + for len(s) > 0 { + var c string + var w int + c, s, w, state = uniseg.FirstGraphemeClusterInString(s, state) + cells = append(cells, cell{chr: c, width: w}) + } + return cells +} + +func cellsToString(cells []cell) string { + var s strings.Builder + for _, c := range cells { + s.WriteString(c.chr) + } + return s.String() +} + +func cellsToStrings(cells []cell) []string { + s := []string{} + for _, c := range cells { + s = append(s, c.chr) + } + return s +} + +func TestLineWrap(t *testing.T) { + testCases := []struct { + name string + line string + columns int + expected []string + }{ + { + name: "Wrap on space", + line: "Hello World", + columns: 5, + expected: []string{ + "Hello", + "World", + }, + }, + { + name: "Wrap on hyphen", + line: "Hello-World", + columns: 6, + expected: []string{ + "Hello-", + "World", + }, + }, + { + name: "Wrap on hyphen 2", + line: "Blah Hello-World", + columns: 12, + expected: []string{ + "Blah Hello-", + "World", + }, + }, + { + name: "Wrap on hyphen 3", + line: "Blah Hello-World", + columns: 11, + expected: []string{ + "Blah Hello-", + "World", + }, + }, + { + name: "Wrap on hyphen 4", + line: "Blah Hello-World", + columns: 10, + expected: []string{ + "Blah Hello", + "-World", + }, + }, + { + name: "Wrap on space 2", + line: "Blah Hello World", + columns: 10, + expected: []string{ + "Blah Hello", + "World", + }, + }, + { + name: "Wrap on space with more words", + line: "Longer word here", + columns: 10, + expected: []string{ + "Longer", + "word here", + }, + }, + { + name: "Split word that's too long", + line: "ThisWordIsWayTooLong", + columns: 10, + expected: []string{ + "ThisWordIs", + "WayTooLong", + }, + }, + { + name: "Split word that's too long over multiple lines", + line: "ThisWordIsWayTooLong", + columns: 5, + expected: []string{ + "ThisW", + "ordIs", + "WayTo", + "oLong", + }, + }, + { + name: "Lots of hyphens", + line: "one-two-three-four-five", + columns: 8, + expected: []string{ + "one-two-", + "three-", + "four-", + "five", + }, + }, + { + name: "Several lines using all the available width", + line: "aaa bb cc ddd-ee ff", + columns: 5, + expected: []string{ + "aaa", + "bb cc", + "ddd-", + "ee ff", + }, + }, + { + name: "Multi-cell runes", + line: "🐤🐤🐤 🐝🐝 🙉 🦊🦊🦊-🐬🐬 🦢🦢", + columns: 9, + expected: []string{ + "🐤🐤🐤", + "🐝🐝 🙉", + "🦊🦊🦊-", + "🐬🐬 🦢🦢", + }, + }, + { + name: "Space in last column", + line: "hello world", + columns: 6, + expected: []string{ + "hello", + "world", + }, + }, + { + name: "Hyphen in last column", + line: "hello-world", + columns: 6, + expected: []string{ + "hello-", + "world", + }, + }, + { + name: "English text", + line: "+The sea reach of the Thames stretched before us like the bedinnind of an interminable waterway. In the offind the sea and the sky were welded todether without a joint, and in the luminous space the tanned sails of the bardes drifting blah blah", + columns: 81, + expected: []string{ + "+The sea reach of the Thames stretched before us like the bedinnind of an", + "interminable waterway. In the offind the sea and the sky were welded todether", + "without a joint, and in the luminous space the tanned sails of the bardes", + "drifting blah blah", + }, + }, + } + + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + lineCells := stringToCells(tc.line) + + result := lineWrap(lineCells, tc.columns) + + resultStrings := make([]string, len(result)) + for i, line := range result { + resultStrings[i] = cellsToString(line) + } + + assert.EqualValues(t, tc.expected, resultStrings) + }) + } +} diff --git a/pkg/gui/background.go b/pkg/gui/background.go index 11f0dde5b..cedc6a78c 100644 --- a/pkg/gui/background.go +++ b/pkg/gui/background.go @@ -5,7 +5,7 @@ import ( "runtime" "time" - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/jesseduffield/lazygit/pkg/utils" ) diff --git a/pkg/gui/context/base_context.go b/pkg/gui/context/base_context.go index 6c86f374e..7584b5a12 100644 --- a/pkg/gui/context/base_context.go +++ b/pkg/gui/context/base_context.go @@ -1,7 +1,7 @@ package context import ( - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/types" ) diff --git a/pkg/gui/context/local_commits_context.go b/pkg/gui/context/local_commits_context.go index 55415c761..056035cce 100644 --- a/pkg/gui/context/local_commits_context.go +++ b/pkg/gui/context/local_commits_context.go @@ -6,8 +6,8 @@ import ( "strings" "time" - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands/models" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/presentation" "github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/samber/lo" diff --git a/pkg/gui/context/main_context.go b/pkg/gui/context/main_context.go index f749c4be2..c8b6edade 100644 --- a/pkg/gui/context/main_context.go +++ b/pkg/gui/context/main_context.go @@ -1,7 +1,7 @@ package context import ( - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/types" ) diff --git a/pkg/gui/context/patch_explorer_context.go b/pkg/gui/context/patch_explorer_context.go index 167bdb41f..334c2e374 100644 --- a/pkg/gui/context/patch_explorer_context.go +++ b/pkg/gui/context/patch_explorer_context.go @@ -1,7 +1,7 @@ package context import ( - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/patch_exploring" "github.com/jesseduffield/lazygit/pkg/gui/types" deadlock "github.com/sasha-s/go-deadlock" diff --git a/pkg/gui/context/simple_context.go b/pkg/gui/context/simple_context.go index 6405e91f5..83d201f3a 100644 --- a/pkg/gui/context/simple_context.go +++ b/pkg/gui/context/simple_context.go @@ -1,7 +1,7 @@ package context import ( - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/types" ) diff --git a/pkg/gui/context/sub_commits_context.go b/pkg/gui/context/sub_commits_context.go index 55a06f286..fee5492ac 100644 --- a/pkg/gui/context/sub_commits_context.go +++ b/pkg/gui/context/sub_commits_context.go @@ -4,9 +4,9 @@ import ( "fmt" "time" - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands/git_commands" "github.com/jesseduffield/lazygit/pkg/commands/models" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/presentation" "github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/samber/lo" diff --git a/pkg/gui/context/view_trait.go b/pkg/gui/context/view_trait.go index d3825b9cf..8e12e083f 100644 --- a/pkg/gui/context/view_trait.go +++ b/pkg/gui/context/view_trait.go @@ -1,7 +1,7 @@ package context import ( - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/types" ) diff --git a/pkg/gui/controllers.go b/pkg/gui/controllers.go index 51c4c3bab..51e240a5d 100644 --- a/pkg/gui/controllers.go +++ b/pkg/gui/controllers.go @@ -1,8 +1,8 @@ package gui import ( - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands/models" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/controllers" "github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers" "github.com/jesseduffield/lazygit/pkg/gui/services/custom_commands" diff --git a/pkg/gui/controllers/base_controller.go b/pkg/gui/controllers/base_controller.go index 4ea0b1fd3..f91f0b4cc 100644 --- a/pkg/gui/controllers/base_controller.go +++ b/pkg/gui/controllers/base_controller.go @@ -1,7 +1,7 @@ package controllers import ( - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/types" ) diff --git a/pkg/gui/controllers/branches_controller.go b/pkg/gui/controllers/branches_controller.go index ab3b3c8d0..2011bb970 100644 --- a/pkg/gui/controllers/branches_controller.go +++ b/pkg/gui/controllers/branches_controller.go @@ -6,9 +6,9 @@ import ( "strings" "github.com/gookit/color" - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands/git_commands" "github.com/jesseduffield/lazygit/pkg/commands/models" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/context" "github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers" "github.com/jesseduffield/lazygit/pkg/gui/presentation" diff --git a/pkg/gui/controllers/commit_description_controller.go b/pkg/gui/controllers/commit_description_controller.go index 8ffcb4f58..4b799a6a0 100644 --- a/pkg/gui/controllers/commit_description_controller.go +++ b/pkg/gui/controllers/commit_description_controller.go @@ -1,7 +1,7 @@ package controllers import ( - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/keybindings" "github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/jesseduffield/lazygit/pkg/utils" diff --git a/pkg/gui/controllers/commit_message_controller.go b/pkg/gui/controllers/commit_message_controller.go index b92e8dd4c..53c7e761e 100644 --- a/pkg/gui/controllers/commit_message_controller.go +++ b/pkg/gui/controllers/commit_message_controller.go @@ -3,8 +3,8 @@ package controllers import ( "errors" - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands/git_commands" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/context" "github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers" "github.com/jesseduffield/lazygit/pkg/gui/types" diff --git a/pkg/gui/controllers/commits_files_controller.go b/pkg/gui/controllers/commits_files_controller.go index 699360b63..0640b7f32 100644 --- a/pkg/gui/controllers/commits_files_controller.go +++ b/pkg/gui/controllers/commits_files_controller.go @@ -6,11 +6,11 @@ import ( "path/filepath" "strings" - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands/git_commands" "github.com/jesseduffield/lazygit/pkg/commands/models" "github.com/jesseduffield/lazygit/pkg/commands/patch" "github.com/jesseduffield/lazygit/pkg/constants" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/context" "github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers" "github.com/jesseduffield/lazygit/pkg/gui/filetree" diff --git a/pkg/gui/controllers/custom_patch_options_menu_action.go b/pkg/gui/controllers/custom_patch_options_menu_action.go index fa39cf374..6d9074802 100644 --- a/pkg/gui/controllers/custom_patch_options_menu_action.go +++ b/pkg/gui/controllers/custom_patch_options_menu_action.go @@ -5,8 +5,8 @@ import ( "fmt" "github.com/jesseduffield/generics/set" - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands/models" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers" "github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/jesseduffield/lazygit/pkg/utils" diff --git a/pkg/gui/controllers/files_controller.go b/pkg/gui/controllers/files_controller.go index ee856ddb5..234a2b65c 100644 --- a/pkg/gui/controllers/files_controller.go +++ b/pkg/gui/controllers/files_controller.go @@ -7,9 +7,9 @@ import ( "strings" "github.com/jesseduffield/generics/set" - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands/git_commands" "github.com/jesseduffield/lazygit/pkg/commands/models" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/context" "github.com/jesseduffield/lazygit/pkg/gui/filetree" "github.com/jesseduffield/lazygit/pkg/gui/types" diff --git a/pkg/gui/controllers/global_controller.go b/pkg/gui/controllers/global_controller.go index 1ae560685..079ad24b5 100644 --- a/pkg/gui/controllers/global_controller.go +++ b/pkg/gui/controllers/global_controller.go @@ -3,7 +3,7 @@ package controllers import ( "fmt" - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/types" ) diff --git a/pkg/gui/controllers/helpers/app_status_helper.go b/pkg/gui/controllers/helpers/app_status_helper.go index 587d219d3..89de221b8 100644 --- a/pkg/gui/controllers/helpers/app_status_helper.go +++ b/pkg/gui/controllers/helpers/app_status_helper.go @@ -3,7 +3,7 @@ package helpers import ( "time" - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/status" "github.com/jesseduffield/lazygit/pkg/gui/types" ) diff --git a/pkg/gui/controllers/helpers/branches_helper.go b/pkg/gui/controllers/helpers/branches_helper.go index 9748fecc5..c3f4242bf 100644 --- a/pkg/gui/controllers/helpers/branches_helper.go +++ b/pkg/gui/controllers/helpers/branches_helper.go @@ -5,9 +5,9 @@ import ( "fmt" "strings" - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands/git_commands" "github.com/jesseduffield/lazygit/pkg/commands/models" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/context" "github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/jesseduffield/lazygit/pkg/utils" diff --git a/pkg/gui/controllers/helpers/commits_helper.go b/pkg/gui/controllers/helpers/commits_helper.go index 73f1d9baf..55b759b48 100644 --- a/pkg/gui/controllers/helpers/commits_helper.go +++ b/pkg/gui/controllers/helpers/commits_helper.go @@ -6,8 +6,8 @@ import ( "strings" "time" - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands/git_commands" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/samber/lo" ) diff --git a/pkg/gui/controllers/helpers/gpg_helper.go b/pkg/gui/controllers/helpers/gpg_helper.go index afac52f13..30ec6ceef 100644 --- a/pkg/gui/controllers/helpers/gpg_helper.go +++ b/pkg/gui/controllers/helpers/gpg_helper.go @@ -3,9 +3,9 @@ package helpers import ( "fmt" - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands/git_commands" "github.com/jesseduffield/lazygit/pkg/commands/oscommands" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/types" ) diff --git a/pkg/gui/controllers/helpers/inline_status_helper.go b/pkg/gui/controllers/helpers/inline_status_helper.go index 38a4e2cf7..13c112811 100644 --- a/pkg/gui/controllers/helpers/inline_status_helper.go +++ b/pkg/gui/controllers/helpers/inline_status_helper.go @@ -3,7 +3,7 @@ package helpers import ( "time" - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/presentation" "github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/jesseduffield/lazygit/pkg/utils" diff --git a/pkg/gui/controllers/helpers/merge_and_rebase_helper.go b/pkg/gui/controllers/helpers/merge_and_rebase_helper.go index 7f51bc35d..8b8d1fb7c 100644 --- a/pkg/gui/controllers/helpers/merge_and_rebase_helper.go +++ b/pkg/gui/controllers/helpers/merge_and_rebase_helper.go @@ -7,9 +7,9 @@ import ( "path/filepath" "strings" - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands/git_commands" "github.com/jesseduffield/lazygit/pkg/commands/models" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/jesseduffield/lazygit/pkg/utils" "github.com/samber/lo" diff --git a/pkg/gui/controllers/helpers/refresh_helper.go b/pkg/gui/controllers/helpers/refresh_helper.go index f2d5a9a49..4a61bde18 100644 --- a/pkg/gui/controllers/helpers/refresh_helper.go +++ b/pkg/gui/controllers/helpers/refresh_helper.go @@ -7,10 +7,10 @@ import ( "time" "github.com/jesseduffield/generics/set" - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands/git_commands" "github.com/jesseduffield/lazygit/pkg/commands/models" "github.com/jesseduffield/lazygit/pkg/config" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/context" "github.com/jesseduffield/lazygit/pkg/gui/filetree" "github.com/jesseduffield/lazygit/pkg/gui/mergeconflicts" diff --git a/pkg/gui/controllers/helpers/refs_helper.go b/pkg/gui/controllers/helpers/refs_helper.go index 791f0d481..c10fad81d 100644 --- a/pkg/gui/controllers/helpers/refs_helper.go +++ b/pkg/gui/controllers/helpers/refs_helper.go @@ -5,9 +5,9 @@ import ( "strings" "text/template" - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands/git_commands" "github.com/jesseduffield/lazygit/pkg/commands/models" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/context" "github.com/jesseduffield/lazygit/pkg/gui/style" "github.com/jesseduffield/lazygit/pkg/gui/types" diff --git a/pkg/gui/controllers/helpers/repos_helper.go b/pkg/gui/controllers/helpers/repos_helper.go index 158606b01..156c0ab30 100644 --- a/pkg/gui/controllers/helpers/repos_helper.go +++ b/pkg/gui/controllers/helpers/repos_helper.go @@ -8,11 +8,11 @@ import ( "strings" "sync" - "github.com/jesseduffield/gocui" appTypes "github.com/jesseduffield/lazygit/pkg/app/types" "github.com/jesseduffield/lazygit/pkg/commands" "github.com/jesseduffield/lazygit/pkg/commands/models" "github.com/jesseduffield/lazygit/pkg/env" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/context" "github.com/jesseduffield/lazygit/pkg/gui/presentation/icons" "github.com/jesseduffield/lazygit/pkg/gui/style" diff --git a/pkg/gui/controllers/helpers/search_helper.go b/pkg/gui/controllers/helpers/search_helper.go index 9b3dcec64..8307a7f67 100644 --- a/pkg/gui/controllers/helpers/search_helper.go +++ b/pkg/gui/controllers/helpers/search_helper.go @@ -4,7 +4,7 @@ import ( "fmt" "strings" - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/context" "github.com/jesseduffield/lazygit/pkg/gui/keybindings" "github.com/jesseduffield/lazygit/pkg/gui/types" diff --git a/pkg/gui/controllers/helpers/suggestions_helper.go b/pkg/gui/controllers/helpers/suggestions_helper.go index de0d04843..e88fe3822 100644 --- a/pkg/gui/controllers/helpers/suggestions_helper.go +++ b/pkg/gui/controllers/helpers/suggestions_helper.go @@ -5,8 +5,8 @@ import ( "strings" "github.com/jesseduffield/generics/set" - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands/models" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/presentation" "github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/jesseduffield/lazygit/pkg/utils" diff --git a/pkg/gui/controllers/helpers/update_helper.go b/pkg/gui/controllers/helpers/update_helper.go index 4491b4330..a108b0bf4 100644 --- a/pkg/gui/controllers/helpers/update_helper.go +++ b/pkg/gui/controllers/helpers/update_helper.go @@ -3,7 +3,7 @@ package helpers import ( "errors" - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/jesseduffield/lazygit/pkg/updates" "github.com/jesseduffield/lazygit/pkg/utils" diff --git a/pkg/gui/controllers/helpers/window_helper.go b/pkg/gui/controllers/helpers/window_helper.go index e2b0e38f0..53531c2ff 100644 --- a/pkg/gui/controllers/helpers/window_helper.go +++ b/pkg/gui/controllers/helpers/window_helper.go @@ -3,7 +3,7 @@ package helpers import ( "fmt" - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/jesseduffield/lazygit/pkg/utils" "github.com/samber/lo" diff --git a/pkg/gui/controllers/helpers/worktree_helper.go b/pkg/gui/controllers/helpers/worktree_helper.go index 671743fe6..6cb22084b 100644 --- a/pkg/gui/controllers/helpers/worktree_helper.go +++ b/pkg/gui/controllers/helpers/worktree_helper.go @@ -4,9 +4,9 @@ import ( "errors" "strings" - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands/git_commands" "github.com/jesseduffield/lazygit/pkg/commands/models" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/context" "github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/jesseduffield/lazygit/pkg/utils" diff --git a/pkg/gui/controllers/jump_to_side_window_controller.go b/pkg/gui/controllers/jump_to_side_window_controller.go index c0ef2faec..25eb2c137 100644 --- a/pkg/gui/controllers/jump_to_side_window_controller.go +++ b/pkg/gui/controllers/jump_to_side_window_controller.go @@ -3,7 +3,7 @@ package controllers import ( "log" - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/samber/lo" ) diff --git a/pkg/gui/controllers/list_controller.go b/pkg/gui/controllers/list_controller.go index a56860bab..dba08552c 100644 --- a/pkg/gui/controllers/list_controller.go +++ b/pkg/gui/controllers/list_controller.go @@ -1,7 +1,7 @@ package controllers import ( - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/types" ) diff --git a/pkg/gui/controllers/local_commits_controller.go b/pkg/gui/controllers/local_commits_controller.go index e4f88b3ca..23f772794 100644 --- a/pkg/gui/controllers/local_commits_controller.go +++ b/pkg/gui/controllers/local_commits_controller.go @@ -4,9 +4,9 @@ import ( "strings" "github.com/go-errors/errors" - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands/git_commands" "github.com/jesseduffield/lazygit/pkg/commands/models" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/context" "github.com/jesseduffield/lazygit/pkg/gui/context/traits" "github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers" diff --git a/pkg/gui/controllers/main_view_controller.go b/pkg/gui/controllers/main_view_controller.go index fa7e6438a..58d88485a 100644 --- a/pkg/gui/controllers/main_view_controller.go +++ b/pkg/gui/controllers/main_view_controller.go @@ -1,7 +1,7 @@ package controllers import ( - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/context" "github.com/jesseduffield/lazygit/pkg/gui/types" ) diff --git a/pkg/gui/controllers/merge_conflicts_controller.go b/pkg/gui/controllers/merge_conflicts_controller.go index dc358bb03..1de192928 100644 --- a/pkg/gui/controllers/merge_conflicts_controller.go +++ b/pkg/gui/controllers/merge_conflicts_controller.go @@ -3,7 +3,7 @@ package controllers import ( "os" - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/context" "github.com/jesseduffield/lazygit/pkg/gui/mergeconflicts" "github.com/jesseduffield/lazygit/pkg/gui/types" diff --git a/pkg/gui/controllers/patch_building_controller.go b/pkg/gui/controllers/patch_building_controller.go index 4d418d7df..9afba75b1 100644 --- a/pkg/gui/controllers/patch_building_controller.go +++ b/pkg/gui/controllers/patch_building_controller.go @@ -3,7 +3,7 @@ package controllers import ( "fmt" - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/keybindings" "github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/samber/lo" diff --git a/pkg/gui/controllers/patch_explorer_controller.go b/pkg/gui/controllers/patch_explorer_controller.go index fdaafec5d..9c0ef078f 100644 --- a/pkg/gui/controllers/patch_explorer_controller.go +++ b/pkg/gui/controllers/patch_explorer_controller.go @@ -3,7 +3,7 @@ package controllers import ( "strings" - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/samber/lo" ) diff --git a/pkg/gui/controllers/prompt_controller.go b/pkg/gui/controllers/prompt_controller.go index 1f6953951..1ad19fa97 100644 --- a/pkg/gui/controllers/prompt_controller.go +++ b/pkg/gui/controllers/prompt_controller.go @@ -3,7 +3,7 @@ package controllers import ( "fmt" - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/context" "github.com/jesseduffield/lazygit/pkg/gui/types" ) diff --git a/pkg/gui/controllers/quit_actions.go b/pkg/gui/controllers/quit_actions.go index 4713a6e23..40ad6f7e3 100644 --- a/pkg/gui/controllers/quit_actions.go +++ b/pkg/gui/controllers/quit_actions.go @@ -1,7 +1,7 @@ package controllers import ( - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/context" "github.com/jesseduffield/lazygit/pkg/gui/types" ) diff --git a/pkg/gui/controllers/remotes_controller.go b/pkg/gui/controllers/remotes_controller.go index 8d47d1721..cbba7b656 100644 --- a/pkg/gui/controllers/remotes_controller.go +++ b/pkg/gui/controllers/remotes_controller.go @@ -7,8 +7,8 @@ import ( "slices" "strings" - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands/models" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/context" "github.com/jesseduffield/lazygit/pkg/gui/style" "github.com/jesseduffield/lazygit/pkg/gui/types" diff --git a/pkg/gui/controllers/screen_mode_actions.go b/pkg/gui/controllers/screen_mode_actions.go index a09331065..887f34603 100644 --- a/pkg/gui/controllers/screen_mode_actions.go +++ b/pkg/gui/controllers/screen_mode_actions.go @@ -1,7 +1,7 @@ package controllers import ( - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/types" ) diff --git a/pkg/gui/controllers/search_prompt_controller.go b/pkg/gui/controllers/search_prompt_controller.go index 9eca74c90..6e0d0b824 100644 --- a/pkg/gui/controllers/search_prompt_controller.go +++ b/pkg/gui/controllers/search_prompt_controller.go @@ -1,7 +1,7 @@ package controllers import ( - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/types" ) diff --git a/pkg/gui/controllers/side_window_controller.go b/pkg/gui/controllers/side_window_controller.go index 2cd421e0e..ddf0f97bd 100644 --- a/pkg/gui/controllers/side_window_controller.go +++ b/pkg/gui/controllers/side_window_controller.go @@ -1,7 +1,7 @@ package controllers import ( - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/types" ) diff --git a/pkg/gui/controllers/staging_controller.go b/pkg/gui/controllers/staging_controller.go index f667dd212..dbce8cff4 100644 --- a/pkg/gui/controllers/staging_controller.go +++ b/pkg/gui/controllers/staging_controller.go @@ -4,9 +4,9 @@ import ( "fmt" "strings" - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands/git_commands" "github.com/jesseduffield/lazygit/pkg/commands/patch" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/keybindings" "github.com/jesseduffield/lazygit/pkg/gui/types" ) diff --git a/pkg/gui/controllers/status_controller.go b/pkg/gui/controllers/status_controller.go index 377fd4994..a3e08e384 100644 --- a/pkg/gui/controllers/status_controller.go +++ b/pkg/gui/controllers/status_controller.go @@ -6,8 +6,8 @@ import ( "strings" "time" - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/constants" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/presentation" "github.com/jesseduffield/lazygit/pkg/gui/style" "github.com/jesseduffield/lazygit/pkg/gui/types" diff --git a/pkg/gui/controllers/submodules_controller.go b/pkg/gui/controllers/submodules_controller.go index c425453aa..d8b403975 100644 --- a/pkg/gui/controllers/submodules_controller.go +++ b/pkg/gui/controllers/submodules_controller.go @@ -5,8 +5,8 @@ import ( "path/filepath" "strings" - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands/models" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/context" "github.com/jesseduffield/lazygit/pkg/gui/keybindings" "github.com/jesseduffield/lazygit/pkg/gui/style" diff --git a/pkg/gui/controllers/suggestions_controller.go b/pkg/gui/controllers/suggestions_controller.go index 715ee12e9..e5de7619b 100644 --- a/pkg/gui/controllers/suggestions_controller.go +++ b/pkg/gui/controllers/suggestions_controller.go @@ -1,7 +1,7 @@ package controllers import ( - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/context" "github.com/jesseduffield/lazygit/pkg/gui/types" ) diff --git a/pkg/gui/controllers/switch_to_focused_main_view_controller.go b/pkg/gui/controllers/switch_to_focused_main_view_controller.go index 132ec96db..5161a5c83 100644 --- a/pkg/gui/controllers/switch_to_focused_main_view_controller.go +++ b/pkg/gui/controllers/switch_to_focused_main_view_controller.go @@ -1,7 +1,7 @@ package controllers import ( - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/types" ) diff --git a/pkg/gui/controllers/sync_controller.go b/pkg/gui/controllers/sync_controller.go index 023ac0d25..00178b1bb 100644 --- a/pkg/gui/controllers/sync_controller.go +++ b/pkg/gui/controllers/sync_controller.go @@ -5,9 +5,9 @@ import ( "fmt" "strings" - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands/git_commands" "github.com/jesseduffield/lazygit/pkg/commands/models" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/context" "github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/jesseduffield/lazygit/pkg/utils" diff --git a/pkg/gui/controllers/tags_controller.go b/pkg/gui/controllers/tags_controller.go index c8a02df87..22c208a38 100644 --- a/pkg/gui/controllers/tags_controller.go +++ b/pkg/gui/controllers/tags_controller.go @@ -4,8 +4,8 @@ import ( "fmt" "strings" - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands/models" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/context" "github.com/jesseduffield/lazygit/pkg/gui/style" "github.com/jesseduffield/lazygit/pkg/gui/types" diff --git a/pkg/gui/controllers/undo_controller.go b/pkg/gui/controllers/undo_controller.go index cdc8a1280..02e27ddce 100644 --- a/pkg/gui/controllers/undo_controller.go +++ b/pkg/gui/controllers/undo_controller.go @@ -4,7 +4,7 @@ import ( "errors" "fmt" - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/jesseduffield/lazygit/pkg/utils" ) diff --git a/pkg/gui/controllers/vertical_scroll_controller.go b/pkg/gui/controllers/vertical_scroll_controller.go index b88574451..1db9bb76e 100644 --- a/pkg/gui/controllers/vertical_scroll_controller.go +++ b/pkg/gui/controllers/vertical_scroll_controller.go @@ -1,7 +1,7 @@ package controllers import ( - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/types" ) diff --git a/pkg/gui/controllers/view_selection_controller.go b/pkg/gui/controllers/view_selection_controller.go index 638c46ba6..0d69c5109 100644 --- a/pkg/gui/controllers/view_selection_controller.go +++ b/pkg/gui/controllers/view_selection_controller.go @@ -1,7 +1,7 @@ package controllers import ( - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/types" ) diff --git a/pkg/gui/controllers/workspace_reset_controller.go b/pkg/gui/controllers/workspace_reset_controller.go index 82357922f..c19d12377 100644 --- a/pkg/gui/controllers/workspace_reset_controller.go +++ b/pkg/gui/controllers/workspace_reset_controller.go @@ -8,7 +8,7 @@ import ( "math/rand" "time" - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers" "github.com/jesseduffield/lazygit/pkg/gui/style" "github.com/jesseduffield/lazygit/pkg/gui/types" diff --git a/pkg/gui/editors.go b/pkg/gui/editors.go index 157f06495..3f6d7154a 100644 --- a/pkg/gui/editors.go +++ b/pkg/gui/editors.go @@ -1,7 +1,7 @@ package gui import ( - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" ) func (gui *Gui) handleEditorKeypress(v *gocui.View, key gocui.Key, ch rune, mod gocui.Modifier, allowMultiline bool) bool { diff --git a/pkg/gui/global_handlers.go b/pkg/gui/global_handlers.go index 9b6551d33..3c4896af4 100644 --- a/pkg/gui/global_handlers.go +++ b/pkg/gui/global_handlers.go @@ -4,7 +4,7 @@ import ( "fmt" "strings" - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/style" "github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/jesseduffield/lazygit/pkg/utils" diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go index 1da39ce05..8822c27a8 100644 --- a/pkg/gui/gui.go +++ b/pkg/gui/gui.go @@ -14,7 +14,6 @@ import ( "sync" "time" - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazycore/pkg/boxlayout" appTypes "github.com/jesseduffield/lazygit/pkg/app/types" "github.com/jesseduffield/lazygit/pkg/commands" @@ -24,6 +23,7 @@ import ( "github.com/jesseduffield/lazygit/pkg/commands/oscommands" "github.com/jesseduffield/lazygit/pkg/common" "github.com/jesseduffield/lazygit/pkg/config" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/context" "github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers" "github.com/jesseduffield/lazygit/pkg/gui/keybindings" diff --git a/pkg/gui/gui_common.go b/pkg/gui/gui_common.go index d946659d1..13f49c46b 100644 --- a/pkg/gui/gui_common.go +++ b/pkg/gui/gui_common.go @@ -1,10 +1,10 @@ package gui import ( - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands" "github.com/jesseduffield/lazygit/pkg/commands/oscommands" "github.com/jesseduffield/lazygit/pkg/config" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers" "github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/jesseduffield/lazygit/pkg/tasks" diff --git a/pkg/gui/gui_driver.go b/pkg/gui/gui_driver.go index 35c201a14..8f3f64dbb 100644 --- a/pkg/gui/gui_driver.go +++ b/pkg/gui/gui_driver.go @@ -7,9 +7,9 @@ import ( "time" "github.com/gdamore/tcell/v2" - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands/models" "github.com/jesseduffield/lazygit/pkg/config" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/keybindings" "github.com/jesseduffield/lazygit/pkg/gui/types" integrationTypes "github.com/jesseduffield/lazygit/pkg/integration/types" diff --git a/pkg/gui/keybindings.go b/pkg/gui/keybindings.go index 9f92fbae8..6ca06a0fc 100644 --- a/pkg/gui/keybindings.go +++ b/pkg/gui/keybindings.go @@ -4,7 +4,7 @@ import ( "errors" "log" - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/context" "github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers" "github.com/jesseduffield/lazygit/pkg/gui/keybindings" diff --git a/pkg/gui/keybindings/keybindings.go b/pkg/gui/keybindings/keybindings.go index 76b757b72..4ffee81b4 100644 --- a/pkg/gui/keybindings/keybindings.go +++ b/pkg/gui/keybindings/keybindings.go @@ -6,9 +6,9 @@ import ( "strings" "unicode/utf8" - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/config" "github.com/jesseduffield/lazygit/pkg/constants" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/types" ) diff --git a/pkg/gui/layout.go b/pkg/gui/layout.go index 7ab7a88a0..21d83ca04 100644 --- a/pkg/gui/layout.go +++ b/pkg/gui/layout.go @@ -3,7 +3,7 @@ package gui import ( "errors" - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/samber/lo" ) diff --git a/pkg/gui/main_panels.go b/pkg/gui/main_panels.go index 30055e805..82f4fcac0 100644 --- a/pkg/gui/main_panels.go +++ b/pkg/gui/main_panels.go @@ -1,7 +1,7 @@ package gui import ( - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/types" ) diff --git a/pkg/gui/patch_exploring/state.go b/pkg/gui/patch_exploring/state.go index aab024ec4..5f1a29e61 100644 --- a/pkg/gui/patch_exploring/state.go +++ b/pkg/gui/patch_exploring/state.go @@ -4,8 +4,8 @@ import ( "strings" "github.com/jesseduffield/generics/set" - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands/patch" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/utils" "github.com/samber/lo" ) diff --git a/pkg/gui/popup/popup_handler.go b/pkg/gui/popup/popup_handler.go index d8824016f..ab067410d 100644 --- a/pkg/gui/popup/popup_handler.go +++ b/pkg/gui/popup/popup_handler.go @@ -5,8 +5,8 @@ import ( "errors" "strings" - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/common" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/style" "github.com/jesseduffield/lazygit/pkg/gui/types" ) diff --git a/pkg/gui/pty.go b/pkg/gui/pty.go index 66bb355f2..f6356b9c0 100644 --- a/pkg/gui/pty.go +++ b/pkg/gui/pty.go @@ -9,7 +9,7 @@ import ( "strings" "github.com/creack/pty" - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/utils" "github.com/samber/lo" ) diff --git a/pkg/gui/pty_windows.go b/pkg/gui/pty_windows.go index 39577a199..31d763870 100644 --- a/pkg/gui/pty_windows.go +++ b/pkg/gui/pty_windows.go @@ -4,7 +4,7 @@ import ( "fmt" "os/exec" - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" ) func (gui *Gui) onResize() error { diff --git a/pkg/gui/services/custom_commands/client.go b/pkg/gui/services/custom_commands/client.go index 12d8c7862..aceaef2dd 100644 --- a/pkg/gui/services/custom_commands/client.go +++ b/pkg/gui/services/custom_commands/client.go @@ -1,8 +1,8 @@ package custom_commands import ( - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/config" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers" "github.com/jesseduffield/lazygit/pkg/gui/keybindings" "github.com/jesseduffield/lazygit/pkg/gui/types" diff --git a/pkg/gui/services/custom_commands/handler_creator.go b/pkg/gui/services/custom_commands/handler_creator.go index a6634c07b..816435588 100644 --- a/pkg/gui/services/custom_commands/handler_creator.go +++ b/pkg/gui/services/custom_commands/handler_creator.go @@ -6,8 +6,8 @@ import ( "strings" "text/template" - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/config" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers" "github.com/jesseduffield/lazygit/pkg/gui/keybindings" "github.com/jesseduffield/lazygit/pkg/gui/style" diff --git a/pkg/gui/services/custom_commands/keybinding_creator.go b/pkg/gui/services/custom_commands/keybinding_creator.go index 259954c17..d7acbcacc 100644 --- a/pkg/gui/services/custom_commands/keybinding_creator.go +++ b/pkg/gui/services/custom_commands/keybinding_creator.go @@ -4,8 +4,8 @@ import ( "fmt" "strings" - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/config" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/context" "github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers" "github.com/jesseduffield/lazygit/pkg/gui/keybindings" diff --git a/pkg/gui/status/status_manager.go b/pkg/gui/status/status_manager.go index 40c68fe2d..2f822c1ee 100644 --- a/pkg/gui/status/status_manager.go +++ b/pkg/gui/status/status_manager.go @@ -3,8 +3,8 @@ package status import ( "time" - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/config" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/presentation" "github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/samber/lo" diff --git a/pkg/gui/tasks_adapter.go b/pkg/gui/tasks_adapter.go index 151d1566b..3bfc64100 100644 --- a/pkg/gui/tasks_adapter.go +++ b/pkg/gui/tasks_adapter.go @@ -5,7 +5,7 @@ import ( "os/exec" "strings" - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/tasks" ) diff --git a/pkg/gui/test_mode.go b/pkg/gui/test_mode.go index ef81e11cb..2ba381078 100644 --- a/pkg/gui/test_mode.go +++ b/pkg/gui/test_mode.go @@ -5,7 +5,7 @@ import ( "os" "time" - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/popup" "github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/jesseduffield/lazygit/pkg/integration/components" diff --git a/pkg/gui/types/common.go b/pkg/gui/types/common.go index 06c459add..1b06baa16 100644 --- a/pkg/gui/types/common.go +++ b/pkg/gui/types/common.go @@ -1,13 +1,13 @@ package types import ( - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands" "github.com/jesseduffield/lazygit/pkg/commands/git_commands" "github.com/jesseduffield/lazygit/pkg/commands/models" "github.com/jesseduffield/lazygit/pkg/commands/oscommands" "github.com/jesseduffield/lazygit/pkg/common" "github.com/jesseduffield/lazygit/pkg/config" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/tasks" "github.com/jesseduffield/lazygit/pkg/utils" "github.com/sasha-s/go-deadlock" diff --git a/pkg/gui/types/context.go b/pkg/gui/types/context.go index 5ef632196..4f1b90c64 100644 --- a/pkg/gui/types/context.go +++ b/pkg/gui/types/context.go @@ -1,8 +1,8 @@ package types import ( - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/config" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/patch_exploring" "github.com/jesseduffield/lazygit/pkg/i18n" "github.com/jesseduffield/lazygit/pkg/utils" diff --git a/pkg/gui/types/keybindings.go b/pkg/gui/types/keybindings.go index 9289dbe9a..aa3a95e7e 100644 --- a/pkg/gui/types/keybindings.go +++ b/pkg/gui/types/keybindings.go @@ -1,7 +1,7 @@ package types import ( - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/style" ) diff --git a/pkg/gui/types/views.go b/pkg/gui/types/views.go index 46a67d23a..c740ccb2e 100644 --- a/pkg/gui/types/views.go +++ b/pkg/gui/types/views.go @@ -1,6 +1,6 @@ package types -import "github.com/jesseduffield/gocui" +import "github.com/jesseduffield/lazygit/pkg/gocui" type Views struct { Status *gocui.View diff --git a/pkg/gui/view_helpers.go b/pkg/gui/view_helpers.go index b8ea49c44..453ccd6c9 100644 --- a/pkg/gui/view_helpers.go +++ b/pkg/gui/view_helpers.go @@ -3,7 +3,7 @@ package gui import ( "time" - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/context" "github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/jesseduffield/lazygit/pkg/tasks" diff --git a/pkg/gui/views.go b/pkg/gui/views.go index ba4b4373f..093257998 100644 --- a/pkg/gui/views.go +++ b/pkg/gui/views.go @@ -4,7 +4,7 @@ import ( "errors" "fmt" - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/context" "github.com/jesseduffield/lazygit/pkg/theme" "github.com/samber/lo" diff --git a/pkg/integration/clients/tui.go b/pkg/integration/clients/tui.go index 13b03726e..0f7a2b3fe 100644 --- a/pkg/integration/clients/tui.go +++ b/pkg/integration/clients/tui.go @@ -9,8 +9,8 @@ import ( "path/filepath" "strings" - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazycore/pkg/utils" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui" "github.com/jesseduffield/lazygit/pkg/gui/style" "github.com/jesseduffield/lazygit/pkg/integration/components" diff --git a/pkg/integration/components/test_test.go b/pkg/integration/components/test_test.go index ea1c79124..ab32f9f89 100644 --- a/pkg/integration/components/test_test.go +++ b/pkg/integration/components/test_test.go @@ -3,10 +3,10 @@ package components import ( "testing" - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands/git_commands" "github.com/jesseduffield/lazygit/pkg/commands/models" "github.com/jesseduffield/lazygit/pkg/config" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/types" integrationTypes "github.com/jesseduffield/lazygit/pkg/integration/types" "github.com/stretchr/testify/assert" diff --git a/pkg/integration/components/view_driver.go b/pkg/integration/components/view_driver.go index ea005d371..ee7c5b68a 100644 --- a/pkg/integration/components/view_driver.go +++ b/pkg/integration/components/view_driver.go @@ -4,7 +4,7 @@ import ( "fmt" "strings" - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/samber/lo" ) diff --git a/pkg/integration/components/views.go b/pkg/integration/components/views.go index 1d32f4828..90795d942 100644 --- a/pkg/integration/components/views.go +++ b/pkg/integration/components/views.go @@ -3,7 +3,7 @@ package components import ( "fmt" - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" ) type Views struct { diff --git a/pkg/integration/types/types.go b/pkg/integration/types/types.go index 9c4f057d2..752639058 100644 --- a/pkg/integration/types/types.go +++ b/pkg/integration/types/types.go @@ -1,9 +1,9 @@ package types import ( - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands/models" "github.com/jesseduffield/lazygit/pkg/config" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/types" ) diff --git a/pkg/tasks/async_handler.go b/pkg/tasks/async_handler.go index 658687af9..ab0770568 100644 --- a/pkg/tasks/async_handler.go +++ b/pkg/tasks/async_handler.go @@ -1,7 +1,7 @@ package tasks import ( - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/sasha-s/go-deadlock" ) diff --git a/pkg/tasks/async_handler_test.go b/pkg/tasks/async_handler_test.go index 6da363cd9..6b354d9c5 100644 --- a/pkg/tasks/async_handler_test.go +++ b/pkg/tasks/async_handler_test.go @@ -5,7 +5,7 @@ import ( "sync" "testing" - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/stretchr/testify/assert" ) diff --git a/pkg/tasks/tasks.go b/pkg/tasks/tasks.go index 5c5875fa8..74c639b24 100644 --- a/pkg/tasks/tasks.go +++ b/pkg/tasks/tasks.go @@ -8,8 +8,8 @@ import ( "sync" "time" - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands/oscommands" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/utils" "github.com/sasha-s/go-deadlock" "github.com/sirupsen/logrus" diff --git a/pkg/tasks/tasks_test.go b/pkg/tasks/tasks_test.go index 452b91eaf..40ff0033d 100644 --- a/pkg/tasks/tasks_test.go +++ b/pkg/tasks/tasks_test.go @@ -10,7 +10,7 @@ import ( "testing" "time" - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/utils" ) diff --git a/pkg/theme/gocui.go b/pkg/theme/gocui.go index 5f8e6a611..6d10f8666 100644 --- a/pkg/theme/gocui.go +++ b/pkg/theme/gocui.go @@ -2,7 +2,7 @@ package theme import ( "github.com/gookit/color" - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/utils" ) diff --git a/pkg/theme/theme.go b/pkg/theme/theme.go index acd8ebf71..d2e5b1291 100644 --- a/pkg/theme/theme.go +++ b/pkg/theme/theme.go @@ -1,8 +1,8 @@ package theme import ( - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/config" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/style" ) diff --git a/pkg/utils/lines_test.go b/pkg/utils/lines_test.go index 973310a33..2b97761d3 100644 --- a/pkg/utils/lines_test.go +++ b/pkg/utils/lines_test.go @@ -5,7 +5,7 @@ import ( "strings" "testing" - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/stretchr/testify/assert" ) diff --git a/pkg/utils/utils.go b/pkg/utils/utils.go index 7eb24b736..40411d520 100644 --- a/pkg/utils/utils.go +++ b/pkg/utils/utils.go @@ -9,7 +9,7 @@ import ( "strconv" "strings" - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" ) // GetProjectRoot returns the path to the root of the project. Only to be used diff --git a/vendor/github.com/jesseduffield/gocui/.gitignore b/vendor/github.com/jesseduffield/gocui/.gitignore deleted file mode 100644 index 1377554eb..000000000 --- a/vendor/github.com/jesseduffield/gocui/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.swp diff --git a/vendor/modules.txt b/vendor/modules.txt index 942160eb2..73ad86ab5 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -99,9 +99,6 @@ github.com/integrii/flaggy github.com/jesseduffield/generics/maps github.com/jesseduffield/generics/orderedset github.com/jesseduffield/generics/set -# github.com/jesseduffield/gocui v0.3.1-0.20260327132312-944dab3bc980 -## explicit; go 1.25 -github.com/jesseduffield/gocui # github.com/jesseduffield/lazycore v0.0.0-20221012050358-03d2e40243c5 ## explicit; go 1.18 github.com/jesseduffield/lazycore/pkg/boxlayout From cfcdcdb5beee2df9b2a741f39d420e8dcbd9ba81 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Tue, 7 Apr 2026 10:00:06 +0200 Subject: [PATCH 2/6] Fix linter warnings --- pkg/gocui/escape_test.go | 1 + pkg/gocui/gui.go | 4 ++-- pkg/gocui/gui_windows.go | 2 -- pkg/gocui/tcell_driver.go | 43 +++++++++++++++++---------------- pkg/gocui/text_area_test.go | 2 +- pkg/gocui/view.go | 48 +++++++++++++++++-------------------- 6 files changed, 49 insertions(+), 51 deletions(-) diff --git a/pkg/gocui/escape_test.go b/pkg/gocui/escape_test.go index 0073463c4..382d27bad 100644 --- a/pkg/gocui/escape_test.go +++ b/pkg/gocui/escape_test.go @@ -151,6 +151,7 @@ func TestParseOneColours(t *testing.T) { } func parseEscRunes(t *testing.T, ei *escapeInterpreter, runes string) { + t.Helper() for _, b := range []byte(runes) { isEscape, err := ei.parseOne([]byte{b}) assert.Equal(t, true, isEscape) diff --git a/pkg/gocui/gui.go b/pkg/gocui/gui.go index 0db418c67..81ddd4ce3 100644 --- a/pkg/gocui/gui.go +++ b/pkg/gocui/gui.go @@ -912,9 +912,9 @@ func calcScrollbarRune( ) rune { if showScrollbar && (position >= scrollbarStart && position <= scrollbarEnd) { return '▐' - } else { - return runeV } + + return runeV } func calcRealScrollbarStartEnd(v *View) (bool, int, int) { diff --git a/pkg/gocui/gui_windows.go b/pkg/gocui/gui_windows.go index 1934a40a9..d8c79ca12 100644 --- a/pkg/gocui/gui_windows.go +++ b/pkg/gocui/gui_windows.go @@ -13,9 +13,7 @@ import ( ) type ( - wchar uint16 short int16 - dword uint32 word uint16 ) diff --git a/pkg/gocui/tcell_driver.go b/pkg/gocui/tcell_driver.go index 6e9c12b4c..696975724 100644 --- a/pkg/gocui/tcell_driver.go +++ b/pkg/gocui/tcell_driver.go @@ -55,17 +55,20 @@ var runeReplacements = map[rune]string{ func (g *Gui) tcellInit(runeReplacements map[rune]string) error { tcell.SetEncodingFallback(tcell.EncodingFallbackASCII) - if s, e := tcell.NewScreen(); e != nil { + s, e := tcell.NewScreen() + if e != nil { return e - } else if e = s.Init(); e != nil { - return e - } else { - registerRuneFallbacks(s, runeReplacements) - - g.screen = s - Screen = s - return nil } + + if e = s.Init(); e != nil { + return e + } + + registerRuneFallbacks(s, runeReplacements) + + g.screen = s + Screen = s + return nil } func registerRuneFallbacks(s tcell.Screen, additional map[rune]string) { @@ -83,15 +86,15 @@ func (g *Gui) tcellInitSimulation(width int, height int) error { s := tcell.NewSimulationScreen("") if e := s.Init(); e != nil { return e - } else { - g.screen = s - Screen = s - // setting to a larger value than the typical terminal size - // so that during a test we're more likely to see an item to select in a view. - s.SetSize(width, height) - s.Sync() - return nil } + + g.screen = s + Screen = s + // setting to a larger value than the typical terminal size + // so that during a test we're more likely to see an item to select in a view. + s.SetSize(width, height) + s.Sync() + return nil } // tcellSetCell sets the character cell at a given location to the given @@ -194,9 +197,9 @@ const ( var ( lastMouseKey tcell.ButtonMask = tcell.ButtonNone lastMouseMod tcell.ModMask = tcell.ModNone - dragState int = NOT_DRAGGING - lastX int = 0 - lastY int = 0 + dragState = NOT_DRAGGING + lastX = 0 + lastY = 0 ) // this wrapper struct has public keys so we can easily serialize/deserialize to JSON diff --git a/pkg/gocui/text_area_test.go b/pkg/gocui/text_area_test.go index 618e1a02e..f0bc2fca8 100644 --- a/pkg/gocui/text_area_test.go +++ b/pkg/gocui/text_area_test.go @@ -1008,7 +1008,7 @@ func Test_AutoWrapContent(t *testing.T) { } } -var testContent string = `Lorem ipsum dolor sit amet, consectetur adipiscing elit. +var testContent = `Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque vehicula mi at elit pellentesque, eu pulvinar ligula molestie. In vitae orci vitae elit fermentum lobortis sed in nisi. Nam non odio nisi. diff --git a/pkg/gocui/view.go b/pkg/gocui/view.go index 16da0a380..1ef40e569 100644 --- a/pkg/gocui/view.go +++ b/pkg/gocui/view.go @@ -881,9 +881,9 @@ func (v *View) writeString(s string) { var linkStartChars = []string{"h", "t", "t", "p", "s", ":", "/", "/"} func findLinkStart(line []cell) int { - for i := 0; i < len(line)-len(linkStartChars); i++ { + for i := range len(line) - len(linkStartChars) { for j := range linkStartChars { - if line[i+j].chr != string(linkStartChars[j]) { + if line[i+j].chr != linkStartChars[j] { break } if j == len(linkStartChars)-1 { @@ -899,7 +899,7 @@ func findLinkStart(line []cell) int { // enough, because in markdown it's common to have a hyperlink followed by a // ')', so we want to stop there. Hopefully URLs containing ')' are uncommon // enough that this is not a problem. -var lineEndCharacters map[string]bool = map[string]bool{ +var lineEndCharacters = map[string]bool{ "": true, " ": true, "\n": true, @@ -927,7 +927,7 @@ func (v *View) autoRenderHyperlinksInCurrentLine() { if _, ok := lineEndCharacters[line[linkEnd].chr]; ok { break } - link.WriteString(string(line[linkEnd].chr)) + link.WriteString(line[linkEnd].chr) } for i := linkStart; i < linkEnd; i++ { v.lines[v.wy][i].hyperlink = link.String() @@ -988,7 +988,7 @@ func (v *View) parseInput(ch []byte, width int, x int, _ int) (bool, []cell) { chr: string(ch), width: width, } - for i := 0; i < repeatCount; i++ { + for range repeatCount { cells = append(cells, c) } } @@ -1265,21 +1265,17 @@ func (v *View) draw() { cellIdx := 0 var c cell - for { - if x >= maxX { - break - } - + for x < maxX { if x < 0 { if cellIdx < len(vline.line) { x += uniseg.StringWidth(vline.line[cellIdx].chr) cellIdx++ continue - } else { - // no more characters to write so we're only going to be printing empty cells - // past this point - x = 0 } + + // no more characters to write so we're only going to be printing empty cells + // past this point + x = 0 } // if we're out of cells to write, we'll just print empty cells. @@ -1424,7 +1420,7 @@ func (v *View) BufferLines() []string { lines := make([]string, len(v.lines)) for i, l := range v.lines { str := lineType(l).String() - str = strings.Replace(str, "\x00", "", -1) + str = strings.ReplaceAll(str, "\x00", "") lines[i] = str } return lines @@ -1447,7 +1443,7 @@ func (v *View) ViewBufferLines() []string { lines := make([]string, len(v.viewLines)) for i, l := range v.viewLines { str := lineType(l.line).String() - str = strings.Replace(str, "\x00", "", -1) + str = strings.ReplaceAll(str, "\x00", "") lines[i] = str } return lines @@ -1696,7 +1692,7 @@ func (v *View) SelectedLines() []string { func (v *View) lineContentAtIdx(idx int) string { line := v.lines[idx] str := lineType(line).String() - return strings.Replace(str, "\x00", "", -1) + return strings.ReplaceAll(str, "\x00", "") } func (v *View) SelectedPoint() (int, int) { @@ -1719,9 +1715,9 @@ func (v *View) SelectedLineRange() (int, int) { if start > end { return end, start - } else { - return start, end } + + return start, end } func (v *View) RenderTextArea() { @@ -1773,7 +1769,7 @@ func (v *View) overwriteLines(y int, content string) { v.wy = y v.clearViewLines() - lines := strings.Replace(content, "\n", "\x1b[K\n", -1) + lines := strings.ReplaceAll(content, "\n", "\x1b[K\n") // If the last line doesn't end with a linefeed, add the erase command at // the end too if !strings.HasSuffix(lines, "\n") { @@ -1799,7 +1795,7 @@ func (v *View) OverwriteLinesAndClearEverythingElse(lineCount int, y int, conten v.overwriteLines(y, content) - for i := 0; i < y; i += 1 { + for i := range y { v.lines[i] = nil } @@ -1924,9 +1920,9 @@ func (v *View) adjustDownwardScrollAmount(scrollHeight int) int { } if oy+scrollHeight < 0 { return 0 - } else { - return scrollHeight } + + return scrollHeight } // scrollMargin is about how many lines must still appear if you scroll @@ -1938,9 +1934,9 @@ func (v *View) scrollMargin() int { // we should make this into a field on the view to be configured by the client. // For now we're hardcoding it. return 2 - } else { - return 0 } + + return 0 } // Returns true if the view contains a line containing the given text with the given @@ -1966,7 +1962,7 @@ func containsColoredTextInLine(fgColorStr string, text string, line []cell) bool cellColor := tcell.NewHexColor(cell.fgColor.Hex()) if cellColor == fgColor { - currentMatch += string(cell.chr) + currentMatch += cell.chr } else if currentMatch != "" { if strings.Contains(currentMatch, text) { return true From d06522482f67f0bb9d3b8cb40410cb4a35a59db4 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Thu, 30 Apr 2026 22:10:09 +0200 Subject: [PATCH 3/6] Exclude gocui from codespell check It has too many typos that I don't care about fixing. --- .codespellrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.codespellrc b/.codespellrc index a51e62395..6a19c8348 100644 --- a/.codespellrc +++ b/.codespellrc @@ -1,6 +1,6 @@ [codespell] # Ref: https://github.com/codespell-project/codespell#using-a-config-file -skip = .git*,go.sum,*.lock,.codespellrc,vendor,translations,Keybindings_*.md +skip = .git*,go.sum,*.lock,.codespellrc,vendor,translations,Keybindings_*.md,./pkg/gocui check-hidden = true # camel-cased ignore-regex = (\b[A-Za-z][a-z]*[A-Z]\S+\b|\.edn\b|\S+…|\\nd\b) From 21e49dc3b7528ac3678f5550d07f98b4aca98c74 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Mon, 6 Apr 2026 20:07:24 +0200 Subject: [PATCH 4/6] Remove unused View.HasLoader functionality --- pkg/gocui/gui.go | 7 ------- pkg/gocui/loader.go | 31 ------------------------------- pkg/gocui/view.go | 10 +--------- 3 files changed, 1 insertion(+), 47 deletions(-) delete mode 100644 pkg/gocui/loader.go diff --git a/pkg/gocui/gui.go b/pkg/gocui/gui.go index 81ddd4ce3..646efc88a 100644 --- a/pkg/gocui/gui.go +++ b/pkg/gocui/gui.go @@ -1609,13 +1609,6 @@ func (g *Gui) StartTicking(ctx context.Context) { if g.suspended { continue outer } - - for _, view := range g.Views() { - if view.HasLoader { - g.UpdateAsync(func(g *Gui) error { return nil }) - continue outer - } - } return case <-ctx.Done(): return diff --git a/pkg/gocui/loader.go b/pkg/gocui/loader.go deleted file mode 100644 index 5f76db7ba..000000000 --- a/pkg/gocui/loader.go +++ /dev/null @@ -1,31 +0,0 @@ -package gocui - -import "time" - -func (v *View) loaderLines() [][]cell { - duplicate := make([][]cell, len(v.lines)) - for i := range v.lines { - if i < len(v.lines)-1 { - duplicate[i] = make([]cell, len(v.lines[i])) - copy(duplicate[i], v.lines[i]) - } else { - duplicate[i] = make([]cell, len(v.lines[i])+2) - copy(duplicate[i], v.lines[i]) - duplicate[i][len(duplicate[i])-2] = cell{chr: " "} - duplicate[i][len(duplicate[i])-1] = Loader() - } - } - - return duplicate -} - -// Loader can show a loading animation -func Loader() cell { - frames := []string{"|", "/", "-", "\\"} - now := time.Now() - nanos := now.UnixNano() - index := nanos / 50000000 % int64(len(frames)) - return cell{ - chr: frames[index], - } -} diff --git a/pkg/gocui/view.go b/pkg/gocui/view.go index 1ef40e569..697ca2029 100644 --- a/pkg/gocui/view.go +++ b/pkg/gocui/view.go @@ -164,9 +164,6 @@ type View struct { // Overlaps describes which edges are overlapping with another view's edges Overlaps byte - // If HasLoader is true, the message will be appended with a spinning loader animation - HasLoader bool - // ParentView is the view which catches events bubbled up from the given view if there's no matching handler ParentView *View @@ -1315,9 +1312,6 @@ func (v *View) refreshViewLinesIfNeeded() { maxX := v.InnerWidth() lineIdx := 0 lines := v.lines - if v.HasLoader { - lines = v.loaderLines() - } for i, line := range lines { wrap := 0 if v.Wrap { @@ -1336,9 +1330,7 @@ func (v *View) refreshViewLinesIfNeeded() { lineIdx++ } } - if !v.HasLoader { - v.tainted = false - } + v.tainted = false } } From 714a1baa430b97057e469577a1004c5ac8f1902e Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Tue, 7 Apr 2026 07:31:34 +0200 Subject: [PATCH 5/6] Remove unused StartTicking and tickingMutex --- pkg/gocui/gui.go | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/pkg/gocui/gui.go b/pkg/gocui/gui.go index 646efc88a..b9ecd090a 100644 --- a/pkg/gocui/gui.go +++ b/pkg/gocui/gui.go @@ -5,7 +5,6 @@ package gocui import ( - "context" standardErrors "errors" "runtime" "strings" @@ -95,10 +94,6 @@ type ViewMouseBindingOpts struct { } type GuiMutexes struct { - // tickingMutex ensures we don't have two loops ticking. The point of 'ticking' - // is to refresh the gui rapidly so that loader characters can be animated. - tickingMutex sync.Mutex - ViewsMutex sync.Mutex } @@ -1595,30 +1590,6 @@ func (g *Gui) onFocus(ev *GocuiEvent) error { return nil } -func (g *Gui) StartTicking(ctx context.Context) { - go func() { - g.Mutexes.tickingMutex.Lock() - defer g.Mutexes.tickingMutex.Unlock() - ticker := time.NewTicker(time.Millisecond * 50) - defer ticker.Stop() - outer: - for { - select { - case <-ticker.C: - // I'm okay with having a data race here: there's no harm in letting one of these updates through - if g.suspended { - continue outer - } - return - case <-ctx.Done(): - return - case <-g.stop: - return - } - } - }() -} - func (g *Gui) Suspend() error { g.suspendedMutex.Lock() defer g.suspendedMutex.Unlock() From fd52adc75298bd1528a22552e43b37ada9efc644 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Tue, 7 Apr 2026 07:28:55 +0200 Subject: [PATCH 6/6] Remove unused Parse/ParseAll and friends We will provide better ones in lazygit later. --- pkg/gocui/keybinding.go | 148 ---------------------------------------- 1 file changed, 148 deletions(-) diff --git a/pkg/gocui/keybinding.go b/pkg/gocui/keybinding.go index 0ad5dbe5c..283dcb822 100644 --- a/pkg/gocui/keybinding.go +++ b/pkg/gocui/keybinding.go @@ -5,8 +5,6 @@ package gocui import ( - "strings" - "github.com/gdamore/tcell/v2" ) @@ -26,71 +24,6 @@ type keybinding struct { handler func(*Gui, *View) error } -// Parse takes the input string and extracts the keybinding. -// Returns a Key / rune, a Modifier and an error. -func Parse(input string) (any, Modifier, error) { - if len(input) == 1 { - _, r, err := getKey(rune(input[0])) - if err != nil { - return nil, ModNone, err - } - return r, ModNone, nil - } - - var modifier Modifier - cleaned := make([]string, 0) - - tokens := strings.SplitSeq(input, "+") - for t := range tokens { - normalized := strings.Title(strings.ToLower(t)) - if t == "Alt" { - modifier = ModAlt - continue - } - cleaned = append(cleaned, normalized) - } - - key, exist := translate[strings.Join(cleaned, "")] - if !exist { - return nil, ModNone, ErrNoSuchKeybind - } - - return key, modifier, nil -} - -// ParseAll takes an array of strings and returns a map of all keybindings. -func ParseAll(input []string) (map[any]Modifier, error) { - ret := make(map[any]Modifier) - for _, i := range input { - k, m, err := Parse(i) - if err != nil { - return ret, err - } - ret[k] = m - } - return ret, nil -} - -// MustParse takes the input string and returns a Key / rune and a Modifier. -// It will panic if any error occured. -func MustParse(input string) (any, Modifier) { - k, m, err := Parse(input) - if err != nil { - panic(err) - } - return k, m -} - -// MustParseAll takes an array of strings and returns a map of all keybindings. -// It will panic if any error occured. -func MustParseAll(input []string) map[any]Modifier { - result, err := ParseAll(input) - if err != nil { - panic(err) - } - return result -} - // newKeybinding returns a new Keybinding object. func newKeybinding(viewname string, key Key, ch rune, mod Modifier, handler func(*Gui, *View) error) (kb *keybinding) { kb = &keybinding{ @@ -122,87 +55,6 @@ func (kb *keybinding) matchKeypress(key Key, ch rune, mod Modifier) bool { return kb.key == key && kb.ch == ch && kb.mod == mod } -// translations for strings to keys -var translate = map[string]Key{ - "F1": KeyF1, - "F2": KeyF2, - "F3": KeyF3, - "F4": KeyF4, - "F5": KeyF5, - "F6": KeyF6, - "F7": KeyF7, - "F8": KeyF8, - "F9": KeyF9, - "F10": KeyF10, - "F11": KeyF11, - "F12": KeyF12, - "Insert": KeyInsert, - "Delete": KeyDelete, - "Home": KeyHome, - "End": KeyEnd, - "Pgup": KeyPgup, - "Pgdn": KeyPgdn, - "ArrowUp": KeyArrowUp, - "ShiftArrowUp": KeyShiftArrowUp, - "ArrowDown": KeyArrowDown, - "ShiftArrowDown": KeyShiftArrowDown, - "ArrowLeft": KeyArrowLeft, - "ArrowRight": KeyArrowRight, - "CtrlTilde": KeyCtrlTilde, - "Ctrl2": KeyCtrl2, - "CtrlSpace": KeyCtrlSpace, - "CtrlA": KeyCtrlA, - "CtrlB": KeyCtrlB, - "CtrlC": KeyCtrlC, - "CtrlD": KeyCtrlD, - "CtrlE": KeyCtrlE, - "CtrlF": KeyCtrlF, - "CtrlG": KeyCtrlG, - "Backspace": KeyBackspace, - "CtrlH": KeyCtrlH, - "Tab": KeyTab, - "BackTab": KeyBacktab, - "CtrlI": KeyCtrlI, - "CtrlJ": KeyCtrlJ, - "CtrlK": KeyCtrlK, - "CtrlL": KeyCtrlL, - "Enter": KeyEnter, - "CtrlM": KeyCtrlM, - "CtrlN": KeyCtrlN, - "CtrlO": KeyCtrlO, - "CtrlP": KeyCtrlP, - "CtrlQ": KeyCtrlQ, - "CtrlR": KeyCtrlR, - "CtrlS": KeyCtrlS, - "CtrlT": KeyCtrlT, - "CtrlU": KeyCtrlU, - "CtrlV": KeyCtrlV, - "CtrlW": KeyCtrlW, - "CtrlX": KeyCtrlX, - "CtrlY": KeyCtrlY, - "CtrlZ": KeyCtrlZ, - "Esc": KeyEsc, - "CtrlLsqBracket": KeyCtrlLsqBracket, - "Ctrl3": KeyCtrl3, - "Ctrl4": KeyCtrl4, - "CtrlBackslash": KeyCtrlBackslash, - "Ctrl5": KeyCtrl5, - "CtrlRsqBracket": KeyCtrlRsqBracket, - "Ctrl6": KeyCtrl6, - "Ctrl7": KeyCtrl7, - "CtrlSlash": KeyCtrlSlash, - "CtrlUnderscore": KeyCtrlUnderscore, - "Space": KeySpace, - "Backspace2": KeyBackspace2, - "Ctrl8": KeyCtrl8, - "Mouseleft": MouseLeft, - "Mousemiddle": MouseMiddle, - "Mouseright": MouseRight, - "Mouserelease": MouseRelease, - "MousewheelUp": MouseWheelUp, - "MousewheelDown": MouseWheelDown, -} - // Special keys. const ( KeyF1 Key = Key(tcell.KeyF1)