ui: Input: fix non-Latin letters

This commit is contained in:
2026-05-13 17:28:10 +03:00
parent b346e364c5
commit e764964a3c
30 changed files with 377 additions and 135 deletions
+6
View File
@@ -0,0 +1,6 @@
{
"$schema": "https://download.qt.io/official_releases/qtcreator/latest/installer_source/jsonschemas/project.json",
"files.exclude": [
".qtcreator/project.json.user"
]
}
+214
View File
@@ -0,0 +1,214 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 19.0.1, 2026-05-13T14:23:37. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
<value type="QByteArray">{8f62499a-75db-4638-afeb-c6cb03c6bf59}</value>
</data>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>
<value type="qlonglong">0</value>
</data>
<data>
<variable>ProjectExplorer.Project.EditorSettings</variable>
<valuemap type="QVariantMap">
<value type="bool" key="EditorConfiguration.AutoDetect">true</value>
<value type="bool" key="EditorConfiguration.AutoIndent">true</value>
<value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
<value type="QString" key="language">Cpp</value>
<valuemap type="QVariantMap" key="value">
<value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
</valuemap>
</valuemap>
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
<value type="QString" key="language">QmlJS</value>
<valuemap type="QVariantMap" key="value">
<value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
</valuemap>
</valuemap>
<value type="qlonglong" key="EditorConfiguration.CodeStyle.Count">2</value>
<value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
<value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
<value type="int" key="EditorConfiguration.IndentSize">4</value>
<value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
<value type="int" key="EditorConfiguration.LineEndingBehavior">0</value>
<value type="int" key="EditorConfiguration.MarginColumn">80</value>
<value type="bool" key="EditorConfiguration.MouseHiding">true</value>
<value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
<value type="int" key="EditorConfiguration.PaddingMode">1</value>
<value type="int" key="EditorConfiguration.PreferAfterWhitespaceComments">0</value>
<value type="bool" key="EditorConfiguration.PreferSingleLineComments">false</value>
<value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
<value type="bool" key="EditorConfiguration.ShowMargin">false</value>
<value type="int" key="EditorConfiguration.SmartBackspaceBehavior">2</value>
<value type="bool" key="EditorConfiguration.SmartSelectionChanging">true</value>
<value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
<value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
<value type="int" key="EditorConfiguration.TabSize">8</value>
<value type="bool" key="EditorConfiguration.UseGlobal">true</value>
<value type="bool" key="EditorConfiguration.UseIndenter">false</value>
<value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
<value type="bool" key="EditorConfiguration.addFinalNewLine">false</value>
<value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
<value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
<value type="QString" key="EditorConfiguration.ignoreFileTypes">*.md, *.MD, Makefile</value>
<value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
<value type="bool" key="EditorConfiguration.skipTrailingWhitespace">true</value>
<value type="bool" key="EditorConfiguration.tintMarginArea">true</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.PluginSettings</variable>
<valuemap type="QVariantMap">
<valuemap type="QVariantMap" key="AutoTest.ActiveFrameworks">
<value type="bool" key="AutoTest.Framework.Boost">true</value>
<value type="bool" key="AutoTest.Framework.CTest">false</value>
<value type="bool" key="AutoTest.Framework.Catch">true</value>
<value type="bool" key="AutoTest.Framework.GTest">true</value>
<value type="bool" key="AutoTest.Framework.QtQuickTest">true</value>
<value type="bool" key="AutoTest.Framework.QtTest">true</value>
</valuemap>
<value type="bool" key="AutoTest.ApplyFilter">false</value>
<valuemap type="QVariantMap" key="AutoTest.CheckStates"/>
<valuelist type="QVariantList" key="AutoTest.PathFilters"/>
<value type="int" key="AutoTest.RunAfterBuild">0</value>
<value type="bool" key="AutoTest.UseGlobal">true</value>
<valuemap type="QVariantMap" key="ClangTools">
<value type="bool" key="ClangTools.AnalyzeOpenFiles">true</value>
<value type="bool" key="ClangTools.BuildBeforeAnalysis">true</value>
<value type="QString" key="ClangTools.DiagnosticConfig">Builtin.DefaultTidyAndClazy</value>
<value type="int" key="ClangTools.ParallelJobs">11</value>
<value type="bool" key="ClangTools.PreferConfigFile">true</value>
<valuelist type="QVariantList" key="ClangTools.SelectedDirs"/>
<valuelist type="QVariantList" key="ClangTools.SelectedFiles"/>
<valuelist type="QVariantList" key="ClangTools.SuppressedDiagnostics"/>
<value type="bool" key="ClangTools.UseGlobalSettings">true</value>
</valuemap>
<value type="int" key="RcSync">0</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.Target.0</variable>
<valuemap type="QVariantMap">
<value type="QString" key="DeviceType">Desktop</value>
<value type="bool" key="HasPerBcDcs">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{7319c3ef-71cf-4230-8aba-dab489ab735e}</value>
<value type="qlonglong" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
<value type="qlonglong" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="qlonglong" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/alexander/Projects/bbs-client-cli/build</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Сборка</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Сборка</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Очистка</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Очистка</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">По умолчанию</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">WorkspaceProject.BuildConfiguration</value>
<value type="qlonglong" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="qlonglong" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Развёртывание</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Развёртывание</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.DeployConfiguration.CustomData"/>
<value type="bool" key="ProjectExplorer.DeployConfiguration.CustomDataEnabled">false</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
<value type="bool" key="Analyzer.Perf.Settings.UseGlobalSettings">true</value>
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
<value type="int" key="Analyzer.Valgrind.Callgrind.CostFormat">0</value>
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.SuppressionFiles"/>
<valuelist type="QVariantList" key="CustomOutputParsers"/>
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="bool" key="PE.EnvironmentAspect.PrintOnRun">false</value>
<value type="QString" key="PerfRecordArgsId">-e cpu-cycles --call-graph dwarf,4096 -F 250</value>
<value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Executable">/home/alexander/Projects/bbs-client-cli/build/src/zbbs-client-tui</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value>
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey"></value>
<value type="bool" key="ProjectExplorer.RunConfiguration.Customized">true</value>
<value type="QString" key="ProjectExplorer.RunConfiguration.UniqueId"></value>
<value type="QString" key="RunConfiguration.Arguments">-h 127.0.0.1 -u zheiling --pass dobkin</value>
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
<value type="bool" key="RunConfiguration.UseTerminal">true</value>
<value type="QString" key="RunConfiguration.WorkingDirectory">/home/alexander/Projects/bbs-client-cli</value>
<value type="QString" key="RunConfiguration.WorkingDirectory.default">%{RunConfig:Executable:Path}</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.Target.BuildConfigurationCount">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Развёртывание</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Развёртывание</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.DeployConfiguration.CustomData"/>
<value type="bool" key="ProjectExplorer.DeployConfiguration.CustomDataEnabled">false</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
<value type="bool" key="Analyzer.Perf.Settings.UseGlobalSettings">true</value>
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
<value type="int" key="Analyzer.Valgrind.Callgrind.CostFormat">0</value>
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.SuppressionFiles"/>
<valuelist type="QVariantList" key="CustomOutputParsers"/>
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="bool" key="PE.EnvironmentAspect.PrintOnRun">false</value>
<value type="QString" key="PerfRecordArgsId">-e cpu-cycles --call-graph dwarf,4096 -F 250</value>
<value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Executable">/home/alexander/Projects/bbs-client-cli/build/src/zbbs-client-tui</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value>
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey"></value>
<value type="bool" key="ProjectExplorer.RunConfiguration.Customized">true</value>
<value type="QString" key="ProjectExplorer.RunConfiguration.UniqueId"></value>
<value type="QString" key="RunConfiguration.Arguments">-h 127.0.0.1 -u zheiling --pass dobkin</value>
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
<value type="bool" key="RunConfiguration.UseTerminal">true</value>
<value type="QString" key="RunConfiguration.WorkingDirectory">/home/alexander/Projects/bbs-client-cli</value>
<value type="QString" key="RunConfiguration.WorkingDirectory.default">%{RunConfig:Executable:Path}</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.TargetCount</variable>
<value type="qlonglong">1</value>
</data>
<data>
<variable>Version</variable>
<value type="int">22</value>
</data>
</qtcreator>
+3 -3
View File
@@ -1,13 +1,13 @@
# TODO: # TODO:
## Current: ## Current:
- [ ] Input: fix non-Latin letters - [ ] File upload multiline description (window)
- [ ] Get rid of unsigned integers - [x] Input: fix non-Latin letters
- [ ] Separate common structures in the common.h - [ ] Separate common structures in the common.h
- [ ] Sorting in the file list - [ ] Sorting in the file list
- [ ] File upload multiline description (window)
- [ ] More intuitive navigation between nested groups (by pressing left and right buttons) - [ ] More intuitive navigation between nested groups (by pressing left and right buttons)
- [ ] Cancel upload/download - [ ] Cancel upload/download
- [x] Get rid of unsigned integers
- [x] Check registration / enter server name again - [x] Check registration / enter server name again
- [x] PageUp/PageDown key functionality in lists - [x] PageUp/PageDown key functionality in lists
- [x] Permission checkboxes for file upload/edit - [x] Permission checkboxes for file upload/edit
+3 -3
View File
@@ -79,8 +79,8 @@ void app_draw_borders(app_t *app) {
box(app->win, 0, 0); box(app->win, 0, 0);
} }
int64_t print_bottom_menu_option(WINDOW *win, char *key, char *title, int64_t y, int32_t print_bottom_menu_option(WINDOW *win, char *key, char *title, int32_t y,
int64_t x, int32_t size) { int32_t x, int32_t size) {
int32_t key_len = 0; int32_t key_len = 0;
int32_t title_len = 0; int32_t title_len = 0;
@@ -108,7 +108,7 @@ void app_draw_bars(app_t *app) {
/* add content to the top bar */ /* add content to the top bar */
if (app->params && app->params->is_connected) { if (app->params && app->params->is_connected) {
uint32_t ip_address = app->params->addr; int32_t ip_address = app->params->addr;
u_char ip_addr[4]; u_char ip_addr[4];
mempcpy(ip_addr, &ip_address, 4); mempcpy(ip_addr, &ip_address, 4);
sprintf(top_text, "Connected to %u.%u.%u.%u, user: %s", ip_addr[0], sprintf(top_text, "Connected to %u.%u.%u.%u, user: %s", ip_addr[0],
+2 -2
View File
@@ -7,8 +7,8 @@
#include <stdint.h> #include <stdint.h>
typedef struct { typedef struct {
uint32_t cur_y, cur_x; int32_t cur_y, cur_x;
uint32_t max_y, max_x; int32_t max_y, max_x;
} coordinates_t; } coordinates_t;
#define MAIN_UI_RESET(app) \ #define MAIN_UI_RESET(app) \
+9 -9
View File
@@ -31,10 +31,10 @@ fl_item_t *fl_select(fl_item_t *start, int num);
void fl_clear(fl_item_t **start, fl_item_t **current); void fl_clear(fl_item_t **start, fl_item_t **current);
void file_list(file_args_t *f_args, query_args_t *q_args) { void file_list(file_args_t *f_args, query_args_t *q_args) {
uint32_t qlen; int32_t qlen;
char *query = NULL; char *query = NULL;
static char qbuf[INBUFSIZE * 2]; static char qbuf[INBUFSIZE * 2];
static uint32_t qbuf_used = 0; static int32_t qbuf_used = 0;
w_ui_file_list_t *fui = (w_ui_file_list_t *)q_args->main_ui->ui; w_ui_file_list_t *fui = (w_ui_file_list_t *)q_args->main_ui->ui;
w_dialogue_t *d = (w_dialogue_t *)q_args->active_dialogue; w_dialogue_t *d = (w_dialogue_t *)q_args->active_dialogue;
fui->start = &(f_args->l_start); fui->start = &(f_args->l_start);
@@ -46,7 +46,7 @@ void file_list(file_args_t *f_args, query_args_t *q_args) {
while ((qlen = query_extract_from_buf(q_args->buf, &(q_args->buf_used), while ((qlen = query_extract_from_buf(q_args->buf, &(q_args->buf_used),
&query))) { &query))) {
if (!strncmp(":END:", query, sizeof(":END:") - 1)) { if (!strncmp(":END:", query, sizeof(":END:") - 1)) {
sscanf(query, ":END: PAGE %u/%u COUNT: %u/%u\n", &fui->current_page, sscanf(query, ":END: PAGE %d/%d COUNT: %d/%d\n", &fui->current_page,
&fui->pages, &fui->current_count, &fui->full_count); &fui->pages, &fui->current_count, &fui->full_count);
if (d != NULL && d->is_initiated) { if (d != NULL && d->is_initiated) {
d->needs_update = true; d->needs_update = true;
@@ -108,7 +108,7 @@ int32_t ui_file_select(file_args_t *f_args, query_args_t *q_args, int32_t idx) {
void file_download(file_args_t *f_args, query_args_t *q_args) { void file_download(file_args_t *f_args, query_args_t *q_args) {
fl_item_t *f_selected = &(f_args->f_selected); fl_item_t *f_selected = &(f_args->f_selected);
static uint32_t it_count = 0; static int32_t it_count = 0;
static size_t it_interval = 0; static size_t it_interval = 0;
if (it_interval == 0) { if (it_interval == 0) {
it_interval = (f_selected->size / INBUFSIZE / 100) * 5; /* every 1% */ it_interval = (f_selected->size / INBUFSIZE / 100) * 5; /* every 1% */
@@ -118,7 +118,7 @@ void file_download(file_args_t *f_args, query_args_t *q_args) {
char answer[256]; char answer[256];
static size_t size_rest = 0; static size_t size_rest = 0;
uint32_t progress = (f_selected->size - size_rest) * 100 / f_selected->size; int32_t progress = (f_selected->size - size_rest) * 100 / f_selected->size;
w_pgb_ui_t *pb = (w_pgb_ui_t *)q_args->progress_bar; w_pgb_ui_t *pb = (w_pgb_ui_t *)q_args->progress_bar;
w_dialogue_t *d = (w_dialogue_t *)q_args->active_dialogue; w_dialogue_t *d = (w_dialogue_t *)q_args->active_dialogue;
w_ui_file_list_t *fui = (w_ui_file_list_t *)q_args->main_ui->ui; w_ui_file_list_t *fui = (w_ui_file_list_t *)q_args->main_ui->ui;
@@ -126,7 +126,7 @@ void file_download(file_args_t *f_args, query_args_t *q_args) {
if (size_rest == 0) if (size_rest == 0)
size_rest = f_selected->size; size_rest = f_selected->size;
uint32_t qlen = write(f_args->file_d, q_args->buf, q_args->buf_used); int32_t qlen = write(f_args->file_d, q_args->buf, q_args->buf_used);
if (qlen) { if (qlen) {
it_count++; it_count++;
if (!(it_count % it_interval)) { if (!(it_count % it_interval)) {
@@ -151,7 +151,7 @@ void file_download(file_args_t *f_args, query_args_t *q_args) {
q_args->notification = malloc(strlen(answer) + 1); q_args->notification = malloc(strlen(answer) + 1);
strcpy(q_args->notification, answer); strcpy(q_args->notification, answer);
free(f_selected->name); free(f_selected->name);
server_send_string(q_args, "file list %u %u\n%n", fui->max_lines, server_send_string(q_args, "file list %d %d\n%n", fui->max_lines,
fui->current_page, &a_len); fui->current_page, &a_len);
q_args->state = S_FILE_LIST; q_args->state = S_FILE_LIST;
} }
@@ -190,14 +190,14 @@ int32_t file_upload_start(query_args_t *q_args) {
} }
int32_t file_upload(query_args_t *q_args) { int32_t file_upload(query_args_t *q_args) {
static uint32_t it_count = 0; static int32_t it_count = 0;
static size_t it_interval = 0; static size_t it_interval = 0;
if (it_interval == 0) { if (it_interval == 0) {
it_interval = (q_args->file->size / INBUFSIZE / 100) * 5; /* every 1% */ it_interval = (q_args->file->size / INBUFSIZE / 100) * 5; /* every 1% */
if (it_interval == 0) if (it_interval == 0)
it_interval = 1; it_interval = 1;
} }
uint32_t progress = int32_t progress =
(q_args->file->size - q_args->file->rest) * 100 / q_args->file->size; (q_args->file->size - q_args->file->rest) * 100 / q_args->file->size;
w_pgb_ui_t *pb = (w_pgb_ui_t *)q_args->progress_bar; w_pgb_ui_t *pb = (w_pgb_ui_t *)q_args->progress_bar;
w_dialogue_t *d = (w_dialogue_t *)q_args->active_dialogue; w_dialogue_t *d = (w_dialogue_t *)q_args->active_dialogue;
+1 -1
View File
@@ -21,7 +21,7 @@
#include "file_list.h" #include "file_list.h"
#include "query.h" #include "query.h"
uint32_t m_id = 0; int32_t m_id = 0;
int32_t process_user_input(app_t *app, w_cb_args_t *d_args); int32_t process_user_input(app_t *app, w_cb_args_t *d_args);
+3 -3
View File
@@ -25,7 +25,7 @@ typedef struct params {
char *pass; char *pass;
char privileges; char privileges;
int32_t sd; int32_t sd;
uint32_t is_connected : 1; int32_t is_connected : 1;
} params_t; } params_t;
enum state { enum state {
@@ -112,8 +112,8 @@ typedef struct query_args {
params_t *params; params_t *params;
struct { struct {
char *text; char *text;
uint64_t capacity; int32_t capacity;
uint64_t size; int32_t size;
} server_message; } server_message;
main_window_t *main_ui; main_window_t *main_ui;
void *progress_bar; void *progress_bar;
-1
View File
@@ -18,7 +18,6 @@ void init_login_credentials_modal_cb(w_cb_args_t *args) {
app_t *app = args->app; app_t *app = args->app;
w_dialogue_t *d = (w_dialogue_t *)app->active_widget; w_dialogue_t *d = (w_dialogue_t *)app->active_widget;
memcpy(&d_args, args, sizeof(w_cb_args_t)); memcpy(&d_args, args, sizeof(w_cb_args_t));
d_args.app = NULL;
d_args.element = app->active_widget; d_args.element = app->active_widget;
w_input_t *in_name = d->g_content->elements[0].element; w_input_t *in_name = d->g_content->elements[0].element;
w_input_t *in_pass = d->g_content->elements[1].element; w_input_t *in_pass = d->g_content->elements[1].element;
+1
View File
@@ -113,6 +113,7 @@ void query_loop(app_t *app) {
process_query(app); process_query(app);
} }
/* process user input */
if (FD_ISSET(STDIN_FILENO, &readfds)) { if (FD_ISSET(STDIN_FILENO, &readfds)) {
if (app->main_ui.cb_b_press != NULL && app->modal.is_initiated == false) { if (app->main_ui.cb_b_press != NULL && app->modal.is_initiated == false) {
if (ERR == app->main_ui.cb_b_press(app, &d_args)) { if (ERR == app->main_ui.cb_b_press(app, &d_args)) {
+3 -3
View File
@@ -39,7 +39,7 @@ int server_wait_reg_confirm_cb(app_t *app, char *line, int l_len) {
w_ui_file_list_t *fui = (w_ui_file_list_t *)q_args->main_ui->ui; w_ui_file_list_t *fui = (w_ui_file_list_t *)q_args->main_ui->ui;
if (!strcmp(line, "ok\n")) { if (!strcmp(line, "ok\n")) {
server_send_string(q_args, "file list %u %u\n", fui->max_lines, server_send_string(q_args, "file list %d %d\n", fui->max_lines,
fui->current_page); fui->current_page);
q_args->state = S_FILE_LIST; q_args->state = S_FILE_LIST;
w_dialogue_destroy(&(app->modal), app); w_dialogue_destroy(&(app->modal), app);
@@ -58,7 +58,7 @@ int server_wait_reg_confirm_cb(app_t *app, char *line, int l_len) {
} }
int server_print_message_cb(app_t *app, char *line, int l_len) { int server_print_message_cb(app_t *app, char *line, int l_len) {
int64_t new_capacity; int32_t new_capacity;
query_args_t *q_args = app->query_args; query_args_t *q_args = app->query_args;
if (q_args->server_message.text == NULL) { if (q_args->server_message.text == NULL) {
q_args->server_message.text = malloc(l_len + 1); q_args->server_message.text = malloc(l_len + 1);
@@ -140,7 +140,7 @@ int process_server_command(char *line, int l_len, app_t *app) {
/* WELCOME MES */ /* WELCOME MES */
if (!strncmp(line, "Welcome, ", ws_pos)) { if (!strncmp(line, "Welcome, ", ws_pos)) {
server_send_string(q_args, "file list %u %u\n", fui->max_lines, server_send_string(q_args, "file list %d %d\n", fui->max_lines,
fui->current_page); fui->current_page);
q_args->state = S_FILE_LIST; q_args->state = S_FILE_LIST;
return 0; return 0;
+3 -3
View File
@@ -4,7 +4,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
void u_d_arr_ptr_init(d_array_ptr_t *arr, int64_t init_capacity) { void u_d_arr_ptr_init(d_array_ptr_t *arr, int32_t init_capacity) {
arr->capacity = init_capacity; arr->capacity = init_capacity;
arr->length = 0; arr->length = 0;
arr->arr = malloc(sizeof(void *) * init_capacity); arr->arr = malloc(sizeof(void *) * init_capacity);
@@ -13,8 +13,8 @@ void u_d_arr_ptr_init(d_array_ptr_t *arr, int64_t init_capacity) {
memset(arr->arr, 0, init_capacity); memset(arr->arr, 0, init_capacity);
} }
void u_d_arr_ptr_add(d_array_ptr_t *arr, void *ptr, int64_t idx) { void u_d_arr_ptr_add(d_array_ptr_t *arr, void *ptr, int32_t idx) {
int64_t new_capacity = idx * 2; int32_t new_capacity = idx * 2;
if (idx > arr->capacity - 1) { if (idx > arr->capacity - 1) {
arr->arr = realloc(arr->arr, new_capacity); arr->arr = realloc(arr->arr, new_capacity);
memset(arr->arr+arr->capacity, 0, arr->capacity - new_capacity); memset(arr->arr+arr->capacity, 0, arr->capacity - new_capacity);
+4 -4
View File
@@ -3,15 +3,15 @@
/* Dynamic array of numbers */ /* Dynamic array of numbers */
#include <stdint.h> #include <stdint.h>
typedef struct d_array_ptr_t { typedef struct d_array_ptr_t {
int64_t capacity; int32_t capacity;
int64_t length; int32_t length;
void **arr; void **arr;
void *fist_el; void *fist_el;
void *last_el; void *last_el;
} d_array_ptr_t; } d_array_ptr_t;
void u_d_arr_ptr_init(d_array_ptr_t *arr, int64_t init_capacity); void u_d_arr_ptr_init(d_array_ptr_t *arr, int32_t init_capacity);
void u_d_arr_ptr_add(d_array_ptr_t *arr, void *ptr, int64_t idx); void u_d_arr_ptr_add(d_array_ptr_t *arr, void *ptr, int32_t idx);
void u_d_arr_ptr_free(d_array_ptr_t *arr); void u_d_arr_ptr_free(d_array_ptr_t *arr);
#endif #endif
+4 -4
View File
@@ -26,7 +26,7 @@ const char *u_utf8_wind_n(const char *s, int n) {
return _s; return _s;
} }
int64_t u_utf8_convert_to_wide(const char *utf8_str, int32_t u_utf8_convert_to_wide(const char *utf8_str,
wchar_t **restrict wide_str, wchar_t **restrict wide_str,
size_t *restrict len) { size_t *restrict len) {
// Step 1: Convert UTF-8 (MBCS) to wchar_t (wide) // Step 1: Convert UTF-8 (MBCS) to wchar_t (wide)
@@ -44,12 +44,12 @@ int64_t u_utf8_convert_to_wide(const char *utf8_str,
return 0; return 0;
} }
int64_t u_utf8_curs_printw(WINDOW *win, int64_t *y, int64_t *x, int32_t u_utf8_curs_printw(WINDOW *win, int32_t *y, int32_t *x,
const char *utf8_str, int max_len, bool multiline) { const char *utf8_str, int max_len, bool multiline) {
wchar_t *wline = NULL; wchar_t *wline = NULL;
size_t nsize = 0; size_t nsize = 0;
int64_t _x = *x; int32_t _x = *x;
int64_t _y = *y; int32_t _y = *y;
u_utf8_convert_to_wide(utf8_str, &wline, &nsize); u_utf8_convert_to_wide(utf8_str, &wline, &nsize);
mvwaddnwstr(win, _y, _x, wline, max_len); mvwaddnwstr(win, _y, _x, wline, max_len);
+2 -2
View File
@@ -7,8 +7,8 @@
const char *u_utf8_wind_n(const char *s, int n); const char *u_utf8_wind_n(const char *s, int n);
size_t u_utf8_code_points_count(const char *s); size_t u_utf8_code_points_count(const char *s);
int64_t u_utf8_convert_to_wide(const char *utf8_str, wchar_t **restrict wide_str, int32_t u_utf8_convert_to_wide(const char *utf8_str, wchar_t **restrict wide_str,
size_t *restrict len); size_t *restrict len);
int64_t u_utf8_curs_printw(WINDOW *win, int64_t *y, int64_t *x, const char* utf8_str, int max_len, bool multiline); int32_t u_utf8_curs_printw(WINDOW *win, int32_t *y, int32_t *x, const char* utf8_str, int max_len, bool multiline);
#endif #endif
+3 -3
View File
@@ -21,11 +21,11 @@ w_button_t *init_button(WINDOW **win, w_t *w_parent, char *label) {
return btn; return btn;
} }
int32_t draw_button(w_button_t *btn, uint32_t active_id) { int32_t draw_button(w_button_t *btn, int32_t active_id) {
char title[DIALOGUE_TITLE + 6]; char title[DIALOGUE_TITLE + 6];
WINDOW *win = *(btn->w.parent_win); WINDOW *win = *(btn->w.parent_win);
uint32_t margin_y = btn->w.ps.y + btn->w.m.y; int32_t margin_y = btn->w.ps.y + btn->w.m.y;
uint32_t margin_x = btn->w.ps.x + btn->w.m.x; int32_t margin_x = btn->w.ps.x + btn->w.m.x;
w_t *w_par = btn->w.w_parent; w_t *w_par = btn->w.w_parent;
+2 -2
View File
@@ -10,11 +10,11 @@
typedef struct { typedef struct {
w_t w; w_t w;
int32_t hotkey; int32_t hotkey;
uint32_t is_disabled : 1; int32_t is_disabled : 1;
} w_button_t; } w_button_t;
w_button_t *init_button(WINDOW **win, w_t *w_parent, char *label); w_button_t *init_button(WINDOW **win, w_t *w_parent, char *label);
int32_t draw_button(w_button_t *btn, uint32_t active_id); int32_t draw_button(w_button_t *btn, int32_t active_id);
void destroy_button(w_button_t *btn); void destroy_button(w_button_t *btn);
#endif #endif
+3 -3
View File
@@ -36,11 +36,11 @@ w_checkbox_t *w_checkbox_init(WINDOW **win, w_t *w_parent, char *label) {
return cbx; return cbx;
} }
int32_t w_checkbox_draw(w_checkbox_t *cbx, uint32_t active_id) { int32_t w_checkbox_draw(w_checkbox_t *cbx, int32_t active_id) {
char title[DIALOGUE_TITLE + 6]; char title[DIALOGUE_TITLE + 6];
WINDOW *win = *(cbx->w.parent_win); WINDOW *win = *(cbx->w.parent_win);
uint32_t margin_y = cbx->w.ps.y + cbx->w.m.y; int32_t margin_y = cbx->w.ps.y + cbx->w.m.y;
uint32_t margin_x = cbx->w.ps.x + cbx->w.m.x; int32_t margin_x = cbx->w.ps.x + cbx->w.m.x;
w_t *w_par = cbx->w.w_parent; w_t *w_par = cbx->w.w_parent;
+1 -1
View File
@@ -15,7 +15,7 @@ typedef struct {
bool w_checkbox_default_key_action(w_cb_args_t *args); bool w_checkbox_default_key_action(w_cb_args_t *args);
w_checkbox_t *w_checkbox_init(WINDOW **win, w_t *w_parent, char *label); w_checkbox_t *w_checkbox_init(WINDOW **win, w_t *w_parent, char *label);
int32_t w_checkbox_draw(w_checkbox_t *cbx, uint32_t active_id); int32_t w_checkbox_draw(w_checkbox_t *cbx, int32_t active_id);
void w_checkbox_destroy(w_checkbox_t *cbx); void w_checkbox_destroy(w_checkbox_t *cbx);
#endif #endif
+6 -6
View File
@@ -142,7 +142,7 @@ void w_dialogue_callback_default(w_cb_args_t *args) {
void w_dialogue_init(w_dialogue_t *dialogue, const char title[], void w_dialogue_init(w_dialogue_t *dialogue, const char title[],
const char text[], coordinates_t *p_coordinates) { const char text[], coordinates_t *p_coordinates) {
uint32_t t_size = 0; int32_t t_size = 0;
dialogue->win = 0; dialogue->win = 0;
dialogue->g_content = NULL; dialogue->g_content = NULL;
dialogue->w.sz.x = 0; dialogue->w.sz.x = 0;
@@ -222,12 +222,12 @@ int32_t w_dialogue_draw(w_dialogue_t *d) {
w_g_el_t *ae_ptr = NULL; /* active element */ w_g_el_t *ae_ptr = NULL; /* active element */
/* count dimensions */ /* count dimensions */
uint32_t x = 1; /* when uses box */ int32_t x = 1; /* when uses box */
uint32_t y = 1; /* when uses box */ int32_t y = 1; /* when uses box */
/* analyze text content */ /* analyze text content */
uint32_t line_count = 0; int32_t line_count = 0;
uint32_t line_max_len = 0; int32_t line_max_len = 0;
line_max_len = w_get_max_line_len(d->text, &line_count); line_max_len = w_get_max_line_len(d->text, &line_count);
y += line_count; y += line_count;
y += 2; /* margin for text */ y += 2; /* margin for text */
@@ -265,7 +265,7 @@ int32_t w_dialogue_draw(w_dialogue_t *d) {
} }
/* title */ /* title */
const uint32_t title_mx_pos = (d->w.sz.x - strlen(d->w.title)) / 2; const int32_t title_mx_pos = (d->w.sz.x - strlen(d->w.title)) / 2;
box(d->win, 0, 0); box(d->win, 0, 0);
mvwprintw(d->win, 0, title_mx_pos - 1, " "); mvwprintw(d->win, 0, title_mx_pos - 1, " ");
mvwprintw(d->win, 0, title_mx_pos, "%s", d->w.title); mvwprintw(d->win, 0, title_mx_pos, "%s", d->w.title);
+4 -4
View File
@@ -13,10 +13,10 @@ typedef struct group_el_init_t {
bool is_default; bool is_default;
bool is_hidden_value; bool is_hidden_value;
char label[DIALOGUE_TITLE]; char label[DIALOGUE_TITLE];
uint32_t length; int32_t length;
enum w_g_dir direction; enum w_g_dir direction;
union { union {
int64_t num; int32_t num;
} val; } val;
struct group_el_init_t *children; struct group_el_init_t *children;
} w_group_el_init_t; } w_group_el_init_t;
@@ -25,8 +25,8 @@ typedef struct group_t {
w_t w; w_t w;
w_g_el_t *elements; w_g_el_t *elements;
enum w_g_dir direction; enum w_g_dir direction;
uint32_t count; int32_t count;
uint32_t first_id, last_id; int32_t first_id, last_id;
struct group_t *parent_group; struct group_t *parent_group;
} w_group_t; } w_group_t;
+31 -10
View File
@@ -8,13 +8,17 @@
#include "../app.h" #include "../app.h"
#include "input.h" #include "input.h"
#include <wchar.h>
#include <widget_core.h> #include <widget_core.h>
bool w_input_default_key_action(w_cb_args_t *args) { bool w_input_default_key_action(w_cb_args_t *args) {
int32_t key = *((int32_t *)args->data); int32_t key = *((int32_t *)args->data);
w_g_el_t *g_el = args->active_el; w_g_el_t *g_el = args->active_el;
w_input_t *input = g_el->element; w_input_t *input = g_el->element;
int64_t start_pos = 0; int32_t start_pos = 0;
wchar_t w_key[2];
app_t *app = args->app;
char long_key[3];
switch (key) { switch (key) {
case KEY_BACKSPACE: case KEY_BACKSPACE:
@@ -30,14 +34,27 @@ bool w_input_default_key_action(w_cb_args_t *args) {
} }
break; break;
default: default:
if (input->value_len == input->max_len) break;
long_key[0] = key;
if ((key & 0xC0) == 0xC0) {
long_key[1] = wgetch(app->win);
long_key[2] = '\0';
} else {
long_key[1] = '\0';
}
mbstowcs(w_key, (const char *)&long_key, 2);
if (input->cur_pos > 0) { if (input->cur_pos > 0) {
start_pos = input->value_len++ - input->cur_pos; start_pos = input->value_len++ - input->cur_pos;
memmove(input->value + start_pos + 1, input->value + start_pos, memmove(input->value + start_pos + 1, input->value + start_pos,
input->value_len - start_pos); input->value_len - start_pos);
input->value[start_pos] = key; input->value[start_pos] = key;
input->w_value[start_pos] = w_key[0];
} else { } else {
input->value[input->value_len++] = key; input->value[input->value_len++] = key;
input->value[input->value_len] = '\0'; input->value[input->value_len] = '\0';
input->w_value[input->value_len - 1] = w_key[0];
input->w_value[input->value_len] = '\0';
} }
break; break;
} }
@@ -46,14 +63,14 @@ bool w_input_default_key_action(w_cb_args_t *args) {
} }
w_input_t *w_input_init(WINDOW **win, w_t *w_parent, char *label, w_input_t *w_input_init(WINDOW **win, w_t *w_parent, char *label,
uint32_t length, uint32_t is_hidden_value) { int32_t length, int32_t is_hidden_value) {
w_input_t *input = malloc(sizeof(w_input_t)); w_input_t *input = malloc(sizeof(w_input_t));
w_init(&(input->w), w_parent, win, label); w_init(&(input->w), w_parent, win, label);
input->is_disabled = 0; input->is_disabled = 0;
input->w.sz.y = 3; // with borders input->w.sz.y = 3; // with borders
input->w.sz.x = input->w.sz.x =
length + 3; // with borders and extra space for the last element length + 3; // with borders and extra space for the last element
uint32_t t_len = strlen(input->w.title) + 4; // with borders and space int32_t t_len = strlen(input->w.title) + 4; // with borders and space
if (input->w.sz.x < t_len) if (input->w.sz.x < t_len)
input->w.sz.x = t_len; input->w.sz.x = t_len;
input->w.ps.x = 1; input->w.ps.x = 1;
@@ -65,11 +82,11 @@ w_input_t *w_input_init(WINDOW **win, w_t *w_parent, char *label,
return input; return input;
} }
int32_t w_input_draw(w_input_t *input, uint32_t active_id) { int32_t w_input_draw(w_input_t *input, int32_t active_id) {
const char stars[] = "*******************"; const char stars[] = "*******************";
WINDOW *win = *(input->w.parent_win); WINDOW *win = *(input->w.parent_win);
uint32_t pos_y = input->w.ps.y + input->w.m.y; int32_t pos_y = input->w.ps.y + input->w.m.y;
uint32_t pos_x = input->w.ps.x + input->w.m.x; int32_t pos_x = input->w.ps.x + input->w.m.x;
/* counts margins of the ancestors of the same window */ /* counts margins of the ancestors of the same window */
w_t *w_par = input->w.w_parent; w_t *w_par = input->w.w_parent;
@@ -108,15 +125,19 @@ int32_t w_input_draw(w_input_t *input, uint32_t active_id) {
wattrset(win, COLOR_PAIR(0) | A_BOLD); wattrset(win, COLOR_PAIR(0) | A_BOLD);
} }
pos_y++;
if (input->is_hidden) { if (input->is_hidden) {
mvwprintw(win, pos_y + 1, pos_x, "%.*s%*s", (int)input->value_len, stars, mvwprintw(win, pos_y, pos_x, "%.*s%*s", (int)input->value_len, stars,
(int)(input->w.sz.x - input->value_len - 2), ""); (int)(input->w.sz.x - input->value_len - 2), "");
} else { } else {
mvwprintw(win, pos_y + 1, pos_x, "%s%*s", input->value, pos_x = 2;
(int)(input->w.sz.x - input->value_len - 2), ""); mvwaddnwstr(win, pos_y, pos_x, input->w_value, input->max_len);
mvwprintw(win, pos_y, pos_x + input->value_len, "%*s",
input->w.sz.x - input->value_len - 2, "");
} }
input->w.cur.y = pos_y + 1; input->w.cur.y = pos_y;
input->w.cur.x = pos_x + input->value_len - input->cur_pos; input->w.cur.x = pos_x + input->value_len - input->cur_pos;
wattroff(win, A_BOLD | A_REVERSE); wattroff(win, A_BOLD | A_REVERSE);
+6 -5
View File
@@ -10,18 +10,19 @@
typedef struct { typedef struct {
w_t w; w_t w;
wchar_t w_value[INPUT_TEXT];
char value[INPUT_TEXT]; char value[INPUT_TEXT];
int64_t cur_pos; /* is relative to the end of a string */ int32_t cur_pos; /* is relative to the end of a string */
int64_t value_len; int32_t value_len;
int64_t max_len; int32_t max_len;
bool is_disabled; bool is_disabled;
bool is_hidden; bool is_hidden;
} w_input_t; } w_input_t;
bool w_input_default_key_action(w_cb_args_t *args); bool w_input_default_key_action(w_cb_args_t *args);
w_input_t *w_input_init(WINDOW **win, w_t *w_parent, char *label, w_input_t *w_input_init(WINDOW **win, w_t *w_parent, char *label,
uint32_t size, uint32_t is_hidden_value); int32_t size, int32_t is_hidden_value);
int32_t w_input_draw(w_input_t *input, uint32_t active_id); int32_t w_input_draw(w_input_t *input, int32_t active_id);
void w_input_destroy(w_input_t *input); void w_input_destroy(w_input_t *input);
#endif #endif
+3 -3
View File
@@ -20,8 +20,8 @@ w_pgb_ui_t *w_pgb_ui_init(WINDOW **win, w_t *w_parent) {
void w_pgb_ui_draw(w_pgb_ui_t *pb) { void w_pgb_ui_draw(w_pgb_ui_t *pb) {
WINDOW *win = *(pb->w.w_parent->parent_win); WINDOW *win = *(pb->w.w_parent->parent_win);
uint32_t margin_y = pb->w.ps.y + pb->w.w_parent->ps.y; int32_t margin_y = pb->w.ps.y + pb->w.w_parent->ps.y;
uint32_t margin_x = pb->w.ps.x + pb->w.w_parent->ps.x + 1; int32_t margin_x = pb->w.ps.x + pb->w.w_parent->ps.x + 1;
wattrset(win, COLOR_PAIR(modal_color_pair)); wattrset(win, COLOR_PAIR(modal_color_pair));
@@ -29,7 +29,7 @@ void w_pgb_ui_draw(w_pgb_ui_t *pb) {
float procent = pb->procent; float procent = pb->procent;
procent /= 100; procent /= 100;
uint32_t filled_num = procent * pb->w.sz.x; int32_t filled_num = procent * pb->w.sz.x;
if (filled_num > 2) { if (filled_num > 2) {
filled_num -= 2; filled_num -= 2;
} }
+1 -1
View File
@@ -8,7 +8,7 @@
typedef struct { typedef struct {
w_t w; w_t w;
uint32_t procent; int32_t procent;
char text[24]; char text[24];
} w_pgb_ui_t; } w_pgb_ui_t;
+22 -22
View File
@@ -13,7 +13,7 @@
#include <string.h> #include <string.h>
#include <utils.h> #include <utils.h>
extern uint32_t m_id; extern int32_t m_id;
void w_init(w_t *w, w_t *w_parent, WINDOW **win, char *title) { void w_init(w_t *w, w_t *w_parent, WINDOW **win, char *title) {
w->id = m_id++; w->id = m_id++;
@@ -35,11 +35,11 @@ void w_init(w_t *w, w_t *w_parent, WINDOW **win, char *title) {
strcpy(w->title, title); strcpy(w->title, title);
} }
int32_t w_get_max_line_len(const char *text, uint32_t *line_count) { int32_t w_get_max_line_len(const char *text, int32_t *line_count) {
uint32_t nl_pos = 0; /* new line position */ int32_t nl_pos = 0; /* new line position */
uint32_t c_len = 0; /* current line length */ int32_t c_len = 0; /* current line length */
uint32_t m_len = 0; /* max length */ int32_t m_len = 0; /* max length */
uint32_t line_num = 1; int32_t line_num = 1;
for (int i = 0; text[i] != '\0'; i++, c_len++) { for (int i = 0; text[i] != '\0'; i++, c_len++) {
if (text[i] == '\n') { if (text[i] == '\n') {
if (i - nl_pos > c_len || !m_len) { if (i - nl_pos > c_len || !m_len) {
@@ -72,41 +72,41 @@ int32_t w_get_max_line_len(const char *text, uint32_t *line_count) {
} }
*/ */
void PRINT_TEXT(WINDOW *win, char *l_buf, char *text, int64_t i, void PRINT_TEXT(WINDOW *win, char *l_buf, char *text, int32_t i,
int64_t c_line_len, int64_t win_width, int64_t line_v_pos, int32_t c_line_len, int32_t win_width, int32_t line_v_pos,
int64_t attrs, int64_t x, int64_t max_line_len) { int32_t attrs, int32_t x, int32_t max_line_len) {
int64_t utf8len = 0; int32_t utf8len = 0;
strncpy(l_buf, text + i - c_line_len, c_line_len); strncpy(l_buf, text + i - c_line_len, c_line_len);
l_buf[c_line_len] = '\0'; l_buf[c_line_len] = '\0';
utf8len = u_utf8_code_points_count(l_buf); utf8len = u_utf8_code_points_count(l_buf);
if ((attrs & PMT_ALIGN_CENTER) == PMT_ALIGN_CENTER) { if ((attrs & PMT_ALIGN_CENTER) == PMT_ALIGN_CENTER) {
int64_t _x = (win_width - utf8len) / 2; int32_t _x = (win_width - utf8len) / 2;
u_utf8_curs_printw(win, &line_v_pos, &_x, l_buf, -1, false); u_utf8_curs_printw(win, &line_v_pos, &_x, l_buf, -1, false);
} else if (attrs & PMT_POS_CENTER) { } else if (attrs & PMT_POS_CENTER) {
int64_t _x = (win_width - max_line_len) / 2; int32_t _x = (win_width - max_line_len) / 2;
u_utf8_curs_printw(win, &line_v_pos, &_x, l_buf, -1, false); u_utf8_curs_printw(win, &line_v_pos, &_x, l_buf, -1, false);
} else { } else {
u_utf8_curs_printw(win, &line_v_pos, &x, l_buf, -1, false); u_utf8_curs_printw(win, &line_v_pos, &x, l_buf, -1, false);
} }
} }
uint32_t w_print_multiline_text(WINDOW *win, const char *_text, int32_t w_print_multiline_text(WINDOW *win, const char *_text,
const uint32_t win_width, const uint32_t y, const int32_t win_width, const int32_t y,
const uint32_t x, const uint16_t attrs) { const int32_t x, const int16_t attrs) {
uint16_t line_v_pos = y; int16_t line_v_pos = y;
int64_t c_line_len = 0; int32_t c_line_len = 0;
int64_t m_line_len = 0; int32_t m_line_len = 0;
int64_t i = 0; int32_t i = 0;
char l_buf[DIALOGUE_TEXT]; char l_buf[DIALOGUE_TEXT];
char *text = malloc(strlen(_text) + 1); char *text = malloc(strlen(_text) + 1);
strcpy(text, _text); strcpy(text, _text);
uint l_size = 0; int l_size = 0;
for (uint m = 0; text[m] != '\0'; m++) { for (int m = 0; text[m] != '\0'; m++) {
if (text[m] != '\n') { if (text[m] != '\n') {
if (l_size >= win_width) { if (l_size >= win_width) {
uint j = m; int j = m;
while (text[j] != ' ') { while (text[j] != ' ') {
j--; j--;
} }
+16 -16
View File
@@ -35,13 +35,13 @@ struct w_val_t {
enum w_val_type type; enum w_val_type type;
union { union {
void *ptr; void *ptr;
int64_t num; int32_t num;
} val; } val;
}; };
typedef struct { typedef struct {
int64_t id; int32_t id;
int64_t idx; /* element index in the group */ int32_t idx; /* element index in the group */
void *element; void *element;
enum w_type type; enum w_type type;
enum w_g_type g_type; enum w_g_type g_type;
@@ -75,23 +75,23 @@ typedef void (*w_cb_t)(w_cb_args_t *args);
typedef int32_t (*w_cb_press_t)(void *app, void *data); typedef int32_t (*w_cb_press_t)(void *app, void *data);
typedef struct w_t { typedef struct w_t {
int64_t id; int32_t id;
char title[DIALOGUE_TITLE]; char title[DIALOGUE_TITLE];
struct { struct {
int64_t y; int32_t y;
int64_t x; int32_t x;
} cur; /* cursor position */ } cur; /* cursor position */
struct { struct {
int64_t y; int32_t y;
int64_t x; int32_t x;
} sz; /* size */ } sz; /* size */
struct { struct {
int64_t y; int32_t y;
int64_t x; int32_t x;
} m; /* margin (relative to the parent) */ } m; /* margin (relative to the parent) */
struct { struct {
int64_t y; int32_t y;
int64_t x; int32_t x;
} ps; /* position (relative to the window) */ } ps; /* position (relative to the window) */
WINDOW *const *parent_win; WINDOW *const *parent_win;
struct w_t *w_parent; struct w_t *w_parent;
@@ -104,9 +104,9 @@ enum w_pmt_attrs {
}; };
void w_init(w_t *w, w_t *w_parent, WINDOW **win, char *title); void w_init(w_t *w, w_t *w_parent, WINDOW **win, char *title);
int32_t w_get_max_line_len(const char *text, uint32_t *line_count); int32_t w_get_max_line_len(const char *text, int32_t *line_count);
uint32_t w_print_multiline_text(WINDOW *win, const char *text, int32_t w_print_multiline_text(WINDOW *win, const char *text,
const uint32_t win_width, const uint32_t y, const int32_t win_width, const int32_t y,
const uint32_t x, const uint16_t attrs); const int32_t x, const int16_t attrs);
#endif #endif
+13 -13
View File
@@ -44,7 +44,7 @@ static void w_fl_cb(w_cb_args_t *args) {
fui->search_key->slen = 0; fui->search_key->slen = 0;
sprintf(q_prefix, "file list"); sprintf(q_prefix, "file list");
} }
server_send_string(app->query_args, "%s %u %u\n", q_prefix, server_send_string(app->query_args, "%s %d %d\n", q_prefix,
fui->max_lines, 1); fui->max_lines, 1);
w_fl_reset(fui); w_fl_reset(fui);
} else { } else {
@@ -60,7 +60,7 @@ static void w_fl_cb(w_cb_args_t *args) {
fui->current_idx++; fui->current_idx++;
} else if (fui->current_page < fui->pages) { } else if (fui->current_page < fui->pages) {
app->query_args->state = S_FILE_LIST; app->query_args->state = S_FILE_LIST;
server_send_string(app->query_args, "%s %u %u\n", q_prefix, server_send_string(app->query_args, "%s %d %d\n", q_prefix,
fui->max_lines, fui->current_page + 1); fui->max_lines, fui->current_page + 1);
w_fl_reset(fui); w_fl_reset(fui);
break; break;
@@ -72,7 +72,7 @@ static void w_fl_cb(w_cb_args_t *args) {
fui->current_idx--; fui->current_idx--;
} else if (fui->current_page > 1) { } else if (fui->current_page > 1) {
app->query_args->state = S_FILE_LIST; app->query_args->state = S_FILE_LIST;
server_send_string(app->query_args, "%s %u %u\n", q_prefix, server_send_string(app->query_args, "%s %d %d\n", q_prefix,
fui->max_lines, fui->current_page - 1); fui->max_lines, fui->current_page - 1);
w_fl_reset(fui); w_fl_reset(fui);
fui->activate_last = true; fui->activate_last = true;
@@ -83,7 +83,7 @@ static void w_fl_cb(w_cb_args_t *args) {
case KEY_NPAGE: case KEY_NPAGE:
if (fui->current_page < fui->pages) { if (fui->current_page < fui->pages) {
app->query_args->state = S_FILE_LIST; app->query_args->state = S_FILE_LIST;
server_send_string(app->query_args, "%s %u %u\n", q_prefix, server_send_string(app->query_args, "%s %d %d\n", q_prefix,
fui->max_lines, fui->current_page + 1); fui->max_lines, fui->current_page + 1);
w_fl_reset(fui); w_fl_reset(fui);
break; break;
@@ -93,7 +93,7 @@ static void w_fl_cb(w_cb_args_t *args) {
case KEY_PPAGE: case KEY_PPAGE:
if (fui->current_page > 1) { if (fui->current_page > 1) {
app->query_args->state = S_FILE_LIST; app->query_args->state = S_FILE_LIST;
server_send_string(app->query_args, "%s %u %u\n", q_prefix, server_send_string(app->query_args, "%s %d %d\n", q_prefix,
fui->max_lines, fui->current_page - 1); fui->max_lines, fui->current_page - 1);
w_fl_reset(fui); w_fl_reset(fui);
fui->activate_last = true; fui->activate_last = true;
@@ -107,7 +107,7 @@ static void w_fl_cb(w_cb_args_t *args) {
fui->search_key->slen = 0; fui->search_key->slen = 0;
sprintf(q_prefix, "file list"); sprintf(q_prefix, "file list");
app->query_args->state = S_FILE_LIST; app->query_args->state = S_FILE_LIST;
server_send_string(app->query_args, "%s %u %u\n", q_prefix, fui->max_lines, server_send_string(app->query_args, "%s %d %d\n", q_prefix, fui->max_lines,
1); 1);
w_fl_reset(fui); w_fl_reset(fui);
case '\n': case '\n':
@@ -196,8 +196,8 @@ void *w_fl_init(app_t *app) {
/* * INIT UI * */ /* * INIT UI * */
/* define the width for each sub window */ /* define the width for each sub window */
int64_t left_w_x = app->coordinates.max_x / 10 * 5; int32_t left_w_x = app->coordinates.max_x / 10 * 5;
int64_t right_w_x = app->coordinates.max_x - left_w_x - 2; int32_t right_w_x = app->coordinates.max_x - left_w_x - 2;
/* create the list window */ /* create the list window */
fui->win_list = newwin(app->coordinates.max_y - 4, left_w_x, 2, 1); fui->win_list = newwin(app->coordinates.max_y - 4, left_w_x, 2, 1);
@@ -234,7 +234,7 @@ void w_fl_reset_app(void *app) {
void w_fl_draw(w_ui_file_list_t *fui) { void w_fl_draw(w_ui_file_list_t *fui) {
int32_t sz_y, sz_x; int32_t sz_y, sz_x;
int64_t p_y, p_x; int32_t p_y, p_x;
WINDOW *win = fui->win_list; WINDOW *win = fui->win_list;
getmaxyx(win, sz_y, sz_x); getmaxyx(win, sz_y, sz_x);
@@ -314,8 +314,8 @@ void w_fl_draw(w_ui_file_list_t *fui) {
curs_set(true); curs_set(true);
wmove(win, p_y, p_x + p_len); wmove(win, p_y, p_x + p_len);
} else { } else {
uint32_t l_pad = 0; int32_t l_pad = 0;
sprintf(p_info, "P: %u/%u F: %u L: %u%n", fui->current_page, fui->pages, sprintf(p_info, "P: %d/%d F: %d L: %d%n", fui->current_page, fui->pages,
fui->current_count, fui->full_count, &p_len); fui->current_count, fui->full_count, &p_len);
if (fui->search_key->slen > 0) { if (fui->search_key->slen > 0) {
@@ -325,7 +325,7 @@ void w_fl_draw(w_ui_file_list_t *fui) {
l_pad = fui->search_key->slen + 2; l_pad = fui->search_key->slen + 2;
mvwprintw(win, p_y, p_x + l_pad, " %.*s", sz_x - l_pad, p_info); mvwprintw(win, p_y, p_x + l_pad, " %.*s", sz_x - l_pad, p_info);
} else { } else {
sprintf(p_info, "page: %u/%u files: %u left: %u%n", fui->current_page, sprintf(p_info, "page: %d/%d files: %d left: %d%n", fui->current_page,
fui->pages, fui->current_count, fui->full_count, &p_len); fui->pages, fui->current_count, fui->full_count, &p_len);
l_pad = (sz_x - p_len) / 2; l_pad = (sz_x - p_len) / 2;
if (!(l_pad % 2)) { if (!(l_pad % 2)) {
@@ -337,7 +337,7 @@ void w_fl_draw(w_ui_file_list_t *fui) {
/* Draw file info [right side] */ /* Draw file info [right side] */
{ {
int64_t p_y = 1; int32_t p_y = 1;
p_x = 1; p_x = 1;
WINDOW *i_win = fui->win_info; WINDOW *i_win = fui->win_info;
wclear(i_win); wclear(i_win);
+5 -5
View File
@@ -14,11 +14,11 @@ typedef struct {
fl_item_t **current; fl_item_t **current;
fl_item_t **start; fl_item_t **start;
int32_t current_idx; int32_t current_idx;
uint32_t current_count; int32_t current_count;
uint32_t full_count; int32_t full_count;
uint32_t pages; int32_t pages;
uint32_t current_page; int32_t current_page;
uint32_t max_lines; int32_t max_lines;
WINDOW *win_info; WINDOW *win_info;
WINDOW *win_list; WINDOW *win_list;
bstring search_key; bstring search_key;
+3 -3
View File
@@ -333,7 +333,7 @@ static int32_t process_user_input(app_t *app, w_cb_args_t *d_args) {
case 'd': case 'd':
case '\33': /* ESC key */ case '\33': /* ESC key */
if (!app->modal.is_initiated) { if (!app->modal.is_initiated) {
server_send_string(app->query_args, "file list %u %u\n", server_send_string(app->query_args, "file list %d %d\n",
fui->max_lines - 1, 1); fui->max_lines - 1, 1);
main_window_set(app, mw_fl_server); main_window_set(app, mw_fl_server);
d_args->element = app->main_ui.ui; d_args->element = app->main_ui.ui;
@@ -410,7 +410,7 @@ void w_lfl_reset_app(void *app) {
void w_lfl_draw(w_lfl_ui_t *fui) { void w_lfl_draw(w_lfl_ui_t *fui) {
int32_t sz_y, sz_x; int32_t sz_y, sz_x;
int64_t p_y, p_x; int32_t p_y, p_x;
WINDOW *win = fui->win_list; WINDOW *win = fui->win_list;
getmaxyx(win, sz_y, sz_x); getmaxyx(win, sz_y, sz_x);
int32_t sz_y_f = sz_y - 1; // actual size (without box) int32_t sz_y_f = sz_y - 1; // actual size (without box)
@@ -453,7 +453,7 @@ void w_lfl_draw(w_lfl_ui_t *fui) {
/* Draw file info [right side] */ /* Draw file info [right side] */
{ {
int64_t p_y = 1; int32_t p_y = 1;
p_x = 1; p_x = 1;
WINDOW *i_win = fui->win_info; WINDOW *i_win = fui->win_info;
wclear(i_win); wclear(i_win);