diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2021-08-31 15:38:52 +1000 |
---|---|---|
committer | Nathan Scott <nathans@redhat.com> | 2021-12-07 17:04:49 +1100 |
commit | 72ba20fa5f077bab4286dd78f9944df15de3b3b4 (patch) | |
tree | 0c4fb4e63b80b3a20d5f50bdac6bed9fe2bee607 /Panel.c | |
parent | ff4f44b22ae8d6522ee22599174a6cdd41bc0314 (diff) |
Introduce screen tabs
This is a forward port (by nathans) of Hisham's original code.
Diffstat (limited to 'Panel.c')
-rw-r--r-- | Panel.c | 21 |
1 files changed, 20 insertions, 1 deletions
@@ -49,6 +49,8 @@ void Panel_init(Panel* this, int x, int y, int w, int h, const ObjectClass* type this->y = y; this->w = w; this->h = h; + this->cursorX = 0; + this->cursorY = 0; this->eventHandlerState = NULL; this->items = Vector_new(type, owner, DEFAULT_SIZE); this->scrollV = 0; @@ -72,6 +74,11 @@ void Panel_done(Panel* this) { RichString_delete(&this->header); } +void Panel_setCursorToSelection(Panel* this) { + this->cursorY = this->y + this->selected - this->scrollV + 1; + this->cursorX = this->x + this->selectedLen - this->scrollH; +} + void Panel_setSelectionColor(Panel* this, ColorElements colorId) { this->selectionColorId = colorId; } @@ -330,7 +337,6 @@ void Panel_draw(Panel* this, bool force_redraw, bool focus, bool highlightSelect this->oldSelected = this->selected; this->wasFocus = focus; this->needsRedraw = false; - move(0, 0); } static int Panel_headerHeight(const Panel* this) { @@ -485,3 +491,16 @@ HandlerResult Panel_selectByTyping(Panel* this, int ch) { return IGNORED; } + +int Panel_getCh(Panel* this) { + if (this->cursorOn) { + move(this->cursorY, this->cursorX); + curs_set(1); + } else { + curs_set(0); + } +#ifdef HAVE_SET_ESCDELAY + set_escdelay(25); +#endif + return getch(); +} |