-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Add to padding to dropdown labels and fields
- Change active items on tab action
- Loading branch information
1 parent
d922e6f
commit 83d8a12
Showing
8 changed files
with
107 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package view | ||
|
||
import ( | ||
"github.com/derailed/tview" | ||
"github.com/gdamore/tcell/v2" | ||
) | ||
|
||
type Tab struct { | ||
*App | ||
items []tview.Primitive | ||
} | ||
|
||
func NewTab(app *App) *Tab { | ||
t := Tab{App: app, items: []tview.Primitive{}} | ||
t.Add() | ||
return &t | ||
} | ||
|
||
func (t *Tab) Add() { | ||
t.items = append(t.items, t.App.profile()) | ||
t.items = append(t.items, t.App.region()) | ||
} | ||
|
||
func (t *Tab) tabAction(event *tcell.EventKey) *tcell.EventKey { | ||
if t.InCmdMode() { | ||
return event | ||
} | ||
|
||
focusIdx := t.currentFocusIdx() | ||
|
||
if event.Key() == tcell.KeyTAB { | ||
if focusIdx + 1 == len(t.items) { | ||
t.App.Application.SetFocus(t.Content.Pages.Current()) | ||
return event | ||
} | ||
focusIdx = focusIdx + 1 | ||
} | ||
|
||
if focusIdx < 0 { | ||
focusIdx = 0 | ||
} | ||
t.App.Application.SetFocus(t.items[focusIdx]) | ||
return event | ||
} | ||
|
||
func (t *Tab) currentFocusIdx() int { | ||
focusIdx := -1 | ||
for i, p := range t.items { | ||
if p.HasFocus() { | ||
focusIdx = i | ||
break | ||
} | ||
} | ||
return focusIdx | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters