Пример #1
0
int main(int argc, char ** argv) {
	dispx = MENU_SCREEN_X*20;
	dispy = MENU_SCREEN_Y*20 + 20;
	if ((dispx > 1000) || (dispy > 1000)) {
		dispx = 1000;
		dispy = 1000*MENU_SCREEN_Y/MENU_SCREEN_X;
	}
	glutInit(&argc, argv); //*must* be called before gui_init
	init_window();
	menu_redraw();
	demo_init();
	gui_init(); //*must* be called before the first menu_keypress()
	int i;
	for (i = 1; i < argc; i++) {
		int x = atoi(argv[i]);
		 if ((x > 0) && (x <= 255)) {
				menu_keypress(x);
		}
	}
	glutMouseFunc(input_mouse_key);
	glutPassiveMotionFunc(input_mouse_move);
	glutSpecialFunc(input_key_special);
	glutKeyboardFunc(input_key_normal);
	glutMainLoop();
	return 0;
}
Пример #2
0
void
modes_update(void)
{
	if(vle_mode_is(CMDLINE_MODE))
	{
		redraw_cmdline();
		return;
	}
	else if(vle_mode_is(MENU_MODE))
	{
		menu_redraw();
		return;
	}
	else if(vle_mode_is(FILE_INFO_MODE))
	{
		redraw_file_info_dialog();
		return;
	}

	touchwin(stdscr);
	update_all_windows();

	if(vle_mode_is(SORT_MODE))
	{
		redraw_sort_dialog();
	}
	else if(vle_mode_is(CHANGE_MODE))
	{
		redraw_change_dialog();
	}
	else if(vle_mode_is(ATTR_MODE))
	{
		redraw_attr_dialog();
	}
}
Пример #3
0
static void
cmd_ctrl_m(key_info_t key_info, keys_info_t *keys_info)
{
	static menu_info *saved_menu;

	vle_mode_set(NORMAL_MODE, VMT_PRIMARY);
	saved_menu = menu;
	if(menu->execute_handler != NULL && menu->execute_handler(curr_view, menu))
	{
		vle_mode_set(MENU_MODE, VMT_PRIMARY);
		menu_redraw();
		return;
	}

	if(!vle_mode_is(MENU_MODE))
	{
		reset_popup_menu(saved_menu);
	}
	else if(menu != saved_menu)
	{
		reset_popup_menu(saved_menu);
		update_menu();
	}

	update_ui_on_leaving();
}
Пример #4
0
static void
cmd_ctrl_m(key_info_t key_info, keys_info_t *keys_info)
{
	static menu_info *saved_menu;

	*mode = NORMAL_MODE;
	saved_menu = menu;
	if(execute_menu_cb(curr_view, menu) != 0)
	{
		*mode = MENU_MODE;
		menu_redraw();
		return;
	}

	if(*mode != MENU_MODE)
	{
		reset_popup_menu(saved_menu);
	}
	else if(menu != saved_menu)
	{
		reset_popup_menu(saved_menu);
		update_menu();
	}

	if(was_redraw)
		update_screen(UT_FULL);
	else
		update_all_windows();
}
Пример #5
0
void
menu_post(void)
{
	if(curr_stats.need_update != UT_NONE)
	{
		menu_redraw();
		curr_stats.need_update = UT_NONE;
	}
	status_bar_message(curr_stats.save_msg ? NULL : "");
}
Пример #6
0
void menu_do()
{
	uint16_t new_pos;
	const struct menuitem_t *menu;
		
	// initialize menu
	menu_depth = 0;
	menu_pos_stack[menu_depth] = 0;
	menu_item_stack[menu_depth] = menu_main;

	while (1) {
		uint8_t event = enc_read();
		
		// check encoder
		if (event == ENC_UP) {
			if (menu_pos_stack[menu_depth] > 0)
				menu_pos_stack[menu_depth]--;
		} else if (event == ENC_DOWN) {
			new_pos = menu_pos_stack[menu_depth] + 1;
			menu = menu_item_stack[menu_depth];

			if (pgm_read_byte(&menu[new_pos].type) != MENU_LAST)
				menu_pos_stack[menu_depth] = new_pos;
		}

		// check button - with stupid debouncer
		if (!(BUTTONS & _BV(BUT))) {
			_delay_ms(1);
			while (!(BUTTONS & _BV(BUT)));
			menu_action();
			_delay_ms(1);
			while (!(BUTTONS & _BV(BUT)));
		}

		menu_redraw();

		_delay_ms(10);
	}
}
Пример #7
0
static void redraw(int param) {
	g_state.subsecond++;
	if (g_state.subsecond == 8) {
		g_state.subsecond = 0;
		if (g_state.timerCountdownSecs) {
			g_state.timerCountdownSecs--;
		}
		animategfx();
	}
	//g_state.time = gettimestamp(); //comment out to test the manual date and time settings
	g_state.timescache = g_state.time % 60;
	g_state.timemcache = (g_state.time / 60) % 60;
	g_state.timehcache = (g_state.time / (60*60)) % 24;
	if (g_dispUpdate) {
		g_dispUpdate();
	}
	if ((g_dispUpdate) || (g_state.subsecond == 0)) {
		menu_redraw();
		menu_screen_flush();
		glutPostRedisplay();
	}
	glutTimerFunc(redraw_ms, redraw, 0);
}
Пример #8
0
void
redraw_cmdline(void)
{
	if(prev_mode == MENU_MODE)
	{
		menu_redraw();
	}
	else
	{
		redraw_window();
		if(prev_mode == SORT_MODE)
			redraw_sort_dialog();
		else if(prev_mode == ATTR_MODE)
			redraw_attr_dialog();
	}

	line_width = getmaxx(stdscr);
	curs_set(TRUE);
	update_cmdline_size();
	update_cmdline_text();

	if(cfg.wild_menu)
		draw_wild_menu(-1);
}
Пример #9
0
void
redraw_cmdline(void)
{
	if(prev_mode == MENU_MODE)
	{
		menu_redraw();
	}
	else
	{
		update_screen(UT_FULL);
		if(prev_mode == SORT_MODE)
			redraw_sort_dialog();
		else if(prev_mode == ATTR_MODE)
			redraw_attr_dialog();
	}

	line_width = getmaxx(stdscr);
	curs_set(TRUE);
	update_cmdline_size();
	update_cmdline_text();

	if(input_stat.complete_continue && cfg.wild_menu)
		draw_wild_menu(-1);
}
Пример #10
0
int mutt_menuLoop (MUTTMENU * menu)
{
  int i = OP_NULL;

  FOREVER {
    if (option (OPTMENUCALLER)) {
      unset_option (OPTMENUCALLER);
      return OP_NULL;
    }


    mutt_curs_set (0);

#ifdef USE_IMAP
    imap_keepalive ();
#endif

    if (menu_redraw (menu) == OP_REDRAW)
      return OP_REDRAW;

    menu->oldcurrent = menu->current;

    if (option (OPTARROWCURSOR))
      move (menu->current - menu->top + menu->offset, SW + 2);
    else if (option (OPTBRAILLEFRIENDLY))
      move (menu->current - menu->top + menu->offset, SW);
    else
      move (menu->current - menu->top + menu->offset, COLS - 1);

    mutt_refresh ();


    /* try to catch dialog keys before ops */
    if (menu->dialog && menu_dialog_dokey (menu, &i) == 0)
      return i;

    i = km_dokey (menu->menu);
    if (i == OP_TAG_PREFIX || i == OP_TAG_PREFIX_COND) {
      if (menu->tagged) {
        mvaddstr (LINES - 1, 0, "Tag-");
        clrtoeol ();
        i = km_dokey (menu->menu);
        menu->tagprefix = 1;
        CLEARLINE (LINES - 1);
      }
      else if (i == OP_TAG_PREFIX) {
        mutt_error _("No tagged entries.");

        i = -1;
      }
      else {                    /* None tagged, OP_TAG_PREFIX_COND */

        event_t tmp;

        while (UngetCount > 0) {
          tmp = mutt_getch ();
          if (tmp.op == OP_END_COND)
            break;
        }
        mutt_message _("Nothing to do.");

        i = -1;
      }
    }
    else if (menu->tagged && option (OPTAUTOTAG))
      menu->tagprefix = 1;
    else
      menu->tagprefix = 0;

    mutt_curs_set (1);

#if defined (USE_SLANG_CURSES) || defined (HAVE_RESIZETERM)
    if (SigWinch) {
      mutt_resize_screen ();
      menu->redraw = REDRAW_FULL;
      SigWinch = 0;
      clearok (stdscr, TRUE);   /*force complete redraw */
    }
#endif

    if (i == -1)
      continue;

    if (!menu->dialog)
      mutt_clear_error ();

    /* Convert menubar movement to scrolling */
    if (menu->dialog)
      i = menu_dialog_translate_op (i);

    switch (i) {
    case OP_NEXT_ENTRY:
      menu_next_entry (menu);
      break;
    case OP_PREV_ENTRY:
      menu_prev_entry (menu);
      break;
    case OP_HALF_DOWN:
      menu_half_down (menu);
      break;
    case OP_HALF_UP:
      menu_half_up (menu);
      break;
    case OP_NEXT_PAGE:
      menu_next_page (menu);
      break;
    case OP_PREV_PAGE:
      menu_prev_page (menu);
      break;
    case OP_NEXT_LINE:
      menu_next_line (menu);
      break;
    case OP_PREV_LINE:
      menu_prev_line (menu);
      break;
    case OP_FIRST_ENTRY:
      menu_first_entry (menu);
      break;
    case OP_LAST_ENTRY:
      menu_last_entry (menu);
      break;
    case OP_TOP_PAGE:
      menu_top_page (menu);
      break;
    case OP_MIDDLE_PAGE:
      menu_middle_page (menu);
      break;
    case OP_BOTTOM_PAGE:
      menu_bottom_page (menu);
      break;
    case OP_CURRENT_TOP:
      menu_current_top (menu);
      break;
    case OP_CURRENT_MIDDLE:
      menu_current_middle (menu);
      break;
    case OP_CURRENT_BOTTOM:
      menu_current_bottom (menu);
      break;
    case OP_SEARCH:
    case OP_SEARCH_REVERSE:
    case OP_SEARCH_NEXT:
    case OP_SEARCH_OPPOSITE:
      if (menu->search && !menu->dialog) {      /* Searching dialogs won't work */
        menu->oldcurrent = menu->current;
        if ((menu->current = menu_search (menu, i)) != -1)
          menu->redraw = REDRAW_MOTION;
        else
          menu->current = menu->oldcurrent;
      }
      else
        mutt_error _("Search is not implemented for this menu.");
      break;

    case OP_JUMP:
      if (menu->dialog)
        mutt_error (_("Jumping is not implemented for dialogs."));

      else
        menu_jump (menu);
      break;

    case OP_ENTER_COMMAND:
      CurrentMenu = menu->menu;
      mutt_enter_command ();
      if (option (OPTFORCEREDRAWINDEX)) {
        menu->redraw = REDRAW_FULL;
        unset_option (OPTFORCEREDRAWINDEX);
        unset_option (OPTFORCEREDRAWPAGER);
      }
      break;

    case OP_TAG:
      if (menu->tag && !menu->dialog) {
        if (menu->tagprefix && !option (OPTAUTOTAG)) {
          for (i = 0; i < menu->max; i++)
            menu->tagged += menu->tag (menu, i, 0);
          menu->redraw = REDRAW_INDEX;
        }
        else if (menu->max) {
          int i = menu->tag (menu, menu->current, -1);

          menu->tagged += i;
          if (i && option (OPTRESOLVE) && menu->current < menu->max - 1) {
            menu->current++;
            menu->redraw = REDRAW_MOTION_RESYNCH;
          }
          else
            menu->redraw = REDRAW_CURRENT;
        }
        else
          mutt_error _("No entries.");
      }
      else
        mutt_error _("Tagging is not supported.");
      break;

    case OP_SHELL_ESCAPE:
      mutt_shell_escape ();
      MAYBE_REDRAW (menu->redraw);
      break;

    case OP_WHAT_KEY:
      mutt_what_key ();
      break;

    case OP_REBUILD_CACHE:
      mx_rebuild_cache ();
      break;

    case OP_REDRAW:
      clearok (stdscr, TRUE);
      menu->redraw = REDRAW_FULL;
      break;

    case OP_HELP:
      mutt_help (menu->menu);
      menu->redraw = REDRAW_FULL;
      break;

    case OP_NULL:
      km_error_key (menu->menu);
      break;

    case OP_END_COND:
      break;

    default:
      return (i);
    }
  }
  /* not reached */
}
Пример #11
0
void menu_highlight(const int line) {
	GUI_Select_Item  (menu_handler, line + 1);
	GUI_Highlight_Sub(menu_handler, line + 1, false);

	menu_redraw();
}
Пример #12
0
void
modes_redraw(void)
{
	LOG_FUNC_ENTER;

	static int in_here;

	if(curr_stats.load_stage < 2)
	{
		return;
	}

	if(in_here++ > 0)
	{
		/* TODO: is this still needed?  Update scheduling might have solved issues
		 * caused by asynchronous execution of this function in the past. */
		return;
	}

	if(curr_stats.term_state != TS_NORMAL)
	{
		update_screen(UT_REDRAW);
		goto finish;
	}

	if(vle_mode_is(CMDLINE_MODE))
	{
		redraw_cmdline();
		goto finish;
	}
	else if(vle_primary_mode_is(MENU_MODE))
	{
		menu_redraw();
		if(vle_mode_is(MSG_MODE))
		{
			redraw_msg_dialog(0);
		}
		goto finish;
	}
	else if(vle_mode_is(FILE_INFO_MODE))
	{
		redraw_file_info_dialog();
		goto finish;
	}

	update_screen(UT_REDRAW);

	if(curr_stats.save_msg)
	{
		status_bar_message(NULL);
	}

	if(vle_mode_is(SORT_MODE))
	{
		redraw_sort_dialog();
	}
	else if(vle_mode_is(CHANGE_MODE))
	{
		redraw_change_dialog();
	}
	else if(vle_mode_is(ATTR_MODE))
	{
		redraw_attr_dialog();
	}
	else if(vle_mode_is(VIEW_MODE))
	{
		view_redraw();
	}
	else if(vle_mode_is(MSG_MODE))
	{
		redraw_msg_dialog(0);
	}

finish:
	if(--in_here > 0)
	{
		modes_redraw();
	}
}
Пример #13
0
/* Redraw TUI. */
static void
cmd_ctrl_l(key_info_t key_info, keys_info_t *keys_info)
{
	menu_redraw();
}
Пример #14
0
static void
input_line_changed(void)
{
	static wchar_t *previous;

	if(!cfg.inc_search || !input_stat.search_mode)
		return;

	if(prev_mode != MENU_MODE)
	{
		curr_view->top_line = input_stat.old_top;
		curr_view->list_pos = input_stat.old_pos;
	}
	else
	{
		load_menu_pos();
	}

	if(input_stat.line == NULL || input_stat.line[0] == L'\0')
	{
		if(cfg.hl_search)
		{
			clean_selected_files(curr_view);
			draw_dir_list(curr_view, curr_view->top_line);
			move_to_list_pos(curr_view, curr_view->list_pos);
		}
		free(previous);
		previous = NULL;
	}
	else if(previous == NULL || wcscmp(previous, input_stat.line) != 0)
	{
		char *p;

		free(previous);
		previous = my_wcsdup(input_stat.line);

		p = to_multibyte(input_stat.line);

		if(sub_mode == SEARCH_FORWARD_SUBMODE)
			exec_command(p, curr_view, GET_FSEARCH_PATTERN);
		else if(sub_mode == SEARCH_BACKWARD_SUBMODE)
			exec_command(p, curr_view, GET_BSEARCH_PATTERN);
		else if(sub_mode == MENU_SEARCH_FORWARD_SUBMODE ||
				sub_mode == MENU_SEARCH_BACKWARD_SUBMODE)
			search_menu_list(p, sub_mode_ptr);
		else if(sub_mode == VSEARCH_FORWARD_SUBMODE)
			exec_command(p, curr_view, GET_VFSEARCH_PATTERN);
		else if(sub_mode == VSEARCH_BACKWARD_SUBMODE)
			exec_command(p, curr_view, GET_VBSEARCH_PATTERN);

		free(p);
	}

	if(prev_mode != MENU_MODE)
	{
		draw_dir_list(curr_view, curr_view->top_line);
		move_to_list_pos(curr_view, curr_view->list_pos);
	}
	else
	{
		menu_redraw();
	}
}
Пример #15
0
/* Callback-like function, which is called every time input line is changed. */
static void
input_line_changed(void)
{
	static wchar_t *previous;

	if(!cfg.inc_search || (!input_stat.search_mode && sub_mode != FILTER_SUBMODE))
		return;

	set_view_port();

	if(input_stat.line == NULL || input_stat.line[0] == L'\0')
	{
		if(cfg.hl_search)
		{
			/* clear selection */
			if(prev_mode != MENU_MODE)
			{
				clean_selected_files(curr_view);
			}
			else
			{
				search_menu_list("", sub_mode_ptr);
			}
		}
		free(previous);
		previous = NULL;

		if(sub_mode == FILTER_SUBMODE)
		{
			set_local_filter("");
		}
	}
	else if(previous == NULL || wcscmp(previous, input_stat.line) != 0)
	{
		char *mbinput;

		free(previous);
		previous = my_wcsdup(input_stat.line);

		mbinput = to_multibyte(input_stat.line);

		switch(sub_mode)
		{
			case SEARCH_FORWARD_SUBMODE:
				exec_command(mbinput, curr_view, GET_FSEARCH_PATTERN);
				break;
			case SEARCH_BACKWARD_SUBMODE:
				exec_command(mbinput, curr_view, GET_BSEARCH_PATTERN);
				break;
			case VSEARCH_FORWARD_SUBMODE:
				exec_command(mbinput, curr_view, GET_VFSEARCH_PATTERN);
				break;
			case VSEARCH_BACKWARD_SUBMODE:
				exec_command(mbinput, curr_view, GET_VBSEARCH_PATTERN);
				break;
			case MENU_SEARCH_FORWARD_SUBMODE:
			case MENU_SEARCH_BACKWARD_SUBMODE:
				search_menu_list(mbinput, sub_mode_ptr);
				break;
			case FILTER_SUBMODE:
				set_local_filter(mbinput);
				break;

			default:
				assert("Unexpected filter type.");
				break;
		}

		free(mbinput);
	}

	if(prev_mode != MENU_MODE && prev_mode != VISUAL_MODE)
	{
		redraw_current_view();
	}
	else if(prev_mode != VISUAL_MODE)
	{
		menu_redraw();
	}
}
Пример #16
0
void menupage_refresh(menu_t *menu) {
	menupage_t *page = menu->current_page;

	menupage_display_line(page, page->current_line);
	menu_redraw();
}