UTF-8 support (initial commit)
This commit is contained in:
+1
-1
@@ -1,7 +1,7 @@
|
||||
#include "main.h"
|
||||
#include <widget.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <ncurses.h>
|
||||
#include <ncursesw/ncurses.h>
|
||||
#include <netinet/in.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
#include <arpa/inet.h>
|
||||
#include <ncurses.h>
|
||||
#include <ncursesw/ncurses.h>
|
||||
#include <netinet/in.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
#include <widget.h>
|
||||
#include <ncurses.h>
|
||||
#include <ncursesw/ncurses.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <ncurses.h>
|
||||
#include <ncursesw/ncurses.h>
|
||||
#include <widget.h>
|
||||
#include <widget_core.h>
|
||||
#include "../connection.h"
|
||||
@@ -23,13 +23,13 @@ void asa_modal_dialogue_callback(callback_args_t *args) {
|
||||
dialogue_default_callback(&d_args);
|
||||
if (d_args.resp_data.code == cbrp_val) {
|
||||
switch (d_args.resp_data.val.val.num) {
|
||||
case 0:
|
||||
case 1:
|
||||
get_ip_port(app->params, in_ip->value, in_port->value);
|
||||
connect_to_server(app);
|
||||
d->needs_destroy = true;
|
||||
app->query_args->state = S_WAIT_SERVER;
|
||||
break;
|
||||
case 1:
|
||||
case 2:
|
||||
destroy_app(app, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "group.h"
|
||||
#include <widget.h>
|
||||
#include <ncurses.h>
|
||||
#include <ncursesw/ncurses.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "group.h"
|
||||
#include <ncurses.h>
|
||||
#include <ncursesw/ncurses.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "group.h"
|
||||
#include <ncurses.h>
|
||||
#include <ncursesw/ncurses.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "group.h"
|
||||
#include <ncurses.h>
|
||||
#include <ncursesw/ncurses.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include <ncurses.h>
|
||||
#include <ncursesw/ncurses.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "group.h"
|
||||
#include <ncurses.h>
|
||||
#include <ncursesw/ncurses.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "../file_processor.h"
|
||||
#include "group.h"
|
||||
#include <ncurses.h>
|
||||
#include <ncursesw/ncurses.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <widget.h>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "group.h"
|
||||
#include <widget.h>
|
||||
#include <ncurses.h>
|
||||
#include <ncursesw/ncurses.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
#include <arpa/inet.h>
|
||||
#include <fcntl.h>
|
||||
#include <ncurses.h>
|
||||
#include <ncursesw/ncurses.h>
|
||||
#include <netinet/in.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
#include <stddef.h>
|
||||
|
||||
size_t count_utf8_code_points(const char *s) {
|
||||
size_t count = 0;
|
||||
while (*s) {
|
||||
count += (*s++ & 0xC0) != 0x80;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
#ifndef UTF8_H
|
||||
#define UTF8_H
|
||||
|
||||
#include <stddef.h>
|
||||
size_t count_utf8_code_points(const char *s);
|
||||
|
||||
#endif
|
||||
@@ -1,4 +1,5 @@
|
||||
#ifndef D_UTILS_H
|
||||
#define D_UTILS_H
|
||||
#include "d_array.h"
|
||||
#include "utf8.h"
|
||||
#endif
|
||||
+3
-1
@@ -1,5 +1,6 @@
|
||||
#include "app.h"
|
||||
#include <ncurses.h>
|
||||
#include <locale.h>
|
||||
#include <ncursesw/ncurses.h>
|
||||
#include <netinet/in.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
@@ -65,6 +66,7 @@ void init_nc() {
|
||||
noecho();
|
||||
curs_set(false);
|
||||
set_escdelay(50);
|
||||
setlocale(LC_ALL, "");
|
||||
|
||||
if (!has_colors()) {
|
||||
printf("Your terminal does not support color\n");
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@
|
||||
#include "../main.h"
|
||||
#include "../common.h"
|
||||
#include "dialogue.h"
|
||||
#include <ncurses.h>
|
||||
#include <ncursesw/ncurses.h>
|
||||
#include <widget_core.h>
|
||||
#include <bstrlib.h>
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
#include <ncurses.h>
|
||||
#include <ncursesw/ncurses.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include <ncurses.h>
|
||||
#include <ncursesw/ncurses.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
#include "../common.h"
|
||||
#include "group.h"
|
||||
#include <ncurses.h>
|
||||
#include <ncursesw/ncurses.h>
|
||||
#include <stdint.h>
|
||||
#include <widget_core.h>
|
||||
#include <utils.h>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include "../fs.h"
|
||||
#include "app.h"
|
||||
#include <bstrlib.h>
|
||||
#include <ncurses.h>
|
||||
#include <ncursesw/ncurses.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "fs_file_list.h"
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
#include <ncurses.h>
|
||||
#include <ncursesw/ncurses.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <uchar.h>
|
||||
#include <unistd.h>
|
||||
|
||||
void reset_file_list(ui_fs_file_list_t *fl_ui);
|
||||
@@ -181,7 +182,13 @@ void draw_fs_file_list(ui_fs_file_list_t *fl_ui) {
|
||||
wattrset(win, COLOR_PAIR(3) | A_BOLD | A_REVERSE);
|
||||
}
|
||||
p_x = 1;
|
||||
mvwprintw(win, p_y, p_x, "%s%n", el->name, &p_x);
|
||||
/* TODO: */
|
||||
wchar_t wname[512];
|
||||
mbstowcs(wname, el->name, 512);
|
||||
// wchar_t text[] = L"ВUTF-8 работает! → ★ ℝ 日本語\n";
|
||||
mvwaddwstr(win, p_y, p_x++, L"Ё");
|
||||
mvwaddwstr(win, p_y, p_x++, L"Ж");
|
||||
// mvwprintw(win, p_y, p_x, "%s%n", el->name, &p_x);
|
||||
mvwprintw(win, p_y, p_x + 1, "%*s", sz_x_f - p_x, "");
|
||||
if (el == fl_ui->current) {
|
||||
wattroff(win, COLOR_PAIR(3) | A_BOLD);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef FS_FILE_LIST_H
|
||||
#define FS_FILE_LIST_H
|
||||
#include <widget_core.h>
|
||||
#include <ncurses.h>
|
||||
#include <ncursesw/ncurses.h>
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
#include "input.h"
|
||||
#include "progress_bar.h"
|
||||
#include "widget_core.h"
|
||||
#include <ncurses.h>
|
||||
#include <ncursesw/ncurses.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
#include <ncurses.h>
|
||||
#include <ncursesw/ncurses.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "progress_bar.h"
|
||||
#include "app.h"
|
||||
#include <ncurses.h>
|
||||
#include <ncursesw/ncurses.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "widget_core.h"
|
||||
#include "../main.h"
|
||||
#include <ncurses.h>
|
||||
#include <ncursesw/ncurses.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#define WIDGET_CORE_H
|
||||
|
||||
#include "../main.h"
|
||||
#include <ncurses.h>
|
||||
#include <ncursesw/ncurses.h>
|
||||
#include <stdint.h>
|
||||
|
||||
enum g_type { g_content, g_action };
|
||||
|
||||
Reference in New Issue
Block a user