char *ft_strtrim(char const *s) { char *swb; int i; int j; int end; i = 0; j = 0; end = ft_strlen(s) - 1; while (ft_space((int)s[i]) == 1) { i++; if (s[i] == '\0') return (((char*)s) + i); } while (ft_space((int)s[end]) == 1) end--; if (!(swb = (char*)malloc(sizeof(char) * (end - i + 2)))) return (NULL); while (i <= end) swb[j++] = s[i++]; swb[j] = '\0'; return (swb); }
t_elem *ft_get_input(char *s, t_elem *l, int *flag) { if (*flag == 1) *flag = 0; else if (s[0] == 27 && s[2] == 'A') ft_up(l); else if (s[0] == 27 && s[2] == 'B') ft_down(l); else if (s[0] == 32) ft_space(l); else if (s[0] == 1) ft_select_all(l); else if (s[0] == 24) ft_unselect_all(l); else if (s[0] == 27 && s[2] == 'F') ft_go_toend(l); else if (s[0] == 27 && s[2] == 'H') ft_go_home(l); else if ((s[0] == 27 && s[1] == 0) || s[0] == 4) ft_unset_canon(); else if (s[0] == '\n') ft_enter(l); else if (s[0] == 8 || s[0] == 127 || (s[0] == 27 && s[2] == '3')) l = ft_delete(l); return (l); }
void ft_print_comb(void) { char tab[3]; tab[0] = '0'; tab[1] = '1'; tab[2] = '2'; while (tab[0] <= '7') { tab[1] = tab[0] + 1; while (tab[1] <= '8') { tab[2] = tab[1] + 1; while (tab[2] <= '9') { ft_char(tab[0], tab[1], tab[2]); if (tab[0] != '7' || tab[1] != '8' || tab[2] != '9') ft_space(); tab[2]++; } tab[1]++; } tab[0]++; } }
long long ft_atoll(const char *str) { long long posneg; long long num; num = 0; posneg = 1; while ((!ft_dig(*str)) && *str != '-' && *str != '+') { if ((!ft_dig(*str)) && (!ft_space(*str)) && *str != '-' && *str != '+') return (0); str++; } if (*str == '-') { posneg = -1; str++; } else if (*str == '+') str++; while (ft_dig(*str)) { num = (num * 10) + ((long long)*str - 48); str++; } return (num * posneg); }
void ft_all(sel_list lalist, int argc, char *pos) { char read_char[5] = {0}; co_list coord; coord.x = 0; coord.y = 0; while (!(*(unsigned int *)read_char == 27)) { tputs(tgetstr("vi", NULL), 1, ft_putc); if (*(unsigned int *)read_char == 32) ft_space(&lalist, &coord, pos); if (*(unsigned int *)read_char == 4348699) ft_down(&lalist, argc, &coord, pos); if (*(unsigned int *)read_char == 4283163) ft_up(&lalist, argc, &coord, pos); if (*(unsigned int *)read_char == 10) { ft_aff(&lalist); exit(0); } ft_bzero(read_char, 5); read(0, read_char, 4); } tputs(tgetstr("te", NULL), 1, ft_putc); }
char *ft_strtrim(char const *s) { size_t i; size_t len; char *s1; if (s == NULL) return (NULL); i = 0; len = ft_strlen(s) - 1; while (i < len && ft_space(s[i])) i++; while (len > i && ft_space(s[len])) len--; if (i == len) return (ft_strnew(1)); s1 = ft_strsub(s, i, len - i + 1); return (s1); }
void key_callback(GLFWwindow *window, int key, int scancode, int action, int mods) { if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS) glfwSetWindowShouldClose(window, GL_TRUE); else if (key == GLFW_KEY_SPACE && (action == GLFW_PRESS || action == GLFW_REPEAT)) ft_space(ft_singleton(NULL)); if (scancode && mods) mods = scancode; }
int ft_print_c(t_env *env) { int i; i = 0; if (env->size && !env->zero && !env->minus && env->quest) i = ft_space(env->size, env); else if (env->size && env->zero && !env->minus && env->quest) i = ft_zero(env->size, env); else if (env->size && env->minus && env->quest) i = ft_minus(env->size, env); else { i = ft_strcmp(env->quest, "0") == -48 ? 1 : ft_strlen(env->quest); write(1, env->quest, ft_strlen(env->quest)); } return (i); }
void ft_command(t_list **l, char buf[4], struct termios *term) { int ret; t_list *cursor; cursor = (*l)->next; while (!check_break(buf, cursor)) { buf[0] = 0; buf[1] = 0; buf[2] = 0; tputs(tgetstr("cl", NULL), 1, tty_putchar); ft_underline(cursor, l); ret = read(0, buf, 3); buf[ret] = '\0'; ft_space(&cursor, buf); ft_up(&cursor, buf); ft_down(&cursor, buf); ft_check_esc(buf, term); ft_delete(cursor, buf, &cursor); } }
char *ft_itoa(int n) { char *a; int len; int pozitiv; if (n == -2147483648) return ("-2147483648"); pozitiv = 1; if (n < 0) { n = n * -1; pozitiv = 0; } len = ft_len1(n); if (pozitiv == 0) len++; a = (char *)malloc(sizeof(char) * len); a = ft_space(a, len, n); if (pozitiv == 0) a[0] = '-'; a[len] = '\0'; return (a); }