summaryrefslogtreecommitdiffstats
path: root/ScreensPanel.c
diff options
context:
space:
mode:
authorBenny Baumann <BenBE@geshi.org>2023-11-23 12:22:02 +0100
committerBenBE <BenBE@geshi.org>2023-12-26 15:14:19 +0100
commit6aa9ef2726e42c4ae062b55be4d5cc015767d997 (patch)
treed5bd033946b404fa99b70b0b1c560725cef302bf /ScreensPanel.c
parenta98fc47ffe67e88b1a83f94382795b8787a9bfe8 (diff)
Fix code style
Diffstat (limited to 'ScreensPanel.c')
-rw-r--r--ScreensPanel.c107
1 files changed, 46 insertions, 61 deletions
diff --git a/ScreensPanel.c b/ScreensPanel.c
index 69d1aeb1..bf08f2e6 100644
--- a/ScreensPanel.c
+++ b/ScreensPanel.c
@@ -71,49 +71,48 @@ static HandlerResult ScreensPanel_eventHandlerRenaming(Panel* super, int ch) {
super->selectedLen = strlen(this->buffer);
Panel_setCursorToSelection(super);
}
- } else {
- switch (ch) {
- case 127:
- case KEY_BACKSPACE:
- {
- if (this->cursor > 0) {
- this->cursor--;
- this->buffer[this->cursor] = '\0';
- super->selectedLen = strlen(this->buffer);
- Panel_setCursorToSelection(super);
- }
- break;
+
+ return HANDLED;
+ }
+
+ switch (ch) {
+ case 127:
+ case KEY_BACKSPACE:
+ if (this->cursor > 0) {
+ this->cursor--;
+ this->buffer[this->cursor] = '\0';
+ super->selectedLen = strlen(this->buffer);
+ Panel_setCursorToSelection(super);
}
- case '\n':
- case '\r':
- case KEY_ENTER:
- {
- ListItem* item = (ListItem*) Panel_getSelected(super);
- if (!item)
- break;
- assert(item == this->renamingItem);
- free(this->saved);
- item->value = xStrdup(this->buffer);
- this->renamingItem = NULL;
- super->cursorOn = false;
- Panel_setSelectionColor(super, PANEL_SELECTION_FOCUS);
- ScreensPanel_update(super);
+ break;
+ case '\n':
+ case '\r':
+ case KEY_ENTER: {
+ ListItem* item = (ListItem*) Panel_getSelected(super);
+ if (!item)
break;
- }
- case 27: // Esc
- {
- ListItem* item = (ListItem*) Panel_getSelected(super);
- if (!item)
- break;
- assert(item == this->renamingItem);
- item->value = this->saved;
- this->renamingItem = NULL;
- super->cursorOn = false;
- Panel_setSelectionColor(super, PANEL_SELECTION_FOCUS);
+ assert(item == this->renamingItem);
+ free(this->saved);
+ item->value = xStrdup(this->buffer);
+ this->renamingItem = NULL;
+ super->cursorOn = false;
+ Panel_setSelectionColor(super, PANEL_SELECTION_FOCUS);
+ ScreensPanel_update(super);
+ break;
+ }
+ case 27: { // Esc
+ ListItem* item = (ListItem*) Panel_getSelected(super);
+ if (!item)
break;
- }
+ assert(item == this->renamingItem);
+ item->value = this->saved;
+ this->renamingItem = NULL;
+ super->cursorOn = false;
+ Panel_setSelectionColor(super, PANEL_SELECTION_FOCUS);
+ break;
}
}
+
return HANDLED;
}
@@ -175,14 +174,14 @@ static HandlerResult ScreensPanel_eventHandlerNormal(Panel* super, int ch) {
ScreenListItem* oldFocus = (ScreenListItem*) Panel_getSelected(super);
bool shouldRebuildArray = false;
HandlerResult result = IGNORED;
+
switch (ch) {
case '\n':
case '\r':
case KEY_ENTER:
case KEY_MOUSE:
- case KEY_RECLICK:
- {
- this->moving = !(this->moving);
+ case KEY_RECLICK: {
+ this->moving = !this->moving;
Panel_setSelectionColor(super, this->moving ? PANEL_SELECTION_FOLLOW : PANEL_SELECTION_FOCUS);
ListItem* item = (ListItem*) Panel_getSelected(super);
if (item)
@@ -196,20 +195,16 @@ static HandlerResult ScreensPanel_eventHandlerNormal(Panel* super, int ch) {
case KEY_NPAGE:
case KEY_PPAGE:
case KEY_HOME:
- case KEY_END: {
+ case KEY_END:
Panel_onKey(super, ch);
break;
- }
case KEY_F(2):
case KEY_CTRL('R'):
- {
startRenaming(super);
result = HANDLED;
break;
- }
case KEY_F(5):
case KEY_CTRL('N'):
- {
if (this->settings->dynamicScreens)
break;
addNewScreen(super);
@@ -217,59 +212,47 @@ static HandlerResult ScreensPanel_eventHandlerNormal(Panel* super, int ch) {
shouldRebuildArray = true;
result = HANDLED;
break;
- }
case KEY_UP:
- {
if (!this->moving) {
Panel_onKey(super, ch);
break;
}
- /* else fallthrough */
- } /* FALLTHRU */
+ /* FALLTHRU */
case KEY_F(7):
case '[':
case '-':
- {
Panel_moveSelectedUp(super);
shouldRebuildArray = true;
result = HANDLED;
break;
- }
case KEY_DOWN:
- {
if (!this->moving) {
Panel_onKey(super, ch);
break;
}
- /* else fallthrough */
- } /* FALLTHRU */
+ /* FALLTHRU */
case KEY_F(8):
case ']':
case '+':
- {
Panel_moveSelectedDown(super);
shouldRebuildArray = true;
result = HANDLED;
break;
- }
case KEY_F(9):
//case KEY_DC:
- {
if (Panel_size(super) > 1)
Panel_remove(super, selected);
shouldRebuildArray = true;
result = HANDLED;
break;
- }
default:
- {
if (ch < 255 && isalpha(ch))
result = Panel_selectByTyping(super, ch);
if (result == BREAK_LOOP)
result = IGNORED;
break;
- }
}
+
ScreenListItem* newFocus = (ScreenListItem*) Panel_getSelected(super);
if (newFocus && oldFocus != newFocus) {
Hashtable* dynamicColumns = this->settings->dynamicColumns;
@@ -277,10 +260,12 @@ static HandlerResult ScreensPanel_eventHandlerNormal(Panel* super, int ch) {
AvailableColumnsPanel_fill(this->availableColumns, newFocus->ss->dynamic, dynamicColumns);
result = HANDLED;
}
+
if (shouldRebuildArray)
rebuildSettingsArray(super, selected);
if (result == HANDLED)
ScreensPanel_update(super);
+
return result;
}

© 2014-2024 Faster IT GmbH | imprint | privacy policy