void term_event(unsigned int key, t_caps *caps) { if (key == 27) ft_exit(caps, 1); else if (ft_check_size(caps) == -1) return ; else if (key == 4345627) move_down(caps); else if (key == 4280091) move_top(caps); else if (key == 32) ft_select(caps); else if (key == 127 || key == 2117294875) ft_delete(caps); else if (key == 10 || key == 5066523) ft_return(caps); }
int check_axe(t_terrain* button, t_terrain* terrain) { if (check_left(button, terrain)) { move_left(button, terrain); return (1); } else if (check_right(button, terrain)) { move_right(button, terrain); return (1); } else if (check_top(button, terrain)) { move_top(button, terrain); return (1); } else if (check_bot(button, terrain)) { move_bot(button, terrain); return (1); } return (0); }
/** * Commands: * a -- * b -- * c -- conversation * d -- delete a tweet * e -- * f -- fav/unfav a tweet * g -- * h -- * i -- * j -- move down one tweet * J -- move down one page * k -- move up one tweet * K -- move up one page * l -- list * m -- direct message * n -- compose a new tweet * o -- * p -- * q -- quit * r -- reply * R -- reply to all * s -- search * t -- retweet * u -- * v -- move to the last viewed tweet * w -- * x -- * y -- * z -- * ? -- show shortcuts help * . -- refresh */ void wait_command(WINDOW *win) { char ch = '\0'; while((ch = getch()) != 'q') { switch(ch) { case 'n': // Compose new tweet notify_state_change(states[STATE_NORMAL]); compose_new_tweet(win,NULL,0); return_to_current_timeline(win); break; case 'J': // move down one page notify_state_change(states[STATE_NORMAL]); if(move_next_page(win,timelines[current_tl_index]->current_bottom,1) != -1) { timelines[current_tl_index]->current = timelines[current_tl_index]->current_top; highlight_status(win, timelines[current_tl_index]->current); } else notify_error_state(); break; case 'K': // move up one page notify_state_change(states[STATE_NORMAL]); if(move_next_page(win,timelines[current_tl_index]->current_top,-1)!= -1) { timelines[current_tl_index]->current = timelines[current_tl_index]->current_top; highlight_status(win, timelines[current_tl_index]->current); } else notify_error_state(); break; case 'j': // move down one tweet notify_state_change(states[STATE_NORMAL]); move_next(win, timelines[current_tl_index]->current,1); break; case 'k': // move up one tweet notify_state_change(states[STATE_NORMAL]); move_next(win, timelines[current_tl_index]->current,-1); break; case '.': // refresh the current timeline /* notify_state_change(states[STATE_RETRIEVING_UPDATES]); struct status_node *to_status = timelines[current_tl_index]->head; int res = update_timeline(current_tl_index,NULL,to_status); if(res >= 0){ char *state_str = malloc(20*sizeof(char)); memset(state_str,'\0',20); if(res == 0) sprintf(state_str,"%s","No updates."); else if(res == 1) sprintf(state_str,"%d new tweet.",res); else sprintf(state_str,"%d new tweets.",res); notify_state_change(state_str); free(state_str); } else notify_error_state(); */ merge_timeline_updates(current_tl_index); timelines[current_tl_index]->last_viewed = timelines[current_tl_index]->current; move_top(win); notify_timeline_updates(current_tl_index,0); break; case 'v': notify_state_change(states[STATE_NORMAL]); if(timelines[current_tl_index]->last_viewed) { int y,x; struct status_node *last_viewed = timelines[current_tl_index]->last_viewed; getmaxyx(win,y,x); timelines[current_tl_index]->current = last_viewed; timelines[current_tl_index]->current_top = last_viewed; timelines[current_tl_index]->current_bottom = show_timeline(win,last_viewed,y,x); highlight_status(win,last_viewed); } else notify_state_change(states[STATE_NO_LAST_VIEWED]); break; case 'r': compose_new_tweet(win,timelines[current_tl_index]->current->st,0); return_to_current_timeline(win); break; case 'R': compose_new_tweet(win,timelines[current_tl_index]->current->st,1); return_to_current_timeline(win); break; case 't': if(timelines[current_tl_index]->current->st) { status *st = timelines[current_tl_index]->current->st; if(st->retweeted_status) st = st->retweeted_status; if(IS_PROTECTED(st->composer->extra_info)) notify_state_change("This user is protected. Cannot retweet."); else retweet_status(st->id); } break; } } }