WIP: almost working selected rows
This commit is contained in:
parent
b6e195c10b
commit
bc7c635aac
13
main.go
13
main.go
|
@ -2,26 +2,25 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os/exec"
|
table "git.sealight.xyz/aynish/poms/table"
|
||||||
"log"
|
task "git.sealight.xyz/aynish/poms/task"
|
||||||
tea "github.com/charmbracelet/bubbletea"
|
tea "github.com/charmbracelet/bubbletea"
|
||||||
"github.com/charmbracelet/lipgloss"
|
"github.com/charmbracelet/lipgloss"
|
||||||
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
"os/exec"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
task "git.sealight.xyz/aynish/poms/task"
|
|
||||||
table "git.sealight.xyz/aynish/poms/table"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
tasks = task.GetTasks()
|
tasks = task.GetTasks()
|
||||||
columns = []table.Column{
|
columns = []table.Column{
|
||||||
{Title: "ID", Width: 4},
|
{Title: "ID", Width: 4},
|
||||||
{Title: "Project", Width: 20},
|
{Title: "Project", Width: 20},
|
||||||
{Title: "Tags", Width: 40},
|
{Title: "Tags", Width: 20},
|
||||||
{Title: "Description", Width: 95},
|
{Title: "Description", Width: 35},
|
||||||
// {Title: "Urgency", Width: 10},
|
// {Title: "Urgency", Width: 10},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -278,10 +278,15 @@ func (m *Model) UpdateViewport() {
|
||||||
// Render only rows from: m.cursor-m.viewport.Height to: m.cursor+m.viewport.Height
|
// Render only rows from: m.cursor-m.viewport.Height to: m.cursor+m.viewport.Height
|
||||||
// Constant runtime, independent of number of rows in a table.
|
// Constant runtime, independent of number of rows in a table.
|
||||||
// Limits the number of renderedRows to a maximum of 2*m.viewport.Height
|
// Limits the number of renderedRows to a maximum of 2*m.viewport.Height
|
||||||
|
if m.activeIndex > 0 {
|
||||||
|
for i := 0; i < m.activeIndex; i++ {
|
||||||
|
renderedRows = append(renderedRows, m.renderRow(i))
|
||||||
|
}
|
||||||
|
}
|
||||||
if m.cursor >= 0 {
|
if m.cursor >= 0 {
|
||||||
m.start = clamp(m.cursor-m.viewport.Height, 0, m.cursor)
|
m.start = clamp(m.cursor-m.viewport.Height, 0, m.cursor) + m.activeIndex
|
||||||
} else {
|
} else {
|
||||||
m.start = 0
|
m.start = 0 + m.activeIndex
|
||||||
}
|
}
|
||||||
m.end = clamp(m.cursor+m.viewport.Height, m.cursor, len(m.rows))
|
m.end = clamp(m.cursor+m.viewport.Height, m.cursor, len(m.rows))
|
||||||
for i := m.start; i < m.end; i++ {
|
for i := m.start; i < m.end; i++ {
|
||||||
|
@ -396,10 +401,10 @@ func (m *Model) MoveUp(n int) {
|
||||||
switch {
|
switch {
|
||||||
case m.start == 0:
|
case m.start == 0:
|
||||||
m.viewport.SetYOffset(clamp(m.viewport.YOffset, 0, m.cursor))
|
m.viewport.SetYOffset(clamp(m.viewport.YOffset, 0, m.cursor))
|
||||||
case m.start < m.viewport.Height:
|
//case m.start < m.viewport.Height:
|
||||||
m.viewport.YOffset = (clamp(clamp(m.viewport.YOffset+n, 0, m.cursor), 0, m.viewport.Height))
|
// m.viewport.YOffset = (clamp(clamp(m.viewport.YOffset+n, 0, m.cursor), 0, m.viewport.Height))
|
||||||
case m.viewport.YOffset >= 1:
|
//case m.viewport.YOffset >= 1:
|
||||||
m.viewport.YOffset = clamp(m.viewport.YOffset+n, 1, m.viewport.Height)
|
// m.viewport.YOffset = clamp(m.viewport.YOffset+n, 1, m.viewport.Height)
|
||||||
}
|
}
|
||||||
m.UpdateViewport()
|
m.UpdateViewport()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue