Restored chat navigation behavior
Up/down scrolls up/down, pageup/pagedown scrolls by a lot Type / and press up/down to scroll through sent command history
This commit is contained in:
parent
70c5e3e530
commit
be7285d759
|
@ -51,6 +51,7 @@ void sent_history_init(ArrayList *arrayList) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void sent_history_add_message(ArrayList *arrayList, const char *newMessage) {
|
void sent_history_add_message(ArrayList *arrayList, const char *newMessage) {
|
||||||
|
if (!newMessage || newMessage[0] != '/') { return; }
|
||||||
if (arrayList->size == MAX_HISTORY_SIZE) {
|
if (arrayList->size == MAX_HISTORY_SIZE) {
|
||||||
for (s32 i = 1; i < MAX_HISTORY_SIZE; i++) {
|
for (s32 i = 1; i < MAX_HISTORY_SIZE; i++) {
|
||||||
snprintf(arrayList->messages[i-1], MAX_MSG_LENGTH, "%s", arrayList->messages[i]);
|
snprintf(arrayList->messages[i-1], MAX_MSG_LENGTH, "%s", arrayList->messages[i]);
|
||||||
|
@ -126,7 +127,7 @@ static void djui_chat_box_input_enter(struct DjuiInputbox* chatInput) {
|
||||||
if (strlen(chatInput->buffer) != 0) {
|
if (strlen(chatInput->buffer) != 0) {
|
||||||
sent_history_add_message(&sentHistory, chatInput->buffer);
|
sent_history_add_message(&sentHistory, chatInput->buffer);
|
||||||
if (chatInput->buffer[0] == '/') {
|
if (chatInput->buffer[0] == '/') {
|
||||||
if (strcmp(chatInput->buffer, "/help") == 0 || strcmp(chatInput->buffer, "/?") == 0) {
|
if (strcmp(chatInput->buffer, "/help") == 0 || strcmp(chatInput->buffer, "/?") == 0 || strcmp(chatInput->buffer, "/") == 0) {
|
||||||
display_chat_commands();
|
display_chat_commands();
|
||||||
} else if (!exec_chat_command(chatInput->buffer)) {
|
} else if (!exec_chat_command(chatInput->buffer)) {
|
||||||
char extendedUnknownCommandMessage[MAX_MSG_LENGTH];
|
char extendedUnknownCommandMessage[MAX_MSG_LENGTH];
|
||||||
|
@ -416,26 +417,36 @@ static bool djui_chat_box_input_on_key_down(struct DjuiBase* base, int scancode)
|
||||||
|
|
||||||
switch (scancode) {
|
switch (scancode) {
|
||||||
case SCANCODE_UP:
|
case SCANCODE_UP:
|
||||||
|
if (gDjuiChatBox->chatInput && gDjuiChatBox->chatInput->buffer && gDjuiChatBox->chatInput->buffer[0] != '/') {
|
||||||
|
gDjuiChatBox->scrolling = true;
|
||||||
|
if (canScrollDown) { *yValue = fmin(*yValue + 15, 0); }
|
||||||
|
} else {
|
||||||
sent_history_update_current_message(&sentHistory, gDjuiChatBox->chatInput->buffer);
|
sent_history_update_current_message(&sentHistory, gDjuiChatBox->chatInput->buffer);
|
||||||
sent_history_navigate(&sentHistory, true);
|
sent_history_navigate(&sentHistory, true);
|
||||||
if (strcmp(previousText, gDjuiChatBox->chatInput->buffer) != 0) {
|
if (strcmp(previousText, gDjuiChatBox->chatInput->buffer) != 0) {
|
||||||
reset_tab_completion_all();
|
reset_tab_completion_all();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
case SCANCODE_DOWN:
|
case SCANCODE_DOWN:
|
||||||
|
if (gDjuiChatBox->chatInput && gDjuiChatBox->chatInput->buffer && gDjuiChatBox->chatInput->buffer[0] != '/') {
|
||||||
|
gDjuiChatBox->scrolling = true;
|
||||||
|
if (canScrollUp) { *yValue = fmax(*yValue - 15, yMax); }
|
||||||
|
} else {
|
||||||
sent_history_update_current_message(&sentHistory, gDjuiChatBox->chatInput->buffer);
|
sent_history_update_current_message(&sentHistory, gDjuiChatBox->chatInput->buffer);
|
||||||
sent_history_navigate(&sentHistory, false);
|
sent_history_navigate(&sentHistory, false);
|
||||||
if (strcmp(previousText, gDjuiChatBox->chatInput->buffer) != 0) {
|
if (strcmp(previousText, gDjuiChatBox->chatInput->buffer) != 0) {
|
||||||
reset_tab_completion_all();
|
reset_tab_completion_all();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
case SCANCODE_PAGE_UP:
|
case SCANCODE_PAGE_UP:
|
||||||
gDjuiChatBox->scrolling = true;
|
gDjuiChatBox->scrolling = true;
|
||||||
if (canScrollDown) { *yValue = fmin(*yValue + 15, 0); }
|
if (canScrollDown) { *yValue = fmin(*yValue + pageAmount, 0); }
|
||||||
return true;
|
return true;
|
||||||
case SCANCODE_PAGE_DOWN:
|
case SCANCODE_PAGE_DOWN:
|
||||||
gDjuiChatBox->scrolling = true;
|
gDjuiChatBox->scrolling = true;
|
||||||
if (canScrollUp) { *yValue = fmax(*yValue - 15, yMax); }
|
if (canScrollUp) { *yValue = fmax(*yValue - pageAmount, yMax); }
|
||||||
return true;
|
return true;
|
||||||
case SCANCODE_POS1:
|
case SCANCODE_POS1:
|
||||||
gDjuiChatBox->scrolling = true;
|
gDjuiChatBox->scrolling = true;
|
||||||
|
|
Loading…
Reference in New Issue