Skip to content

Commit 924e52d

Browse files
committed
feat: allow setting of fixed columns in the list of issues
1 parent 84206aa commit 924e52d

File tree

3 files changed

+24
-9
lines changed

3 files changed

+24
-9
lines changed

internal/cmd/issue/list/list.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@ func loadList(cmd *cobra.Command) {
116116
noTruncate, err := cmd.Flags().GetBool("no-truncate")
117117
cmdutil.ExitIfError(err)
118118

119+
fixedColumns, err := cmd.Flags().GetUint("fixed-columns")
120+
cmdutil.ExitIfError(err)
121+
119122
columns, err := cmd.Flags().GetString("columns")
120123
cmdutil.ExitIfError(err)
121124

@@ -128,9 +131,10 @@ func loadList(cmd *cobra.Command) {
128131
loadList(cmd)
129132
},
130133
Display: view.DisplayFormat{
131-
Plain: plain,
132-
NoHeaders: noHeaders,
133-
NoTruncate: noTruncate,
134+
Plain: plain,
135+
NoHeaders: noHeaders,
136+
NoTruncate: noTruncate,
137+
FixedColumns: fixedColumns,
134138
Columns: func() []string {
135139
if columns != "" {
136140
return strings.Split(columns, ",")
@@ -178,6 +182,7 @@ func SetFlags(cmd *cobra.Command) {
178182
cmd.Flags().Bool("plain", false, "Display output in plain mode")
179183
cmd.Flags().Bool("no-headers", false, "Don't display table headers in plain mode. Works only with --plain")
180184
cmd.Flags().Bool("no-truncate", false, "Show all available columns in plain mode. Works only with --plain")
185+
cmd.Flags().Uint("fixed-columns", 1, "Number of fixed columns in the interactive mode.")
181186

182187
if cmd.HasParent() && cmd.Parent().Name() != "sprint" {
183188
cmd.Flags().String("columns", "", "Comma separated list of columns to display in the plain mode.\n"+

internal/view/issues.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@ import (
1515

1616
// DisplayFormat is a issue display type.
1717
type DisplayFormat struct {
18-
Plain bool
19-
NoHeaders bool
20-
NoTruncate bool
21-
Columns []string
22-
TableStyle tui.TableStyle
18+
Plain bool
19+
NoHeaders bool
20+
NoTruncate bool
21+
Columns []string
22+
FixedColumns uint
23+
TableStyle tui.TableStyle
2324
}
2425

2526
// IssueList is a list view for issues.
@@ -73,6 +74,7 @@ func (l *IssueList) Render() error {
7374
tui.WithCopyFunc(copyURL(l.Server)),
7475
tui.WithCopyKeyFunc(copyKey()),
7576
tui.WithRefreshFunc(l.Refresh),
77+
tui.WithFixedColumns(l.Display.FixedColumns),
7678
)
7779

7880
return view.Paint(data)

pkg/tui/table.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ type Table struct {
4949
style TableStyle
5050
data TableData
5151
colPad uint
52+
colFixed uint
5253
maxColWidth uint
5354
footerText string
5455
selectedFunc SelectedFunc
@@ -141,6 +142,13 @@ func WithCopyKeyFunc(fn CopyKeyFunc) TableOption {
141142
}
142143
}
143144

145+
// WithFixedColumns sets the number of columns that are locked (do not scroll right).
146+
func WithFixedColumns(cols uint) TableOption {
147+
return func(t *Table) {
148+
t.colFixed = cols
149+
}
150+
}
151+
144152
// Paint paints the table layout. First row is treated as a table header.
145153
func (t *Table) Paint(data TableData) error {
146154
if len(data) == 0 {
@@ -229,7 +237,7 @@ func (t *Table) initTable() {
229237
return ev
230238
})
231239

232-
t.view.SetFixed(1, 1)
240+
t.view.SetFixed(1, int(t.colFixed))
233241
}
234242

235243
func renderTableHeader(t *Table, data []string) {

0 commit comments

Comments
 (0)