这篇教程C++ vim_strchr函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中vim_strchr函数的典型用法代码示例。如果您正苦于以下问题:C++ vim_strchr函数的具体用法?C++ vim_strchr怎么用?C++ vim_strchr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了vim_strchr函数的23个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: vim_strchr/* * Duplicate the menu item text and then process to see if a mnemonic key * and/or accelerator text has been identified. * Returns a pointer to allocated memory, or NULL for failure. * If mnemonic != NULL, *mnemonic is set to the character after the first '&'. * If actext != NULL, *actext is set to the text after the first TAB. */static char_u *menu_text(char_u *str, int *mnemonic, char_u **actext){ char_u *p; char_u *text; /* Locate accelerator text, after the first TAB */ p = vim_strchr(str, TAB); if (p != NULL) { if (actext != NULL) *actext = vim_strsave(p + 1); text = vim_strnsave(str, (int)(p - str)); } else text = vim_strsave(str); /* Find mnemonic characters "&a" and reduce "&&" to "&". */ for (p = text; p != NULL; ) { p = vim_strchr(p, '&'); if (p != NULL) { if (p[1] == NUL) /* trailing "&" */ break; if (mnemonic != NULL && p[1] != '&') *mnemonic = p[1]; STRMOVE(p, p + 1); p = p + 1; } } return text;}
开发者ID:Happy-Dude,项目名称:neovim,代码行数:35,
示例2: workshop_init voidworkshop_init(void){ char_u buf[64]; int is_dirty = FALSE; int width, height; XtInputMask mask; /* * Turn on MenuBar, ToolBar, and Footer. */ STRCPY(buf, p_go); if (vim_strchr(p_go, GO_MENUS) == NULL) { STRCAT(buf, "m"); is_dirty = TRUE; } if (vim_strchr(p_go, GO_TOOLBAR) == NULL) { STRCAT(buf, "T"); is_dirty = TRUE; } if (vim_strchr(p_go, GO_FOOTER) == NULL) { STRCAT(buf, "F"); is_dirty = TRUE; } if (is_dirty) set_option_value((char_u *)"go", 0L, buf, 0); /* * Set size from workshop_get_width_height(). */ width = height = 0; if (workshop_get_width_height(&width, &height)) { XtVaSetValues(vimShell, XmNwidth, width, XmNheight, height, NULL); } /* * Now read in the initial messages from eserve. */ while ((mask = XtAppPending(app_context)) && (mask & XtIMAlternateInput) && !workshopInitDone) XtAppProcessEvent(app_context, (XtInputMask)XtIMAlternateInput);}
开发者ID:KarstenHopp,项目名称:vim,代码行数:49,
示例3: while/* * Reverse the characters in the search path and substitute section * accordingly. * TODO: handle different separator characters. Use skip_regexp(). */char_u *lrF_sub(char_u *ibuf){ char_u *p, *ep; int i, cnt; p = ibuf; /* Find the boundary of the search path */ while (((p = vim_strchr(p + 1, '/')) != NULL) && p[-1] == '//') ; if (p == NULL) return ibuf; /* Reverse the Farsi characters in the search path. */ lrFswap(ibuf, (int)(p-ibuf)); /* Now find the boundary of the substitute section */ if ((ep = (char_u *)strrchr((char *)++p, '/')) != NULL) cnt = (int)(ep - p); else cnt = (int)STRLEN(p); /* Reverse the characters in the substitute section and take care of '/' */ for (i = 0; i < cnt-1; i++) if (p[i] == '//') { p[i] = p[i+1]; p[++i] = '//'; } lrswapbuf(p, cnt); return ibuf;}
开发者ID:Aldemarka,项目名称:neovim,代码行数:39,
示例4: maybe_intro_message/* * Show the intro message when not editing a file. */ voidmaybe_intro_message(void){ if (BUFEMPTY() && curbuf->b_fname == NULL && firstwin->w_next == NULL && vim_strchr(p_shm, SHM_INTRO) == NULL) intro_message(FALSE);}
开发者ID:mischief,项目名称:vim,代码行数:12,
示例5: vim_is_vt300int vim_is_vt300(char_u *name){ if (name == NULL) return FALSE; /* actually all ANSI comp. terminals should be here */ /* catch VT100 - VT5xx */ return (STRNICMP(name, "vt", 2) == 0 && vim_strchr((char_u *)"12345", name[2]) != NULL) || STRCMP(name, "builtin_vt320") == 0;}
开发者ID:RichiH,项目名称:neovim,代码行数:9,
示例6: maybe_intro_message/// Show the intro message when not editing a file.void maybe_intro_message(void){ if (bufempty() && (curbuf->b_fname == NULL) && (firstwin->w_next == NULL) && (vim_strchr(p_shm, SHM_INTRO) == NULL)) { intro_message(FALSE); }}
开发者ID:ENjOyAbLE1991,项目名称:neovim,代码行数:10,
示例7: vim_strchr/* * Duplicate the menu item text and then process to see if a mnemonic key * and/or accelerator text has been identified. * Returns a pointer to allocated memory, or NULL for failure. * If mnemonic != NULL, *mnemonic is set to the character after the first '&'. * If actext != NULL, *actext is set to the text after the first TAB. */static char_u *menu_text(char_u *str, int *mnemonic, char_u **actext){ char_u *p; char_u *text; /* Locate accelerator text, after the first TAB */ p = vim_strchr(str, TAB); if (p != NULL) { if (actext != NULL) *actext = vim_strsave(p + 1); text = vim_strnsave(str, (int)(p - str)); } else text = vim_strsave(str); /* Find mnemonic characters "&a" and reduce "&&" to "&". */ for (p = text; p != NULL; ) { p = vim_strchr(p, '&'); if (p != NULL) { if (p[1] == NUL) /* trailing "&" */ break; if (mnemonic != NULL && p[1] != '&')#if !defined(__MVS__) || defined(MOTIF390_MNEMONIC_FIXED) *mnemonic = p[1];#else { /* * Well there is a bug in the Motif libraries on OS390 Unix. * The mnemonic keys needs to be converted to ASCII values * first. * This behavior has been seen in 2.8 and 2.9. */ char c = p[1]; __etoa_l(&c, 1); *mnemonic = c; }#endif STRMOVE(p, p + 1); p = p + 1; } } return text;}
开发者ID:bountysource-support,项目名称:neovim,代码行数:49,
示例8: maybe_intro_message/* * Show the intro message when not editing a file. */ voidmaybe_intro_message(void){ if (bufempty() && curbuf->b_fname == NULL#ifdef FEAT_WINDOWS && firstwin->w_next == NULL#endif && vim_strchr(p_shm, SHM_INTRO) == NULL) intro_message(FALSE);}
开发者ID:ybian,项目名称:macvim,代码行数:14,
示例9: workshop_menu_end voidworkshop_menu_end(){ Boolean using_tearoff; /* set per current option setting */#ifdef WSDEBUG_TRACE if (WSDLEVEL(WS_TRACE_VERBOSE | WS_TRACE)) wstrace("workshop_menu_end()/n");#endif using_tearoff = vim_strchr(p_go, GO_TEAROFF) != NULL; gui_mch_toggle_tearoffs(using_tearoff);}
开发者ID:UTSASRG,项目名称:DoubleTake,代码行数:13,
示例10: mouse_has/* * Return true if * - "c" is in 'mouse', or * - 'a' is in 'mouse' and "c" is in MOUSE_A, or * - the current buffer is a help file and 'h' is in 'mouse' and we are in a * normal editing mode (not at hit-return message). */int mouse_has(int c){ for (char_u *p = p_mouse; *p; ++p) switch (*p) { case 'a': if (vim_strchr((char_u *)MOUSE_A, c) != NULL) return true; break; case MOUSE_HELP: if (c != MOUSE_RETURN && curbuf->b_help) return true; break; default: if (c == *p) return true; break; } return false;}
开发者ID:hoop33,项目名称:neovim,代码行数:21,
示例11: show_one_markstatic voidshow_one_mark( int c, char_u *arg, pos_T *p, char_u *name, int current /* in current file */){ static int did_title = FALSE; int mustfree = FALSE; if (c == -1) { /* finish up */ if (did_title) did_title = FALSE; else { if (arg == NULL) MSG(_("No marks set")); else EMSG2(_("E283: No marks matching /"%s/""), arg); } } /* don't output anything if 'q' typed at --more-- prompt */ else if (!got_int && (arg == NULL || vim_strchr(arg, c) != NULL) && p->lnum != 0) { if (!did_title) { /* Highlight title */ MSG_PUTS_TITLE(_("/nmark line col file/text")); did_title = TRUE; } msg_putchar('/n'); if (!got_int) { sprintf((char *)IObuff, " %c %6ld %4d ", c, p->lnum, p->col); msg_outtrans(IObuff); if (name == NULL && current) { name = mark_line(p, 15); mustfree = TRUE; } if (name != NULL) { msg_outtrans_attr(name, current ? HL_ATTR(HLF_D) : 0); if (mustfree) { xfree(name); } } } ui_flush(); /* show one line at a time */ }}
开发者ID:ZyX-I,项目名称:neovim,代码行数:49,
示例12: initialise_toolbar/* * Create the toolbar, initially unpopulated. * (just like the menu, there are no defaults, it's all * set up through menu.vim) */ static voidinitialise_toolbar(void){ s_toolbarhwnd = CreateToolbar( s_hwnd, WS_CHILD | WS_VISIBLE, CMD_TB_BASE, /*<vn>*/ 31, //number of images in initial bitmap s_hinst, IDR_TOOLBAR1, // id of initial bitmap NULL, 0 // initial number of buttons ); gui_mch_show_toolbar(vim_strchr(p_go, GO_TOOLBAR) != NULL);}
开发者ID:Stolas,项目名称:vim-qt,代码行数:21,
示例13: get_breakindent_win/* * Return appropriate space number for breakindent, taking influencing * parameters into account. Window must be specified, since it is not * necessarily always the current one. */int get_breakindent_win(win_T *wp, char_u *line) { static int prev_indent = 0; /* cached indent value */ static int prev_ts = 0L; /* cached tabstop value */ static char_u *prev_line = NULL; /* cached pointer to line */ int bri = 0; /* window width minus window margin space, i.e. what rests for text */ const int eff_wwidth = wp->w_width - ((wp->w_p_nu || wp->w_p_rnu) && (vim_strchr(p_cpo, CPO_NUMCOL) == NULL) ? number_width(wp) + 1 : 0); /* used cached indent, unless pointer or 'tabstop' changed */ if (prev_line != line || prev_ts != wp->w_buffer->b_p_ts) { prev_line = line; prev_ts = wp->w_buffer->b_p_ts; prev_indent = get_indent_str(line, (int)wp->w_buffer->b_p_ts, wp->w_p_list); } bri = prev_indent + wp->w_p_brishift; /* indent minus the length of the showbreak string */ if (wp->w_p_brisbr) bri -= vim_strsize(p_sbr); /* Add offset for number column, if 'n' is in 'cpoptions' */ bri += win_col_off2(wp); /* never indent past left window margin */ if (bri < 0) bri = 0; /* always leave at least bri_min characters on the left, * if text width is sufficient */ else if (bri > eff_wwidth - wp->w_p_brimin) bri = (eff_wwidth - wp->w_p_brimin < 0) ? 0 : eff_wwidth - wp->w_p_brimin; return bri;}
开发者ID:bradparks,项目名称:neovim,代码行数:44,
示例14: workshop_toolbar_end voidworkshop_toolbar_end(){ char_u buf[64];#ifdef WSDEBUG_TRACE if (WSDLEVEL(WS_TRACE_VERBOSE | WS_TRACE)) { wstrace("workshop_toolbar_end()/n"); }#endif /* * Turn on ToolBar. */ STRCPY(buf, p_go); if (vim_strchr(p_go, 'T') == NULL) { STRCAT(buf, "T"); set_option_value((char_u *)"go", 0L, buf, 0); } workshopInitDone = True;}
开发者ID:UTSASRG,项目名称:DoubleTake,代码行数:23,
示例15: lrF_sub/// Reverse the characters in the search path and substitute section/// accordingly./// TODO: handle different separator characters. Use skip_regexp().////// @param ibuf////// @return The buffer with the characters in the search path and substitute/// section reversed.char_u* lrF_sub(char_u *ibuf){ char_u *p, *ep; int i, cnt; p = ibuf; // Find the boundary of the search path while (((p = vim_strchr(p + 1, '/')) != NULL) && p[-1] == '//') { // empty } if (p == NULL) { return ibuf; } // Reverse the Farsi characters in the search path. lrFswap(ibuf, (int)(p - ibuf)); // Now find the boundary of the substitute section if ((ep = (char_u *)strrchr((char *)++p, '/')) != NULL) { cnt = (int)(ep - p); } else { cnt = (int)STRLEN(p); } // Reverse the characters in the substitute section and take care of '/' for (i = 0; i < cnt - 1; i++) { if (p[i] == '//') { p[i] = p[i + 1]; p[++i] = '//'; } } lrswapbuf(p, cnt); return ibuf;}
开发者ID:jamessan,项目名称:neovim,代码行数:45,
示例16: gui_mch_dialog//.........这里部分代码省略......... /* Allocate array to hold the X position of each button */ buttonPositions = (int *) lalloc(numButtons * sizeof(int), TRUE); if (buttonPositions == NULL) return -1; /* * Calculate how big the dialog must be. */ hwnd = GetDesktopWindow(); hdc = GetWindowDC(hwnd); oldFont = SelectFont(hdc, GetStockObject(SYSTEM_FONT)); dlgPaddingX = DLG_OLD_STYLE_PADDING_X; dlgPaddingY = DLG_OLD_STYLE_PADDING_Y; GetTextMetrics(hdc, &fontInfo); fontHeight = fontInfo.tmHeight; /* Minimum width for horizontal button */ minButtonWidth = GetTextWidth(hdc, "Cancel", 6); /* Maximum width of a dialog, if possible */ GetWindowRect(s_hwnd, &rect); maxDialogWidth = rect.right - rect.left - GetSystemMetrics(SM_CXFRAME) * 2; if (maxDialogWidth < DLG_MIN_MAX_WIDTH) maxDialogWidth = DLG_MIN_MAX_WIDTH; /* Set dlgwidth to width of message */ pstart = message; messageWidth = 0; msgheight = 0; do { pend = vim_strchr(pstart, DLG_BUTTON_SEP); if (pend == NULL) pend = pstart + STRLEN(pstart); /* Last line of message. */ msgheight += fontHeight; textWidth = GetTextWidth(hdc, pstart, pend - pstart); if (textWidth > messageWidth) messageWidth = textWidth; pstart = pend + 1; } while (*pend != NUL); dlgwidth = messageWidth; /* Add width of icon to dlgwidth, and some space */ dlgwidth += DLG_ICON_WIDTH + 3 * dlgPaddingX; if (msgheight < DLG_ICON_HEIGHT) msgheight = DLG_ICON_HEIGHT; /* * Check button names. A long one will make the dialog wider. */ vertical = (vim_strchr(p_go, GO_VERTICAL) != NULL); if (!vertical) { // Place buttons horizontally if they fit. horizWidth = dlgPaddingX; pstart = tbuffer; i = 0; do { pend = vim_strchr(pstart, DLG_BUTTON_SEP); if (pend == NULL) pend = pstart + STRLEN(pstart); // Last button name. textWidth = GetTextWidth(hdc, pstart, pend - pstart);
开发者ID:Stolas,项目名称:vim-qt,代码行数:67,
示例17: vim_findfile_init//.........这里部分代码省略......... search_ctx = xcalloc(1, sizeof(ff_search_ctx_T)); } search_ctx->ffsc_find_what = find_what; search_ctx->ffsc_tagfile = tagfile; /* clear the search context, but NOT the visited lists */ ff_clear(search_ctx); /* clear visited list if wanted */ if (free_visited == TRUE) vim_findfile_free_visited(search_ctx); else { /* Reuse old visited lists. Get the visited list for the given * filename. If no list for the current filename exists, creates a new * one. */ search_ctx->ffsc_visited_list = ff_get_visited_list(filename, &search_ctx->ffsc_visited_lists_list); if (search_ctx->ffsc_visited_list == NULL) goto error_return; search_ctx->ffsc_dir_visited_list = ff_get_visited_list(filename, &search_ctx->ffsc_dir_visited_lists_list); if (search_ctx->ffsc_dir_visited_list == NULL) goto error_return; } if (ff_expand_buffer == NULL) { ff_expand_buffer = xmalloc(MAXPATHL); } /* Store information on starting dir now if path is relative. * If path is absolute, we do that later. */ if (path[0] == '.' && (vim_ispathsep(path[1]) || path[1] == NUL) && (!tagfile || vim_strchr(p_cpo, CPO_DOTTAG) == NULL) && rel_fname != NULL) { int len = (int)(path_tail(rel_fname) - rel_fname); if (!vim_isAbsName(rel_fname) && len + 1 < MAXPATHL) { /* Make the start dir an absolute path name. */ STRLCPY(ff_expand_buffer, rel_fname, len + 1); search_ctx->ffsc_start_dir = FullName_save(ff_expand_buffer, FALSE); } else search_ctx->ffsc_start_dir = vim_strnsave(rel_fname, len); if (*++path != NUL) ++path; } else if (*path == NUL || !vim_isAbsName(path)) {#ifdef BACKSLASH_IN_FILENAME /* "c:dir" needs "c:" to be expanded, otherwise use current dir */ if (*path != NUL && path[1] == ':') { char_u drive[3]; drive[0] = path[0]; drive[1] = ':'; drive[2] = NUL; if (vim_FullName(drive, ff_expand_buffer, MAXPATHL, TRUE) == FAIL) goto error_return; path += 2; } else#endif if (os_dirname(ff_expand_buffer, MAXPATHL) == FAIL) goto error_return; search_ctx->ffsc_start_dir = vim_strsave(ff_expand_buffer);#ifdef BACKSLASH_IN_FILENAME /* A path that starts with "/dir" is relative to the drive, not to the
开发者ID:abhishekkumar-,项目名称:neovim,代码行数:67,
示例18: while/* * Parse the 'guicursor' option ("what" is SHAPE_CURSOR) or 'mouseshape' * ("what" is SHAPE_MOUSE). * Returns error message for an illegal option, NULL otherwise. */char_u *parse_shape_opt(int what){ char_u *modep; char_u *colonp; char_u *commap; char_u *slashp; char_u *p, *endp; int idx = 0; /* init for GCC */ int all_idx; int len; int i; int found_ve = FALSE; /* found "ve" flag */ int round; /* * First round: check for errors; second round: do it for real. */ for (round = 1; round <= 2; ++round) { /* * Repeat for all comma separated parts. */ modep = p_guicursor; while (*modep != NUL) { colonp = vim_strchr(modep, ':'); if (colonp == NULL) return (char_u *)N_("E545: Missing colon"); if (colonp == modep) return (char_u *)N_("E546: Illegal mode"); commap = vim_strchr(modep, ','); /* * Repeat for all mode's before the colon. * For the 'a' mode, we loop to handle all the modes. */ all_idx = -1; assert(modep < colonp); while (modep < colonp || all_idx >= 0) { if (all_idx < 0) { /* Find the mode. */ if (modep[1] == '-' || modep[1] == ':') len = 1; else len = 2; if (len == 1 && TOLOWER_ASC(modep[0]) == 'a') all_idx = SHAPE_IDX_COUNT - 1; else { for (idx = 0; idx < SHAPE_IDX_COUNT; ++idx) if (STRNICMP(modep, shape_table[idx].name, len) == 0) break; if (idx == SHAPE_IDX_COUNT || (shape_table[idx].used_for & what) == 0) return (char_u *)N_("E546: Illegal mode"); if (len == 2 && modep[0] == 'v' && modep[1] == 'e') found_ve = TRUE; } modep += len + 1; } if (all_idx >= 0) idx = all_idx--; else if (round == 2) { { /* Set the defaults, for the missing parts */ shape_table[idx].shape = SHAPE_BLOCK; shape_table[idx].blinkwait = 700L; shape_table[idx].blinkon = 400L; shape_table[idx].blinkoff = 250L; } } /* Parse the part after the colon */ for (p = colonp + 1; *p && *p != ','; ) { { /* * First handle the ones with a number argument. */ i = *p; len = 0; if (STRNICMP(p, "ver", 3) == 0) len = 3; else if (STRNICMP(p, "hor", 3) == 0) len = 3; else if (STRNICMP(p, "blinkwait", 9) == 0) len = 9; else if (STRNICMP(p, "blinkon", 7) == 0) len = 7; else if (STRNICMP(p, "blinkoff", 8) == 0) len = 8; if (len != 0) { p += len; if (!VIM_ISDIGIT(*p)) return (char_u *)N_("E548: digit expected"); long digits = getdigits(&p); assert(digits <= INT_MAX);//.........这里部分代码省略.........
开发者ID:GlenDC,项目名称:neovim,代码行数:101,
示例19: replace_termcodes// Replace any terminal code strings in from[] with the equivalent internal// vim representation. This is used for the "from" and "to" part of a// mapping, and the "to" part of a menu command.// Any strings like "<C-UP>" are also replaced, unless 'cpoptions' contains// '<'.// K_SPECIAL by itself is replaced by K_SPECIAL KS_SPECIAL KE_FILLER.//// The replacement is done in result[] and finally copied into allocated// memory. If this all works well *bufp is set to the allocated memory and a// pointer to it is returned. If something fails *bufp is set to NULL and from// is returned.//// CTRL-V characters are removed. When "from_part" is TRUE, a trailing CTRL-V// is included, otherwise it is removed (for ":map xx ^V", maps xx to// nothing). When 'cpoptions' does not contain 'B', a backslash can be used// instead of a CTRL-V.char_u * replace_termcodes ( char_u *from, char_u **bufp, int from_part, int do_lt, // also translate <lt> int special // always accept <key> notation){ ssize_t i; size_t slen; char_u key; size_t dlen = 0; char_u *src; int do_backslash; // backslash is a special character int do_special; // recognize <> key codes char_u *result; // buffer for resulting string do_backslash = (vim_strchr(p_cpo, CPO_BSLASH) == NULL); do_special = (vim_strchr(p_cpo, CPO_SPECI) == NULL) || special; // Allocate space for the translation. Worst case a single character is // replaced by 6 bytes (shifted special key), plus a NUL at the end. result = xmalloc(STRLEN(from) * 6 + 1); src = from; // Check for #n at start only: function key n if (from_part && src[0] == '#' && VIM_ISDIGIT(src[1])) { // function key result[dlen++] = K_SPECIAL; result[dlen++] = 'k'; if (src[1] == '0') { result[dlen++] = ';'; // #0 is F10 is "k;" } else { result[dlen++] = src[1]; // #3 is F3 is "k3" } src += 2; } // Copy each byte from *from to result[dlen] while (*src != NUL) { // If 'cpoptions' does not contain '<', check for special key codes, // like "<C-S-LeftMouse>" if (do_special && (do_lt || STRNCMP(src, "<lt>", 4) != 0)) { // Replace <SID> by K_SNR <script-nr> _. // (room: 5 * 6 = 30 bytes; needed: 3 + <nr> + 1 <= 14) if (STRNICMP(src, "<SID>", 5) == 0) { if (current_SID <= 0) { EMSG(_(e_usingsid)); } else { src += 5; result[dlen++] = K_SPECIAL; result[dlen++] = (int)KS_EXTRA; result[dlen++] = (int)KE_SNR; sprintf((char *)result + dlen, "%" PRId64, (int64_t)current_SID); dlen += STRLEN(result + dlen); result[dlen++] = '_'; continue; } } slen = trans_special(&src, result + dlen, TRUE); if (slen) { dlen += slen; continue; } } if (do_special) { char_u *p, *s, len; // Replace <Leader> by the value of "mapleader". // Replace <LocalLeader> by the value of "maplocalleader". // If "mapleader" or "maplocalleader" isn't set use a backslash. if (STRNICMP(src, "<Leader>", 8) == 0) { len = 8; p = get_var_value((char_u *)"g:mapleader"); } else if (STRNICMP(src, "<LocalLeader>", 13) == 0) { len = 13; p = get_var_value((char_u *)"g:maplocalleader"); } else { len = 0; p = NULL; }//.........这里部分代码省略.........
开发者ID:Happy-Dude,项目名称:neovim,代码行数:101,
示例20: write_selection/// To remain compatible with the old implementation(which forked a process/// for writing) the entire text is copied to a temporary buffer before the/// event loop starts. If we don't(by writing in chunks returned by `ml_get`)/// the buffer being modified might get modified by reading from the process/// before we finish writing.static void write_selection(uv_write_t *req){ ProcessData *pdata = (ProcessData *)req->data; // TODO(tarruda): use a static buffer for up to a limit(BUFFER_LENGTH) and // only after filled we should start allocating memory(skip unnecessary // allocations for small writes) int buflen = BUFFER_LENGTH; pdata->wbuffer = (char *)xmalloc(buflen); uv_buf_t uvbuf; linenr_T lnum = curbuf->b_op_start.lnum; int off = 0; int written = 0; char_u *lp = ml_get(lnum); int l; int len; for (;;) { l = strlen((char *)lp + written); if (l == 0) { len = 0; } else if (lp[written] == NL) { // NL -> NUL translation len = 1; if (off + len >= buflen) { // Resize the buffer buflen *= 2; pdata->wbuffer = xrealloc(pdata->wbuffer, buflen); } pdata->wbuffer[off++] = NUL; } else { char_u *s = vim_strchr(lp + written, NL); len = s == NULL ? l : s - (lp + written); while (off + len >= buflen) { // Resize the buffer buflen *= 2; pdata->wbuffer = xrealloc(pdata->wbuffer, buflen); } memcpy(pdata->wbuffer + off, lp + written, len); off += len; } if (len == l) { // Finished a line, add a NL, unless this line // should not have one. // FIXME need to make this more readable if (lnum != curbuf->b_op_end.lnum || !curbuf->b_p_bin || (lnum != curbuf->b_no_eol_lnum && (lnum != curbuf->b_ml.ml_line_count || curbuf->b_p_eol))) { if (off + 1 >= buflen) { // Resize the buffer buflen *= 2; pdata->wbuffer = xrealloc(pdata->wbuffer, buflen); } pdata->wbuffer[off++] = NL; } ++lnum; if (lnum > curbuf->b_op_end.lnum) { break; } lp = ml_get(lnum); written = 0; } else if (len > 0) { written += len; } } uvbuf.base = pdata->wbuffer; uvbuf.len = off; uv_write(req, pdata->shell_stdin, &uvbuf, 1, write_cb);}
开发者ID:MarcWeber,项目名称:neovim,代码行数:78,
示例21: get_lisp_indent// TODO(unknown):// Findmatch() should be adapted for lisp, also to make showmatch// work correctly: now (v5.3) it seems all C/C++ oriented:// - it does not recognize the #/( and #/) notations as character literals// - it doesn't know about comments starting with a semicolon// - it incorrectly interprets '(' as a character literal// All this messes up get_lisp_indent in some rare cases.// Update from Sergey Khorev:// I tried to fix the first two issues.int get_lisp_indent(void){ pos_T *pos, realpos, paren; int amount; char_u *that; colnr_T col; colnr_T firsttry; int parencount; int quotecount; int vi_lisp; // Set vi_lisp to use the vi-compatible method. vi_lisp = (vim_strchr(p_cpo, CPO_LISP) != NULL); realpos = curwin->w_cursor; curwin->w_cursor.col = 0; if ((pos = findmatch(NULL, '(')) == NULL) { pos = findmatch(NULL, '['); } else { paren = *pos; pos = findmatch(NULL, '['); if ((pos == NULL) || ltp(pos, &paren)) { pos = &paren; } } if (pos != NULL) { // Extra trick: Take the indent of the first previous non-white // line that is at the same () level. amount = -1; parencount = 0; while (--curwin->w_cursor.lnum >= pos->lnum) { if (linewhite(curwin->w_cursor.lnum)) { continue; } for (that = ml_get_curline(); *that != '/0'; ++that) { if (*that == ';') { while (*(that + 1) != '/0') { that++; } continue; } if (*that == '//') { if (*(that + 1) != '/0') { that++; } continue; } if ((*that == '"') && (*(that + 1) != '/0')) { while (*++that && *that != '"') { // Skipping escaped characters in the string if (*that == '//') { if (*++that == '/0') { break; } if (that[1] == '/0') { that++; break; } } } } if ((*that == '(') || (*that == '[')) { parencount++; } else if ((*that == ')') || (*that == ']')) { parencount--; } } if (parencount == 0) { amount = get_indent(); break; } } if (amount == -1) { curwin->w_cursor.lnum = pos->lnum; curwin->w_cursor.col = pos->col; col = pos->col; that = ml_get_curline(); if (vi_lisp && (get_indent() == 0)) { amount = 2; } else {//.........这里部分代码省略.........
开发者ID:cschneid,项目名称:neovim,代码行数:101,
示例22: FUNC_ATTR_NONNULL_ARG/// @param[out] mnemonic If non-NULL, *mnemonic is set to the character after/// the first '&'./// @param[out] actext If non-NULL, *actext is set to the text after the first/// TAB, but only if a TAB was found. Memory pointed to is newly/// allocated.////// @return a pointer to allocated memory.static char_u *menu_text(const char_u *str, int *mnemonic, char_u **actext)FUNC_ATTR_NONNULL_RET FUNC_ATTR_MALLOC FUNC_ATTR_WARN_UNUSED_RESULTFUNC_ATTR_NONNULL_ARG(1){ char_u *p; char_u *text; /* Locate accelerator text, after the first TAB */ p = vim_strchr(str, TAB); if (p != NULL) { if (actext != NULL) *actext = vim_strsave(p + 1); assert(p >= str); text = vim_strnsave(str, (size_t)(p - str)); } else text = vim_strsave(str); /* Find mnemonic characters "&a" and reduce "&&" to "&". */ for (p = text; p != NULL; ) { p = vim_strchr(p, '&'); if (p != NULL) { if (p[1] == NUL) /* trailing "&" */ break; if (mnemonic != NULL && p[1] != '&')
开发者ID:WhitmanH,项目名称:neovim,代码行数:31,
示例23: pum_set_selected/* * Set the index of the currently selected item. The menu will scroll when * necessary. When "n" is out of range don't scroll. * This may be repeated when the preview window is used: * "repeat" == 0: open preview window normally * "repeat" == 1: open preview window but don't set the size * "repeat" == 2: don't open preview window * Returns TRUE when the window was resized and the location of the popup menu * must be recomputed. */ static intpum_set_selected(int n, int repeat){ int resized = FALSE; int context = pum_height / 2; pum_selected = n; if (pum_selected >= 0 && pum_selected < pum_size) { if (pum_first > pum_selected - 4) { /* scroll down; when we did a jump it's probably a PageUp then * scroll a whole page */ if (pum_first > pum_selected - 2) { pum_first -= pum_height - 2; if (pum_first < 0) pum_first = 0; else if (pum_first > pum_selected) pum_first = pum_selected; } else pum_first = pum_selected; } else if (pum_first < pum_selected - pum_height + 5) { /* scroll up; when we did a jump it's probably a PageDown then * scroll a whole page */ if (pum_first < pum_selected - pum_height + 1 + 2) { pum_first += pum_height - 2; if (pum_first < pum_selected - pum_height + 1) pum_first = pum_selected - pum_height + 1; } else pum_first = pum_selected - pum_height + 1; } /* Give a few lines of context when possible. */ if (context > 3) context = 3; if (pum_height > 2) { if (pum_first > pum_selected - context) { /* scroll down */ pum_first = pum_selected - context; if (pum_first < 0) pum_first = 0; } else if (pum_first < pum_selected + context - pum_height + 1) { /* scroll up */ pum_first = pum_selected + context - pum_height + 1; } }#if defined(FEAT_QUICKFIX) /* * Show extra info in the preview window if there is something and * 'completeopt' contains "preview". * Skip this when tried twice already. * Skip this also when there is not much room. * NOTE: Be very careful not to sync undo! */ if (pum_array[pum_selected].pum_info != NULL && Rows > 10 && repeat <= 1 && vim_strchr(p_cot, 'p') != NULL) { win_T *curwin_save = curwin; tabpage_T *curtab_save = curtab; int res = OK; /* Open a preview window. 3 lines by default. Prefer * 'previewheight' if set and smaller. */ g_do_tagpreview = 3; if (p_pvh > 0 && p_pvh < g_do_tagpreview) g_do_tagpreview = p_pvh; ++RedrawingDisabled; /* Prevent undo sync here, if an autocommand syncs undo weird * things can happen to the undo tree. */ ++no_u_sync; resized = prepare_tagpreview(FALSE); --no_u_sync; --RedrawingDisabled; g_do_tagpreview = 0; if (curwin->w_p_pvw)//.........这里部分代码省略.........
开发者ID:applidium,项目名称:Vim,代码行数:101,
注:本文中的vim_strchr函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ vim_strsave函数代码示例 C++ villageEffect函数代码示例 |