Issue 23: Added progress indicators and cancellation (#34)
- Wrapped all table operations in a new foreground job context, which mediates foreground tasks. - Added cancellation support and partial results for table read operations. - Added the "mark" command, which can mark, unmark & toggle marked items - Added support for alias arguments. - Removed the "unmark" command, and replaced it as an alias to the "marked" command - Fixed seg faults raised when there is no table shown in the result set.
This commit is contained in:
parent
982d3a9ca7
commit
79692302af
29 changed files with 609 additions and 170 deletions
|
|
@ -5,6 +5,10 @@ type columnModel struct {
|
|||
}
|
||||
|
||||
func (cm columnModel) Len() int {
|
||||
if len(cm.m.columns) == 0 {
|
||||
return 0
|
||||
}
|
||||
|
||||
return len(cm.m.columns[cm.m.colOffset:]) + 1
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -118,6 +118,10 @@ func (m *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|||
}
|
||||
|
||||
func (m *Model) setLeftmostDisplayedColumn(newCol int) {
|
||||
if m.columnsProvider == nil || m.columnsProvider.Columns() == nil {
|
||||
return
|
||||
}
|
||||
|
||||
if newCol < 0 {
|
||||
m.colOffset = 0
|
||||
} else if newCol >= len(m.columnsProvider.Columns().Columns) {
|
||||
|
|
@ -163,11 +167,8 @@ func (m *Model) rebuildTable(targetTbl *table.Model) {
|
|||
|
||||
// Use the target table model if you can, but if it's nil or the number of rows is smaller than the
|
||||
// existing table, create a new one
|
||||
if targetTbl == nil || len(resultSet.Items()) > len(m.rows) {
|
||||
if targetTbl == nil {
|
||||
tbl = table.New(columnModel{m}, m.w, m.h-m.frameTitle.HeaderHeight())
|
||||
if targetTbl != nil {
|
||||
tbl.GoBottom()
|
||||
}
|
||||
} else {
|
||||
tbl = *targetTbl
|
||||
}
|
||||
|
|
@ -191,6 +192,7 @@ func (m *Model) rebuildTable(targetTbl *table.Model) {
|
|||
|
||||
m.rows = newRows
|
||||
tbl.SetRows(newRows)
|
||||
tbl.GoTop() // Preserve top and cursor location
|
||||
|
||||
m.table = tbl
|
||||
}
|
||||
|
|
@ -205,6 +207,12 @@ func (m *Model) SelectedItemIndex() int {
|
|||
|
||||
func (m *Model) selectedItem() (itemTableRow, bool) {
|
||||
resultSet := m.resultSet
|
||||
|
||||
// Fix bug??
|
||||
if m.table.Cursor() < 0 {
|
||||
return itemTableRow{}, false
|
||||
}
|
||||
|
||||
if resultSet != nil && len(m.rows) > 0 {
|
||||
selectedItem, ok := m.table.SelectedRow().(itemTableRow)
|
||||
if ok {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue