ScreenPanel: misc updates

- use ASCII escape sequences
- use array allocation wrappers
This commit is contained in:
Christian Göttsche 2021-12-08 15:18:10 +01:00
parent df1914f429
commit c9e0bd2002

View File

@ -44,7 +44,7 @@ static void ScreensPanel_delete(Object* object) {
static HandlerResult ScreensPanel_eventHandlerRenaming(Panel* super, int ch) {
ScreensPanel* const this = (ScreensPanel*) super;
if (ch >= 32 && ch < 127 && ch != 61) {
if (ch >= 32 && ch < 127 && ch != '=') {
if (this->cursor < SCREEN_NAME_LEN - 1) {
this->buffer[this->cursor] = (char)ch;
this->cursor++;
@ -64,8 +64,8 @@ static HandlerResult ScreensPanel_eventHandlerRenaming(Panel* super, int ch) {
}
break;
}
case 0x0a:
case 0x0d:
case '\n':
case '\r':
case KEY_ENTER:
{
ListItem* item = (ListItem*) Panel_getSelected(super);
@ -119,7 +119,7 @@ static void rebuildSettingsArray(Panel* super) {
int n = Panel_size(super);
free(this->settings->screens);
this->settings->screens = xMalloc(sizeof(ScreenSettings*) * (n + 1));
this->settings->screens = xMallocArray(n + 1, sizeof(ScreenSettings*));
this->settings->screens[n] = NULL;
for (int i = 0; i < n; i++) {
ScreenListItem* item = (ScreenListItem*) Panel_get(super, i);
@ -147,8 +147,8 @@ static HandlerResult ScreensPanel_eventHandlerNormal(Panel* super, int ch) {
bool shouldRebuildArray = false;
HandlerResult result = IGNORED;
switch(ch) {
case 0x0a:
case 0x0d:
case '\n':
case '\r':
case KEY_ENTER:
case KEY_MOUSE:
case KEY_RECLICK:
@ -297,7 +297,7 @@ void ScreensPanel_update(Panel* super) {
ScreensPanel* this = (ScreensPanel*) super;
int size = Panel_size(super);
this->settings->changed = true;
this->settings->screens = xRealloc(this->settings->screens, sizeof(char*) * (size+1));
this->settings->screens = xReallocArray(this->settings->screens, size + 1, sizeof(ScreenSettings*));
for (int i = 0; i < size; i++) {
ScreenListItem* item = (ScreenListItem*) Panel_get(super, i);
ScreenSettings* ss = item->ss;