Documentation
¶
Overview ¶
Package textsel provides a `tview.TextView` widget that supports selecting text with the keyboard.
Index ¶
- type TextSel
- func (ts *TextSel) FinishSelection() *TextSel
- func (ts *TextSel) GetCursorPosition() (int, int)
- func (ts *TextSel) GetSelectedText() string
- func (ts *TextSel) GetSelectionRange() (int, int, int, int)
- func (ts *TextSel) GetText(stripFormatting bool) string
- func (ts *TextSel) MoveDown() *TextSel
- func (ts *TextSel) MoveLeft() *TextSel
- func (ts *TextSel) MoveRight() *TextSel
- func (ts *TextSel) MoveToEndOfLine() *TextSel
- func (ts *TextSel) MoveToFirstLine() *TextSel
- func (ts *TextSel) MoveToLastLine() *TextSel
- func (ts *TextSel) MoveToStartOfLine() *TextSel
- func (ts *TextSel) MoveUp() *TextSel
- func (ts *TextSel) ResetCursor() *TextSel
- func (ts *TextSel) ResetSelection() *TextSel
- func (ts *TextSel) SetCursorPosition(row int, col int) *TextSel
- func (ts *TextSel) SetSelectFunc(f func(string)) *TextSel
- func (ts *TextSel) SetText(text string) *TextSel
- func (ts *TextSel) StartSelection() *TextSel
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type TextSel ¶
TextSel is a `tview.TextView` widget that supports selecting text with the keyboard.
func NewTextSel ¶
func NewTextSel() *TextSel
NewTextSel creates and returns a new TextSel instance.
Example:
textSel := textsel.NewTextSel().SetText("Hello, World!")
func (*TextSel) FinishSelection ¶ added in v0.1.6
Finishes the selection process and calls the selectFunc callback.
func (*TextSel) GetCursorPosition ¶ added in v0.1.6
Returns the current cursor position as row and column.
func (*TextSel) GetSelectedText ¶
GetSelectedText returns the currently selected text. If no text is selected, an empty string is returned.
Example:
selectedText := textSel.GetSelectedText() fmt.Println("Selected text:", selectedText)
func (*TextSel) GetSelectionRange ¶ added in v0.1.6
GetSelectionRange returns the start and end row and column of the current selection. Note that if the selection range is backwards (e.g. the selection began at (1, 5) and ends at (0, 0)), the values will be swapped so that the first point always preceeds the second.
func (*TextSel) GetText ¶ added in v0.1.3
GetText returns the text content of the TextSel widget. If `stripFormatting` is true, any format codes in the text will be removed.
Example:
text := textSel.GetText(false)
func (*TextSel) MoveLeft ¶ added in v0.1.6
Moves the cursor left by one column, wrapping to the previous row if necessary.
func (*TextSel) MoveRight ¶ added in v0.1.6
Moves the cursor right by one column, wrapping to the next row if necessary.
func (*TextSel) MoveToEndOfLine ¶ added in v0.1.6
Moves the cursor to the end of the current line.
func (*TextSel) MoveToFirstLine ¶ added in v0.1.7
Moves the cursor to the first line of the text. The current column is preserved if it is within the bounds of the first line. Otherwise, the cursor is placed at the end of the first line.
func (*TextSel) MoveToLastLine ¶ added in v0.1.7
Moves the cursor to the last line of the text. The current column is preserved if it is within the bounds of the last line. Otherwise, the cursor is placed at the end of the last line.
func (*TextSel) MoveToStartOfLine ¶ added in v0.1.6
Moves the cursor to the start of the current line.
func (*TextSel) ResetCursor ¶ added in v0.1.6
Resets the cursor position to the beginning of the text.
func (*TextSel) ResetSelection ¶ added in v0.1.6
Resets the selection state.
func (*TextSel) SetCursorPosition ¶ added in v0.1.6
func (*TextSel) SetSelectFunc ¶
SetSelectFunc sets the callback function that will be called when text is selected.
Example:
textSel.SetSelectFunc(func(selectedText string) { fmt.Println("Selected text:\n\n", selectedText) })
func (*TextSel) SetText ¶
SetText sets the text content of the TextSel widget, resetting the cursor position and selection state.
Example:
textSel.SetText("New text content")
func (*TextSel) StartSelection ¶ added in v0.1.6
Starts the selection process at the current position in the document.