int treat_key_backsp(void) { t_ctx *ctx; ctx = CTX; if (ctx->i > 0) { tputs(tgetstr("le", NULL), 1, ft_putput); tputs(tgetstr("dc", NULL), 1, ft_putput); --ctx->i; --ctx->pos.x; ft_del_char(); if (ctx->pos.x < 0) { tputs(tgetstr("up", NULL), 1, ft_putput); st_go_end(ctx->cols); tputs(tgetstr("dc", NULL), 1, ft_putput); ctx->pos.x = ctx->cols - 1; --ctx->pos.y; } if (ft_exceed()) ft_rewrite(FALSE); } return (OK); }
void w_set_map_or_directive(t_app *app, t_list **lst, char *line, int token) { int size; size = 0; if ((line[0] >= '0' && line[0] <= '9') || line[0] == '!') { if (w_check_line(app, line) == 1) token = 1; if (token == 0) line = ft_del_char(line, ' '); size = ft_strlen(line) + 2; if (line[size - 3] == '0') line[size - 3] = '1'; if (line[0] == '0') line[0] = '1'; ft_lstpush_back(lst, line, size); ft_strdel(&line); if (token == 0) app->map.y++; if (size > app->map.x && token == 0) app->map.x = size - 2; } }
void ft_delete_button(t_terminfo **nfo) { tputs(tgoto(tgetstr("le", NULL), 0, 0), 1, ft_int_putchar); tputs(tgetstr("dc", NULL), 1, ft_int_putchar); (*nfo)->line = ft_del_char((*nfo)->line, (*nfo)->pos_x - g_promptsz - 1); (*nfo)->pos_x--; (*nfo)->max_x--; }
static void ft_scroll2(int *i) { while (*i < g_e.i) { ft_del_char(g_e.buff, --g_e.i); tputs(tgetstr("le", NULL), 1, ft_putonterm); tputs(tgetstr("dc", NULL), 1, ft_putonterm); } ft_putstr(&g_e.buff[g_e.i]); }
char *ft_handle_quote(void) { char *specials; specials = ft_strdup("\"'"); while (*specials) { if (ft_count_char(g_main_line.cmd, *specials) % 2 != 0) return (ft_del_char(ft_complete_cmd(*specials, "\n"), *specials)); specials++; } return (g_main_line.cmd); }
void ft_arrow_down(t_terminfo **nf, t_hcontrol *control) { if (control->head->prev != NULL) control->head = control->head->prev; while ((*nf)->pos_x < (*nf)->max_x) ft_arrow_right(nf); while ((*nf)->pos_x > g_promptsz) { tputs(tgoto(tgetstr("le", NULL), 0, 0), 1, ft_int_putchar); tputs(tgetstr("dc", NULL), 1, ft_int_putchar); (*nf)->line = ft_del_char((*nf)->line, (*nf)->pos_x - g_promptsz + 1); (*nf)->pos_x--; (*nf)->max_x--; } if (control->head != NULL) { free((*nf)->line); (*nf)->line = ft_memalloc(ft_strlen(control->head->command)); ft_strcpy((*nf)->line, control->head->command); ft_putstr(control->head->command); (*nf)->pos_x = ft_strlen((*nf)->line) + g_promptsz; (*nf)->max_x = (*nf)->pos_x; } }