📄 pull.c
字号:
case SplitVertical: { int left = (func == MakeHalfVertical || func == SplitHalfVertical) ? ((g_status.current_window->left + g_status.current_window->end_col + 1) / 2) : g_status.current_window->ccol; if (g_status.current_window->left + 15 > left || g_status.current_window->end_col - 15 < left) dis = TRUE; break; }#if defined( __DJGPP__ ) case PasteFromClipboard: if (!test_clipboard( )) dis = TRUE; break;#endif /* case PreviousPosition: if (!g_status.current_file->marker[0].marked) dis = TRUE; break; */ /* case Redo: if (g_status.current_file->undo_count == 0) dis = TRUE; break; */ case RepeatDiff: if (!diff.defined) dis = TRUE; break; case RepeatFindBackward: case RepeatFindForward: if (bm.search_defined != OK) dis = TRUE; break; case RepeatGrep: if (!g_status.sas_defined || g_status.sas_arg >= g_status.sas_argc) dis = TRUE; break; case RepeatRegXBackward: case RepeatRegXForward: if (regx.search_defined != OK) dis = TRUE; break; case RepeatSearch: if (search_type == ERROR) dis = TRUE; break; case RestoreLine: if (g_status.buff_node != g_status.current_window->ll) dis = TRUE; break; case RetrieveLine: if (g_status.current_file->undo_lines == 0 || g_status.current_window->rline == 0) dis = TRUE; break; case SizeWindow: if (!g_status.current_window->vertical && g_status.current_window->bottom_line == g_display.end_line && g_status.current_window->top == mode.display_cwd) dis = TRUE; break; case ToggleSyntax: if (g_status.current_file->syntax == NULL) dis = TRUE; break; /* case Undo: if (g_status.current_file->undo_count == 0) dis = TRUE; break; */ /* case UnMarkBlock: if (g_status.current_file->block_type == 0) dis = TRUE; break; */#if defined( __UNIX__ ) case UserScreen: if (xterm) dis = TRUE; break;#endif } mnu->minor[i].disabled = dis; } /* * See if the User menu has a Language sub-menu. */ if (mnu == &menu[user_idx].menu) { i = mnu->minor_cnt - 2; if (g_status.current_file->syntax && g_status.current_file->syntax->menu.minor_cnt != 0) { mnu->minor[i].pop_out = &g_status.current_file->syntax->menu; mnu->minor[i].disabled = FALSE; g_status.current_file->syntax->menu.checked = FALSE; } else mnu->minor[i].disabled = TRUE; }}/* * Name: get_bar_spacing * Purpose: calculate headings for main menu choices * Date: November 13, 1993 * Passed: major_col: column to display each menu heading * major_width: width of each menu heading * Notes: assume 6 spaces between the menu items * jmh 991025: since I added another menu, use 5 spaces. * jmh 031129: with the User menu, drop it down to 4. * jmh 050710: with the Help menu, drop it down to 3. * jmh 050722: with customisation, calculate it. */void get_bar_spacing( int major_col[], int major_width[] ){int i;int spc, col;char *hdr; col = 0; for (i = 0; i < menu_cnt; i++) { hdr = menu[i].major_name; if (*hdr == '\0') ++hdr; major_width[i] = strlen( hdr ); col += major_width[i]; } if (menu_cnt == 1) spc = 0; else { spc = (g_display.ncols - 2 - col) / (menu_cnt - 1); if (spc <= 0) spc = 1; else if (spc > 6) spc = 6; } col = (g_display.ncols - 2 - (col + spc * (menu_cnt - 1))) / 2; if (col < 0) col = 0; else if (col > 6) col = 6; for (i = 0; i < menu_cnt; i++) { major_col[i] = col; col += spc + major_width[i]; }}/* * Name: draw_lite_head * Purpose: slap the main menu choices on the lite bar * Date: November 13, 1993 * Passed: row: lite bar row * major_col: column to display each menu heading * * jmh 991021: add a space before and after the heading. */void draw_lite_head( int row, int major_col[] ){int i;char *hdr; for (i = 0; i < menu_cnt; i++) { hdr = menu[i].major_name; if (*hdr == '\0') ++hdr; s_output( hdr, row, major_col[i], Color( Menu_header ) ); } refresh( );}/* * Name: get_minor_counts * Purpose: determine the first and last valid selections * Date: November 13, 1993 * Passed: menu: pointer to menu * jmh 980809: this was used to count the number of selections in the menu, * but that's now done with the sizeof operator. * By the way, it assumes there's something in the menu. * jmh 991127: corrected last selection error (forgot to minus one). * jmh 010624: set current value, add menu parameter. * jmh 031204: the User menu could only contain separators. */void get_minor_counts( MENU_STR* menu ){int cnt;int pos; /* * find first valid minor selection. */ cnt = menu->minor_cnt; for (pos = 1; pos < cnt && menu->minor[pos].minor_func < 0; pos++) ; if (pos < cnt) { menu->first = menu->current = pos; /* * find last valid minor selection */ for (pos = cnt - 2; menu->minor[pos].minor_func < 0; pos--) ; menu->last = pos; } else menu->current = 0;}/* * Name: init_menu * Purpose: initialise some menu "constants" and find key definitions * Author: Jason Hood * Date: 30 December, 1996 * Notes: If a function is defined twice, the first found will be used * Makes a duplicate of the menu, inserting the key definition * * 980524: Create the menu frame from scratch. * 980803: Made keys an array, rather than dynamic allocation. * 980819: Create an array of keys based on function. * Recognize two-keys. * 990412: Place letters in menu, using windowletters sequence. * 990429: Prevent viewer functions being placed in the menu. * 991019: Custom frame style. * 991022: Find the largest area to preserve screen. * 010624: Moved actual menu code to make_menu(). * 031129: Disable the djgpp clipboard popout if the clipboard's not present. * 031130: With the new line member, update the menu with the new key settings. * The init parameter is TRUE for the first call, FALSE otherwise. * 031203: Get the counts here to prevent the config file resetting current. */void init_menu( int init ){long func_key[NUM_FUNCS];int i, j, k;int key;MENU_LIST *ml; get_bar_spacing( major_col, major_width ); memset( func_key, 0, sizeof(func_key) ); for (k = 0; k < MODIFIERS; ++k) { key = 256 | (k << 9); for (i = 0; i < MAX_KEYS; ++i) { j = key_func[k][i]; if (j != 0 && func_key[j] == 0) { if (!viewer( i | key )) func_key[j] = i | key; } } } for (i = 1; i < NUM_FUNCS; ++i) { if (func_key[i] == 0) { func_key[i] = cfg_search_tree( i, key_tree.right ); if (func_key[i] == ERROR || viewer( PARENT_KEY( func_key[i] ))) func_key[i] = 0; } } for (i = 0; i < menu_cnt; i++) { get_minor_counts( &menu[i].menu ); make_menu( &menu[i].menu, func_key, 0 ); } for (ml = popout_menu; ml != NULL; ml = ml->next) { get_minor_counts( &ml->popout ); make_menu( &ml->popout, func_key, 1 ); } if (init) { get_minor_counts( &make_window_menu ); make_menu( &make_window_menu, NULL, 0 ); } if (saved_major >= menu_cnt) saved_major = 0;}/* * Name: make_menu * Purpose: create the menu outline and add the function key * Author: Jason Hood * Date: June 24, 2001 * Passed: menu: menu being made * func_key: keys assigned to functions * level: 0 for top-level menu, 1 for popout */void make_menu( MENU_STR* menu, long *func_key, int level ){char *new_name;char *item;char *old;int cnt;int len;int width;int wid;long func;int pos;int seps;int inner[10];int j;static const char *fc, *fc2;static int frame = -1; if (frame != g_display.frame_style) { frame = g_display.frame_style; fc = graphic_char[frame]; fc2 = (frame < 3) ? fc : graphic_char[2]; } cnt = menu->minor_cnt; pos = 0; /* Position into windowletters */ width = 0; /* Length of the longest function */ wid = -2; /* Length of the longest key */ seps = 0; /* Number of separators */ for (j = 1; j < cnt - 1; ++j) { item = menu->minor[j].minor_name; if (item && *item == '\0') ++item; func = menu->minor[j].minor_func; if (func == ERROR && (item == NULL || *item != ' ')) inner[seps++] = j; if (item != NULL) { len = strlen( item ); if (len > width) width = len; item = create_menu_key( func, func_key ); if (item != NULL) { len = strlen( item ); if (len > wid) wid = len; } } } /* frame+space, letter+bracket+space, function, two spaces, key, space+frame */ len = 2 + 3 + width + 2 + wid + 2; new_name = create_frame( len, cnt, seps, inner, -1, -1 ); if (new_name == NULL) return; old = menu->minor[0].line; if (old != NULL) free( old ); for (j = 0; j < cnt; new_name += len+1, ++j) { item = menu->minor[j].minor_name; if (item && *item == '\0') ++item; func = menu->minor[j].minor_func; if (func < 0) { if (item != NULL) { if (*item == ' ') ++item; wid = strlen( item ); memcpy( new_name + (len-wid) / 2, item, wid ); } } else { if (windowletters[pos]) { new_name[2] = windowletters[pos++]; new_name[3] = ')'; } memcpy( new_name+5, item, strlen( item ) ); item = create_menu_key( func, func_key ); if (item != NULL) { wid = strlen( item ); memcpy( new_name + len-2-wid, item, wid ); } } menu->minor[j].line = new_name; } menu->width = len; len = (len + 2 + g_display.shadow_width) * (cnt + 1); if (len > buf_len[level]) { buf_len[level] = len; if (buffer[level]) { free( buffer[level] ); buffer[level] = NULL; } }}/* * Name: create_menu_key * Purpose: create the string to be used for the key in the menu * Author: Jason Hood * Date: October 25, 1999 * Passed: func: menu function or key * func_key: array relating functions to keys * Returns: pointer to the key string or NULL if no key * Notes: the pointer is static. * 010624: use key 0 for the pop-out menu indicator. * 031204: recognise PseudoMacro triggers (for the User menu). */static char *create_menu_key( long func, long *func_key ){static char name[40];long key;int parent;int len; if (func == ERROR) return( NULL ); if (func == 0) { name[0] = POP_OUT; name[1] = '\0'; } else if (func >= 0x2121 && func < 0x10000L) { name[0] = (unsigned)func >> 8; name[1] = (int)func & 0xff; name[2] = '\0'; } else if (func_key == NULL && (func & _FUNCTION)) return( NULL ); else { if (func & _FUNCTION) { key = func_key[(int)func & ~_FUNCTION]; if (key == 0) return( NULL ); } else key = func; parent = PARENT_KEY( key ); if (parent) { menu_key_name( parent, name ); len = strlen( name ); name[len++] = ' '; menu_key_name( CHILD_KEY( key ), name + len ); } else menu_key_name( (int)key, name ); } return( name );}/* * Name: menu_key_name * Purpose: create a function key name for the menu * Author: Jason Hood * Date: October 25, 1999 * Passed: key: key to create * buf: buffer to place name * Notes: function keys only (no two-keys). * * jmh 021031: combined the '+' directly into the key (which also allows * '-' to be defined in the config, if you'd prefer). */static void menu_key_name( int key, char *buf ){ *buf = '\0'; if (key & _SHIFT) strcat( buf, key_word[KEY( _SHIFTKEY )] ); if (key & _CTRL) strcat( buf, key_word[KEY( _CONTROLKEY )] ); if (key & _ALT) strcat( buf, key_word[KEY( _ALTKEY )] ); strcat( buf, key_word[KEY( key )] );}/* * Name: viewer * Purpose: determine if a key is a viewer key * Author: Jason Hood * Date: August 18, 2002 * Passed: key: key to test * Returns: TRUE for a viewer key, FALSE otherwise. * Notes: used to prevent viewer keys being placed on the menu. */int viewer( long key ){ /* * Only unshifted and Shift keys can be viewer. */ if (key & (_CTRL | _ALT)) return( FALSE ); key = KEY( key ) | 256; if (key == _ESC || key == _BACKSPACE || key == _TAB || key == _ENTER || key == _GREY_STAR || (key > _SPACEBAR && key != _LEFT_BACKSLASH)) return( FALSE ); return( TRUE );}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -