UTF-8 support (initial commit)
This commit is contained in:
+1
-1
@@ -11,7 +11,7 @@ if(
|
|||||||
add_compile_definitions(_GNU_SOURCE)
|
add_compile_definitions(_GNU_SOURCE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(CURSES_NEED_NCURSES TRUE)
|
set(CURSES_NEED_WIDE TRUE)
|
||||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||||
find_package(Curses REQUIRED)
|
find_package(Curses REQUIRED)
|
||||||
|
|
||||||
|
|||||||
@@ -17,11 +17,10 @@
|
|||||||
- [ ] UTF-8 support
|
- [ ] UTF-8 support
|
||||||
|
|
||||||
## Future ideas
|
## Future ideas
|
||||||
- [ ] Advanced ui element positioning system
|
|
||||||
- [ ] Get rid of old notification mechanism
|
- [ ] Get rid of old notification mechanism
|
||||||
|
|
||||||
## Fixes:
|
## Fixes:
|
||||||
- [ ] Check and fix registration and login
|
- [x] Check and fix registration and login
|
||||||
- [ ] Hotkeys for buttons
|
- [ ] Hotkeys for buttons
|
||||||
- [ ] Group elements as lists
|
- [ ] Group elements as lists
|
||||||
- [ ] "Server message" to notification
|
- [ ] "Server message" to notification
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include <widget.h>
|
#include <widget.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <ncurses.h>
|
#include <ncursesw/ncurses.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <ncurses.h>
|
#include <ncursesw/ncurses.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
#include <widget.h>
|
#include <widget.h>
|
||||||
#include <ncurses.h>
|
#include <ncursesw/ncurses.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ncurses.h>
|
#include <ncursesw/ncurses.h>
|
||||||
#include <widget.h>
|
#include <widget.h>
|
||||||
#include <widget_core.h>
|
#include <widget_core.h>
|
||||||
#include "../connection.h"
|
#include "../connection.h"
|
||||||
@@ -23,13 +23,13 @@ void asa_modal_dialogue_callback(callback_args_t *args) {
|
|||||||
dialogue_default_callback(&d_args);
|
dialogue_default_callback(&d_args);
|
||||||
if (d_args.resp_data.code == cbrp_val) {
|
if (d_args.resp_data.code == cbrp_val) {
|
||||||
switch (d_args.resp_data.val.val.num) {
|
switch (d_args.resp_data.val.val.num) {
|
||||||
case 0:
|
case 1:
|
||||||
get_ip_port(app->params, in_ip->value, in_port->value);
|
get_ip_port(app->params, in_ip->value, in_port->value);
|
||||||
connect_to_server(app);
|
connect_to_server(app);
|
||||||
d->needs_destroy = true;
|
d->needs_destroy = true;
|
||||||
app->query_args->state = S_WAIT_SERVER;
|
app->query_args->state = S_WAIT_SERVER;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 2:
|
||||||
destroy_app(app, 0);
|
destroy_app(app, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include "group.h"
|
#include "group.h"
|
||||||
#include <widget.h>
|
#include <widget.h>
|
||||||
#include <ncurses.h>
|
#include <ncursesw/ncurses.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#include "group.h"
|
#include "group.h"
|
||||||
#include <ncurses.h>
|
#include <ncursesw/ncurses.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#include "group.h"
|
#include "group.h"
|
||||||
#include <ncurses.h>
|
#include <ncursesw/ncurses.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#include "group.h"
|
#include "group.h"
|
||||||
#include <ncurses.h>
|
#include <ncursesw/ncurses.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include <ncurses.h>
|
#include <ncursesw/ncurses.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#include "group.h"
|
#include "group.h"
|
||||||
#include <ncurses.h>
|
#include <ncursesw/ncurses.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include "../file_processor.h"
|
#include "../file_processor.h"
|
||||||
#include "group.h"
|
#include "group.h"
|
||||||
#include <ncurses.h>
|
#include <ncursesw/ncurses.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <widget.h>
|
#include <widget.h>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include "group.h"
|
#include "group.h"
|
||||||
#include <widget.h>
|
#include <widget.h>
|
||||||
#include <ncurses.h>
|
#include <ncursesw/ncurses.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <ncurses.h>
|
#include <ncursesw/ncurses.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdint.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
|
#ifndef D_UTILS_H
|
||||||
#define D_UTILS_H
|
#define D_UTILS_H
|
||||||
#include "d_array.h"
|
#include "d_array.h"
|
||||||
|
#include "utf8.h"
|
||||||
#endif
|
#endif
|
||||||
+3
-1
@@ -1,5 +1,6 @@
|
|||||||
#include "app.h"
|
#include "app.h"
|
||||||
#include <ncurses.h>
|
#include <locale.h>
|
||||||
|
#include <ncursesw/ncurses.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -65,6 +66,7 @@ void init_nc() {
|
|||||||
noecho();
|
noecho();
|
||||||
curs_set(false);
|
curs_set(false);
|
||||||
set_escdelay(50);
|
set_escdelay(50);
|
||||||
|
setlocale(LC_ALL, "");
|
||||||
|
|
||||||
if (!has_colors()) {
|
if (!has_colors()) {
|
||||||
printf("Your terminal does not support color\n");
|
printf("Your terminal does not support color\n");
|
||||||
|
|||||||
+1
-1
@@ -4,7 +4,7 @@
|
|||||||
#include "../main.h"
|
#include "../main.h"
|
||||||
#include "../common.h"
|
#include "../common.h"
|
||||||
#include "dialogue.h"
|
#include "dialogue.h"
|
||||||
#include <ncurses.h>
|
#include <ncursesw/ncurses.h>
|
||||||
#include <widget_core.h>
|
#include <widget_core.h>
|
||||||
#include <bstrlib.h>
|
#include <bstrlib.h>
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
#include <ncurses.h>
|
#include <ncursesw/ncurses.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include <ncurses.h>
|
#include <ncursesw/ncurses.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
#include "../common.h"
|
#include "../common.h"
|
||||||
#include "group.h"
|
#include "group.h"
|
||||||
#include <ncurses.h>
|
#include <ncursesw/ncurses.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <widget_core.h>
|
#include <widget_core.h>
|
||||||
#include <utils.h>
|
#include <utils.h>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
#include "../fs.h"
|
#include "../fs.h"
|
||||||
#include "app.h"
|
#include "app.h"
|
||||||
#include <bstrlib.h>
|
#include <bstrlib.h>
|
||||||
#include <ncurses.h>
|
#include <ncursesw/ncurses.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include "fs_file_list.h"
|
#include "fs_file_list.h"
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <ncurses.h>
|
#include <ncursesw/ncurses.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
@@ -9,6 +9,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
#include <uchar.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
void reset_file_list(ui_fs_file_list_t *fl_ui);
|
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);
|
wattrset(win, COLOR_PAIR(3) | A_BOLD | A_REVERSE);
|
||||||
}
|
}
|
||||||
p_x = 1;
|
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, "");
|
mvwprintw(win, p_y, p_x + 1, "%*s", sz_x_f - p_x, "");
|
||||||
if (el == fl_ui->current) {
|
if (el == fl_ui->current) {
|
||||||
wattroff(win, COLOR_PAIR(3) | A_BOLD);
|
wattroff(win, COLOR_PAIR(3) | A_BOLD);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#ifndef FS_FILE_LIST_H
|
#ifndef FS_FILE_LIST_H
|
||||||
#define FS_FILE_LIST_H
|
#define FS_FILE_LIST_H
|
||||||
#include <widget_core.h>
|
#include <widget_core.h>
|
||||||
#include <ncurses.h>
|
#include <ncursesw/ncurses.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -5,7 +5,7 @@
|
|||||||
#include "input.h"
|
#include "input.h"
|
||||||
#include "progress_bar.h"
|
#include "progress_bar.h"
|
||||||
#include "widget_core.h"
|
#include "widget_core.h"
|
||||||
#include <ncurses.h>
|
#include <ncursesw/ncurses.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
#include <ncurses.h>
|
#include <ncursesw/ncurses.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include "progress_bar.h"
|
#include "progress_bar.h"
|
||||||
#include "app.h"
|
#include "app.h"
|
||||||
#include <ncurses.h>
|
#include <ncursesw/ncurses.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include "widget_core.h"
|
#include "widget_core.h"
|
||||||
#include "../main.h"
|
#include "../main.h"
|
||||||
#include <ncurses.h>
|
#include <ncursesw/ncurses.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
#define WIDGET_CORE_H
|
#define WIDGET_CORE_H
|
||||||
|
|
||||||
#include "../main.h"
|
#include "../main.h"
|
||||||
#include <ncurses.h>
|
#include <ncursesw/ncurses.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
enum g_type { g_content, g_action };
|
enum g_type { g_content, g_action };
|
||||||
|
|||||||
Reference in New Issue
Block a user