int edit_drop_hotkey_menu (WEdit * e, int key)
{
    int m = 0;
    switch (key) {
    case ALT ('f'):
	if (edit_key_emulation == EDIT_KEY_EMULATION_EMACS)
	    return 0;
	m = 0;
	break;
    case ALT ('e'):
	m = 1;
	break;
    case ALT ('s'):
	m = 2;
	break;
    case ALT ('c'):
	m = 3;
	break;
    case ALT ('o'):
	m = 4;
	break;
    default:
	return 0;
    }

    edit_drop_menu_cmd (e, m);
    return 1;
}
Esempio n. 2
0
void setup_land()
{
	int x, y, xw, yw;
	int aridity = global_aridity;

	distance_to_river();

	for (y = 0; y < WORLD_SIDE_LEN; y++) {
		for (x = 0; x < WORLD_SIDE_LEN; x++) {
			int d2w_min = 2 * WORLD_SIDE_LEN * WORLD_SIDE_LEN;
			int r;
			int arid = aridity;
			//int alt0 = 0;

			/* test against IS_RIVER to prevent terrible recursion */
			if (IS_RIVER(x, y))
				continue;

			d2w_min = lmap.dist2w[x][y];

			/* near river lower aridity */
			if (aridity > 0) {
				if (d2w_min < 5)
					arid = aridity / 3;
				else if (d2w_min < 17)
					arid = (aridity * 2) / 3;
			}
			/* Altitude has same effect as distance */
			r = rand() % (d2w_min / 3 + 1) \
			    + arid \
			    + abs(ALT(x, y) * 15 / alt_step) \
			    + 3 * (ALT(x, y) * ALT(x, y)) / 1000000;

			lmap.ecotable[x][y] = r;
			/* needed to setup quasi randome land. The flag is set below */
			MP_FLAG(x, y) |= FLAG_HAS_UNDERGROUND_WATER;
			do_rand_ecology(x, y);

			/* preserve rivers, so that we can connect port later */
			if (MP_TYPE(x, y) == WATER) {
				int navigable = MP_FLAG(x, y) & FLAG_IS_RIVER;
				set_mappoint(x, y, WATER);
				MP_FLAG(x, y) |= navigable;
				MP_FLAG(x, y) |= FLAG_HAS_UNDERGROUND_WATER;
			}
			/* set undergroung water according to first random land setup */
			if (MP_TYPE(x, y) == DESERT) {
				MP_FLAG(x, y) &= (0xffffffff - FLAG_HAS_UNDERGROUND_WATER);
			}
		}
	}
	for (y = 0; y < WORLD_SIDE_LEN; y++)
		for (x = 0; x < WORLD_SIDE_LEN; x++)
			if (MP_TYPE(x, y) == WATER)
				MP_FLAG(x, y) |= FLAG_HAS_UNDERGROUND_WATER;

	//connect_rivers();
}
Esempio n. 3
0
static void try_shore_point(int x, int y, Shoreline * shore)
{
	Shoreline *current;
	int a;
	current = shore;
	a = ALT(x, y);

	while (current->next != NULL) {
		if (a < current->next->altitude) {
			// insert in beginning of the list
			add_shore_point(current, x, y, a);
			return;
		} else if (a == current->next->altitude) {
			while ((current->next != NULL) && (current->next->altitude == a)) {
				if ((current->x == x) && (current->y == y)) {
					// do not insert the same shore point several times at different places
					return;
				};
				current = current->next;
			};
			//insert the shore point in the list
			add_shore_point(current, x, y, a);
			return;
		};
		current = current->next;
	};
	// we reached end of list
	// altitude of the point is strict maximum of the list
	if ((current->x != x) && (current->y != y))
		add_shore_point(current, x, y, a);
}
Esempio n. 4
0
static void overfill_lake(int x, int y, Shoreline * shore, int lake_id)
{
	// Starting point is a local minimum
	// Lake growth is done iteratively by flooding the lowest shore point and rising water level
	// shore point = neighbour without water 
	//      (at this point we have no water in the map, except other lakes and rivers)
	//
	// We have a list of shore points sorted by altitude

	int i, level;

	if (is_border(x, y))
		return;

	set_river_tile(x, y);
	level = ALT(x, y);

	// find neighbours
	for (i = 0; i < 8; i++) {
		if (in_map(x + di[i], y + dj[i]) && !IS_WATER(x + di[i], y + dj[i]))
			try_shore_point(x + di[i], y + dj[i], shore);
	}

	if (shore->next != NULL) {
		shore = shore->next;
		x = shore->x;
		y = shore->y;

		if ((ALT(x, y) < level)) {
			set_river_tile(x, y);
			// create river and continue to build shoreline
			// we will continue to overfill (from a lower point) until we reach border of the map
			//fprintf(stdout, "We found a pass x %i, y %i, alt %i \n", x, y, ALT(x,y));
			setup_one_river(x, y, lake_id, shore);
		}
		overfill_lake(x, y, shore, lake_id);
	} else {
		// Q: ? Should this happen ?
		// A: yes if we are in a lake that was previously filled by a higher one which overfilled here
		//    else ? it should not happen ?
		//fprintf(stderr,"the shoreline list is empty, x = %i, y = %i\n", x, y);
	}
}
Esempio n. 5
0
static void sort_by_altitude(int n, int *tabx, int *taby)
{
	// sort ascending
	int tmp_x, tmp_y;
	bool sorted = false;

	// bubble sort. n is near 10 so ...
	for (int i = 0; i < n && !sorted; i++) {
		sorted = true;
		for (int j = 1; j < n - i; j++)
			if (ALT(tabx[j], taby[j]) < ALT(tabx[j - 1], taby[j - 1])) {
				tmp_x = tabx[j - 1];
				tmp_y = taby[j - 1];
				tabx[j - 1] = tabx[j];
				taby[j - 1] = taby[j];
				tabx[j] = tmp_x;
				taby[j] = tmp_y;
				sorted = false;
			}
	}
}
Esempio n. 6
0
int
edit_drop_hotkey_menu (WEdit * e, int key)
{
    int m = 0;
    switch (key)
    {
    case ALT ('f'):
        m = 0;
        break;
    case ALT ('e'):
        m = 1;
        break;
    case ALT ('s'):
        m = 2;
        break;
    case ALT ('c'):
        m = 3;
        break;
    case ALT ('m'):
        m = 4;
        break;
    case ALT ('o'):
        m = 5;
        break;
    default:
        return 0;
    }

    edit_drop_menu_cmd (e, m);
    return 1;
}
Esempio n. 7
0
void mps_water(int x, int y)
{
    int i;
    const char *p;

    for(i = 0; i < MPS_PARAGRAPH_COUNT; ++i)
                        mps_store_title( i, "" );

    i = 0;
    mps_store_title(i++, _("Water"));
    i++;

    p = (MP_INFO(x, y).flags & FLAG_IS_RIVER) ? _("Yes") : _("No");
    mps_store_ss(i++, _("Navigable"), p);

#ifdef DEBUG
    mps_store_sd(10, "x = ", x);
    mps_store_sd(11, "y = ", y);
    mps_store_sd(12, "altitude = ", ALT(x, y));

    fprintf(stderr, "water x %i, y %i, Alt %i\n", x, y, ALT(x,y));
#endif

}
Esempio n. 8
0
void setup_lake_river(void)
{
	// brute search of local minimum

	int lakx[WORLD_SIDE_LEN * WORLD_SIDE_LEN], laky[WORLD_SIDE_LEN * WORLD_SIDE_LEN];
	Shoreline *shore;
	int i, j, l, m, alt;

	// Put the gray border (not visible) at alt_min - 1, for easier rivers handling.
	for (i = 0; i < WORLD_SIDE_LEN; i++) {
		ALT(i, 0) = alt_min - 1;
		ALT(i, WORLD_SIDE_LEN - 1) = alt_min - 1;
		ALT(0, i) = alt_min - 1;
		ALT(WORLD_SIDE_LEN - 1, i) = alt_min - 1;
	}

	l = 0;
	for (i = 1; i < WORLD_SIDE_LEN - 1; i++) {
		for (j = 1; j < WORLD_SIDE_LEN - 1; j++) {
			alt = ALT(i, j);
			m = -1;
			for (int n = 0; n < 8; n++) {
				if (ALT(i + di[n], j + dj[n]) < alt) {
					m = n;
				}
			}
			if (m == -1) {
				lakx[l] = i;
				laky[l] = j;
				l++;
			}
		}
	}

	sort_by_altitude(l, lakx, laky);
	for (i = 0; i < l; i++) {
		// start by the lowest lake
		//fprintf(stdout, "LAKE %i : %i, %i, alt %f\n", i, lakx[i], laky[i], ALT(lakx[i], laky[i]));
		shore = init_shore();
		set_river_tile(lakx[i], laky[i]);
		overfill_lake(lakx[i], laky[i], shore, WORLD_SIDE_LEN * lakx[i] + laky[i]);
		free_shore(shore);
	}
}
Esempio n. 9
0
static int setup_one_river(int xx, int yy, int lake_id, Shoreline * shore)
{
	int alt_max, x, y, alt, x0, y0;
	// start a river from point (xx, yy)
	set_river_tile(xx, yy);
	alt_max = ALT(xx, yy);

	x0 = xx;
	y0 = yy;
	/* follow most important slope and go downward */
	while (((xx != x) || (yy != y)) && (xx != 0) && (xx != (WORLD_SIDE_LEN - 1)) && (yy != 0)
	       && (yy != WORLD_SIDE_LEN - 1)) {
		int m = 0;
		x = xx;
		y = yy;
		alt = ALT(x, y);
		for (int n = 0; n < 8; n++) {
			if (in_map(x + di[n], y + dj[n])) {
				if (ALT(x + di[n], y + dj[n]) < alt) {
					xx = x + di[n];
					yy = y + dj[n];
					alt = ALT(xx, yy);
					m = n;
				}
				// find neighbours and update shore line if needed
				// may mark as shoreline a point which will be set as river later. We don't care
				if (!IS_WATER(x + di[n], y + dj[n]))
					try_shore_point(x + di[n], y + dj[n], shore);
			}
		}

		set_river_tile(xx, yy);
		if (m > 3) {
			// we did diagonal move, so we need to connect river
			if (ALT(x + di[m], y) > ALT(x, y + dj[m]))
				set_river_tile(x, y + dj[m]);
			else
				set_river_tile(x + di[m], y);
		}
	};
	// We are in a local minimum or at the borders of the map (strictly the lowest points)

}
static int translate_key_code(int asc, int scan)
{
    int c;
    switch(scan){
    case 106: /* KP_MULT*/
	return ALT('*');
    case 107: /* KP_PLUS*/
	return ALT('+');
    case 109: /* KP_MINUS*/
	return ALT('-');
    }
    c = VKtoCurses (scan);
    if (!asc && !c)
	return 0;
    if (asc && c)
	return c;
    if (!asc || asc=='\t' )
    {
	if (shift_pressed() && (c >= KEY_F(1)) && (c <= KEY_F(10)))
	    c += 10;
	if (alt_pressed() && (c >= KEY_F(1)) && (c <= KEY_F(2)))
	    c += 10;
	if (alt_pressed() && (c == KEY_F(7)))
	    c = ALT('?');
 	if (asc == '\t'){
 		if(ctrl_pressed())c = ALT('\t');
 		else c=asc;
 	}
	return c;
    }
    if (ctrl_pressed())
	return XCTRL(asc);
    if (alt_pressed())
	return ALT(asc);
    if (asc == 13)
	return 10;
    return asc;
}
#define AC_NO_BSLS KC_EQUAL
#define AC_NO_QUOTE KC_BSLS
#define AC_NO_MINS KC_SLSH
#define AC_NO_PIPE KC_GRAVE


