コード例 #1
0
ファイル: selcodepage.c プロジェクト: sfionov/mc-dev
/* Return value:
 *   -2 (SELECT_CHARSET_CANCEL)       : Cancel
 *   -1 (SELECT_CHARSET_OTHER_8BIT)   : "Other 8 bit"    if seldisplay == TRUE
 *   -1 (SELECT_CHARSET_NO_TRANSLATE) : "No translation" if seldisplay == FALSE
 *   >= 0                             : charset number
 */
int
select_charset (int center_y, int center_x, int current_charset, gboolean seldisplay)
{
    int i;
    char buffer[255];

    /* Create listbox */
    Listbox *listbox = create_listbox_window_centered (center_y, center_x,
					      n_codepages + 1, ENTRY_LEN + 2,
					      _("Choose codepage"),
					      "[Codepages Translation]");

    if (!seldisplay)
	LISTBOX_APPEND_TEXT (listbox, '-', _("-  < No translation >"),
			     NULL);

    /* insert all the items found */
    for (i = 0; i < n_codepages; i++) {
	char *name = codepages[i].name;
	g_snprintf (buffer, sizeof (buffer), "%c  %s", get_hotkey (i),
		    name);
	LISTBOX_APPEND_TEXT (listbox, get_hotkey (i), buffer, NULL);
    }
    if (seldisplay) {
	g_snprintf (buffer, sizeof (buffer), "%c  %s",
		    get_hotkey (n_codepages), _("Other 8 bit"));
	LISTBOX_APPEND_TEXT (listbox, get_hotkey (n_codepages), buffer,
			     NULL);
    }

    /* Select the default entry */
    i = (seldisplay)
	? ((current_charset < 0) ? n_codepages : current_charset)
	: (current_charset + 1);

    listbox_select_by_number (listbox->list, i);

    i = run_listbox (listbox);

    if (i < 0) {
	/* Cancel dialog */
	return SELECT_CHARSET_CANCEL;
    } else {
	/* some charset has been selected */
	if (seldisplay) {
	    /* charset list is finished with "Other 8 bit" item */
	    return (i >= n_codepages) ? SELECT_CHARSET_OTHER_8BIT : i;
	} else {
	    /* charset list is began with "-  < No translation >" item */
	    return (i - 1);
	}
    }
}
コード例 #2
0
ファイル: hotkeys.cpp プロジェクト: freeors/War-Of-Kingdom
hotkey_item& get_hotkey(const SDL_KeyboardEvent& event)
{
	return get_hotkey(event.keysym.sym, event.keysym.sym,
			(event.keysym.mod & KMOD_SHIFT) != 0,
			(event.keysym.mod & KMOD_CTRL) != 0,
			(event.keysym.mod & KMOD_ALT) != 0,
			(event.keysym.mod & KMOD_LGUI) != 0);
}
コード例 #3
0
ファイル: Curses.c プロジェクト: RajasekharBhumi/L4Re
/** Refresh the options window. */
static void refresh_options_window(void)
{
  int nPos = 0;
  const char* szHotKey = NULL;

  wclear(application_windows.pOptionsWin);
  mvwprintw(application_windows.pOptionsWin, 0, 1, "%s", f_szOptions);

  get_hotkey(f_szOptions, NULL);
  wattron(application_windows.pOptionsWin, A_BOLD);
  while (NULL != (szHotKey = get_hotkey((const char*)NULL, &nPos))) {
    mvwaddstr(application_windows.pOptionsWin, 0, nPos + 1, szHotKey);
  }
  wattroff(application_windows.pOptionsWin, A_BOLD);

  wrefresh(application_windows.pOptionsWin);
}
コード例 #4
0
ファイル: hotkeys.cpp プロジェクト: AG-Dev/wesnoth_ios
void key_event_execute(display& disp, const SDL_KeyboardEvent& event, command_executor* executor)
{
	const hotkey_item* hk = &get_hotkey(event);

#if 0
	// This is not generally possible without knowing keyboard layout.
	if(hk->null()) {
		//no matching hotkey was found, but try an in-exact match.
		hk = &get_hotkey(event, true);
	}
#endif

	if(hk->null())
		return;

	execute_command(disp,hk->get_id(),executor);
}
コード例 #5
0
void jhat_event_execute(display& disp, const SDL_JoyHatEvent& event, command_executor* executor)
{
	const hotkey_item* hk = &get_hotkey(event);
	if (!hk->active()) {
		return;
	}

	execute_command(disp, get_hotkey_command(hk->get_command()), executor);
	executor->set_button_state(disp);
}
コード例 #6
0
ファイル: hotkeys.cpp プロジェクト: freeors/War-Of-Kingdom
void load_hotkeys(const config& cfg)
{
	BOOST_FOREACH (const config &hk, cfg.child_range(hotkey_tag_name))
	{
		hotkey_item& h = get_hotkey(hk["command"].str());
		if(h.get_id() != HOTKEY_NULL) {
			h.load_from_config(hk);
		}
	}
}
コード例 #7
0
ファイル: hotkey_item.cpp プロジェクト: nwforrer/wesnoth
const hotkey_item& get_hotkey(const SDL_MouseButtonEvent& event)
{
	CKey keystate;
	bool shift = keystate[SDLK_RSHIFT] || keystate[SDLK_LSHIFT];
	bool ctrl  = keystate[SDLK_RCTRL]  || keystate[SDLK_LCTRL];
	bool cmd   = keystate[SDLK_RMETA]  || keystate[SDLK_LMETA];
	bool alt   = keystate[SDLK_RALT]   || keystate[SDLK_LALT];

	return get_hotkey(event.which, -1, event.button, -1, -1, shift, ctrl, cmd, alt);
}
コード例 #8
0
ファイル: hotkey_item.cpp プロジェクト: nwforrer/wesnoth
const hotkey_item& get_hotkey(const SDL_JoyHatEvent& event)
{
	CKey keystate;
	bool shift = keystate[SDLK_RSHIFT] || keystate[SDLK_LSHIFT];
	bool ctrl  = keystate[SDLK_RCTRL]  || keystate[SDLK_LCTRL];
	bool cmd   = keystate[SDLK_RMETA]  || keystate[SDLK_LMETA];
	bool alt   = keystate[SDLK_RALT]   || keystate[SDLK_LALT];

	return get_hotkey(-1, event.which, -1, event.hat, event.value, shift, ctrl, cmd, alt);
}
コード例 #9
0
ファイル: hotkeys.cpp プロジェクト: oys0317/opensanguo
void load_hotkeys(const config& cfg)
{
	foreach (const config &hk, cfg.child_range(hotkey_tag_name))
	{
		hotkey_item& h = get_hotkey(hk["command"]);
		if(h.get_id() != HOTKEY_NULL) {
			h.load_from_config(hk);
		}
	}
}
コード例 #10
0
ファイル: command_executor.cpp プロジェクト: nwforrer/wesnoth
void mbutton_event_execute(display& disp, const SDL_MouseButtonEvent& event, command_executor* executor)
{
	if (!executor) return;
	const hotkey_item* hk = &get_hotkey(event);
	if (!hk->active()) {
		return;
	}

	execute_command(disp, hotkey::get_hotkey_command(hk->get_command()), executor);
	executor->set_button_state(disp);
}
コード例 #11
0
ファイル: hotkeys.cpp プロジェクト: AG-Dev/wesnoth_ios
hotkey_item& get_hotkey(const SDL_KeyboardEvent& event)
{
	return get_hotkey(event.keysym.unicode, event.keysym.sym,
			(event.keysym.mod & KMOD_SHIFT) != 0,
			(event.keysym.mod & KMOD_CTRL) != 0,
			(event.keysym.mod & KMOD_ALT) != 0,
			(event.keysym.mod & KMOD_LMETA) != 0
#ifdef __APPLE__
			|| (event.keysym.mod & KMOD_RMETA) != 0
#endif
			);
}
コード例 #12
0
ファイル: command_executor.cpp プロジェクト: aquileia/wesnoth
static void event_execute( const SDL_Event& event, command_executor* executor)
{
	if (!executor) return;
	const hotkey_ptr hk = get_hotkey(event);
	if (!hk->active() || hk->is_disabled()) {
		return;
	}

	bool press = event.type == SDL_KEYDOWN || event.type == SDL_JOYBUTTONDOWN || event.type == SDL_MOUSEBUTTONDOWN;

	execute_command(hotkey::get_hotkey_command(hk->get_command()), executor, -1, press);
	executor->set_button_state();
}
コード例 #13
0
ファイル: hotkey_item.cpp プロジェクト: nwforrer/wesnoth
const hotkey_item& get_hotkey(const SDL_KeyboardEvent& event)
{
	return get_hotkey(
#if SDL_VERSION_ATLEAST(2, 0, 0)
			event.keysym.scancode,
#else
			event.keysym.unicode,
#endif
			event.keysym.sym,
			(event.keysym.mod & KMOD_SHIFT) != 0,
			(event.keysym.mod & KMOD_CTRL)  != 0,
			(event.keysym.mod & KMOD_META)  != 0,
			(event.keysym.mod & KMOD_ALT)   != 0
			);
}
コード例 #14
0
ファイル: editwidget.c プロジェクト: TomyLobo/mc
static void
edit_window_list (const Dlg_head * h)
{
    const size_t offset = 2;    /* skip menu and buttonbar */
    const size_t dlg_num = g_list_length (h->widgets) - offset;
    int lines, cols;
    Listbox *listbox;
    GList *w;
    int i = 0;
    int rv;

    lines = min ((size_t) (LINES * 2 / 3), dlg_num);
    cols = COLS * 2 / 3;

    listbox = create_listbox_window (lines, cols, _("Open files"), "[Open files]");

    for (w = h->widgets; w != NULL; w = g_list_next (w))
        if (edit_widget_is_editor ((Widget *) w->data))
        {
            WEdit *e = (WEdit *) w->data;
            char *fname;

            if (e->filename_vpath == NULL)
                fname = g_strdup_printf ("%c [%s]", e->modified ? '*' : ' ', _("NoName"));
            else
            {
                char *fname2;

                fname2 = vfs_path_to_str (e->filename_vpath);
                fname = g_strdup_printf ("%c%s", e->modified ? '*' : ' ', fname2);
                g_free (fname2);
            }

            listbox_add_item (listbox->list, LISTBOX_APPEND_AT_END, get_hotkey (i++),
                              str_term_trim (fname, listbox->list->widget.cols - 2), NULL);
            g_free (fname);
        }

    rv = g_list_position (h->widgets, h->current) - offset;
    listbox_select_entry (listbox->list, rv);
    rv = run_listbox (listbox);
    if (rv >= 0)
    {
        w = g_list_nth (h->widgets, rv + offset);
        dlg_set_top_widget (w->data);
    }
}
コード例 #15
0
void
dialog_switch_list (void)
{
    const size_t dlg_num = g_list_length (mc_dialogs);
    int lines, cols;
    Listbox *listbox;
    GList *h;
    int i = 0;
    int rv;

    if (mc_global.widget.midnight_shutdown || mc_current == NULL)
        return;

    lines = min ((size_t) (LINES * 2 / 3), dlg_num);
    cols = COLS * 2 / 3;

    listbox = create_listbox_window (lines, cols, _("Screens"), "[Screen selector]");

    for (h = mc_dialogs; h != NULL; h = g_list_next (h))
    {
        Dlg_head *dlg;
        char *title;

        dlg = (Dlg_head *) h->data;

        if ((dlg != NULL) && (dlg->get_title != NULL))
            title = dlg->get_title (dlg, listbox->list->widget.cols - 2);       /* FIXME! */
        else
            title = g_strdup ("");

        listbox_add_item (listbox->list, LISTBOX_APPEND_BEFORE, get_hotkey (i++), title, NULL);

        g_free (title);
    }

    listbox_select_entry (listbox->list, dlg_num - 1 - g_list_position (mc_dialogs, mc_current));
    rv = run_listbox (listbox);

    if (rv >= 0)
    {
        h = g_list_nth (mc_dialogs, dlg_num - 1 - rv);
        dialog_switch_goto (h);
    }
}
コード例 #16
0
ファイル: editwidget.c プロジェクト: MidnightCommander/mc
static void
edit_window_list (const WDialog * h)
{
    const size_t dlg_num = g_list_length (h->widgets) - 2;      /* 2 = skip menu and buttonbar */
    int lines, cols;
    Listbox *listbox;
    GList *w;
    WEdit *selected;
    int i = 0;

    lines = MIN ((size_t) (LINES * 2 / 3), dlg_num);
    cols = COLS * 2 / 3;

    listbox = create_listbox_window (lines, cols, _("Open files"), "[Open files]");

    for (w = h->widgets; w != NULL; w = g_list_next (w))
        if (edit_widget_is_editor (CONST_WIDGET (w->data)))
        {
            WEdit *e = (WEdit *) w->data;
            char *fname;

            if (e->filename_vpath == NULL)
                fname = g_strdup_printf ("%c [%s]", e->modified ? '*' : ' ', _("NoName"));
            else
                fname =
                    g_strdup_printf ("%c%s", e->modified ? '*' : ' ',
                                     vfs_path_as_str (e->filename_vpath));

            listbox_add_item (listbox->list, LISTBOX_APPEND_AT_END, get_hotkey (i++),
                              str_term_trim (fname, WIDGET (listbox->list)->cols - 2), e, FALSE);
            g_free (fname);
        }

    selected = run_listbox_with_data (listbox, h->current->data);
    if (selected != NULL)
        widget_select (WIDGET (selected));
}
コード例 #17
0
ファイル: hotkeys.cpp プロジェクト: AG-Dev/wesnoth_ios
hotkey_item& get_hotkey(const SDL_JoyHatEvent& event)
{
	return get_hotkey(event.which, event.hat, event.value);
}
コード例 #18
0
ファイル: hotkeys.cpp プロジェクト: AG-Dev/wesnoth_ios
hotkey_item& get_hotkey(const SDL_JoyButtonEvent& event)
{
	return get_hotkey(event.which, event.button);
}