Skip to content

Add GetOffset method on Table#56

Merged
rivo merged 1 commit intorivo:masterfrom
sachaos:master
Feb 13, 2018
Merged

Add GetOffset method on Table#56
rivo merged 1 commit intorivo:masterfrom
sachaos:master

Conversation

@sachaos
Copy link
Copy Markdown
Contributor

@sachaos sachaos commented Feb 11, 2018

Firstly, Thank you for your great job!

I propose GetOffset method for Table struct.

Context

I'm developping application which switching between force scrolling mode and row selectable mode dynamically. (like a less +F command option)
I was trying to get current visible rows & cols number and set the top of the visible rows as selected row, by func (t *Table) Select(row, column int) *Table.
But the rowOffset, columnOffset field was private, and no getter method for these.
So I implemented the getter method.

Use case

	table.SetDoneFunc(func(key tcell.Key) {
		...

		if key == tcell.KeyEnter {
			table.SetSelectable(true, false)
			table.Select(table.GetOffset()) // Set the top of visible rows as selected row.
		}

		if key == tcell.KeyEscape {
			table.SetSelectable(false, false)
		}

		...							
	})

@rivo rivo merged commit 2a7e773 into rivo:master Feb 13, 2018
@rivo
Copy link
Copy Markdown
Owner

rivo commented Feb 13, 2018

Yes, this is a good idea, thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants