[PR #56] [MERGED] Add GetOffset method on Table #847

Closed
opened 2026-03-04 01:08:13 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/rivo/tview/pull/56
Author: @sachaos
Created: 2/11/2018
Status: Merged
Merged: 2/13/2018
Merged by: @rivo

Base: masterHead: master


📝 Commits (1)

  • 453c374 Add GetOffset method on Table

📊 Changes

1 file changed (+6 additions, -0 deletions)

View changed files

📝 table.go (+6 -0)

📄 Description

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)
		}

		...							
	})

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/rivo/tview/pull/56 **Author:** [@sachaos](https://github.com/sachaos) **Created:** 2/11/2018 **Status:** ✅ Merged **Merged:** 2/13/2018 **Merged by:** [@rivo](https://github.com/rivo) **Base:** `master` ← **Head:** `master` --- ### 📝 Commits (1) - [`453c374`](https://github.com/rivo/tview/commit/453c374c1c9fd8bfca0104e1c30dd33d2cb4ef3b) Add GetOffset method on Table ### 📊 Changes **1 file changed** (+6 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `table.go` (+6 -0) </details> ### 📄 Description 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 ```go 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) } ... }) ``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-04 01:08:13 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/tview#847
No description provided.