mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-15 06:04:40 +00:00
feat(tui): add circular wrap-around navigation to all menus (#82)
Co-authored-by: xes garcia <xes.garcia@deus.ai>
This commit is contained in:
parent
d2b60f11eb
commit
cc9773b34e
3 changed files with 12 additions and 12 deletions
|
|
@ -185,14 +185,14 @@ export class ModelSelectorComponent extends Container {
|
|||
}
|
||||
|
||||
handleInput(keyData: string): void {
|
||||
// Up arrow
|
||||
// Up arrow - wrap to bottom when at top
|
||||
if (keyData === "\x1b[A") {
|
||||
this.selectedIndex = Math.max(0, this.selectedIndex - 1);
|
||||
this.selectedIndex = this.selectedIndex === 0 ? this.filteredModels.length - 1 : this.selectedIndex - 1;
|
||||
this.updateList();
|
||||
}
|
||||
// Down arrow
|
||||
// Down arrow - wrap to top when at bottom
|
||||
else if (keyData === "\x1b[B") {
|
||||
this.selectedIndex = Math.min(this.filteredModels.length - 1, this.selectedIndex + 1);
|
||||
this.selectedIndex = this.selectedIndex === this.filteredModels.length - 1 ? 0 : this.selectedIndex + 1;
|
||||
this.updateList();
|
||||
}
|
||||
// Enter
|
||||
|
|
|
|||
|
|
@ -78,13 +78,13 @@ class UserMessageList implements Component {
|
|||
}
|
||||
|
||||
handleInput(keyData: string): void {
|
||||
// Up arrow - go to previous (older) message
|
||||
// Up arrow - go to previous (older) message, wrap to bottom when at top
|
||||
if (keyData === "\x1b[A") {
|
||||
this.selectedIndex = Math.max(0, this.selectedIndex - 1);
|
||||
this.selectedIndex = this.selectedIndex === 0 ? this.messages.length - 1 : this.selectedIndex - 1;
|
||||
}
|
||||
// Down arrow - go to next (newer) message
|
||||
// Down arrow - go to next (newer) message, wrap to top when at bottom
|
||||
else if (keyData === "\x1b[B") {
|
||||
this.selectedIndex = Math.min(this.messages.length - 1, this.selectedIndex + 1);
|
||||
this.selectedIndex = this.selectedIndex === this.messages.length - 1 ? 0 : this.selectedIndex + 1;
|
||||
}
|
||||
// Enter - select message and branch
|
||||
else if (keyData === "\r") {
|
||||
|
|
|
|||
|
|
@ -145,14 +145,14 @@ export class SelectList implements Component {
|
|||
}
|
||||
|
||||
handleInput(keyData: string): void {
|
||||
// Up arrow
|
||||
// Up arrow - wrap to bottom when at top
|
||||
if (keyData === "\x1b[A") {
|
||||
this.selectedIndex = Math.max(0, this.selectedIndex - 1);
|
||||
this.selectedIndex = this.selectedIndex === 0 ? this.filteredItems.length - 1 : this.selectedIndex - 1;
|
||||
this.notifySelectionChange();
|
||||
}
|
||||
// Down arrow
|
||||
// Down arrow - wrap to top when at bottom
|
||||
else if (keyData === "\x1b[B") {
|
||||
this.selectedIndex = Math.min(this.filteredItems.length - 1, this.selectedIndex + 1);
|
||||
this.selectedIndex = this.selectedIndex === this.filteredItems.length - 1 ? 0 : this.selectedIndex + 1;
|
||||
this.notifySelectionChange();
|
||||
}
|
||||
// Enter
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue