static void nullmodem_timer_proc(unsigned long data) { int i; unsigned long flags; //dprint("%s jiffies: %lu\n", __FUNCTION__, jiffies); unsigned long current_jiffies = jiffies; delta_jiffies = current_jiffies - last_timer_jiffies; last_timer_jiffies = current_jiffies; for (i=0; i<NULLMODEM_PAIRS; ++i) { struct nullmodem_pair *pair = &pair_table[i]; spin_lock_irqsave(&pair->spin, flags); handle_end(&pair->a); handle_end(&pair->b); spin_unlock_irqrestore(&pair->spin, flags); } nullmodem_timer.expires += TIMER_INTERVAL; add_timer(&nullmodem_timer); }
// Wait for input from user, quit if recieved 'q' keypress void Menu::get_keyboard_input() { while (! dying) { // Check if we need to resize window display if (is_term_resized(screen_lines, screen_cols)) { reframe_resized_window(); } // Check if we need to update content (i.e. been longer than 5 seconds) std::chrono::steady_clock::time_point current_time = std::chrono::steady_clock::now(); if (current_time > (last_update + std::chrono::seconds(5))) { get_lines(); } // Update window display after each key press print_window(); // This is blocking ch = getch(); switch(ch) { case KEY_UP: case 'k': move_cursor_up(); break; case KEY_DOWN: case 'j': move_cursor_down(); break; case KEY_LEFT: case 'h': move_cursor_left(); break; case KEY_RIGHT: case 'l': move_cursor_right(); break; case 'q': endwin(); dying = true; break; case KEY_PPAGE: handle_page_up(); break; case KEY_NPAGE: handle_page_down(); break; case KEY_HOME: handle_home(); break; case KEY_END: handle_end(); break; case KEY_ENTER: case 10: case 13: handle_enter_key(); break; default: // Uncoded key, ignore break; } } }
static int handle_end_array(void *ctx) { return handle_end(ctx, 1); }
static int handle_end_map(void *ctx) { return handle_end(ctx, 0); }