Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions editor_workspace.v
Original file line number Diff line number Diff line change
Expand Up @@ -243,13 +243,87 @@ fn (mut m EditorWorkspaceModel) update(msg tea.Msg) (tea.Model, ?tea.Cmd) {
}
}
}
// NOTE(tauraamui):
// This whole horrible event handling for 'nav' state is not intended to stay around. I cba to
// fully explain, but the reason this is here is, I personally configure my TMUX prefix bind to be
// C-w instead of C-b (the default), to allow me to use the same binds for navigating between (n)vim
// splits and TMUX splits seemlessly/together. However, I have no current method to distinguish forwarding
// C-w + h/j/k/l binds to Lilly or petal (Lilly v2), so for now it helps a lot if there's two methods/binds
// for petal to allow navigating between splits. Hope this helps.
.navigation {
match msg.k_type {
.special {
if msg.string() == 'escape' {
cmds << switch_mode(.normal)
}
}
.runes {
match msg.string() {
'h' {
// move to previous split (left)
if m.split_tree.count() > 1 {
old_id := m.split_tree.active_editor_id
moved := m.split_tree.navigate_prev(m.tmux_wrapped)

if moved == false {
os.execute('tmux select-pane -L')
} else {
new_id := m.split_tree.active_editor_id
m.active_editor_id = new_id

cmds << tea.sequence(
unfocus_editor(old_id),
focus_editor(new_id),
query_editor_data(new_id),
query_pwd_git_branch
)
}
} else {
if m.tmux_wrapped {
os.execute('tmux select-pane -L')
}
}
}
'l' {
// move to next split (right)
if m.split_tree.count() > 1 {
old_id := m.split_tree.active_editor_id
moved := m.split_tree.navigate_next(m.tmux_wrapped)
if moved == false {
os.execute('tmux select-pane -R')
} else {
new_id := m.split_tree.active_editor_id
m.active_editor_id = new_id

cmds << tea.sequence(
unfocus_editor(old_id),
focus_editor(new_id),
query_editor_data(new_id),
query_pwd_git_branch
)
}
} else {
if m.tmux_wrapped {
os.execute('tmux select-pane -R')
}
}
}
else {}
}
}
}
cmds << switch_mode(.normal)
}
.normal {
match msg.k_type {
.special {
match msg.string() {
"escape" {
cmds << hide_error
}
"ctrl+b" {
cmds << switch_mode(.navigation)
}
"ctrl+w+h" {
// move to previous split (left)
if m.split_tree.count() > 1 {
Expand Down
3 changes: 3 additions & 0 deletions mode.v
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ enum Mode as u8 {
insert
visual
visual_line
navigation
}

fn (m Mode) color() tea.Color {
Expand All @@ -20,6 +21,7 @@ fn (m Mode) color() tea.Color {
.insert { palette.status_orange }
.visual { palette.status_lilac }
.visual_line { palette.status_lilac }
.navigation { palette.status_cyan }
}
}

Expand All @@ -31,6 +33,7 @@ fn (m Mode) str() string {
.insert { 'INSERT' }
.visual { 'VISUAL' }
.visual_line { 'VISUAL LINE' }
.navigation { 'NAVIGATION' }
}
}