aboutsummaryrefslogtreecommitdiff
path: root/client/ui_orders.c
diff options
context:
space:
mode:
Diffstat (limited to 'client/ui_orders.c')
-rw-r--r--client/ui_orders.c46
1 files changed, 21 insertions, 25 deletions
diff --git a/client/ui_orders.c b/client/ui_orders.c
index 4951ba6..6c5de27 100644
--- a/client/ui_orders.c
+++ b/client/ui_orders.c
@@ -1,36 +1,32 @@
+#include <stdint.h>
#include <stdlib.h>
#include <string.h>
-#include <stdint.h>
-#include "ui.h"
-#include "errcatch.h"
-#include "../shared/util.h"
#include "../shared/bin.h"
#include "../shared/protocol.h"
-#include "i18n.h"
+#include "../shared/util.h"
#include "commands.h"
+#include "errcatch.h"
+#include "i18n.h"
#include "main.h"
+#include "ui.h"
#define W2_IS_CMD(cmd) strncmp(g_w2_command_buffer, cmd, sizeof(cmd) - 1) == 0
-#define W2_UI_ORDERS_PRINT_CONST(text) \
- w2_wmvaddstr(g_w2_ui_pad_body, g_w2_order_line, 0, text); \
+#define W2_UI_ORDERS_PRINT_CONST(text) \
+ w2_wmvaddstr(g_w2_ui_pad_body, g_w2_order_line, 0, text); \
g_w2_order_line += w2_newline_count(text, sizeof(text));
-char g_w2_command_buffer[W2_UI_ORDER_CMD_BUFFER_SIZE] = { 0x00 };
-int g_w2_command_buffer_index = 0;
-int g_w2_order_line = 0;
-bool g_w2_order_recording = false;
-bool g_w2_order_saved = false;
-uint16_t g_w2_order_buffer[W2_UI_ORDER_BUFFER_SIZE] = { 0 };
-int g_w2_order_buffer_index = 0;
+char g_w2_command_buffer[W2_UI_ORDER_CMD_BUFFER_SIZE] = {0x00};
+int g_w2_command_buffer_index = 0;
+int g_w2_order_line = 0;
+bool g_w2_order_recording = false;
+bool g_w2_order_saved = false;
+uint16_t g_w2_order_buffer[W2_UI_ORDER_BUFFER_SIZE] = {0};
+int g_w2_order_buffer_index = 0;
-void w2_ui_orders_cmd_error() {
- W2_UI_ORDERS_PRINT_CONST(W2_UI_ORDER_MSG_ERROR);
-}
+void w2_ui_orders_cmd_error() { W2_UI_ORDERS_PRINT_CONST(W2_UI_ORDER_MSG_ERROR); }
-void w2_ui_orders_cmd_help() {
- W2_UI_ORDERS_PRINT_CONST(W2_UI_ORDER_MSG_HELP);
-}
+void w2_ui_orders_cmd_help() { W2_UI_ORDERS_PRINT_CONST(W2_UI_ORDER_MSG_HELP); }
void w2_ui_orders_cmd_start() {
if (g_w2_order_recording) {
@@ -60,7 +56,7 @@ void w2_ui_orders_cmd_done() {
} else {
W2_UI_ORDERS_PRINT_CONST(W2_UI_ORDER_MSG_ORDER_DONE_ERR);
}
- g_w2_order_saved = true;
+ g_w2_order_saved = true;
g_w2_order_recording = false;
}
@@ -69,7 +65,7 @@ void w2_ui_orders_cmd_send() {
W2_CREATE_MSG_BIN(w2_s_cmd_bomd_rx, msg, bin);
msg->position = w2_bin_hton16(g_w2_order_buffer[i]);
- msg->id = rand();
+ msg->id = rand();
w2_send_bin(bin);
free(bin);
@@ -91,9 +87,10 @@ void w2_ui_onkey_orders(int ch) {
if (ch >= 'A' && ch <= 'Z') ch += 0x20; // convert uppercase to lowercase
if ((ch >= 'a' && ch <= 'z') || (ch >= '0' && ch <= '9') || (ch == ' ')) {
g_w2_command_buffer[g_w2_command_buffer_index] = ch;
- g_w2_command_buffer_index = W2_MIN(g_w2_command_buffer_index + 1, W2_UI_ORDER_CMD_BUFFER_SIZE - 1);
+ g_w2_command_buffer_index =
+ W2_MIN(g_w2_command_buffer_index + 1, W2_UI_ORDER_CMD_BUFFER_SIZE - 1);
} else if (ch == KEY_BACKSPACE) {
- g_w2_command_buffer_index = W2_MAX(g_w2_command_buffer_index - 1, 0);
+ g_w2_command_buffer_index = W2_MAX(g_w2_command_buffer_index - 1, 0);
g_w2_command_buffer[g_w2_command_buffer_index] = 0x00;
} else if (ch == 0x0a) {
// clear cursor
@@ -113,4 +110,3 @@ void w2_ui_tab_orders(bool first) {
sprintf(temp, "> %s_ ", g_w2_command_buffer);
w2_wmvaddstr(g_w2_ui_pad_body, g_w2_order_line, 0, temp);
}
-