poe

Уређивач .po фајлова
Дневник | Датотеке | Референце | ПРОЧИТАЈМЕ | ЛИЦЕНЦА

чување 7a8e79afe7e405ed2fe508a8fc856dbe91ea12ee
родитељ 7b0d1012c036793ce3dd29fe96c25549184055c6
Аутор: Страхиња Радић <contact@strahinja.org>
Датум:   Fri,  9 Jul 2021 19:50:58 +0200

Small fixes in pre-0.5 code

Signed-off-by: Страхиња Радић <contact@strahinja.org>

Diffstat:
Mdraw.c | 2+-
Mpoe.c | 46++++++++++++++++++++++++++--------------------
измењених датотека: 2, додавања: 27(+), брисања: 21(-)

diff --git a/draw.c b/draw.c @@ -537,7 +537,7 @@ draw_help(const struct DrawState* state) while (row < LEN(help)) { if (!draw_string(startx+1, starty+1+row, DLG_FG, DLG_BG, - help[row], w-2, w-2, 2, 2, LEFT, 0, 1, + help[row], w-2, w-2, 1, 1, LEFT, 0, 1, NULL, 0, 0)) return NULL; row++; diff --git a/poe.c b/poe.c @@ -70,7 +70,8 @@ void erase_forward(struct DrawState* state); void erase_to_start(struct DrawState* state); void erase_to_end(struct DrawState* state); struct DrawState* insert_line(struct DrawState* state); -struct DrawState* join_lines(struct DrawState* state, size_t first_line); +struct DrawState* join_lines(struct DrawState* state, size_t first_line, + int forward); void handle_editbox_key_event(struct tb_event* ev, struct DrawState* state); void handle_key_event(struct tb_event* ev, struct DrawState* state); void handle_search_key_event(struct tb_event* ev, struct DrawState* state); @@ -986,7 +987,7 @@ move_end(struct DrawState* state) size_t dlen = display_length(state, state->input_buffer[ state->input_row].text, state->input_column); state->input_display_column = dlen; - if (dlen > EDIT_WIDTH-3) + if (dlen > EDIT_WIDTH-4) state->input_first_shown_column = dlen - EDIT_WIDTH+4; else state->input_first_shown_column = 0; @@ -1127,10 +1128,10 @@ insert_char(struct DrawState* state, uint32_t ch) state->input_buffer[state->input_row].text, state->input_column); if (state->input_display_column - state->input_first_shown_column - > EDIT_WIDTH-5) + > EDIT_WIDTH-4) { state->input_first_shown_column = state->input_display_column - - EDIT_WIDTH+5; + - EDIT_WIDTH+4; state->input_display_column = display_length(state, state->input_buffer[state->input_row].text, state->input_column); @@ -1158,27 +1159,25 @@ erase_backwards(struct DrawState* state) buffer_line->text[i-1] = 0; buffer_line->length--; state->input_column--; - if (state->input_column < - state->input_first_shown_column) - { - if (state->input_column > EDIT_WIDTH-6) - state->input_first_shown_column = - state->input_column - - EDIT_WIDTH+6; - else - state->input_first_shown_column = 0; - } state->input_display_column = display_length(state, state->input_buffer[ state->input_row].text, state->input_column); + if (state->input_display_column < + state->input_first_shown_column) + state->input_first_shown_column = + state->input_display_column; } else if (state->input_row > 0) - if (!join_lines(state, state->input_row-1)) + { + if (!join_lines(state, state->input_row-1, 0)) { strcpy(state->error, errors[ERR_CANT_ALLOC]); state->running = 0; } + else + move_end(state); + } } void @@ -1199,11 +1198,15 @@ erase_forward(struct DrawState* state) state->dirty = 1; } else if (state->input_row < state->input_rows_count-1) - if (!join_lines(state, state->input_row)) + { + if (!join_lines(state, state->input_row, 1)) { strcpy(state->error, errors[ERR_CANT_ALLOC]); state->running = 0; } + else + ; + } } void @@ -1285,7 +1288,7 @@ insert_line(struct DrawState* state) } struct DrawState* -join_lines(struct DrawState* state, size_t first_line) +join_lines(struct DrawState* state, size_t first_line, int forward) { if (!state) return NULL; @@ -1298,9 +1301,12 @@ join_lines(struct DrawState* state, size_t first_line) first_line+1].text, MAXBUFLINE); state->input_buffer[first_line].length = u32_strlen( state->input_buffer[first_line].text); - state->input_row--; - if (state->input_row < 0) - state->input_row = 0; + if (!forward) + { + state->input_row--; + if (state->input_row < 0) + state->input_row = 0; + } for (size_t i = first_line+1; i < state->input_rows_count-1; i++) {