From ad7703df65e09d23bb7e709ca9b22251673ac272 Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Sat, 26 Mar 2022 14:44:30 +1100 Subject: [PATCH] show namesake for child views --- docs/keybindings/Keybindings_en.md | 154 ++++------ docs/keybindings/Keybindings_nl.md | 170 +++++----- docs/keybindings/Keybindings_pl.md | 290 ++++++++---------- docs/keybindings/Keybindings_zh.md | 253 +++++++-------- pkg/cheatsheet/generate.go | 39 +-- pkg/cheatsheet/generate_test.go | 70 ++--- pkg/gui/commit_files_panel.go | 4 +- pkg/gui/context.go | 15 +- pkg/gui/context/branches_context.go | 10 + pkg/gui/context/commit_files_context.go | 9 +- pkg/gui/context/context.go | 19 +- pkg/gui/context/dynamic_title_builder.go | 23 ++ pkg/gui/context/local_commits_context.go | 10 + pkg/gui/context/reflog_commits_context.go | 10 + pkg/gui/context/remote_branches_context.go | 17 +- pkg/gui/context/stash_context.go | 10 + pkg/gui/context/sub_commits_context.go | 12 + pkg/gui/context/tags_context.go | 10 + .../controllers/local_commits_controller.go | 15 +- pkg/gui/controllers/remotes_controller.go | 5 + .../switch_to_diff_files_controller.go | 8 +- .../switch_to_sub_commits_controller.go | 2 + pkg/gui/controllers/types.go | 14 +- pkg/gui/gui.go | 71 +++-- pkg/gui/keybindings.go | 2 +- pkg/gui/layout.go | 5 +- pkg/gui/list_context_config.go | 2 +- pkg/gui/refresh.go | 2 + pkg/i18n/chinese.go | 2 +- pkg/i18n/dutch.go | 10 +- pkg/i18n/english.go | 26 +- .../reflogCommitFiles/recording.json | 126 +++++++- 32 files changed, 766 insertions(+), 649 deletions(-) create mode 100644 pkg/gui/context/dynamic_title_builder.go diff --git a/docs/keybindings/Keybindings_en.md b/docs/keybindings/Keybindings_en.md index 357468176..eda2fa1a4 100644 --- a/docs/keybindings/Keybindings_en.md +++ b/docs/keybindings/Keybindings_en.md @@ -41,7 +41,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct [: previous tab -## Branches Panel (Branches Tab) +## Branches
   ctrl+o: copy branch name to clipboard
@@ -62,56 +62,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
   enter: view commits
 
-## Branches Panel (Remote Branches (in Remotes tab)) - -
-  space: checkout
-  n: new branch
-  M: merge into currently checked out branch
-  r: rebase checked-out branch onto this branch
-  d: delete branch
-  u: set as upstream of checked-out branch
-  esc: Return to remotes list
-  g: view reset options
-  enter: view commits
-
- -## Branches Panel (Remotes Tab) - -
-  f: fetch remote
-  n: add new remote
-  d: remove remote
-  e: edit remote
-
- -## Branches Panel (Sub-commits) - -
-  ctrl+o: copy commit SHA to clipboard
-  space: checkout commit
-  y: copy commit attribute
-  o: open commit in browser
-  n: create new branch off of commit
-  g: reset to this commit
-  c: copy commit (cherry-pick)
-  C: copy commit range (cherry-pick)
-  ctrl+r: reset cherry-picked (copied) commits selection
-  enter: view selected item's files
-
- -## Branches Panel (Tags Tab) - -
-  space: checkout
-  d: delete tag
-  P: push tag
-  n: create tag
-  g: view reset options
-  enter: view commits
-
- -## Commit Files Panel (Commit Files) +## Commit Files
   ctrl+o: copy the committed file name to the clipboard
@@ -125,7 +76,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
   `: toggle file tree view
 
-## Commits Panel (Commits) +## Commits
   ctrl+o: copy commit SHA to clipboard
@@ -157,28 +108,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
   enter: view selected item's files
 
-## Commits Panel (Reflog Tab) - -
-  ctrl+o: copy commit SHA to clipboard
-  space: checkout commit
-  y: copy commit attribute
-  o: open commit in browser
-  n: create new branch off of commit
-  g: reset to this commit
-  c: copy commit (cherry-pick)
-  C: copy commit range (cherry-pick)
-  ctrl+r: reset cherry-picked (copied) commits selection
-  enter: view commits
-
- -## Extras Panel - -
-  @: open command log menu
-
- -## Files Panel (Files) +## Files
   ctrl+o: copy the file name to the clipboard
@@ -205,19 +135,6 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
   f: fetch
 
-## Files Panel (Submodules) - -
-  ctrl+o: copy submodule name to clipboard
-  enter: enter submodule
-  d: remove submodule
-  u: update submodule
-  n: add new submodule
-  e: update submodule URL
-  i: initialize submodule
-  b: view bulk submodule options
-
- ## Main Panel (Merging)
@@ -277,13 +194,42 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
   C: commit changes using git editor
 
-## Menu Panel +## Reflog
-  esc: close menu
+  ctrl+o: copy commit SHA to clipboard
+  space: checkout commit
+  g: view reset options
+  c: copy commit (cherry-pick)
+  C: copy commit range (cherry-pick)
+  ctrl+r: reset cherry-picked (copied) commits selection
+  enter: view commits
 
-## Stash Panel (Stash) +## Remote Branches + +
+  space: checkout
+  n: new branch
+  M: merge into currently checked out branch
+  r: rebase checked-out branch onto this branch
+  d: delete branch
+  u: set as upstream of checked-out branch
+  esc: Return to remotes list
+  g: view reset options
+  enter: view commits
+
+ +## Remotes + +
+  f: fetch remote
+  n: add new remote
+  d: remove remote
+  e: edit remote
+
+ +## Stash
   space: apply
@@ -293,7 +239,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
   enter: view selected item's files
 
-## Status Panel (Status) +## Status
   e: edit config file
@@ -303,7 +249,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
   a: show all branch logs
 
-## Sub-commits Panel (Sub-commits) +## Sub-commits
   ctrl+o: copy commit SHA to clipboard
@@ -315,3 +261,27 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
   ctrl+r: reset cherry-picked (copied) commits selection
   enter: view selected item's files
 
+ +## Submodules + +
+  ctrl+o: copy submodule name to clipboard
+  enter: enter submodule
+  d: remove submodule
+  u: update submodule
+  n: add new submodule
+  e: update submodule URL
+  i: initialize submodule
+  b: view bulk submodule options
+
+ +## Tags + +
+  space: checkout
+  d: delete tag
+  P: push tag
+  n: create tag
+  g: view reset options
+  enter: view commits
+
diff --git a/docs/keybindings/Keybindings_nl.md b/docs/keybindings/Keybindings_nl.md index 4764eb821..b6220463f 100644 --- a/docs/keybindings/Keybindings_nl.md +++ b/docs/keybindings/Keybindings_nl.md @@ -41,7 +41,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct [: vorige tabblad -## Bestanden Paneel (Bestanden) +## Bestanden
   ctrl+o: kopieer de bestandsnaam naar het klembord
@@ -68,20 +68,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
   f: fetch
 
-## Bestanden Paneel (Submodules) - -
-  ctrl+o: kopieer submodule naam naar klembord
-  enter: enter submodule
-  d: remove submodule
-  u: update submodule
-  n: voeg nieuwe submodule toe
-  e: update submodule URL
-  i: initialiseer submodule
-  b: bekijk bulk submodule opties
-
- -## Branches Paneel (Branches Tabblad) +## Branches
   ctrl+o: kopieer branch name naar klembord
@@ -102,56 +89,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
   enter: bekijk commits
 
-## Branches Paneel (Remote Branches (in Remotes tabblad)) - -
-  space: uitchecken
-  n: nieuwe branch
-  M: merge in met huidige checked out branch
-  r: rebase branch
-  d: verwijder branch
-  u: stel in als upstream van uitgecheckte branch
-  esc: ga terug naar remotes lijst
-  g: bekijk reset opties
-  enter: bekijk commits
-
- -## Branches Paneel (Remotes Tabblad) - -
-  f: fetch remote
-  n: voeg een nieuwe remote toe
-  d: verwijder remote
-  e: wijzig remote
-
- -## Branches Paneel (Sub-commits) - -
-  ctrl+o: kopieer commit SHA naar klembord
-  space: checkout commit
-  y: copy commit attribute
-  o: open commit in browser
-  n: creëer nieuwe branch van commit
-  g: reset naar deze commit
-  c: kopieer commit (cherry-pick)
-  C: kopieer commit reeks (cherry-pick)
-  ctrl+r: reset cherry-picked (gekopieerde) commits selectie
-  enter: bekijk gecommite bestanden
-
- -## Branches Paneel (Tags Tabblad) - -
-  space: uitchecken
-  d: verwijder tag
-  P: push tag
-  n: creëer tag
-  g: bekijk reset opties
-  enter: bekijk commits
-
- -## Commit bestanden Paneel (Commit bestanden) +## Commit bestanden
   ctrl+o: kopieer de vastgelegde bestandsnaam naar het klembord
@@ -165,7 +103,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
   `: toggle bestandsboom weergave
 
-## Commits Paneel (Commits) +## Commits
   ctrl+o: kopieer commit SHA naar klembord
@@ -197,28 +135,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
   enter: bekijk gecommite bestanden
 
-## Commits Paneel (Reflog Tabblad) - -
-  ctrl+o: kopieer commit SHA naar klembord
-  space: checkout commit
-  y: copy commit attribute
-  o: open commit in browser
-  n: creëer nieuwe branch van commit
-  g: reset naar deze commit
-  c: kopieer commit (cherry-pick)
-  C: kopieer commit reeks (cherry-pick)
-  ctrl+r: reset cherry-picked (gekopieerde) commits selectie
-  enter: bekijk commits
-
- -## Extras Paneel - -
-  @: open command log menu
-
- -## Hoofd Paneel (Mergen) +## Mergen
   esc: ga terug naar het bestanden paneel
@@ -232,14 +149,14 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
   z: ongedaan maken
 
-## Hoofd Paneel (Normaal) +## Normaal
   mouse wheel down: scroll omlaag (fn+up)
   mouse wheel up: scroll omhoog (fn+down)
 
-## Hoofd Paneel (Patch Bouwen) +## Patch Bouwen
   esc: sluit lijn-bij-lijn modus
@@ -255,7 +172,42 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
   a: toggle selecteer hunk
 
-## Hoofd Paneel (Staging) +## Reflog + +
+  ctrl+o: kopieer commit SHA naar klembord
+  space: checkout commit
+  g: bekijk reset opties
+  c: kopieer commit (cherry-pick)
+  C: kopieer commit reeks (cherry-pick)
+  ctrl+r: reset cherry-picked (gekopieerde) commits selectie
+  enter: bekijk commits
+
+ +## Remote Branches + +
+  space: uitchecken
+  n: nieuwe branch
+  M: merge in met huidige checked out branch
+  r: rebase branch
+  d: verwijder branch
+  u: stel in als upstream van uitgecheckte branch
+  esc: ga terug naar remotes lijst
+  g: bekijk reset opties
+  enter: bekijk commits
+
+ +## Remotes + +
+  f: fetch remote
+  n: voeg een nieuwe remote toe
+  d: verwijder remote
+  e: wijzig remote
+
+ +## Staging
   esc: ga terug naar het bestanden paneel
@@ -277,13 +229,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
   C: commit veranderingen met de git editor
 
-## Menu Paneel - -
-  esc: sluit menu
-
- -## Stash Paneel (Stash) +## Stash
   space: toepassen
@@ -293,7 +239,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
   enter: bekijk gecommite bestanden
 
-## Status Paneel (Status) +## Status
   e: verander config bestand
@@ -303,7 +249,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
   a: alle logs van de branch laten zien
 
-## Sub-commits Paneel (Sub-commits) +## Sub-commits
   ctrl+o: kopieer commit SHA naar klembord
@@ -315,3 +261,27 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
   ctrl+r: reset cherry-picked (gekopieerde) commits selectie
   enter: bekijk gecommite bestanden
 
+ +## Submodules + +
+  ctrl+o: kopieer submodule naam naar klembord
+  enter: enter submodule
+  d: remove submodule
+  u: update submodule
+  n: voeg nieuwe submodule toe
+  e: update submodule URL
+  i: initialiseer submodule
+  b: bekijk bulk submodule opties
+
+ +## Tags + +
+  space: uitchecken
+  d: verwijder tag
+  P: push tag
+  n: creëer tag
+  g: bekijk reset opties
+  enter: bekijk commits
+
diff --git a/docs/keybindings/Keybindings_pl.md b/docs/keybindings/Keybindings_pl.md index f7c9d726c..aa1b9295b 100644 --- a/docs/keybindings/Keybindings_pl.md +++ b/docs/keybindings/Keybindings_pl.md @@ -41,7 +41,28 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct [: previous tab -## Commity Panel (Commity) +## Branches + +
+  ctrl+o: copy branch name to clipboard
+  i: show git-flow options
+  space: przełącz
+  n: nowa gałąź
+  o: utwórz żądanie pobrania
+  O: utwórz opcje żądania ściągnięcia
+  ctrl+y: skopiuj adres URL żądania pobrania do schowka
+  c: przełącz używając nazwy
+  F: wymuś przełączenie
+  d: usuń gałąź
+  r: zmiana bazy gałęzi
+  M: scal do obecnej gałęzi
+  f: fast-forward this branch from its upstream
+  g: wyświetl opcje resetu
+  R: rename branch
+  enter: view commits
+
+ +## Commity
   ctrl+o: copy commit SHA to clipboard
@@ -73,98 +94,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
   enter: przeglądaj pliki commita
 
-## Commity Panel (Reflog Tab) - -
-  ctrl+o: copy commit SHA to clipboard
-  space: checkout commit
-  y: copy commit attribute
-  o: open commit in browser
-  n: create new branch off of commit
-  g: zresetuj do tego commita
-  c: kopiuj commit (przebieranie)
-  C: kopiuj zakres commitów (przebieranie)
-  ctrl+r: reset cherry-picked (copied) commits selection
-  enter: view commits
-
- -## Extras Panel - -
-  @: open command log menu
-
- -## Gałęzie Panel (Branches Tab) - -
-  ctrl+o: copy branch name to clipboard
-  i: show git-flow options
-  space: przełącz
-  n: nowa gałąź
-  o: utwórz żądanie pobrania
-  O: utwórz opcje żądania ściągnięcia
-  ctrl+y: skopiuj adres URL żądania pobrania do schowka
-  c: przełącz używając nazwy
-  F: wymuś przełączenie
-  d: usuń gałąź
-  r: zmiana bazy gałęzi
-  M: scal do obecnej gałęzi
-  f: fast-forward this branch from its upstream
-  g: wyświetl opcje resetu
-  R: rename branch
-  enter: view commits
-
- -## Gałęzie Panel (Remote Branches (in Remotes tab)) - -
-  space: przełącz
-  n: nowa gałąź
-  M: scal do obecnej gałęzi
-  r: zmiana bazy gałęzi
-  d: usuń gałąź
-  u: set as upstream of checked-out branch
-  esc: wróć do listy repozytoriów zdalnych
-  g: wyświetl opcje resetu
-  enter: view commits
-
- -## Gałęzie Panel (Remotes Tab) - -
-  f: fetch remote
-  n: add new remote
-  d: remove remote
-  e: edit remote
-
- -## Gałęzie Panel (Sub-commits) - -
-  ctrl+o: copy commit SHA to clipboard
-  space: checkout commit
-  y: copy commit attribute
-  o: open commit in browser
-  n: create new branch off of commit
-  g: zresetuj do tego commita
-  c: kopiuj commit (przebieranie)
-  C: kopiuj zakres commitów (przebieranie)
-  ctrl+r: reset cherry-picked (copied) commits selection
-  enter: przeglądaj pliki commita
-
- -## Gałęzie Panel (Tags Tab) - -
-  space: przełącz
-  d: delete tag
-  P: push tag
-  n: create tag
-  g: wyświetl opcje resetu
-  enter: view commits
-
- -## Główne Panel (Patch Building) +## Main Panel (Patch Building)
   esc: wyście z trybu "linia po linii"
@@ -180,56 +110,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
   a: toggle select hunk
 
-## Główne Panel (Poczekalnia) - -
-  esc: wróć do panelu plików
-  space: toggle line staged / unstaged
-  d: delete change (git reset)
-  tab: switch to other panel
-  o: otwórz plik
-  : poprzednia linia
-  : następna linia
-  : poprzedni kawałek
-  : następny kawałek
-  ctrl+o: copy the selected text to the clipboard
-  e: edytuj plik
-  v: toggle drag select
-  V: toggle drag select
-  a: toggle select hunk
-  c: Zatwierdź zmiany
-  w: zatwierdź zmiany bez skryptu pre-commit
-  C: Zatwierdź zmiany używając edytora
-
- -## Główne Panel (Scalanie) - -
-  esc: wróć do panelu plików
-  M: open external merge tool (git mergetool)
-  space: wybierz kawałek
-  b: wybierz wszystkie kawałki
-  : poprzedni konflikt
-  : następny konflikt
-  : wybierz poprzedni kawałek
-  : wybierz następny kawałek
-  z: cofnij
-
- -## Główne Panel (Zwykłe) - -
-  mouse wheel down: przewiń w dół (fn+up)
-  mouse wheel up: przewiń w górę (fn+down)
-
- -## Menu Panel - -
-  esc: close menu
-
- -## Pliki Panel (Pliki) +## Pliki
   ctrl+o: copy the file name to the clipboard
@@ -256,20 +137,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
   f: pobierz
 
-## Pliki Panel (Submodules) - -
-  ctrl+o: copy submodule name to clipboard
-  enter: enter submodule
-  d: remove submodule
-  u: update submodule
-  n: add new submodule
-  e: update submodule URL
-  i: initialize submodule
-  b: view bulk submodule options
-
- -## Pliki commita Panel (Pliki commita) +## Pliki commita
   ctrl+o: copy the committed file name to the clipboard
@@ -283,7 +151,78 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
   `: toggle file tree view
 
-## Schowek Panel (Schowek) +## Poczekalnia + +
+  esc: wróć do panelu plików
+  space: toggle line staged / unstaged
+  d: delete change (git reset)
+  tab: switch to other panel
+  o: otwórz plik
+  : poprzednia linia
+  : następna linia
+  : poprzedni kawałek
+  : następny kawałek
+  ctrl+o: copy the selected text to the clipboard
+  e: edytuj plik
+  v: toggle drag select
+  V: toggle drag select
+  a: toggle select hunk
+  c: Zatwierdź zmiany
+  w: zatwierdź zmiany bez skryptu pre-commit
+  C: Zatwierdź zmiany używając edytora
+
+ +## Reflog + +
+  ctrl+o: copy commit SHA to clipboard
+  space: checkout commit
+  g: wyświetl opcje resetu
+  c: kopiuj commit (przebieranie)
+  C: kopiuj zakres commitów (przebieranie)
+  ctrl+r: reset cherry-picked (copied) commits selection
+  enter: view commits
+
+ +## Remote Branches + +
+  space: przełącz
+  n: nowa gałąź
+  M: scal do obecnej gałęzi
+  r: zmiana bazy gałęzi
+  d: usuń gałąź
+  u: set as upstream of checked-out branch
+  esc: wróć do listy repozytoriów zdalnych
+  g: wyświetl opcje resetu
+  enter: view commits
+
+ +## Remotes + +
+  f: fetch remote
+  n: add new remote
+  d: remove remote
+  e: edit remote
+
+ +## Scalanie + +
+  esc: wróć do panelu plików
+  M: open external merge tool (git mergetool)
+  space: wybierz kawałek
+  b: wybierz wszystkie kawałki
+  : poprzedni konflikt
+  : następny konflikt
+  : wybierz poprzedni kawałek
+  : wybierz następny kawałek
+  z: cofnij
+
+ +## Schowek
   space: zastosuj
@@ -293,7 +232,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
   enter: przeglądaj pliki commita
 
-## Status Panel (Status) +## Status
   e: edytuj konfigurację
@@ -303,7 +242,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
   a: pokaż wszystkie logi gałęzi
 
-## Sub-commits Panel (Sub-commits) +## Sub-commits
   ctrl+o: copy commit SHA to clipboard
@@ -315,3 +254,34 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
   ctrl+r: reset cherry-picked (copied) commits selection
   enter: przeglądaj pliki commita
 
+ +## Submodules + +
+  ctrl+o: copy submodule name to clipboard
+  enter: enter submodule
+  d: remove submodule
+  u: update submodule
+  n: add new submodule
+  e: update submodule URL
+  i: initialize submodule
+  b: view bulk submodule options
+
+ +## Tags + +
+  space: przełącz
+  d: delete tag
+  P: push tag
+  n: create tag
+  g: wyświetl opcje resetu
+  enter: view commits
+
+ +## Zwykłe + +
+  mouse wheel down: przewiń w dół (fn+up)
+  mouse wheel up: przewiń w górę (fn+down)
+
diff --git a/docs/keybindings/Keybindings_zh.md b/docs/keybindings/Keybindings_zh.md index 7dc0d9f7b..3af2b795b 100644 --- a/docs/keybindings/Keybindings_zh.md +++ b/docs/keybindings/Keybindings_zh.md @@ -41,66 +41,19 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct [: 上一个标签 -## 主要 面板 (构建补丁中) +## Reflog 页面
-  esc: 退出逐行模式
-  o: 打开文件
-  : 选择上一行
-  : 选择下一行
-  : 选择上一个区块
-  : 选择下一个区块
-  ctrl+o: 将选中文本复制到剪贴板
-  space: 添加/移除 行到补丁
-  v: 切换拖动选择
-  V: 切换拖动选择
-  a: 切换选择区块
+  ctrl+o: 将提交的 SHA 复制到剪贴板
+  space: 检出提交
+  g: 查看重置选项
+  c: 复制提交(拣选)
+  C: 复制提交范围(拣选)
+  ctrl+r: 重置已拣选(复制)的提交
+  enter: 查看提交
 
-## 主要 面板 (正在合并) - -
-  esc: 返回文件面板
-  M: 打开外部合并工具 (git mergetool)
-  space: 选中区块
-  b: 选中所有区块
-  : 选择上一个冲突
-  : 选择下一个冲突
-  : 选择顶部块
-  : 选择底部块
-  z: 撤销
-
- -## 主要 面板 (正在暂存) - -
-  esc: 返回文件面板
-  space: 切换行暂存状态
-  d: 取消变更 (git reset)
-  tab: 切换到其他面板
-  o: 打开文件
-  : 选择上一行
-  : 选择下一行
-  : 选择上一个区块
-  : 选择下一个区块
-  ctrl+o: 将选中文本复制到剪贴板
-  e: 编辑文件
-  v: 切换拖动选择
-  V: 切换拖动选择
-  a: 切换选择区块
-  c: 提交更改
-  w: 提交更改而无需预先提交钩子
-  C: 提交更改(使用编辑器编辑提交信息)
-
- -## 主要 面板 (正常) - -
-  mouse wheel down: 向下滚动 (fn+up)
-  mouse wheel up: 向上滚动 (fn+down)
-
- -## 分支 面板 (分支页面) +## 分支页面
   ctrl+o: 将分支名称复制到剪贴板
@@ -121,7 +74,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
   enter: 查看提交
 
-## 分支 面板 (子提交) +## 子提交
   ctrl+o: 将提交的 SHA 复制到剪贴板
@@ -136,68 +89,20 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
   enter: 查看提交的文件
 
-## 分支 面板 (标签页面) +## 子模块
-  space: 检出
-  d: 删除标签
-  P: 推送标签
-  n: 创建标签
-  g: 查看重置选项
-  enter: 查看提交
+  ctrl+o: 将子模块名称复制到剪贴板
+  enter: 输入子模块
+  d: 删除子模块
+  u: 更新子模块
+  n: 添加新的子模块
+  e: 更新子模块 URL
+  i: 初始化子模块
+  b: 查看批量子模块选项
 
-## 分支 面板 (远程分支(在远程页面中)) - -
-  space: 检出
-  n: 新分支
-  M: 合并到当前检出的分支
-  r: 将已检出的分支变基到该分支
-  d: 删除分支
-  u: 设置为检出分支的上游
-  esc: 返回远程仓库列表
-  g: 查看重置选项
-  enter: 查看提交
-
- -## 分支 面板 (远程页面) - -
-  f: 抓取远程仓库
-  n: 添加新的远程仓库
-  d: 删除远程
-  e: 编辑远程仓库
-
- -## 提交 面板 (Reflog 页面) - -
-  ctrl+o: 将提交的 SHA 复制到剪贴板
-  space: 检出提交
-  y: copy commit attribute
-  o: 在浏览器中打开提交
-  n: 从提交创建新分支
-  g: 重置为此提交
-  c: 复制提交(拣选)
-  C: 复制提交范围(拣选)
-  ctrl+r: 重置已拣选(复制)的提交
-  enter: 查看提交的文件
-
- -## 提交 面板 (Reflog) - -
-  ctrl+o: 将提交的 SHA 复制到剪贴板
-  space: 检出提交
-  g: 查看重置选项
-  c: 复制提交(拣选)
-  C: 复制提交范围(拣选)
-  ctrl+r: 重置已拣选(复制)的提交
-  enter: 查看提交
-
- -## 提交 面板 (提交) +## 提交
   ctrl+o: 将提交的 SHA 复制到剪贴板
@@ -229,7 +134,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
   enter: 查看提交的文件
 
-## 提交文件 面板 (提交文件) +## 提交文件
   ctrl+o: 将提交的文件名复制到剪贴板
@@ -243,20 +148,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
   `: 切换文件树视图
 
-## 文件 面板 (子模块) - -
-  ctrl+o: 将子模块名称复制到剪贴板
-  enter: 输入子模块
-  d: 删除子模块
-  u: 更新子模块
-  n: 添加新的子模块
-  e: 更新子模块 URL
-  i: 初始化子模块
-  b: 查看批量子模块选项
-
- -## 文件 面板 (文件) +## 文件
   ctrl+o: 将文件名复制到剪贴板
@@ -283,7 +175,77 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
   f: 抓取
 
-## 状态 面板 (状态) +## 构建补丁中 + +
+  esc: 退出逐行模式
+  o: 打开文件
+  : 选择上一行
+  : 选择下一行
+  : 选择上一个区块
+  : 选择下一个区块
+  ctrl+o: 将选中文本复制到剪贴板
+  space: 添加/移除 行到补丁
+  v: 切换拖动选择
+  V: 切换拖动选择
+  a: 切换选择区块
+
+ +## 标签页面 + +
+  space: 检出
+  d: 删除标签
+  P: 推送标签
+  n: 创建标签
+  g: 查看重置选项
+  enter: 查看提交
+
+ +## 正在合并 + +
+  esc: 返回文件面板
+  M: 打开外部合并工具 (git mergetool)
+  space: 选中区块
+  b: 选中所有区块
+  : 选择上一个冲突
+  : 选择下一个冲突
+  : 选择顶部块
+  : 选择底部块
+  z: 撤销
+
+ +## 正在暂存 + +
+  esc: 返回文件面板
+  space: 切换行暂存状态
+  d: 取消变更 (git reset)
+  tab: 切换到其他面板
+  o: 打开文件
+  : 选择上一行
+  : 选择下一行
+  : 选择上一个区块
+  : 选择下一个区块
+  ctrl+o: 将选中文本复制到剪贴板
+  e: 编辑文件
+  v: 切换拖动选择
+  V: 切换拖动选择
+  a: 切换选择区块
+  c: 提交更改
+  w: 提交更改而无需预先提交钩子
+  C: 提交更改(使用编辑器编辑提交信息)
+
+ +## 正常 + +
+  mouse wheel down: 向下滚动 (fn+up)
+  mouse wheel up: 向上滚动 (fn+down)
+
+ +## 状态
   e: 编辑配置文件
@@ -293,13 +255,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
   a: 显示所有分支的日志
 
-## 菜单 面板 - -
-  esc: 关闭菜单
-
- -## 贮藏 面板 (贮藏) +## 贮藏
   space: 应用
@@ -309,8 +265,25 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
   enter: 查看提交的文件
 
-## 附加 面板 +## 远程分支
-  @: 打开命令日志菜单
+  space: 检出
+  n: 新分支
+  M: 合并到当前检出的分支
+  r: 将已检出的分支变基到该分支
+  d: 删除分支
+  u: 设置为检出分支的上游
+  esc: 返回远程仓库列表
+  g: 查看重置选项
+  enter: 查看提交
+
+ +## 远程页面 + +
+  f: 抓取远程仓库
+  n: 添加新的远程仓库
+  d: 删除远程
+  e: 编辑远程仓库
 
diff --git a/pkg/cheatsheet/generate.go b/pkg/cheatsheet/generate.go index d20a0c71a..6c641fa1f 100644 --- a/pkg/cheatsheet/generate.go +++ b/pkg/cheatsheet/generate.go @@ -131,16 +131,19 @@ func getBindingSections(bindings []*types.Binding, tr *i18n.TranslationSet) []*b return getHeaders(binding, tr) }) - bindingGroups := maps.MapToSlice(bindingsByHeader, func(header header, hBindings []*types.Binding) headerWithBindings { - uniqBindings := lo.UniqBy(hBindings, func(binding *types.Binding) string { - return binding.Description + gui.GetKeyDisplay(binding.Key) - }) + bindingGroups := maps.MapToSlice( + bindingsByHeader, + func(header header, hBindings []*types.Binding) headerWithBindings { + uniqBindings := lo.UniqBy(hBindings, func(binding *types.Binding) string { + return binding.Description + gui.GetKeyDisplay(binding.Key) + }) - return headerWithBindings{ - header: header, - bindings: uniqBindings, - } - }) + return headerWithBindings{ + header: header, + bindings: uniqBindings, + } + }, + ) slices.SortFunc(bindingGroups, func(a, b headerWithBindings) bool { if a.header.priority != b.header.priority { @@ -169,18 +172,11 @@ func getHeaders(binding *types.Binding, tr *i18n.TranslationSet) []header { } if len(binding.Contexts) == 0 { - translatedView := localisedTitle(tr, binding.ViewName) - title := fmt.Sprintf("%s %s", translatedView, tr.Panel) - - return []header{{priority: 1, title: title}} + return []header{} } return slices.Map(binding.Contexts, func(context string) header { - translatedView := localisedTitle(tr, binding.ViewName) - translatedContextName := localisedTitle(tr, context) - title := fmt.Sprintf("%s %s (%s)", translatedView, tr.Panel, translatedContextName) - - return header{priority: 1, title: title} + return header{priority: 1, title: localisedTitle(tr, context)} }) } @@ -205,7 +201,12 @@ func formatTitle(title string) string { func formatBinding(binding *types.Binding) string { if binding.Alternative != "" { - return fmt.Sprintf(" %s: %s (%s)\n", gui.GetKeyDisplay(binding.Key), binding.Description, binding.Alternative) + return fmt.Sprintf( + " %s: %s (%s)\n", + gui.GetKeyDisplay(binding.Key), + binding.Description, + binding.Alternative, + ) } return fmt.Sprintf(" %s: %s\n", gui.GetKeyDisplay(binding.Key), binding.Description) } diff --git a/pkg/cheatsheet/generate_test.go b/pkg/cheatsheet/generate_test.go index 94b571454..149ed28c7 100644 --- a/pkg/cheatsheet/generate_test.go +++ b/pkg/cheatsheet/generate_test.go @@ -26,43 +26,23 @@ func TestGetBindingSections(t *testing.T) { bindings: []*types.Binding{ { ViewName: "files", + Contexts: []string{"files"}, Description: "stage file", }, }, expected: []*bindingSection{ { - title: "Files Panel", + title: "Files", bindings: []*types.Binding{ { ViewName: "files", + Contexts: []string{"files"}, Description: "stage file", }, }, }, }, }, - { - testName: "one binding with context", - bindings: []*types.Binding{ - { - ViewName: "files", - Description: "stage file", - Contexts: []string{"submodules"}, - }, - }, - expected: []*bindingSection{ - { - title: "Files Panel (Submodules)", - bindings: []*types.Binding{ - { - ViewName: "files", - Description: "stage file", - Contexts: []string{"submodules"}, - }, - }, - }, - }, - }, { testName: "global binding", bindings: []*types.Binding{ @@ -101,23 +81,10 @@ func TestGetBindingSections(t *testing.T) { Description: "drop submodule", Contexts: []string{"submodules"}, }, - { - ViewName: "commits", - Description: "revert commit", - }, }, expected: []*bindingSection{ { - title: "Commits Panel", - bindings: []*types.Binding{ - { - ViewName: "commits", - Description: "revert commit", - }, - }, - }, - { - title: "Files Panel (Files)", + title: "Files", bindings: []*types.Binding{ { ViewName: "files", @@ -132,7 +99,7 @@ func TestGetBindingSections(t *testing.T) { }, }, { - title: "Files Panel (Submodules)", + title: "Submodules", bindings: []*types.Binding{ { ViewName: "files", @@ -148,19 +115,23 @@ func TestGetBindingSections(t *testing.T) { bindings: []*types.Binding{ { ViewName: "files", + Contexts: []string{"files"}, Description: "stage file", }, { ViewName: "files", + Contexts: []string{"files"}, Description: "unstage file", }, { ViewName: "files", + Contexts: []string{"files"}, Description: "scroll", Tag: "navigation", }, { ViewName: "commits", + Contexts: []string{"commits"}, Description: "revert commit", }, }, @@ -170,29 +141,33 @@ func TestGetBindingSections(t *testing.T) { bindings: []*types.Binding{ { ViewName: "files", + Contexts: []string{"files"}, Description: "scroll", Tag: "navigation", }, }, }, { - title: "Commits Panel", + title: "Commits", bindings: []*types.Binding{ { ViewName: "commits", + Contexts: []string{"commits"}, Description: "revert commit", }, }, }, { - title: "Files Panel", + title: "Files", bindings: []*types.Binding{ { ViewName: "files", + Contexts: []string{"files"}, Description: "stage file", }, { ViewName: "files", + Contexts: []string{"files"}, Description: "unstage file", }, }, @@ -204,28 +179,34 @@ func TestGetBindingSections(t *testing.T) { bindings: []*types.Binding{ { ViewName: "files", + Contexts: []string{"files"}, Description: "stage file", }, { ViewName: "files", + Contexts: []string{"files"}, Description: "unstage file", }, { ViewName: "files", + Contexts: []string{"files"}, Description: "scroll", Tag: "navigation", }, { ViewName: "commits", + Contexts: []string{"commits"}, Description: "revert commit", }, { ViewName: "commits", + Contexts: []string{"commits"}, Description: "scroll", Tag: "navigation", }, { ViewName: "commits", + Contexts: []string{"commits"}, Description: "page up", Tag: "navigation", }, @@ -236,34 +217,39 @@ func TestGetBindingSections(t *testing.T) { bindings: []*types.Binding{ { ViewName: "files", + Contexts: []string{"files"}, Description: "scroll", Tag: "navigation", }, { ViewName: "commits", + Contexts: []string{"commits"}, Description: "page up", Tag: "navigation", }, }, }, { - title: "Commits Panel", + title: "Commits", bindings: []*types.Binding{ { ViewName: "commits", + Contexts: []string{"commits"}, Description: "revert commit", }, }, }, { - title: "Files Panel", + title: "Files", bindings: []*types.Binding{ { ViewName: "files", + Contexts: []string{"files"}, Description: "stage file", }, { ViewName: "files", + Contexts: []string{"files"}, Description: "unstage file", }, }, diff --git a/pkg/gui/commit_files_panel.go b/pkg/gui/commit_files_panel.go index 4f292d3eb..a93486b07 100644 --- a/pkg/gui/commit_files_panel.go +++ b/pkg/gui/commit_files_panel.go @@ -41,6 +41,7 @@ func (gui *Gui) commitFilesRenderToMain() error { func (gui *Gui) SwitchToCommitFilesContext(opts controllers.SwitchToCommitFilesContextOpts) error { gui.State.Contexts.CommitFiles.SetSelectedLineIdx(0) gui.State.Contexts.CommitFiles.SetRefName(opts.RefName) + gui.State.Contexts.CommitFiles.SetTitleRef(opts.RefDescription) gui.State.Contexts.CommitFiles.SetCanRebase(opts.CanRebase) gui.State.Contexts.CommitFiles.SetParentContext(opts.Context) gui.State.Contexts.CommitFiles.SetWindowName(opts.Context.GetWindowName()) @@ -54,7 +55,8 @@ func (gui *Gui) SwitchToCommitFilesContext(opts controllers.SwitchToCommitFilesC func (gui *Gui) refreshCommitFilesContext() error { currentSideContext := gui.currentSideContext() - if currentSideContext.GetKey() == context.COMMIT_FILES_CONTEXT_KEY || currentSideContext.GetKey() == context.LOCAL_COMMITS_CONTEXT_KEY { + if currentSideContext.GetKey() == context.COMMIT_FILES_CONTEXT_KEY || + currentSideContext.GetKey() == context.LOCAL_COMMITS_CONTEXT_KEY { if err := gui.handleRefreshPatchBuildingPanel(-1); err != nil { return err } diff --git a/pkg/gui/context.go b/pkg/gui/context.go index c02411640..c63defba4 100644 --- a/pkg/gui/context.go +++ b/pkg/gui/context.go @@ -151,8 +151,7 @@ func (gui *Gui) deactivateContext(c types.Context) error { if view != nil && (c.GetKind() == types.TEMPORARY_POPUP || c.GetKind() == types.PERSISTENT_POPUP || - c.GetKey() == context.COMMIT_FILES_CONTEXT_KEY || - c.GetKey() == context.SUB_COMMITS_CONTEXT_KEY) { + c.IsTransient()) { view.Visible = false } @@ -393,11 +392,7 @@ func (gui *Gui) onViewFocusLost(oldView *gocui.View, newView *gocui.View) error _ = oldView.SetOriginX(0) if !lo.Contains([]*gocui.View{gui.Views.Main, gui.Views.Secondary, gui.Views.Search}, newView) { - transientContexts := slices.Filter(gui.State.Contexts.Flatten(), func(context types.Context) bool { - return context.IsTransient() - }) - - for _, context := range transientContexts { + for _, context := range gui.TransientContexts() { if oldView.Name() == context.GetViewName() { if err := gui.deactivateContext(context); err != nil { return err @@ -409,6 +404,12 @@ func (gui *Gui) onViewFocusLost(oldView *gocui.View, newView *gocui.View) error return nil } +func (gui *Gui) TransientContexts() []types.Context { + return slices.Filter(gui.State.Contexts.Flatten(), func(context types.Context) bool { + return context.IsTransient() + }) +} + // changeContext is a helper function for when we want to change a 'main' context // which currently just means a context that affects both the main and secondary views // other views can have their context changed directly but this function helps diff --git a/pkg/gui/context/branches_context.go b/pkg/gui/context/branches_context.go index e5de639d9..302f0c1d9 100644 --- a/pkg/gui/context/branches_context.go +++ b/pkg/gui/context/branches_context.go @@ -65,3 +65,13 @@ func (self *BranchesContext) GetSelectedRefName() string { return item.RefName() } + +func (self *BranchesContext) GetSelectedDescription() string { + item := self.GetSelected() + + if item == nil { + return "" + } + + return item.Description() +} diff --git a/pkg/gui/context/commit_files_context.go b/pkg/gui/context/commit_files_context.go index 5ad7144dc..c95486cbf 100644 --- a/pkg/gui/context/commit_files_context.go +++ b/pkg/gui/context/commit_files_context.go @@ -1,18 +1,16 @@ package context import ( - "fmt" - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands/models" "github.com/jesseduffield/lazygit/pkg/gui/filetree" "github.com/jesseduffield/lazygit/pkg/gui/types" - "github.com/jesseduffield/lazygit/pkg/utils" ) type CommitFilesContext struct { *filetree.CommitFileTreeViewModel *ListContextTrait + *DynamicTitleBuilder } var _ types.IListContext = (*CommitFilesContext)(nil) @@ -32,6 +30,7 @@ func NewCommitFilesContext( return &CommitFilesContext{ CommitFileTreeViewModel: viewModel, + DynamicTitleBuilder: NewDynamicTitleBuilder(c.Tr.CommitFilesDynamicTitle), ListContextTrait: &ListContextTrait{ Context: NewSimpleContext( NewBaseContext(NewBaseContextOpts{ @@ -63,7 +62,3 @@ func (self *CommitFilesContext) GetSelectedItemId() string { return item.ID() } - -func (self *CommitFilesContext) Title() string { - return fmt.Sprintf(self.c.Tr.CommitFilesDynamicTitle, utils.TruncateWithEllipsis(self.GetRefName(), 50)) -} diff --git a/pkg/gui/context/context.go b/pkg/gui/context/context.go index add336cfd..fb5a4bd64 100644 --- a/pkg/gui/context/context.go +++ b/pkg/gui/context/context.go @@ -152,11 +152,8 @@ func (tree ContextTree) InitialViewTabContextMap() map[string][]TabContext { Contexts: []types.Context{tree.Branches}, }, { - Tab: "Remotes", - Contexts: []types.Context{ - tree.Remotes, - tree.RemoteBranches, - }, + Tab: "Remotes", + Contexts: []types.Context{tree.Remotes}, }, { Tab: "Tags", @@ -169,10 +166,8 @@ func (tree ContextTree) InitialViewTabContextMap() map[string][]TabContext { Contexts: []types.Context{tree.LocalCommits}, }, { - Tab: "Reflog", - Contexts: []types.Context{ - tree.ReflogCommits, - }, + Tab: "Reflog", + Contexts: []types.Context{tree.ReflogCommits}, }, }, "files": { @@ -181,10 +176,8 @@ func (tree ContextTree) InitialViewTabContextMap() map[string][]TabContext { Contexts: []types.Context{tree.Files}, }, { - Tab: "Submodules", - Contexts: []types.Context{ - tree.Submodules, - }, + Tab: "Submodules", + Contexts: []types.Context{tree.Submodules}, }, }, } diff --git a/pkg/gui/context/dynamic_title_builder.go b/pkg/gui/context/dynamic_title_builder.go new file mode 100644 index 000000000..ee4facad2 --- /dev/null +++ b/pkg/gui/context/dynamic_title_builder.go @@ -0,0 +1,23 @@ +package context + +import "fmt" + +type DynamicTitleBuilder struct { + formatStr string // e.g. 'remote branches for %s' + + titleRef string // e.g. 'origin' +} + +func NewDynamicTitleBuilder(formatStr string) *DynamicTitleBuilder { + return &DynamicTitleBuilder{ + formatStr: formatStr, + } +} + +func (self *DynamicTitleBuilder) SetTitleRef(titleRef string) { + self.titleRef = titleRef +} + +func (self *DynamicTitleBuilder) Title() string { + return fmt.Sprintf(self.formatStr, self.titleRef) +} diff --git a/pkg/gui/context/local_commits_context.go b/pkg/gui/context/local_commits_context.go index cc7a2a0d2..0d7cc2f54 100644 --- a/pkg/gui/context/local_commits_context.go +++ b/pkg/gui/context/local_commits_context.go @@ -93,6 +93,16 @@ func (self *LocalCommitsContext) GetSelectedRefName() string { return item.RefName() } +func (self *LocalCommitsViewModel) GetSelectedDescription() string { + item := self.GetSelected() + + if item == nil { + return "" + } + + return item.Description() +} + func (self *LocalCommitsViewModel) SetLimitCommits(value bool) { self.limitCommits = value } diff --git a/pkg/gui/context/reflog_commits_context.go b/pkg/gui/context/reflog_commits_context.go index a1ad6cfda..0274a921e 100644 --- a/pkg/gui/context/reflog_commits_context.go +++ b/pkg/gui/context/reflog_commits_context.go @@ -74,3 +74,13 @@ func (self *ReflogCommitsContext) GetSelectedRefName() string { func (self *ReflogCommitsContext) GetCommits() []*models.Commit { return self.getModel() } + +func (self *ReflogCommitsContext) GetSelectedDescription() string { + item := self.GetSelected() + + if item == nil { + return "" + } + + return item.Description() +} diff --git a/pkg/gui/context/remote_branches_context.go b/pkg/gui/context/remote_branches_context.go index 3cdd43a69..52217ef11 100644 --- a/pkg/gui/context/remote_branches_context.go +++ b/pkg/gui/context/remote_branches_context.go @@ -9,6 +9,7 @@ import ( type RemoteBranchesContext struct { *BasicViewModel[*models.RemoteBranch] *ListContextTrait + *DynamicTitleBuilder } var _ types.IListContext = (*RemoteBranchesContext)(nil) @@ -27,14 +28,16 @@ func NewRemoteBranchesContext( viewModel := NewBasicViewModel(getModel) return &RemoteBranchesContext{ - BasicViewModel: viewModel, + BasicViewModel: viewModel, + DynamicTitleBuilder: NewDynamicTitleBuilder(c.Tr.RemoteBranchesDynamicTitle), ListContextTrait: &ListContextTrait{ Context: NewSimpleContext(NewBaseContext(NewBaseContextOpts{ - ViewName: "branches", + ViewName: "remoteBranches", WindowName: "branches", Key: REMOTE_BRANCHES_CONTEXT_KEY, Kind: types.SIDE_CONTEXT, Focusable: true, + Transient: true, }), ContextCallbackOpts{ OnFocus: onFocus, OnFocusLost: onFocusLost, @@ -65,3 +68,13 @@ func (self *RemoteBranchesContext) GetSelectedRefName() string { return item.RefName() } + +func (self *RemoteBranchesContext) GetSelectedDescription() string { + item := self.GetSelected() + + if item == nil { + return "" + } + + return item.Description() +} diff --git a/pkg/gui/context/stash_context.go b/pkg/gui/context/stash_context.go index e2af64d10..ef443846f 100644 --- a/pkg/gui/context/stash_context.go +++ b/pkg/gui/context/stash_context.go @@ -70,3 +70,13 @@ func (self *StashContext) GetSelectedRefName() string { return item.RefName() } + +func (self *StashContext) GetSelectedDescription() string { + item := self.GetSelected() + + if item == nil { + return "" + } + + return item.Description() +} diff --git a/pkg/gui/context/sub_commits_context.go b/pkg/gui/context/sub_commits_context.go index 6c1d5910f..ffc053267 100644 --- a/pkg/gui/context/sub_commits_context.go +++ b/pkg/gui/context/sub_commits_context.go @@ -12,6 +12,7 @@ import ( type SubCommitsContext struct { *SubCommitsViewModel *ViewportListContextTrait + *DynamicTitleBuilder } var _ types.IListContext = (*SubCommitsContext)(nil) @@ -34,6 +35,7 @@ func NewSubCommitsContext( return &SubCommitsContext{ SubCommitsViewModel: viewModel, + DynamicTitleBuilder: NewDynamicTitleBuilder(c.Tr.SubCommitsDynamicTitle), ViewportListContextTrait: &ViewportListContextTrait{ ListContextTrait: &ListContextTrait{ Context: NewSimpleContext(NewBaseContext(NewBaseContextOpts{ @@ -99,3 +101,13 @@ func (self *SubCommitsContext) GetCommits() []*models.Commit { func (self *SubCommitsContext) Title() string { return fmt.Sprintf(self.c.Tr.SubCommitsDynamicTitle, utils.TruncateWithEllipsis(self.refName, 50)) } + +func (self *SubCommitsContext) GetSelectedDescription() string { + item := self.GetSelected() + + if item == nil { + return "" + } + + return item.Description() +} diff --git a/pkg/gui/context/tags_context.go b/pkg/gui/context/tags_context.go index fd411ec9a..d6f8d78ac 100644 --- a/pkg/gui/context/tags_context.go +++ b/pkg/gui/context/tags_context.go @@ -65,3 +65,13 @@ func (self *TagsContext) GetSelectedRefName() string { return item.RefName() } + +func (self *TagsContext) GetSelectedDescription() string { + item := self.GetSelected() + + if item == nil { + return "" + } + + return item.Description() +} diff --git a/pkg/gui/controllers/local_commits_controller.go b/pkg/gui/controllers/local_commits_controller.go index 41433068d..1df223365 100644 --- a/pkg/gui/controllers/local_commits_controller.go +++ b/pkg/gui/controllers/local_commits_controller.go @@ -497,9 +497,7 @@ func (self *LocalCommitsController) createFixupCommit(commit *models.Commit) err func (self *LocalCommitsController) squashAllAboveFixupCommits(commit *models.Commit) error { prompt := utils.ResolvePlaceholderString( self.c.Tr.SureSquashAboveCommits, - map[string]string{ - "commit": commit.Sha, - }, + map[string]string{"commit": commit.Sha}, ) return self.c.Ask(types.AskOpts{ @@ -561,7 +559,9 @@ func (self *LocalCommitsController) handleOpenLogMenu() error { } return self.c.WithWaitingStatus(self.c.Tr.LcLoadingCommits, func() error { - return self.c.Refresh(types.RefreshOptions{Mode: types.SYNC, Scope: []types.RefreshableView{types.COMMITS}}) + return self.c.Refresh( + types.RefreshOptions{Mode: types.SYNC, Scope: []types.RefreshableView{types.COMMITS}}, + ) }) }, }, @@ -602,7 +602,12 @@ func (self *LocalCommitsController) handleOpenLogMenu() error { return func() error { self.c.UserConfig.Git.Log.Order = value return self.c.WithWaitingStatus(self.c.Tr.LcLoadingCommits, func() error { - return self.c.Refresh(types.RefreshOptions{Mode: types.SYNC, Scope: []types.RefreshableView{types.COMMITS}}) + return self.c.Refresh( + types.RefreshOptions{ + Mode: types.SYNC, + Scope: []types.RefreshableView{types.COMMITS}, + }, + ) }) } } diff --git a/pkg/gui/controllers/remotes_controller.go b/pkg/gui/controllers/remotes_controller.go index fd4b34297..208f36af7 100644 --- a/pkg/gui/controllers/remotes_controller.go +++ b/pkg/gui/controllers/remotes_controller.go @@ -73,6 +73,11 @@ func (self *RemotesController) enter(remote *models.Remote) error { newSelectedLine = -1 } self.contexts.RemoteBranches.SetSelectedLineIdx(newSelectedLine) + self.contexts.RemoteBranches.SetTitleRef(remote.Name) + + if err := self.c.PostRefreshUpdate(self.contexts.RemoteBranches); err != nil { + return err + } return self.c.PushContext(self.contexts.RemoteBranches) } diff --git a/pkg/gui/controllers/switch_to_diff_files_controller.go b/pkg/gui/controllers/switch_to_diff_files_controller.go index 9a3111cae..c41dbdd37 100644 --- a/pkg/gui/controllers/switch_to_diff_files_controller.go +++ b/pkg/gui/controllers/switch_to_diff_files_controller.go @@ -12,6 +12,7 @@ type CanSwitchToDiffFiles interface { types.Context CanRebase() bool GetSelectedRefName() string + GetSelectedDescription() string } type SwitchToDiffFilesController struct { @@ -63,9 +64,10 @@ func (self *SwitchToDiffFilesController) checkSelected(callback func(string) err func (self *SwitchToDiffFilesController) enter(refName string) error { return self.viewFiles(SwitchToCommitFilesContextOpts{ - RefName: refName, - CanRebase: self.context.CanRebase(), - Context: self.context, + RefName: refName, + RefDescription: self.context.GetSelectedDescription(), + CanRebase: self.context.CanRebase(), + Context: self.context, }) } diff --git a/pkg/gui/controllers/switch_to_sub_commits_controller.go b/pkg/gui/controllers/switch_to_sub_commits_controller.go index 82b52509b..d59f4fdbf 100644 --- a/pkg/gui/controllers/switch_to_sub_commits_controller.go +++ b/pkg/gui/controllers/switch_to_sub_commits_controller.go @@ -11,6 +11,7 @@ var _ types.IController = &SwitchToSubCommitsController{} type CanSwitchToSubCommits interface { types.Context GetSelectedRefName() string + GetSelectedDescription() string } type SwitchToSubCommitsController struct { @@ -74,6 +75,7 @@ func (self *SwitchToSubCommitsController) viewCommits() error { self.contexts.SubCommits.SetSelectedLineIdx(0) self.contexts.SubCommits.SetParentContext(self.context) self.contexts.SubCommits.SetWindowName(self.context.GetWindowName()) + self.contexts.SubCommits.SetTitleRef(self.context.GetSelectedDescription()) self.contexts.SubCommits.SetRefName(refName) err = self.c.PostRefreshUpdate(self.contexts.SubCommits) diff --git a/pkg/gui/controllers/types.go b/pkg/gui/controllers/types.go index 9783ca3b7..e9af41089 100644 --- a/pkg/gui/controllers/types.go +++ b/pkg/gui/controllers/types.go @@ -6,7 +6,17 @@ import ( // all fields mandatory (except `CanRebase` because it's boolean) type SwitchToCommitFilesContextOpts struct { - RefName string + // this is something like a commit sha or branch name + RefName string + + // this will be displayed in the title of the view so we know whose diff files + // we're viewing + RefDescription string + + // from the local commits view we're allowed to do rebase stuff with any patch + // we generate from the diff files context, but we don't have that same ability + // with say the sub commits context or the reflog context. CanRebase bool - Context types.Context + + Context types.Context } diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go index 334133487..b4e0f8de4 100644 --- a/pkg/gui/gui.go +++ b/pkg/gui/gui.go @@ -240,26 +240,27 @@ type panelStates struct { } type Views struct { - Status *gocui.View - Files *gocui.View - Branches *gocui.View - Commits *gocui.View - Stash *gocui.View - Main *gocui.View - Secondary *gocui.View - Options *gocui.View - Confirmation *gocui.View - Menu *gocui.View - CommitMessage *gocui.View - CommitFiles *gocui.View - SubCommits *gocui.View - Information *gocui.View - AppStatus *gocui.View - Search *gocui.View - SearchPrefix *gocui.View - Limit *gocui.View - Suggestions *gocui.View - Extras *gocui.View + Status *gocui.View + Files *gocui.View + Branches *gocui.View + RemoteBranches *gocui.View + Commits *gocui.View + Stash *gocui.View + Main *gocui.View + Secondary *gocui.View + Options *gocui.View + Confirmation *gocui.View + Menu *gocui.View + CommitMessage *gocui.View + CommitFiles *gocui.View + SubCommits *gocui.View + Information *gocui.View + AppStatus *gocui.View + Search *gocui.View + SearchPrefix *gocui.View + Limit *gocui.View + Suggestions *gocui.View + Extras *gocui.View } type searchingState struct { @@ -406,19 +407,20 @@ func (gui *Gui) syncViewContexts() { func initialViewContextMapping(contextTree *context.ContextTree) map[string]types.Context { return map[string]types.Context{ - "status": contextTree.Status, - "files": contextTree.Files, - "branches": contextTree.Branches, - "commits": contextTree.LocalCommits, - "commitFiles": contextTree.CommitFiles, - "subCommits": contextTree.SubCommits, - "stash": contextTree.Stash, - "menu": contextTree.Menu, - "confirmation": contextTree.Confirmation, - "commitMessage": contextTree.CommitMessage, - "main": contextTree.Normal, - "secondary": contextTree.Normal, - "extras": contextTree.CommandLog, + "status": contextTree.Status, + "files": contextTree.Files, + "branches": contextTree.Branches, + "remoteBranches": contextTree.RemoteBranches, + "commits": contextTree.LocalCommits, + "commitFiles": contextTree.CommitFiles, + "subCommits": contextTree.SubCommits, + "stash": contextTree.Stash, + "menu": contextTree.Menu, + "confirmation": contextTree.Confirmation, + "commitMessage": contextTree.CommitMessage, + "main": contextTree.Normal, + "secondary": contextTree.Normal, + "extras": contextTree.CommandLog, } } @@ -600,6 +602,7 @@ func (gui *Gui) createAllViews() error { {viewPtr: &gui.Views.Status, name: "status"}, {viewPtr: &gui.Views.Files, name: "files"}, {viewPtr: &gui.Views.Branches, name: "branches"}, + {viewPtr: &gui.Views.RemoteBranches, name: "remoteBranches"}, {viewPtr: &gui.Views.Commits, name: "commits"}, {viewPtr: &gui.Views.Stash, name: "stash"}, {viewPtr: &gui.Views.CommitFiles, name: "commitFiles"}, @@ -649,6 +652,8 @@ func (gui *Gui) createAllViews() error { gui.Views.Branches.Title = gui.c.Tr.BranchesTitle gui.Views.Branches.FgColor = theme.GocuiDefaultTextColor + gui.Views.RemoteBranches.FgColor = theme.GocuiDefaultTextColor + gui.Views.Files.Highlight = true gui.Views.Files.Title = gui.c.Tr.FilesTitle gui.Views.Files.FgColor = theme.GocuiDefaultTextColor diff --git a/pkg/gui/keybindings.go b/pkg/gui/keybindings.go index 122fbfd04..e19f42935 100644 --- a/pkg/gui/keybindings.go +++ b/pkg/gui/keybindings.go @@ -999,7 +999,7 @@ func (self *Gui) GetInitialKeybindings() ([]*types.Binding, []*gocui.ViewMouseBi mouseKeybindings = append(mouseKeybindings, c.GetMouseKeybindings(opts)...) } - for _, viewName := range []string{"status", "branches", "files", "commits", "commitFiles", "subCommits", "stash", "menu"} { + for _, viewName := range []string{"status", "branches", "remoteBranches", "files", "commits", "commitFiles", "subCommits", "stash", "menu"} { bindings = append(bindings, []*types.Binding{ {ViewName: viewName, Key: opts.GetKey(opts.Config.Universal.PrevBlock), Modifier: gocui.ModNone, Handler: self.previousSideWindow}, {ViewName: viewName, Key: opts.GetKey(opts.Config.Universal.NextBlock), Modifier: gocui.ModNone, Handler: self.nextSideWindow}, diff --git a/pkg/gui/layout.go b/pkg/gui/layout.go index c77c9030d..2fb165ff4 100644 --- a/pkg/gui/layout.go +++ b/pkg/gui/layout.go @@ -2,7 +2,6 @@ package gui import ( "github.com/jesseduffield/gocui" - "github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/jesseduffield/lazygit/pkg/theme" ) @@ -96,6 +95,7 @@ func (gui *Gui) layout(g *gocui.Gui) error { {viewName: "status", windowName: "status", frame: true}, {viewName: "files", windowName: "files", frame: true}, {viewName: "branches", windowName: "branches", frame: true}, + {viewName: "remoteBranches", windowName: "branches", frame: true}, {viewName: "commitFiles", windowName: gui.State.Contexts.CommitFiles.GetWindowName(), frame: true}, {viewName: "subCommits", windowName: gui.State.Contexts.SubCommits.GetWindowName(), frame: true}, {viewName: "commits", windowName: "commits", frame: true}, @@ -115,7 +115,7 @@ func (gui *Gui) layout(g *gocui.Gui) error { } } - for _, context := range []types.Context{gui.State.Contexts.SubCommits, gui.State.Contexts.CommitFiles} { + for _, context := range gui.TransientContexts() { view, err := gui.g.View(context.GetViewName()) if err != nil && err.Error() != UNKNOWN_VIEW_ERROR_MSG { return err @@ -211,6 +211,7 @@ func (gui *Gui) onInitialViewsCreation() error { gui.Views.Status, gui.Views.Files, gui.Views.Branches, + gui.Views.RemoteBranches, gui.Views.Commits, gui.Views.Stash, gui.Views.SubCommits, diff --git a/pkg/gui/list_context_config.go b/pkg/gui/list_context_config.go index b2f267a6a..e8a65d6da 100644 --- a/pkg/gui/list_context_config.go +++ b/pkg/gui/list_context_config.go @@ -71,7 +71,7 @@ func (gui *Gui) remotesListContext() *context.RemotesContext { func (gui *Gui) remoteBranchesListContext() *context.RemoteBranchesContext { return context.NewRemoteBranchesContext( func() []*models.RemoteBranch { return gui.State.Model.RemoteBranches }, - gui.Views.Branches, + gui.Views.RemoteBranches, func(startIdx int, length int) [][]string { return presentation.GetRemoteBranchListDisplayStrings(gui.State.Model.RemoteBranches, gui.State.Modes.Diffing.Ref) }, diff --git a/pkg/gui/refresh.go b/pkg/gui/refresh.go index f56cb55d7..244c0c050 100644 --- a/pkg/gui/refresh.go +++ b/pkg/gui/refresh.go @@ -187,6 +187,7 @@ func (gui *Gui) refreshCommits() { commit := gui.getSelectedLocalCommit() if commit != nil { gui.State.Contexts.CommitFiles.SetRefName(commit.RefName()) + gui.State.Contexts.CommitFiles.SetTitleRef(commit.RefName()) _ = gui.refreshCommitFilesContext() } } @@ -490,6 +491,7 @@ func (gui *Gui) refreshRemotes() error { for _, remote := range remotes { if remote.Name == prevSelectedRemote.Name { gui.State.Model.RemoteBranches = remote.Branches + break } } } diff --git a/pkg/i18n/chinese.go b/pkg/i18n/chinese.go index 400a12da6..3b33f3841 100644 --- a/pkg/i18n/chinese.go +++ b/pkg/i18n/chinese.go @@ -196,7 +196,7 @@ func chineseTranslationSet() TranslationSet { TagsTitle: "标签页面", MenuTitle: "菜单", RemotesTitle: "远程页面", - RemoteBranchesTitle: "远程分支(在远程页面中)", + RemoteBranchesTitle: "远程分支", PatchBuildingTitle: "构建补丁中", InformationTitle: "信息", SecondaryTitle: "次要", diff --git a/pkg/i18n/dutch.go b/pkg/i18n/dutch.go index c77321ae2..394b4abc4 100644 --- a/pkg/i18n/dutch.go +++ b/pkg/i18n/dutch.go @@ -156,16 +156,16 @@ func dutchTranslationSet() TranslationSet { MergeOptionsTitle: "Merge Opties", RebaseOptionsTitle: "Rebase Opties", CommitMessageTitle: "Commit Bericht", - LocalBranchesTitle: "Branches Tabblad", + LocalBranchesTitle: "Branches", SearchTitle: "Zoek", - TagsTitle: "Tags Tabblad", + TagsTitle: "Tags", MenuTitle: "Menu", - RemotesTitle: "Remotes Tabblad", - RemoteBranchesTitle: "Remote Branches (in Remotes tabblad)", + RemotesTitle: "Remotes", + RemoteBranchesTitle: "Remote Branches", PatchBuildingTitle: "Patch Bouwen", InformationTitle: "Informatie", SecondaryTitle: "Secondary", - ReflogCommitsTitle: "Reflog Tabblad", + ReflogCommitsTitle: "Reflog", GlobalTitle: "Globale Sneltoetsen", ConflictsResolved: "alle merge conflicten zijn opgelost. Wilt je verder gaan?", RebasingTitle: "Rebasen", diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go index a5cadb47d..678b8cd18 100644 --- a/pkg/i18n/english.go +++ b/pkg/i18n/english.go @@ -232,6 +232,7 @@ type TranslationSet struct { CommitFiles string SubCommitsDynamicTitle string CommitFilesDynamicTitle string + RemoteBranchesDynamicTitle string LcViewItemFiles string CommitFilesTitle string LcCheckoutCommitFile string @@ -611,9 +612,9 @@ func EnglishTranslationSet() TranslationSet { UnstagedChanges: `Unstaged Changes`, StagedChanges: `Staged Changes`, MainTitle: "Main", - StagingTitle: "Staging", - MergingTitle: "Merging", - NormalTitle: "Normal", + StagingTitle: "Main Panel (Staging)", + MergingTitle: "Main Panel (Merging)", + NormalTitle: "Main Panel (Normal)", CommitMessage: "Commit message", CredentialsUsername: "Username", CredentialsPassword: "Password", @@ -762,16 +763,16 @@ func EnglishTranslationSet() TranslationSet { MergeOptionsTitle: "Merge Options", RebaseOptionsTitle: "Rebase Options", CommitMessageTitle: "Commit Message", - LocalBranchesTitle: "Branches Tab", + LocalBranchesTitle: "Branches", SearchTitle: "Search", - TagsTitle: "Tags Tab", + TagsTitle: "Tags", MenuTitle: "Menu", - RemotesTitle: "Remotes Tab", - RemoteBranchesTitle: "Remote Branches (in Remotes tab)", - PatchBuildingTitle: "Patch Building", + RemotesTitle: "Remotes", + RemoteBranchesTitle: "Remote Branches", + PatchBuildingTitle: "Main Panel (Patch Building)", InformationTitle: "Information", SecondaryTitle: "Secondary", - ReflogCommitsTitle: "Reflog Tab", + ReflogCommitsTitle: "Reflog", GlobalTitle: "Global Keybindings", ConflictsResolved: "all merge conflicts resolved. Continue?", RebasingTitle: "Rebasing", @@ -821,8 +822,9 @@ func EnglishTranslationSet() TranslationSet { CheckingOutStatus: "checking out", CommittingStatus: "committing", CommitFiles: "Commit files", - SubCommitsDynamicTitle: "Commits for %s", - CommitFilesDynamicTitle: "Diff files for %s", + SubCommitsDynamicTitle: "Commits (%s)", + CommitFilesDynamicTitle: "Diff files (%s)", + RemoteBranchesDynamicTitle: "Remote branches (%s)", LcViewItemFiles: "view selected item's files", CommitFilesTitle: "Commit Files", LcCheckoutCommitFile: "checkout file", @@ -1010,7 +1012,7 @@ func EnglishTranslationSet() TranslationSet { NavigationTitle: "List Panel Navigation", SuggestionsCheatsheetTitle: "Suggestions", SuggestionsTitle: "Suggestions (press %s to focus)", - ExtrasTitle: "Extras", + ExtrasTitle: "Command Log", PushingTagStatus: "pushing tag", PullRequestURLCopiedToClipboard: "Pull request URL copied to clipboard", CommitDiffCopiedToClipboard: "Commit diff copied to clipboard", diff --git a/test/integration/reflogCommitFiles/recording.json b/test/integration/reflogCommitFiles/recording.json index bf91fbcf3..8339b7ea7 100644 --- a/test/integration/reflogCommitFiles/recording.json +++ b/test/integration/reflogCommitFiles/recording.json @@ -1 +1,125 @@ -{"KeyEvents":[{"Timestamp":608,"Mod":0,"Key":259,"Ch":0},{"Timestamp":768,"Mod":0,"Key":259,"Ch":0},{"Timestamp":1376,"Mod":0,"Key":256,"Ch":93},{"Timestamp":1817,"Mod":0,"Key":258,"Ch":0},{"Timestamp":2560,"Mod":0,"Key":13,"Ch":13},{"Timestamp":3271,"Mod":0,"Key":256,"Ch":32},{"Timestamp":3936,"Mod":2,"Key":16,"Ch":16},{"Timestamp":4680,"Mod":0,"Key":258,"Ch":0},{"Timestamp":4945,"Mod":0,"Key":258,"Ch":0},{"Timestamp":5216,"Mod":0,"Key":13,"Ch":13},{"Timestamp":5712,"Mod":0,"Key":260,"Ch":0},{"Timestamp":5952,"Mod":0,"Key":260,"Ch":0},{"Timestamp":6191,"Mod":0,"Key":256,"Ch":99},{"Timestamp":6456,"Mod":0,"Key":256,"Ch":97},{"Timestamp":6536,"Mod":0,"Key":256,"Ch":115},{"Timestamp":6647,"Mod":0,"Key":256,"Ch":100},{"Timestamp":6968,"Mod":0,"Key":13,"Ch":13},{"Timestamp":7376,"Mod":0,"Key":256,"Ch":113}],"ResizeEvents":[{"Timestamp":0,"Width":272,"Height":74}]} \ No newline at end of file +{ + "KeyEvents": [ + { + "Timestamp": 608, + "Mod": 0, + "Key": 259, + "Ch": 0 + }, + { + "Timestamp": 768, + "Mod": 0, + "Key": 259, + "Ch": 0 + }, + { + "Timestamp": 1376, + "Mod": 0, + "Key": 256, + "Ch": 93 + }, + { + "Timestamp": 1817, + "Mod": 0, + "Key": 258, + "Ch": 0 + }, + { + "Timestamp": 2560, + "Mod": 0, + "Key": 13, + "Ch": 13 + }, + { + "Timestamp": 2860, + "Mod": 0, + "Key": 13, + "Ch": 13 + }, + { + "Timestamp": 3271, + "Mod": 0, + "Key": 256, + "Ch": 32 + }, + { + "Timestamp": 3936, + "Mod": 2, + "Key": 16, + "Ch": 16 + }, + { + "Timestamp": 4680, + "Mod": 0, + "Key": 258, + "Ch": 0 + }, + { + "Timestamp": 4945, + "Mod": 0, + "Key": 258, + "Ch": 0 + }, + { + "Timestamp": 5216, + "Mod": 0, + "Key": 13, + "Ch": 13 + }, + { + "Timestamp": 5712, + "Mod": 0, + "Key": 260, + "Ch": 0 + }, + { + "Timestamp": 5952, + "Mod": 0, + "Key": 260, + "Ch": 0 + }, + { + "Timestamp": 6191, + "Mod": 0, + "Key": 256, + "Ch": 99 + }, + { + "Timestamp": 6456, + "Mod": 0, + "Key": 256, + "Ch": 97 + }, + { + "Timestamp": 6536, + "Mod": 0, + "Key": 256, + "Ch": 115 + }, + { + "Timestamp": 6647, + "Mod": 0, + "Key": 256, + "Ch": 100 + }, + { + "Timestamp": 6968, + "Mod": 0, + "Key": 13, + "Ch": 13 + }, + { + "Timestamp": 7376, + "Mod": 0, + "Key": 256, + "Ch": 113 + } + ], + "ResizeEvents": [ + { + "Timestamp": 0, + "Width": 272, + "Height": 74 + } + ] +}