const uint16_t PROGMEM actionmaps[][MATRIX_ROWS][MATRIX_COLS] = {
  KEYMAP( /* 0: mostly letters */
    Q,   W,         E,         R,         T,   					   /*|,, |*/         Y,              U,         I,   	          O,    P,    \
    A,   S,         D,         F,         G,   					   /*|,, |*/         H,              J,         K,   	          L,    COMM, \
		Z,   X,         C,         V,         B,               /*|,, |*/         N,              M,         COMM,           DOT,  KP_SLASH, \
    ESC, TAPT(3),   OSM(LGUI), OSM(LSFT), MK(LCTL,BSPC), TAPT(1), TAPT(2),   MK(LALT,SPC),   TACK(TAB), TACSK(SLSH), SH(2), ENT
  ),
  KEYMAP( /* layer one is mostly for programming and shell. lots of idea shortcute on left, not sure how much i will use them.*/
    ACK(7),  CTRL(W),    NO_AE,      SH(F10),     ACSK(L),                     SH(NO_ACNT), RA(7), RA(0), NO_OE,   SH(1), \
    NO_AA,   ACK(LEFT),  CSK(ENT),   ACK(RIGHT),  ALT(INS),                    0,           SH(8), SH(9), NO_PIPE, RA(4), \
    CSK(A),  CSK(F),     ACSK(T),    ALT(V),      CTRL(F9),                    SH(NO_BSLS), RA(8), RA(9), SH(6),   RA(NO_ACNT), \
    ESC,     TRNS,       OSM(LGUI),  OSM(LSFT),   TRNS,    TRNS,    TRNS,      SPC,         OFF(1),RA(2), NO_QUOTE,KP_EQUAL
  ),
  KEYMAP( /* hold space brings up move pad and numpad */
    INS,      HOME,   UP  ,      END  ,     PGUP,                          SH(5),         7     , 8  , 9, SH(NO_QUOTE),     \
    DEL,      LEFT,   DOWN,      RIGHT,     PGDN,                          NO_MINS,       4     , 5  , 6, NO_PLUS, \
    GUI(1),   GUI(2), GUI(3),    GUI(4),    GUI(5),                        RA(4),         1     , 2  , 3, NO_BSLS,      \
    ACK(DEL), TRNS, OSM(LGUI), OSM(LSFT),   GUI(D) , TRNS, TRNS,           MK(LALT,SPC),  OFF(1), DOT, 0, KP_EQUAL
  ),
  KEYMAP( /* hold tab to have fpad and mouse */
    F1,     F2,    F3,        F4,         F5,                             WH_D ,           BTN1   ,  MS_U ,         BTN2 ,      SH(3) , \
    F6,     F7,    F8,        F9,         F10,                            WH_U ,           MS_L   ,  MS_D ,         MS_R ,      BTN3 , \
    F11,    F12,   F13,       F14,        BOOT,                           NO   ,           ACL0   ,  NO_LT,         SH(NO_LT) , BTN4 , \
    BOOT, TRNS,   OSM(LGUI), OSM(LSFT),   MK(LCTL,BSPC), TRNS, TRNS,      MK(LALT,SPC),    TACK(TAB),TACSK(MINS) , SH(NO_BSLS), KP_EQUAL
  ),
Esempio n. 12
0
/*
 * Translate the keycode into either 'command' or 'char_for_insertion'.
 * 'command' is one of the editor commands from editcmddef.h.
 */
int
edit_translate_key (WEdit *edit, long x_key, int *cmd, int *ch)
{
    int command = CK_Insert_Char;
    int char_for_insertion = -1;
    int i = 0;
    int extmod = 0;
    const edit_key_map_type *key_map = NULL;

    switch (edit_key_emulation) {
    case EDIT_KEY_EMULATION_NORMAL:
	key_map = cooledit_key_map;
	break;
    case EDIT_KEY_EMULATION_EMACS:
	key_map = emacs_key_map;
	if (x_key == XCTRL ('x')) {
	    int ext_key;
	    ext_key =
		edit_raw_key_query (" Ctrl-X ", _(" Emacs key: "), 0);
	    switch (ext_key) {
	    case 's':
		command = CK_Save;
		goto fin;
	    case 'x':
		command = CK_Exit;
		goto fin;
	    case 'k':
		command = CK_New;
		goto fin;
	    case 'e':
		command =
		    CK_Macro (edit_raw_key_query
			      (_(" Execute Macro "),
			       _(" Press macro hotkey: "), 1));
		if (command == CK_Macro (0))
		    command = CK_Insert_Char;
		goto fin;
	    }
	    goto fin;
	}
	break;

    case EDIT_KEY_EMULATION_USER:
	if (edit->user_map != NULL) {
	    if (edit->extmod && edit->ext_map != NULL) {
		key_map = edit->ext_map;
		extmod = 1;
	    } else {
		key_map = edit->user_map;
	    }
	    edit->extmod = 0;
	} else {
	    key_map = edit->user_map = cooledit_key_map;
	}
	break;
    }
    assert (key_map != NULL);

    /* an ordinary insertable character */
    if (x_key < 256 && !extmod) {
	int c = convert_from_input_c (x_key);

	if (is_printable (c)) {
	    char_for_insertion = c;
	    goto fin;
	}
    }

    /* Commands specific to the key emulation */
    for (i = 0; key_map[i].key != 0 && key_map[i].key != x_key; i++)
	continue;
    if (key_map[i].key != 0) {
	command = key_map[i].command;
	goto fin;
    }

    /* Commands common for the key emulations */
    key_map = common_key_map;
    for (i = 0; key_map[i].key != 0 && key_map[i].key != x_key; i++)
	continue;
    if (key_map[i].key != 0) {
	command = key_map[i].command;
	goto fin;
    }

    /* Function still not found for this key, so try macros */
    /* This allows the same macro to be
       enabled by either eg "ALT('f')" or "XCTRL('f')" or "XCTRL('a'), 'f'" */

    if (x_key & ALT (0)) {	/* is an alt key ? */
	command = CK_Macro (x_key - ALT (0));
	goto fin;
    }
    if (x_key < ' ') {		/* is a ctrl key ? */
	command = CK_Macro (x_key);
	goto fin;
    }
  fin:

    *cmd = command;
    *ch = char_for_insertion;

    if (command == CK_Insert_Char && char_for_insertion == -1) {
	/* unchanged, key has no function here */
	return 0;
    }

    return 1;
}
Esempio n. 13
0
#include "../src/global.h"

#include "edit.h"
#include "edit-widget.h"	/* edit->macro_i */
#include "editcmddef.h"		/* list of commands */
#include "../src/key.h"		/* KEY_M_SHIFT */
#include "../src/tty.h"		/* keys */
#include "../src/charsets.h"	/* convert_from_input_c() */
#include "../src/selcodepage.h"	/* do_select_codepage() */

/*
 * Ordinary translations.  Note that the keys listed first take priority
 * when the key is assigned to more than one command.
 */
static const edit_key_map_type cooledit_key_map[] = {
    { ALT ('b'), CK_Match_Bracket },
    { ALT ('m'), CK_Mail },
    { XCTRL ('f'), CK_Save_Block },
    { XCTRL ('n'), CK_New },
    { XCTRL ('p'), CK_Pipe_Block (1) },	/* spell check */
    { XCTRL ('x'), CK_Word_Right },
    { XCTRL ('y'), CK_Delete_Line },
    { XCTRL ('z'), CK_Word_Left },
    { 0, 0 }
};

static const edit_key_map_type emacs_key_map[] = {
    { ALT ('$'), CK_Pipe_Block (1) },	/* spell check */
    { ALT ('b'), CK_Word_Left },
    { ALT ('f'), CK_Word_Right },
    { ALT ('v'), CK_Page_Up },
Esempio n. 14
0
static cb_ret_t
view_handle_key (WDiff *view, int c)
{
    struct display_file *lf = &view->df[view->ord];
    struct display_file *rf = &view->df[view->ord ^ 1];

    c = convert_from_input_c(c);

    switch (c) {
	case 'l':
	    view->display_numbers ^= 1;
	    view->new_frame = 1;
	    return MSG_HANDLED;

	case 'f':
	    view->full ^= 1;
	    view->new_frame = 1;
	    return MSG_HANDLED;

	case '=': /* XXX testing only */
	    if (!view->full) {
		view->bias = 0;
		view->new_frame = 1;
	    }
	    return MSG_HANDLED;

	case '>': /* XXX testing only */
	    if (!view->full) {
		view_compute_split(view, 1);
		view->new_frame = 1;
	    }
	    return MSG_HANDLED;

	case '<': /* XXX testing only */
	    if (!view->full) {
		view_compute_split(view, -1);
		view->new_frame = 1;
	    }
	    return MSG_HANDLED;

	case '+':
	    if (view->subtract) {
		view->subtract--;
		view->new_frame = 1;
	    }
	    return MSG_HANDLED;
	case '-':
	    view->subtract++;
	    view->new_frame = 1;
	    return MSG_HANDLED;

	case '1':
	    lf->move = 1;
	    rf->move ^= 1;
	    return MSG_HANDLED;
	case '2':
	    lf->move ^= 1;
	    rf->move = 1;
	    return MSG_HANDLED;

	case XCTRL('u'): {
	    view->ord ^= 1;
	    return MSG_HANDLED;
	}

	case XCTRL('r'):
	    view_redo(view);
	    return MSG_HANDLED;

	case 'n':
	    find_next_hunk(view);
	    return MSG_HANDLED;

	case 'p':
	    find_prev_hunk(view);
	    return MSG_HANDLED;

	case KEY_DC:
	    view->last_found = -1;
	    return MSG_HANDLED;

	case KEY_F(4):
	    view_edit(view, view->ord);
	    return MSG_HANDLED;

	case KEY_F(14):
	    view_edit(view, view->ord ^ 1);
	    return MSG_HANDLED;

	case KEY_F(17):
	    view_search(view, 1);
	    return MSG_HANDLED;

	case KEY_HOME:
	case ALT ('<'):
	case KEY_M_CTRL | KEY_PPAGE:
	    view->last_found = -1;
	    if (lf->move) lf->offs = 0;
	    if (rf->move) rf->offs = 0;
	    return MSG_HANDLED;

	case KEY_END:
	case ALT ('>'):
	case KEY_M_CTRL | KEY_NPAGE:
	    view->last_found = -1;
	    if (lf->move) lf->offs = view->max - 1;
	    if (rf->move) rf->offs = view->max - 1;
	    return MSG_HANDLED;

	case KEY_UP:
	    if (lf->move) lf->offs -= view->nbytes;
	    if (rf->move) rf->offs -= view->nbytes;
	    return MSG_HANDLED;

	case KEY_DOWN:
	    if (lf->move) lf->offs += view->nbytes;
	    if (rf->move) rf->offs += view->nbytes;
	    return MSG_HANDLED;

	case KEY_NPAGE:
	    if (lf->move) lf->offs += view->pbytes;
	    if (rf->move) rf->offs += view->pbytes;
	    return MSG_HANDLED;

	case KEY_PPAGE:
	    if (lf->move) lf->offs -= view->pbytes;
	    if (rf->move) rf->offs -= view->pbytes;
	    return MSG_HANDLED;

	case KEY_LEFT:
	    if (lf->move) lf->offs--;
	    if (rf->move) rf->offs--;
	    return MSG_HANDLED;

	case KEY_RIGHT:
	    if (lf->move) lf->offs++;
	    if (rf->move) rf->offs++;
	    return MSG_HANDLED;

	case KEY_M_CTRL | KEY_LEFT:
	    if (lf->move) lf->offs -= 16;
	    if (rf->move) rf->offs -= 16;
	    return MSG_HANDLED;

	case KEY_M_CTRL | KEY_RIGHT:
	    if (lf->move) lf->offs += 16;
	    if (rf->move) rf->offs += 16;
	    return MSG_HANDLED;

	case XCTRL('o'):
	    view_other_cmd();
	    return MSG_HANDLED;

	case 't':
	    diff_view(view->file[0], view->file[1]);
	    return MSG_HANDLED;

	case 'q':
	case ESC_CHAR:
	    view->view_quit = 1;
	    return MSG_HANDLED;

	case '\n':
	    return MSG_HANDLED;

#ifdef HAVE_CHARSET
	case XCTRL ('t'):
	    do_select_codepage ();
	    view_update (view);
	    return MSG_HANDLED;
#endif				/* HAVE_CHARSET */
    }

    /* Key not used */
    return MSG_NOT_HANDLED;
}
Esempio n. 15
0
static cb_ret_t
advanced_chown_callback (Dlg_head *h, dlg_msg_t msg, int parm)
{
    int i = 0, f_pos = BUTTONS - h->current->dlg_id - single_set - 1;

    switch (msg) {
    case DLG_DRAW:
	chown_refresh ();
	chown_info_update ();
	return MSG_HANDLED;

    case DLG_POST_KEY:
	if (f_pos < 3)
	    b_setpos (f_pos);
	return MSG_HANDLED;

    case DLG_FOCUS:
	if (f_pos < 3) {
	    if ((flag_pos / 3) != f_pos)
		flag_pos = f_pos * 3;
	    b_setpos (f_pos);
	} else if (f_pos < 5)
	    flag_pos = f_pos + 6;
	return MSG_HANDLED;

    case DLG_KEY:
	switch (parm) {

	case XCTRL ('b'):
	case KEY_LEFT:
	    if (f_pos < 5)
		return (dec_flag_pos (f_pos));
	    break;

	case XCTRL ('f'):
	case KEY_RIGHT:
	    if (f_pos < 5)
		return (inc_flag_pos (f_pos));
	    break;

	case ' ':
	    if (f_pos < 3)
		return MSG_HANDLED;
	    break;

	case '\n':
	case KEY_ENTER:
	    if (f_pos <= 2 || f_pos >= 5)
		break;
	    do_enter_key (h, f_pos);
	    return MSG_HANDLED;

	case ALT ('x'):
	    i++;

	case ALT ('w'):
	    i++;

	case ALT ('r'):
	    parm = i + 3;
	    for (i = 0; i < 3; i++)
		ch_flags[i * 3 + parm - 3] =
		    (x_toggle & (1 << parm)) ? '-' : '+';
	    x_toggle ^= (1 << parm);
	    update_mode (h);
	    dlg_broadcast_msg (h, WIDGET_DRAW, 0);
	    send_message (h->current, WIDGET_FOCUS, 0);
	    break;

	case XCTRL ('x'):
	    i++;

	case XCTRL ('w'):
	    i++;

	case XCTRL ('r'):
	    parm = i;
	    for (i = 0; i < 3; i++)
		ch_flags[i * 3 + parm] =
		    (x_toggle & (1 << parm)) ? '-' : '+';
	    x_toggle ^= (1 << parm);
	    update_mode (h);
	    dlg_broadcast_msg (h, WIDGET_DRAW, 0);
	    send_message (h->current, WIDGET_FOCUS, 0);
	    break;

	case 'x':
	    i++;

	case 'w':
	    i++;

	case 'r':
	    if (f_pos > 2)
		break;
	    flag_pos = f_pos * 3 + i;	/* (strchr(ch_perm,parm)-ch_perm); */
	    if (((WButton *) h->current)->text.start[(flag_pos % 3)] ==
		'-')
		ch_flags[flag_pos] = '+';
	    else
		ch_flags[flag_pos] = '-';
	    update_mode (h);
	    break;

	case '4':
	    i++;

	case '2':
	    i++;

	case '1':
	    if (f_pos > 2)
		break;
	    flag_pos = i + f_pos * 3;
	    ch_flags[flag_pos] = '=';
	    update_mode (h);
	    break;

	case '-':
	    if (f_pos > 2)
		break;

	case '*':
	    if (parm == '*')
		parm = '=';

	case '=':
	case '+':
	    if (f_pos > 4)
		break;
	    ch_flags[flag_pos] = parm;
	    update_mode (h);
	    advanced_chown_callback (h, DLG_KEY, KEY_RIGHT);
	    if (flag_pos > 8 || !(flag_pos % 3))
		dlg_one_down (h);

	    break;
	}
	return MSG_NOT_HANDLED;

    default:
	return default_dlg_callback (h, msg, parm);
    }
}
Esempio n. 16
0
static int
menubar_handle_key (WMenuBar * menubar, int key)
{
    /* Lowercase */
    if (isascii (key))
        key = g_ascii_tolower (key);

    if (is_abort_char (key))
    {
        menubar_finish (menubar);
        return 1;
    }

    /* menubar help or menubar navigation */
    switch (key)
    {
    case KEY_F (1):
        {
            ev_help_t event_data = { NULL, NULL };

            if (menubar->is_dropped)
                event_data.node =
                    MENU (g_list_nth_data (menubar->menu, menubar->selected))->help_node;
            else
                event_data.node = "[Menu Bar]";

            mc_event_raise (MCEVENT_GROUP_CORE, "help", &event_data);
            menubar_draw (menubar);
            return 1;
        }

    case KEY_LEFT:
    case XCTRL ('b'):
        menubar_left (menubar);
        return 1;

    case KEY_RIGHT:
    case XCTRL ('f'):
        menubar_right (menubar);
        return 1;

    default:
        break;
    }

    if (!menubar->is_dropped)
    {
        GList *i;

        /* drop menu by hotkey */
        for (i = menubar->menu; i != NULL; i = g_list_next (i))
        {
            menu_t *menu = MENU (i->data);

            if ((menu->text.hotkey != NULL) && (key == g_ascii_tolower (menu->text.hotkey[0])))
            {
                menubar_drop (menubar, g_list_position (menubar->menu, i));
                return 1;
            }
        }

        /* drop menu by Enter or Dowwn key */
        if (key == KEY_ENTER || key == XCTRL ('n') || key == KEY_DOWN || key == '\n')
            menubar_drop (menubar, menubar->selected);

        return 1;
    }

    {
        menu_t *menu = MENU (g_list_nth_data (menubar->menu, menubar->selected));
        GList *i;

        /* execute menu command by hotkey */
        for (i = menu->entries; i != NULL; i = g_list_next (i))
        {
            const menu_entry_t *entry = MENUENTRY (i->data);

            if ((entry != NULL) && (entry->command != CK_IgnoreKey)
                && (entry->text.hotkey != NULL) && (key == g_ascii_tolower (entry->text.hotkey[0])))
            {
                menu->selected = g_list_position (menu->entries, i);
                menubar_execute (menubar);
                return 1;
            }
        }

        /* menu execute by Enter or menu navigation */
        switch (key)
        {
        case KEY_ENTER:
        case '\n':
            menubar_execute (menubar);
            return 1;

        case KEY_HOME:
        case ALT ('<'):
            menubar_first (menubar);
            break;

        case KEY_END:
        case ALT ('>'):
            menubar_last (menubar);
            break;

        case KEY_DOWN:
        case XCTRL ('n'):
            menubar_down (menubar);
            break;

        case KEY_UP:
        case XCTRL ('p'):
            menubar_up (menubar);
            break;

        default:
            break;
        }
    }

    return 0;
}
Esempio n. 17
0
namespace KStandardShortcut
{

struct KStandardShortcutInfo
{
    //! The standard shortcut id. @see StandardShortcut
    StandardShortcut id;

    /** 
     * Unique name for the given accel. The name is used to save the user
     * settings. It's not representable. Use description for that.
     * @warning NEVER EVER CHANGE IT OR TRANSLATE IT!
     */
    const char* name;

    //! Context for the translation
    const char* translation_context;

    //! Localized label for user-visible display
    const char* description;

    //! The keys for this shortcut
    int cutDefault, cutDefault2;

    //! A shortcut that is created with @a cutDefault and @cutDefault2
    KShortcut cut;

    //! If this struct is initialized. If not initialized @cut is not valid
    bool isInitialized;
};

//! We need to remember the context to get the correct translation.
#undef I18N_NOOP2
#define I18N_NOOP2(comment,x) comment, x

#define CTRL(x) Qt::CTRL+Qt::Key_##x
#define SHIFT(x) Qt::SHIFT+Qt::Key_##x
#define CTRLSHIFT(x) Qt::CTRL+Qt::SHIFT+Qt::Key_##x
#define ALT(x) Qt::ALT+Qt::Key_##x
#define ALTSHIFT(x) Qt::ALT+Qt::SHIFT+Qt::Key_##x

/** Array of predefined KStandardShortcutInfo objects, which cover all
    the "standard" accelerators. Each enum value from StandardShortcut
    should appear in this table.
*/
// STUFF WILL BREAK IF YOU DON'T READ THIS!!!
// Read the comments of the big enum in kstandardshortcut.h before you change anything!
static KStandardShortcutInfo g_infoStandardShortcut[] =
{
//Group File,
    {AccelNone, 0      , 0                   , 0       , 0      , 0           , KShortcut(), false },
    { Open    , "Open" , I18N_NOOP2("@action", "Open") , CTRL(O), 0           , KShortcut(), false }    ,
    { New     , "New"  , I18N_NOOP2("@action", "New")  , CTRL(N), 0           , KShortcut(), false }    ,
    { Close   , "Close", I18N_NOOP2("@action", "Close"), CTRL(W), CTRL(Escape), KShortcut(), false }    ,
    { Save    , "Save" , I18N_NOOP2("@action", "Save") , CTRL(S), 0           , KShortcut(), false }    ,
    { Print   , "Print", I18N_NOOP2("@action", "Print"), CTRL(P), 0           , KShortcut(), false }    ,
    { Quit    , "Quit" , I18N_NOOP2("@action", "Quit") , CTRL(Q), 0           , KShortcut(), false }    ,

//Group Edit
    { Undo             , "Undo"             , I18N_NOOP2("@action", "Undo")                 , CTRL(Z)          , 0            , KShortcut(), false },
    { Redo             , "Redo"             , I18N_NOOP2("@action", "Redo")                 , CTRLSHIFT(Z)     , 0            , KShortcut(), false },
    { Cut              , "Cut"              , I18N_NOOP2("@action", "Cut")                  , CTRL(X)          , SHIFT(Delete), KShortcut(), false },
    { Copy             , "Copy"             , I18N_NOOP2("@action", "Copy")                 , CTRL(C)          , CTRL(Insert) , KShortcut(), false },
    { Paste            , "Paste"            , I18N_NOOP2("@action", "Paste")                , CTRL(V)          , SHIFT(Insert), KShortcut(), false },
    { PasteSelection   , "Paste Selection"  , I18N_NOOP2("@action", "Paste Selection")      , CTRLSHIFT(Insert), 0            , KShortcut(), false },

    { SelectAll        , "SelectAll"        , I18N_NOOP2("@action", "Select All")           , CTRL(A)          , 0            , KShortcut(), false },
    { Deselect         , "Deselect"         , I18N_NOOP2("@action", "Deselect")             , CTRLSHIFT(A)     , 0            , KShortcut(), false },
    { DeleteWordBack   , "DeleteWordBack"   , I18N_NOOP2("@action", "Delete Word Backwards"), CTRL(Backspace)  , 0            , KShortcut(), false },
    { DeleteWordForward, "DeleteWordForward", I18N_NOOP2("@action", "Delete Word Forward")  , CTRL(Delete)     , 0            , KShortcut(), false },

    { Find             , "Find"             , I18N_NOOP2("@action", "Find")                 , CTRL(F)          , 0            , KShortcut(), false },
    { FindNext         , "FindNext"         , I18N_NOOP2("@action", "Find Next")            , Qt::Key_F3       , 0            , KShortcut(), false },
    { FindPrev         , "FindPrev"         , I18N_NOOP2("@action", "Find Prev")            , SHIFT(F3)        , 0            , KShortcut(), false },
    { Replace          , "Replace"          , I18N_NOOP2("@action", "Replace")              , CTRL(R)          , 0            , KShortcut(), false },

//Group Navigation
    { Home           , "Home"                 , I18N_NOOP2("@action Go to main page"      , "Home")                 , ALT(Home)       , Qt::Key_HomePage  , KShortcut(), false },
    { Begin          , "Begin"                , I18N_NOOP2("@action Beginning of document", "Begin")                , CTRL(Home)      , 0                 , KShortcut(), false },
    { End            , "End"                  , I18N_NOOP2("@action End of document"      , "End")                  , CTRL(End)       , 0                 , KShortcut(), false },
    { Prior          , "Prior"                , I18N_NOOP2("@action"                      , "Prior")                , Qt::Key_PageUp  , 0                 , KShortcut(), false },
    { Next           , "Next"                 , I18N_NOOP2("@action Opposite to Prior"    , "Next")                 , Qt::Key_PageDown, 0                 , KShortcut(), false },

    { Up             , "Up"                   , I18N_NOOP2("@action"                      , "Up")                   , ALT(Up)         , 0                 , KShortcut(), false },
    { Back           , "Back"                 , I18N_NOOP2("@action"                      , "Back")                 , ALT(Left)       , Qt::Key_Back      , KShortcut(), false },
    { Forward        , "Forward"              , I18N_NOOP2("@action"                      , "Forward")              , ALT(Right)      , Qt::Key_Forward   , KShortcut(), false },
    { Reload         , "Reload"               , I18N_NOOP2("@action"                      , "Reload")               , Qt::Key_F5      , Qt::Key_Refresh   , KShortcut(), false },

    { BeginningOfLine, "BeginningOfLine"      , I18N_NOOP2("@action"                      , "Beginning of Line")    , Qt::Key_Home    , 0                 , KShortcut(), false },
    { EndOfLine      , "EndOfLine"            , I18N_NOOP2("@action"                      , "End of Line")          , Qt::Key_End     , 0                 , KShortcut(), false },
    { GotoLine       , "GotoLine"             , I18N_NOOP2("@action"                      , "Go to Line")           , CTRL(G)         , 0                 , KShortcut(), false },
    { BackwardWord   , "BackwardWord"         , I18N_NOOP2("@action"                      , "Backward Word")        , CTRL(Left)      , 0                 , KShortcut(), false },
    { ForwardWord    , "ForwardWord"          , I18N_NOOP2("@action"                      , "Forward Word")         , CTRL(Right)     , 0                 , KShortcut(), false },

    { AddBookmark    , "AddBookmark"          , I18N_NOOP2("@action"                      , "Add Bookmark")         , CTRL(B)         , 0                 , KShortcut(), false },
    { ZoomIn         , "ZoomIn"               , I18N_NOOP2("@action"                      , "Zoom In")              , CTRL(Plus)      , CTRL(Equal)       , KShortcut(), false },
    { ZoomOut        , "ZoomOut"              , I18N_NOOP2("@action"                      , "Zoom Out")             , CTRL(Minus)     , 0                 , KShortcut(), false },
    { FullScreen     , "FullScreen"           , I18N_NOOP2("@action"                      , "Full Screen Mode")     , CTRLSHIFT(F)    , 0                 , KShortcut(), false },

    { ShowMenubar    , "ShowMenubar"          , I18N_NOOP2("@action"                      , "Show Menu Bar")        , CTRL(M)         , 0                 , KShortcut(), false },
    { TabNext        , "Activate Next Tab"    , I18N_NOOP2("@action"                      , "Activate Next Tab")    , CTRL(Period)    , CTRL(BracketRight), KShortcut(), false },
    { TabPrev        , "Activate Previous Tab", I18N_NOOP2("@action"                      , "Activate Previous Tab"), CTRL(Comma)     , CTRL(BracketLeft) , KShortcut(), false },

    //Group Help
    { Help           , "Help"                 , I18N_NOOP2("@action"                      , "Help")                 , Qt::Key_F1      , 0                 , KShortcut(), false },
    { WhatsThis      , "WhatsThis"            , I18N_NOOP2("@action"                      , "What's This")          , SHIFT(F1)       , 0                 , KShortcut(), false },

//Group TextCompletion
    { TextCompletion           , "TextCompletion"           , I18N_NOOP2("@action", "Text Completion")          , CTRL(E)     , 0, KShortcut(), false },
    { PrevCompletion           , "PrevCompletion"           , I18N_NOOP2("@action", "Previous Completion Match"), CTRL(Up)    , 0, KShortcut(), false },
    { NextCompletion           , "NextCompletion"           , I18N_NOOP2("@action", "Next Completion Match")    , CTRL(Down)  , 0, KShortcut(), false },
    { SubstringCompletion      , "SubstringCompletion"      , I18N_NOOP2("@action", "Substring Completion")     , CTRL(T)     , 0, KShortcut(), false },

    { RotateUp                 , "RotateUp"                 , I18N_NOOP2("@action", "Previous Item in List")    , Qt::Key_Up  , 0, KShortcut(), false },
    { RotateDown               , "RotateDown"               , I18N_NOOP2("@action", "Next Item in List")        , Qt::Key_Down, 0, KShortcut(), false },

    { OpenRecent               , "OpenRecent"               , I18N_NOOP2("@action", "Open Recent")               , 0           , 0, KShortcut(), false },
    { SaveAs                   , "SaveAs"                   , I18N_NOOP2("@action", "Save As")                   , 0           , 0, KShortcut(), false },
    { Revert                   , "Revert"                   , I18N_NOOP2("@action", "Revert")                   , 0           , 0, KShortcut(), false },
    { PrintPreview             , "PrintPreview"             , I18N_NOOP2("@action", "Print Preview")             , 0           , 0, KShortcut(), false },
    { Mail                     , "Mail"                     , I18N_NOOP2("@action", "Mail")                     , 0           , 0, KShortcut(), false },
    { Clear                    , "Clear"                    , I18N_NOOP2("@action", "Clear")                    , 0           , 0, KShortcut(), false },
    { ActualSize               , "ActualSize"               , I18N_NOOP2("@action", "Actual Size")               , 0           , 0, KShortcut(), false },
    { FitToPage                , "FitToPage"                , I18N_NOOP2("@action", "Fit To Page")                , 0           , 0, KShortcut(), false },
    { FitToWidth               , "FitToWidth"               , I18N_NOOP2("@action", "Fit To Width")               , 0           , 0, KShortcut(), false },
    { FitToHeight              , "FitToHeight"              , I18N_NOOP2("@action", "Fit To Height")              , 0           , 0, KShortcut(), false },
    { Zoom                     , "Zoom"                     , I18N_NOOP2("@action", "Zoom")                     , 0           , 0, KShortcut(), false },
    { Goto                     , "Goto"                     , I18N_NOOP2("@action", "Goto")                     , 0           , 0, KShortcut(), false },
    { GotoPage                 , "GotoPage"                 , I18N_NOOP2("@action", "Goto Page")                 , 0           , 0, KShortcut(), false },
    { DocumentBack             , "DocumentBack"             , I18N_NOOP2("@action", "Document Back")             , ALTSHIFT(Left), 0, KShortcut(), false },
    { DocumentForward          , "DocumentForward"          , I18N_NOOP2("@action", "Document Forward")          , ALTSHIFT(Right), 0, KShortcut(), false },
    { EditBookmarks            , "EditBookmarks"            , I18N_NOOP2("@action", "Edit Bookmarks")            , 0           , 0, KShortcut(), false },
    { Spelling                 , "Spelling"                 , I18N_NOOP2("@action", "Spelling")                 , 0           , 0, KShortcut(), false },
    { ShowToolbar              , "ShowToolbar"              , I18N_NOOP2("@action", "Show Toolbar")              , 0           , 0, KShortcut(), false },
    { ShowStatusbar            , "ShowStatusbar"            , I18N_NOOP2("@action", "Show Statusbar")            , 0           , 0, KShortcut(), false },
    { SaveOptions              , "SaveOptions"              , I18N_NOOP2("@action", "Save Options")              , 0           , 0, KShortcut(), false },
    { KeyBindings              , "KeyBindings"              , I18N_NOOP2("@action", "Key Bindings")              , 0           , 0, KShortcut(), false },
    { Preferences              , "Preferences"              , I18N_NOOP2("@action", "Preferences")              , 0           , 0, KShortcut(), false },
    { ConfigureToolbars        , "ConfigureToolbars"        , I18N_NOOP2("@action", "Configure Toolbars")        , 0           , 0, KShortcut(), false },
    { ConfigureNotifications   , "ConfigureNotifications"   , I18N_NOOP2("@action", "Configure Notifications")   , 0           , 0, KShortcut(), false },
    { TipofDay                 , "TipofDay"                 , I18N_NOOP2("@action", "Tip Of Day")                 , 0           , 0, KShortcut(), false },
    { ReportBug                , "ReportBug"                , I18N_NOOP2("@action", "Report Bug")                , 0           , 0, KShortcut(), false },
    { SwitchApplicationLanguage, "SwitchApplicationLanguage", I18N_NOOP2("@action", "Switch Application Language"), 0           , 0, KShortcut(), false },
    { AboutApp                 , "AboutApp"                 , I18N_NOOP2("@action", "About Application")                 , 0           , 0, KShortcut(), false },
    { AboutKDE                 , "AboutKDE"                 , I18N_NOOP2("@action", "About KDE")                 , 0           , 0, KShortcut(), false },

    //dummy entry to catch simple off-by-one errors. Insert new entries before this line.
    { AccelNone                , 0                          , 0                   , 0                           , 0, 0, KShortcut(), false }
};


/** Search for the KStandardShortcutInfo object associated with the given @p id.
    Return a dummy entry with no name and an empty shortcut if @p id is invalid.
*/
static KStandardShortcutInfo *guardedStandardShortcutInfo(StandardShortcut id)
{
    if (id >= static_cast<int>(sizeof(g_infoStandardShortcut) / sizeof(KStandardShortcutInfo)) ||
             id < 0) {
        kWarning(125) << "KStandardShortcut: id not found!";
        return &g_infoStandardShortcut[AccelNone];
    } else
        return &g_infoStandardShortcut[id];
}

/** Initialize the accelerator @p id by checking if it is overridden
    in the configuration file (and if it isn't, use the default).
    On X11, if QApplication was initialized with GUI disabled,
    the default will always be used.
*/
static void initialize(StandardShortcut id)
{
    KStandardShortcutInfo *info = guardedStandardShortcutInfo(id);

    // All three are needed.
    if (info->id!=AccelNone) {
        Q_ASSERT(info->description);
        Q_ASSERT(info->translation_context);
        Q_ASSERT(info->name);
    }

    KConfigGroup cg(KGlobal::config(), "Shortcuts");

#ifdef Q_WS_X11
    // Code within this block breaks if we aren't running in GUI mode.
    if(QX11Info::display() && cg.hasKey(info->name))
#else
    if(cg.hasKey(info->name))
#endif
    {
        QString s = cg.readEntry(info->name);
        if (s != "none")
            info->cut = KShortcut(s);
        else
            info->cut = KShortcut();
    } else {
        info->cut = hardcodedDefaultShortcut(id);
    }

    info->isInitialized = true;
}

void saveShortcut(StandardShortcut id, const KShortcut &newShortcut)
{
    KStandardShortcutInfo *info = guardedStandardShortcutInfo(id);
    // If the action has no standard shortcut associated there is nothing to
    // save
    if(info->id == AccelNone)
        return;

    KConfigGroup cg(KGlobal::config(), "Shortcuts");

    info->cut = newShortcut;
    bool sameAsDefault = (newShortcut == hardcodedDefaultShortcut(id));

    if (sameAsDefault) {
        // If the shortcut is the equal to the hardcoded one we remove it from
        // kdeglobal if necessary and return.
        if(cg.hasKey(info->name))
            cg.deleteEntry(info->name, KConfig::Global|KConfig::Persistent);

        return;
    }

    // Write the changed shortcut to kdeglobals
    cg.writeEntry(info->name, info->cut.toString(), KConfig::Global|KConfig::Persistent);
}

QString name(StandardShortcut id)
{
    return guardedStandardShortcutInfo(id)->name;
}

QString label(StandardShortcut id)
{
    KStandardShortcutInfo *info = guardedStandardShortcutInfo( id );
    return i18nc(
        info->translation_context,
        info->description);
}

// TODO: Add psWhatsThis entry to KStandardShortcutInfo
QString whatsThis( StandardShortcut /*id*/ )
{
//  KStandardShortcutInfo* info = guardedStandardShortcutInfo( id );
//  if( info && info->whatsThis )
//      return i18n(info->whatsThis);
//  else
        return QString();
}

const KShortcut &shortcut(StandardShortcut id)
{
    KStandardShortcutInfo *info = guardedStandardShortcutInfo(id);

    if(!info->isInitialized)
        initialize(id);

    return info->cut;
}

StandardShortcut find(const QKeySequence &seq)
{
    if( !seq.isEmpty() ) {
        for(uint i = 0; i < sizeof(g_infoStandardShortcut) / sizeof(KStandardShortcutInfo); i++) {
            StandardShortcut id = g_infoStandardShortcut[i].id;
            if( id != AccelNone ) {
                if(!g_infoStandardShortcut[i].isInitialized)
                    initialize(id);
                if(g_infoStandardShortcut[i].cut.contains(seq))
                    return id;
            }
        }
    }
    return AccelNone;
}

StandardShortcut find(const char *keyName)
{
    for(uint i = 0; i < sizeof(g_infoStandardShortcut) / sizeof(KStandardShortcutInfo); i++)
        if (qstrcmp(g_infoStandardShortcut[i].name, keyName))
            return g_infoStandardShortcut[i].id;

    return AccelNone;
}

KShortcut hardcodedDefaultShortcut(StandardShortcut id)
{
    KShortcut cut;
    KStandardShortcutInfo *info = guardedStandardShortcutInfo(id);

    return KShortcut(info->cutDefault, info->cutDefault2);
}

const KShortcut& open()                  { return shortcut( Open ); }
const KShortcut& openNew()               { return shortcut( New ); }
const KShortcut& close()                 { return shortcut( Close ); }
const KShortcut& save()                  { return shortcut( Save ); }
const KShortcut& print()                 { return shortcut( Print ); }
const KShortcut& quit()                  { return shortcut( Quit ); }
const KShortcut& cut()                   { return shortcut( Cut ); }
const KShortcut& copy()                  { return shortcut( Copy ); }
const KShortcut& paste()                 { return shortcut( Paste ); }
const KShortcut& pasteSelection()        { return shortcut( PasteSelection ); }
const KShortcut& deleteWordBack()        { return shortcut( DeleteWordBack ); }
const KShortcut& deleteWordForward()     { return shortcut( DeleteWordForward ); }
const KShortcut& undo()                  { return shortcut( Undo ); }
const KShortcut& redo()                  { return shortcut( Redo ); }
const KShortcut& find()                  { return shortcut( Find ); }
const KShortcut& findNext()              { return shortcut( FindNext ); }
const KShortcut& findPrev()              { return shortcut( FindPrev ); }
const KShortcut& replace()               { return shortcut( Replace ); }
const KShortcut& home()                  { return shortcut( Home ); }
const KShortcut& begin()                 { return shortcut( Begin ); }
const KShortcut& end()                   { return shortcut( End ); }
const KShortcut& beginningOfLine()       { return shortcut( BeginningOfLine ); }
const KShortcut& endOfLine()             { return shortcut( EndOfLine ); }
const KShortcut& prior()                 { return shortcut( Prior ); }
const KShortcut& next()                  { return shortcut( Next ); }
const KShortcut& backwardWord()          { return shortcut( BackwardWord ); }
const KShortcut& forwardWord()           { return shortcut( ForwardWord ); }
const KShortcut& gotoLine()              { return shortcut( GotoLine ); }
const KShortcut& addBookmark()           { return shortcut( AddBookmark ); }
const KShortcut& tabNext()               { return shortcut( TabNext ); }
const KShortcut& tabPrev()               { return shortcut( TabPrev ); }
const KShortcut& fullScreen()            { return shortcut( FullScreen ); }
const KShortcut& zoomIn()                { return shortcut( ZoomIn ); }
const KShortcut& zoomOut()               { return shortcut( ZoomOut ); }
const KShortcut& help()                  { return shortcut( Help ); }
const KShortcut& completion()            { return shortcut( TextCompletion ); }
const KShortcut& prevCompletion()        { return shortcut( PrevCompletion ); }
const KShortcut& nextCompletion()        { return shortcut( NextCompletion ); }
const KShortcut& rotateUp()              { return shortcut( RotateUp ); }
const KShortcut& rotateDown()            { return shortcut( RotateDown ); }
const KShortcut& substringCompletion()   { return shortcut( SubstringCompletion ); }
const KShortcut& whatsThis()             { return shortcut( WhatsThis ); }
const KShortcut& reload()                { return shortcut( Reload ); }
const KShortcut& selectAll()             { return shortcut( SelectAll ); }
const KShortcut& up()                    { return shortcut( Up ); }
const KShortcut& back()                  { return shortcut( Back ); }
const KShortcut& forward()               { return shortcut( Forward ); }
const KShortcut& showMenubar()           { return shortcut( ShowMenubar ); }

}
Esempio n. 18
0
File: tree.c Progetto: ebichu/dd-wrt
typedef void (*tree_key_action) (WTree *);
typedef struct {
    int key_code;
    tree_key_action fn;
} tree_key_map;

static const tree_key_map tree_keymap [] = {
    { XCTRL('n'), move_down    },
    { XCTRL('p'), move_up      },
    { KEY_DOWN,   move_down    },
    { KEY_UP,     move_up      },
    { '\n',       chdir_sel    },
    { KEY_ENTER,  chdir_sel    },
    { KEY_HOME,   move_home    },
    { KEY_A1,     move_home    },
    { ALT ('<'),  move_home    },
    { KEY_END,    move_end     },
    { KEY_C1,     move_end     },
    { ALT ('>'),  move_end     },
    { KEY_NPAGE,  move_nextp   },
    { KEY_PPAGE,  move_prevp   },
    { XCTRL('v'), move_nextp   },
    { ALT('v'),   move_prevp   },
    { XCTRL('p'), move_up      },
    { XCTRL('p'), move_down    },
    { XCTRL('s'), tree_start_search },
    { ALT('s'),   tree_start_search },
    { XCTRL('r'), tree_rescan_cmd },
    { KEY_DC,     tree_rmdir_cmd },
    { 0, 0 }
    };
Esempio n. 19
0
void load_city_2(char *cname)
{
    int i, x, y, p;
    int dumbint = 0;
    int num_pbars, pbar_data_size;
    int pbar_tmp;
    int dummy;
    gzFile gzfile;
    char s[512];

    clear_game();

    gzfile = gzopen(cname, "rb");
    if (gzfile == NULL) {
        printf(_("Can't open <%s> (gzipped)"), cname);
        do_error("Can't open it!");
    }

    sscanf(gzgets(gzfile, s, 256), "%d", &ldsv_version);
    if (ldsv_version < WATERWELL_V2) {
        gzclose(gzfile);
        load_city_old( cname );
        /* Fix desert frontier for old saved games and scenarios */
        desert_frontier(0, 0, WORLD_SIDE_LEN, WORLD_SIDE_LEN);
        return;
    }

    fprintf(stderr, " ldsv_version = %i \n", ldsv_version);
    use_waterwell = true;

    init_pbars();
    num_pbars = NUM_PBARS;
    pbar_data_size = PBAR_DATA_SIZE;

    init_inventory();
    print_time_for_year();

    // Easier debugging from saved game: #Line = 100 x + y + 1  (first line = ldsv_version)
    for (x = 0; x < WORLD_SIDE_LEN; x++) {
        for (y = 0; y < WORLD_SIDE_LEN; y++) {
            gzgets(gzfile, s, 512);
            //         TY  po fl cr  or  i1 i2 i3 i4 i5 i6 i7 PL al ec ws gp wa wp ww wn g1 g2 g3 g4 DA TK AN d4 d5 d6 d7 d8 d9
            sscanf(s, "%hi %d %i %hu %hu %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d"
                    , &MP_TYPE(x, y)
                    , &MP_INFO(x, y).population
                    , &MP_INFO(x, y).flags
                    , &MP_INFO(x, y).coal_reserve
                    , &MP_INFO(x, y).ore_reserve
                    , &MP_INFO(x, y).int_1
                    , &MP_INFO(x, y).int_2
                    , &MP_INFO(x, y).int_3
                    , &MP_INFO(x, y).int_4
                    , &MP_INFO(x, y).int_5
                    , &MP_INFO(x, y).int_6
                    , &MP_INFO(x, y).int_7
                    , &MP_POL(x, y)
                    , &ground[x][y].altitude
                    , &ground[x][y].ecotable
                    , &ground[x][y].wastes
                    , &ground[x][y].pollution
                    , &ground[x][y].water_alt
                    , &ground[x][y].water_pol
                    , &ground[x][y].water_wast
                    , &ground[x][y].water_next
                    , &ground[x][y].int1
                    , &ground[x][y].int2
                    , &ground[x][y].int3
                    , &ground[x][y].int4
                    , &MP_DATE(x,y)   // d1 = date of built
                    , &MP_TECH(x,y)   // d2 = tech at build time
                    , &MP_ANIM(x,y)   // d3 = animation_time (see reset_animation_time mess :)
                    , &dumbint        // d4  could be         image index for smooth animation, cf windmill anim_tile
                    , &dumbint        // d5                   percentage of activity to choose family of pic
                    , &dumbint        // d6
                    , &dumbint        // d7
                    , &dumbint        // d8
                    , &dumbint        // d9
                    );
            if (get_group_of_type(MP_TYPE(x, y)) == GROUP_MARKET)
                inventory(x, y);
        }
    }
    set_map_groups();

    sscanf(gzgets(gzfile, s, 256), "%d", &main_screen_originx);
    sscanf(gzgets(gzfile, s, 256), "%d", &main_screen_originy);

    sscanf(gzgets(gzfile, s, 256), "%d", &total_time);

    for (x = 0; x < MAX_NUMOF_SUBSTATIONS; x++) {
        sscanf(gzgets(gzfile, s, 256), "%d", &substationx[x]);
        sscanf(gzgets(gzfile, s, 256), "%d", &substationy[x]);
    }
    sscanf(gzgets(gzfile, s, 256), "%d", &numof_substations);

    for (x = 0; x < MAX_NUMOF_MARKETS; x++) {
        sscanf(gzgets(gzfile, s, 256), "%d", &marketx[x]);
        sscanf(gzgets(gzfile, s, 256), "%d", &markety[x]);
    }
    sscanf(gzgets(gzfile, s, 256), "%d", &numof_markets);
    sscanf(gzgets(gzfile, s, 256), "%d", &people_pool);
    sscanf(gzgets(gzfile, s, 256), "%o", &total_money);
    sscanf(gzgets(gzfile, s, 256), "%d", &income_tax_rate);
    sscanf(gzgets(gzfile, s, 256), "%d", &coal_tax_rate);
    sscanf(gzgets(gzfile, s, 256), "%d", &dole_rate);
    sscanf(gzgets(gzfile, s, 256), "%d", &transport_cost_rate);
    sscanf(gzgets(gzfile, s, 256), "%d", &goods_tax_rate);
    sscanf(gzgets(gzfile, s, 256), "%d", &export_tax);
    sscanf(gzgets(gzfile, s, 256), "%d", &export_tax_rate);
    sscanf(gzgets(gzfile, s, 256), "%d", &import_cost);
    sscanf(gzgets(gzfile, s, 256), "%d", &import_cost_rate);
    sscanf(gzgets(gzfile, s, 256), "%d", &tech_level);
    sscanf(gzgets(gzfile, s, 256), "%d", &tpopulation);
    sscanf(gzgets(gzfile, s, 256), "%d", &tstarving_population);
    sscanf(gzgets(gzfile, s, 256), "%d", &tunemployed_population);
    sscanf(gzgets(gzfile, s, 256), "%d", &x);   /* waste_goods obsolete */
    sscanf(gzgets(gzfile, s, 256), "%d", &power_made);
    sscanf(gzgets(gzfile, s, 256), "%d", &power_used);
    sscanf(gzgets(gzfile, s, 256), "%d", &coal_made);
    sscanf(gzgets(gzfile, s, 256), "%d", &coal_used);
    sscanf(gzgets(gzfile, s, 256), "%d", &goods_made);
    sscanf(gzgets(gzfile, s, 256), "%d", &goods_used);
    sscanf(gzgets(gzfile, s, 256), "%d", &ore_made);
    sscanf(gzgets(gzfile, s, 256), "%d", &ore_used);
    sscanf(gzgets(gzfile, s, 256), "%d", &dummy);       /* &diff_old_population */

    /* Update variables calculated from those above */
    housed_population = tpopulation / ((total_time % NUMOF_DAYS_IN_MONTH) + 1);

    /* Get size of monthgraph array */
    sscanf(gzgets(gzfile, s, 256), "%d", &i);
    for (x = 0; x < i; x++) {
        /* If more entries in file than will fit on screen, 
           then we need to skip past them. */
        if (x >= monthgraph_size) {
            sscanf(gzgets(gzfile, s, 256), "%d", &dummy);       /* &monthgraph_pop[x] */
            sscanf(gzgets(gzfile, s, 256), "%d", &dummy);       /* &monthgraph_starve[x] */
            sscanf(gzgets(gzfile, s, 256), "%d", &dummy);       /* &monthgraph_nojobs[x] */
            sscanf(gzgets(gzfile, s, 256), "%d", &dummy);       /* &monthgraph_ppool[x] */
        } else {
            sscanf(gzgets(gzfile, s, 256), "%d", &monthgraph_pop[x]);
            sscanf(gzgets(gzfile, s, 256), "%d", &monthgraph_starve[x]);
            sscanf(gzgets(gzfile, s, 256), "%d", &monthgraph_nojobs[x]);
            sscanf(gzgets(gzfile, s, 256), "%d", &monthgraph_ppool[x]);
        }
    }
    /* If screen bigger than number of entries in file, pad with zeroes */
    while (x < monthgraph_size) {
        monthgraph_pop[x] = 0;
        monthgraph_starve[x] = 0;
        monthgraph_nojobs[x] = 0;
        monthgraph_ppool[x] = 0;
        x++;
    }
    sscanf(gzgets(gzfile, s, 256), "%d", &rockets_launched);
    sscanf(gzgets(gzfile, s, 256), "%d", &rockets_launched_success);
    sscanf(gzgets(gzfile, s, 256), "%d", &coal_survey_done);

    for (x = 0; x < pbar_data_size; x++) {
        for (p = 0; p < num_pbars; p++) {
            sscanf(gzgets(gzfile, s, 256), "%d", &(pbar_tmp));
            update_pbar(p, pbar_tmp, 1);
        }
    }

    for (p = 0; p < num_pbars; p++)
        pbars[p].data_size = pbar_data_size;

    for (p = 0; p < num_pbars; p++) {
        sscanf(gzgets(gzfile, s, 256), "%d", &(pbars[p].oldtot));
        sscanf(gzgets(gzfile, s, 256), "%d", &(pbars[p].diff));
    }

    sscanf(gzgets(gzfile, s, 256), "%d", &cheat_flag);
    sscanf(gzgets(gzfile, s, 256), "%d", &total_pollution_deaths);
    sscanf(gzgets(gzfile, s, 256), "%f", &pollution_deaths_history);
    sscanf(gzgets(gzfile, s, 256), "%d", &total_starve_deaths);
    sscanf(gzgets(gzfile, s, 256), "%f", &starve_deaths_history);
    sscanf(gzgets(gzfile, s, 256), "%d", &total_unemployed_years);
    sscanf(gzgets(gzfile, s, 256), "%f", &unemployed_history);
    sscanf(gzgets(gzfile, s, 256), "%d", &max_pop_ever);
    sscanf(gzgets(gzfile, s, 256), "%d", &total_evacuated);
    sscanf(gzgets(gzfile, s, 256), "%d", &total_births);

    for (x = 0; x < NUMOF_MODULES; x++)
        sscanf(gzgets(gzfile, s, 256), "%d", &(module_help_flag[x]));

    sscanf(gzgets(gzfile, s, 256), "%128s", given_scene);
    if (strncmp(given_scene, "dummy", 5) == 0 || strlen(given_scene) < 3)
        given_scene[0] = 0;
    sscanf(gzgets(gzfile, s, 256), "%128s", s);
    if (strncmp(given_scene, "dummy", 5) != 0)
        sscanf(s, "%d", &highest_tech_level);
    else
        highest_tech_level = 0;

    gzgets(gzfile, s, 200);   
    if (sscanf
        (s, "sust %d %d %d %d %d %d %d %d %d %d", &sust_dig_ore_coal_count, &sust_port_count, &sust_old_money_count,
         &sust_old_population_count, &sust_old_tech_count, &sust_fire_count, &sust_old_money, &sust_old_population,
         &sust_old_tech, &sustain_flag) == 10) {
        sust_dig_ore_coal_tip_flag = sust_port_flag = 1;
    } else
        sustain_flag = sust_dig_ore_coal_count = sust_port_count
            = sust_old_money_count = sust_old_population_count
            = sust_old_tech_count = sust_fire_count = sust_old_money = sust_old_population = sust_old_tech = 0;

    gzgets(gzfile, s, 80);
    sscanf(s, "arid %d %d", &global_aridity, &global_mountainity);

    gzclose(gzfile);

    /* FIXME: AL1 this is initialisation stuff, should go elsewhere */

    // Engine stuff
    if (tech_level > MODERN_WINDMILL_TECH)
        modern_windmill_flag = 1;

    numof_shanties = count_groups(GROUP_SHANTY);
    numof_communes = count_groups(GROUP_COMMUNE);

    /* set up the university intake. */
    x = count_groups(GROUP_UNIVERSITY);
    if (x > 0) {
        university_intake_rate = (count_groups(GROUP_SCHOOL) * 20) / x;
        if (university_intake_rate > 100)
            university_intake_rate = 100;
    } else
        university_intake_rate = 50;

    print_total_money();

    //reset_animation_times
    //get alt_min, alt_max
    alt_min = 2000000000;
    alt_max = -alt_min;
    for ( y = 0; y < WORLD_SIDE_LEN; y++){
        for ( x = 0; x < WORLD_SIDE_LEN; x++) {
            MP_ANIM(x,y) = 0;
            if (MP_GROUP(x, y) == GROUP_FIRE){
                MP_INFO(x, y).int_3 = 0;
            }
            if (alt_min > ALT(x,y)){
                 alt_min = ALT(x,y);
            }
            if (alt_max < ALT(x,y)){
                 alt_max = ALT(x,y);
            }
        }
    }
    alt_step = (alt_max - alt_min) /10;

    map_power_grid(true);       /* WCK:  Is this safe to do here?
                                 * AL1: No, in NG_1.1
                                 * In case of error message with ok_dial_box
                                 *    the dialog cannot appear because the screen
                                 *    is not set up => crash.
                                 * FIXME: move all initialisation elsewhere, in 
                                 *    engine.cpp or simulate.cpp.
                                 */
    // UI stuff
    if (main_screen_originx > WORLD_SIDE_LEN - getMainWindowWidth() / 16 - 1)
        main_screen_originx = WORLD_SIDE_LEN - getMainWindowWidth() / 16 - 1;

    if (main_screen_originy > WORLD_SIDE_LEN - getMainWindowHeight() / 16 - 1)
        main_screen_originy = WORLD_SIDE_LEN - getMainWindowHeight() / 16 - 1;

    unhighlight_module_button(selected_module);
    selected_module = sbut[7];  /* 7 is track.  Watch out though! */
    highlight_module_button(selected_module);
    set_selected_module(CST_TRACK_LR);
    connect_transport(1, 1, WORLD_SIDE_LEN - 2, WORLD_SIDE_LEN - 2);
    /* Fix desert frontier for old saved games and scenarios */
    desert_frontier(0, 0, WORLD_SIDE_LEN, WORLD_SIDE_LEN);

}
    { KEY_F(19), VK_F19 },
    { KEY_F(20), VK_F20 },	
    { KEY_IC,    VK_INSERT },		
    { KEY_DC,    VK_DELETE },
    { KEY_BACKSPACE, VK_BACK },

    { KEY_PPAGE, VK_PRIOR },
    { KEY_NPAGE, VK_NEXT },
    { KEY_LEFT,  VK_LEFT },
    { KEY_RIGHT, VK_RIGHT },
    { KEY_UP,    VK_UP },
    { KEY_DOWN,  VK_DOWN },
    { KEY_HOME,  VK_HOME },
    { KEY_END,	 VK_END },

    { ALT('*'),  VK_MULTIPLY },
    { ALT('+'),  VK_ADD },
    { ALT('-'),  VK_SUBTRACT },
    { ALT('\t'), VK_PAUSE }, /* Added to make Complete work press Pause */

    { ESC_CHAR, VK_ESCAPE },

    { 0, 0}
};		

/*  init_key  - Called in main.c to initialize ourselves
		Get handle to console input
*/
void init_key (void)
{
    win32APICALL_HANDLE (hConsoleInput, GetStdHandle (STD_INPUT_HANDLE));
Esempio n. 21
0
File: achown.c Progetto: jskDr/mc
static cb_ret_t
advanced_chown_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data)
{
    WDialog *h = DIALOG (w);
    int i;
    int f_pos;
    unsigned long id;

    id = dlg_get_current_widget_id (h);

    for (i = 0; i < BUTTONS_PERM; i++)
        if (chown_advanced_but[i].id == id)
            break;

    f_pos = i;
    i = 0;

    switch (msg)
    {
    case MSG_DRAW:
        chown_refresh ();
        chown_info_update ();
        return MSG_HANDLED;

    case MSG_POST_KEY:
        if (f_pos < 3)
            b_setpos (f_pos);
        return MSG_HANDLED;

    case MSG_FOCUS:
        if (f_pos < 3)
        {
            if ((flag_pos / 3) != f_pos)
                flag_pos = f_pos * 3;
            b_setpos (f_pos);
        }
        else if (f_pos < BUTTONS_PERM)
            flag_pos = f_pos + 6;
        return MSG_HANDLED;

    case MSG_KEY:
        switch (parm)
        {
        case XCTRL ('b'):
        case KEY_LEFT:
            if (f_pos < BUTTONS_PERM)
                return (dec_flag_pos (f_pos));
            break;

        case XCTRL ('f'):
        case KEY_RIGHT:
            if (f_pos < BUTTONS_PERM)
                return (inc_flag_pos (f_pos));
            break;

        case ' ':
            if (f_pos < 3)
                return MSG_HANDLED;
            break;

        case '\n':
        case KEY_ENTER:
            if (f_pos <= 2 || f_pos >= BUTTONS_PERM)
                break;
            do_enter_key (h, f_pos);
            return MSG_HANDLED;

        case ALT ('x'):
            i++;

        case ALT ('w'):
            i++;

        case ALT ('r'):
            parm = i + 3;
            for (i = 0; i < 3; i++)
                ch_flags[i * 3 + parm - 3] = (x_toggle & (1 << parm)) ? '-' : '+';
            x_toggle ^= (1 << parm);
            update_mode (h);
            dlg_broadcast_msg (h, MSG_DRAW);
            send_message (h->current->data, NULL, MSG_FOCUS, 0, NULL);
            break;

        case XCTRL ('x'):
            i++;

        case XCTRL ('w'):
            i++;

        case XCTRL ('r'):
            parm = i;
            for (i = 0; i < 3; i++)
                ch_flags[i * 3 + parm] = (x_toggle & (1 << parm)) ? '-' : '+';
            x_toggle ^= (1 << parm);
            update_mode (h);
            dlg_broadcast_msg (h, MSG_DRAW);
            send_message (h->current->data, NULL, MSG_FOCUS, 0, NULL);
            break;

        case 'x':
            i++;

        case 'w':
            i++;

        case 'r':
            if (f_pos > 2)
                break;
            flag_pos = f_pos * 3 + i;   /* (strchr(ch_perm,parm)-ch_perm); */
            if (BUTTON (h->current->data)->text.start[(flag_pos % 3)] == '-')
                ch_flags[flag_pos] = '+';
            else
                ch_flags[flag_pos] = '-';
            update_mode (h);
            break;

        case '4':
            i++;

        case '2':
            i++;

        case '1':
            if (f_pos <= 2)
            {
                flag_pos = i + f_pos * 3;
                ch_flags[flag_pos] = '=';
                update_mode (h);
            }
            break;

        case '-':
            if (f_pos > 2)
                break;

        case '*':
            if (parm == '*')
                parm = '=';

        case '=':
        case '+':
            if (f_pos <= 4)
            {
                ch_flags[flag_pos] = parm;
                update_mode (h);
                send_message (h, sender, MSG_KEY, KEY_RIGHT, NULL);
                if (flag_pos > 8 || (flag_pos % 3) == 0)
                    dlg_one_down (h);
            }
            break;

        default:
            break;
        }
        return MSG_NOT_HANDLED;

    default:
        return dlg_default_callback (w, sender, msg, parm, data);
    }
}
Esempio n. 22
0
void DBG_TileInfo(int x, int y) {
    fprintf(stderr, "%u,%u:Type=%d, Group=%s(%d), Flags= %08X, Alt.=%d\n", x, y,
        MP_TYPE(x, y), _(main_groups[MP_GROUP(x, y)].name), MP_GROUP(x, y),
        MP_INFO(x, y).flags, ALT(x, y));
}
Esempio n. 23
0
static cb_ret_t
dlg_try_hotkey (WDialog * h, int d_key)
{
    GList *hot_cur;
    Widget *current;
    cb_ret_t handled;
    int c;

    if (h->widgets == NULL)
        return MSG_NOT_HANDLED;

    if (h->current == NULL)
        h->current = h->widgets;

    /*
     * Explanation: we don't send letter hotkeys to other widgets if
     * the currently selected widget is an input line
     */

    current = WIDGET (h->current->data);

    if ((current->options & W_DISABLED) != 0)
        return MSG_NOT_HANDLED;

    if (current->options & W_IS_INPUT)
    {
        /* skip ascii control characters, anything else can valid character in
         * some encoding */
        if (d_key >= 32 && d_key < 256)
            return MSG_NOT_HANDLED;
    }

    /* If it's an alt key, send the message */
    c = d_key & ~ALT (0);
    if (d_key & ALT (0) && g_ascii_isalpha (c))
        d_key = g_ascii_tolower (c);

    handled = MSG_NOT_HANDLED;
    if ((current->options & W_WANT_HOTKEY) != 0)
        handled = send_message (current, NULL, MSG_HOTKEY, d_key, NULL);

    /* If not used, send hotkey to other widgets */
    if (handled == MSG_HANDLED)
        return MSG_HANDLED;

    hot_cur = dlg_widget_next (h, h->current);

    /* send it to all widgets */
    while (h->current != hot_cur && handled == MSG_NOT_HANDLED)
    {
        current = WIDGET (hot_cur->data);

        if ((current->options & W_WANT_HOTKEY) != 0 && (current->options & W_DISABLED) == 0)
            handled = send_message (current, NULL, MSG_HOTKEY, d_key, NULL);

        if (handled == MSG_NOT_HANDLED)
            hot_cur = dlg_widget_next (h, hot_cur);
    }

    if (handled == MSG_HANDLED)
        do_select_widget (h, hot_cur, SELECT_EXACT);

    return handled;
}
Esempio n. 24
0
 * - all the mods are oneshot. see here for information about this. https://github.com/tmk/tmk_keyboard/blob/master/tmk_core/doc/keymap.md
 * - layer one has norwegian special characters at AEO positions
 * - needs us mac keyboard layout
 */

const uint16_t PROGMEM actionmaps[][MATRIX_ROWS][MATRIX_COLS] = {
KEYMAP(
Q       , W        , E        , R        , T          ,                       Y         , U         , I       , O         , P        , \
A       , S        , D        , F        , G          ,                       H         , J         , K       , L         , SCLN     , \
Z       , X        , C        , V        , B          ,                       N         , M         , COMM    , DOT       , SLSH     , \
ESC     , OSM(RALT), OSM(LCTL), OSM(LSFT), TAP(1,BSPC), OSM(LGUI), OSM(LALT), TAP(2,SPC), TAP(3,TAB), MINS    , QUOT      , ENT     ),

KEYMAP(
AGK(F7) , GUI(F12) , RA(QUOT) , ACK(R)   , AGSK(L)    ,                       SH(6)     , SH(LBRC)  , SH(RBRC), RA(O)     , SH(1)    , \
RA(A)   , GUI(LBRC), CSK(ENT) , GUI(RBRC), GSK(T)     ,                       0         , SH(9)     , SH(0)   , SH(BSLS)  , SH(4)    , \
GSK(A)  , GSK(F)   , CTRL(T)  , ALT(V)   , GUI(F9)    ,                       GRAVE     , LBRC      , RBRC    , SH(7)     , SH(GRAVE), \
GA      , OSM(RALT), OSM(LCTL), OSM(LSFT), TRNS       , OSM(LGUI), OSM(LALT), CTRL(F2)  , OFF(1)    , SH(2)   , QUOT      , OSM(LGUI)),

KEYMAP(
INS     , HOME     , UP       , END      , PGUP       ,                       SH(5)     , 7         , 8       , 9         , SH(8)    , \
DEL     , LEFT     , DOWN     , RIGHT    , PGDN       ,                       MINS      , 4         , 5       , 6         , SH(EQUAL), \
VOLU    , MPRV     , MPLY     , MNXT     , GCK(Q)     ,                       SH(4)     , 1         , 2       , 3         , BSLS     , \
VOLD    , MUTE     , OSM(LCTL), OSM(LSFT), CSK(SPC)   , OSM(LGUI), OSM(LALT), TRNS      , OFF(1)    , DOT     , 0         , KP_EQUAL),

KEYMAP(
F1      , F2       , F3       , F4       , F5         ,                       WH_D      , BTN1      , MS_U    , BTN2      , SH(3)    , \
F6      , F7       , F8       , F9       , F10        ,                       WH_U      , MS_L      , MS_D    , MS_R      , BTN3     , \
F11     , F12      , F13      , F14      , BOOT       ,                       NO        , ACL0      , NO      , NO        , NO       , \
GA      , OSM(RALT), OSM(LCTL), OSM(LSFT), GS         , OSM(LGUI), OSM(LALT), SPC       , TRNS      , MINS    , SH(BSLS)  , KP_EQUAL)

};
Esempio n. 25
0
    {KEY_F (7), Key_f7},
    {KEY_F (8), Key_f8},
    {KEY_F (9), Key_f9},
    {KEY_F (10), Key_f10},
    {KEY_F (11), Key_f11},
    {KEY_F (12), Key_f12},
    {KEY_F (13), Key_f13},
    {KEY_F (14), Key_f14},
    {KEY_F (15), Key_f15},
    {KEY_F (16), Key_f16},
    {KEY_F (17), Key_f17},
    {KEY_F (18), Key_f18},
    {KEY_F (19), Key_f19},
    {KEY_F (20), Key_f20},
#endif
    {ALT ('a'), Key_alt_a},
    {ALT ('b'), Key_alt_b},
    {ALT ('c'), Key_alt_c},
    {ALT ('d'), Key_alt_d},
    {ALT ('e'), Key_alt_e},
    {ALT ('f'), Key_alt_f},
    {ALT ('g'), Key_alt_g},
    {ALT ('h'), Key_alt_h},
    {ALT ('i'), Key_alt_i},
    {ALT ('j'), Key_alt_j},
    {ALT ('k'), Key_alt_k},
    {ALT ('l'), Key_alt_l},
    {ALT ('m'), Key_alt_m},
    {ALT ('n'), Key_alt_n},
    {ALT ('o'), Key_alt_o},
    {ALT ('p'), Key_alt_p},
Esempio n. 26
0
    { "SelectCodepage",                    CK_SelectCodepage },

    { NULL,                                0 }
};

/*** global variables ****************************************************************************/

/* viewer/actions_cmd.c */
const global_key_map_t default_viewer_keymap[] = {

    { '?',                                  CK_ViewSearch },
    { '/',                                  CK_ViewSearch },
    { XCTRL('r'),                           CK_ViewContinueSearch },
    { XCTRL('s'),                           CK_ViewContinueSearch },
    { KEY_F (17),                           CK_ViewContinueSearch },
    { ALT('r'),                             CK_ViewToggleRuler  },

    { KEY_HOME,                             CK_ViewMoveToBol },
    { KEY_END,                              CK_ViewMoveToEol },

    { 'h',                                  CK_ViewMoveLeft },
    { KEY_LEFT,                             CK_ViewMoveLeft },

    { 'l',                                  CK_ViewMoveRight },
    { KEY_RIGHT,                            CK_ViewMoveRight },

    { 'k',                                  CK_ViewMoveUp },
    { 'y',                                  CK_ViewMoveUp },
    { KEY_IC,                               CK_ViewMoveUp },
    { KEY_UP,                               CK_ViewMoveUp },