Skip to content

Commit

Permalink
Ignore keypress if the viewport is not focused
Browse files Browse the repository at this point in the history
  • Loading branch information
andrea committed Apr 14, 2024
1 parent 28e6bae commit a8e4eda
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
7 changes: 7 additions & 0 deletions components/table/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,13 @@ func (t *Model) SetSize(w, h int) {
t.SetHeight(h)
}

func (m *Model) SetRelWidths(percentages ...int) {
m.RelWidths = make([]int, 0)
m.RelWidths = append(m.RelWidths, percentages...)

m.SetWidth(m.GetWidth())
}

func (m *Model) GetHeight() int {
return lipgloss.Height(m.View())
}
Expand Down
6 changes: 6 additions & 0 deletions components/viewport/viewport.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ func (m *Model) Init() tea.Cmd {

// Update updates the viewport model based on the received message.
func (m *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch msg.(type) {
case tea.KeyMsg:
if !m.focused {
return m, nil
}
}
t, cmd := m.Model.Update(msg)
m.Model = &t

Expand Down
7 changes: 1 addition & 6 deletions layout/layout.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ package layout
// for styling and resizing. The package is designed to work with the Lipgloss library
// for styling, providing a visually appealing interface.
import (
"log"

"github.com/charmbracelet/lipgloss"
)

Expand Down Expand Up @@ -109,10 +107,7 @@ func (l *Layout) SetSize(width int, height int) {
w := width - l.styles.Container.GetHorizontalFrameSize()
h := height - l.styles.Container.GetVerticalFrameSize()

for i, item := range l.items {
if i == 3 {
log.Println("Status W", w)
}
for _, item := range l.items {
item.SetWidth(w)
}

Expand Down

0 comments on commit a8e4eda

Please # to comment.