这篇教程C++ vim_strsize函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中vim_strsize函数的典型用法代码示例。如果您正苦于以下问题:C++ vim_strsize函数的具体用法?C++ vim_strsize怎么用?C++ vim_strsize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了vim_strsize函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: pum_compute_size static voidpum_compute_size(void){ int i; int w; /* Compute the width of the widest match and the widest extra. */ pum_base_width = 0; pum_kind_width = 0; pum_extra_width = 0; for (i = 0; i < pum_size; ++i) { w = vim_strsize(pum_array[i].pum_text); if (pum_base_width < w) pum_base_width = w; if (pum_array[i].pum_kind != NULL) { w = vim_strsize(pum_array[i].pum_kind) + 1; if (pum_kind_width < w) pum_kind_width = w; } if (pum_array[i].pum_extra != NULL) { w = vim_strsize(pum_array[i].pum_extra) + 1; if (pum_extra_width < w) pum_extra_width = w; } }}
开发者ID:applidium,项目名称:Vim,代码行数:29,
示例2: do_intro_linestatic void do_intro_line(long row, char_u *mesg, int attr){ long col; char_u *p; int l; int clen; // Center the message horizontally. col = vim_strsize(mesg); col = (Columns - col) / 2; if (col < 0) { col = 0; } // Split up in parts to highlight <> items differently. for (p = mesg; *p != NUL; p += l) { clen = 0; for (l = 0; p[l] != NUL && (l == 0 || (p[l] != '<' && p[l - 1] != '>')); ++l) { if (has_mbyte) { clen += ptr2cells(p + l); l += (*mb_ptr2len)(p + l) - 1; } else { clen += byte2cells(p[l]); } } assert(row <= INT_MAX && col <= INT_MAX); screen_puts_len(p, l, (int)row, (int)col, *p == '<' ? hl_attr(HLF_8) : attr); col += clen; }}
开发者ID:ENjOyAbLE1991,项目名称:neovim,代码行数:34,
示例3: while/* * Translate a string into allocated memory, replacing special chars with * printable chars. Returns NULL when out of memory. */char_u *transstr(char_u *s){ char_u *res; char_u *p; int l, len, c; char_u hexbuf[11]; if (has_mbyte) { /* Compute the length of the result, taking account of unprintable * multi-byte characters. */ len = 0; p = s; while (*p != NUL) { if ((l = (*mb_ptr2len)(p)) > 1) { c = (*mb_ptr2char)(p); p += l; if (vim_isprintc(c)) len += l; else { transchar_hex(hexbuf, c); len += (int)STRLEN(hexbuf); } } else { l = byte2cells(*p++); if (l > 0) len += l; else len += 4; /* illegal byte sequence */ } } res = alloc((unsigned)(len + 1)); } else res = alloc((unsigned)(vim_strsize(s) + 1)); if (res != NULL) { *res = NUL; p = s; while (*p != NUL) { if (has_mbyte && (l = (*mb_ptr2len)(p)) > 1) { c = (*mb_ptr2char)(p); if (vim_isprintc(c)) STRNCAT(res, p, l); /* append printable multi-byte char */ else transchar_hex(res + STRLEN(res), c); p += l; } else STRCAT(res, transchar_byte(*p++)); } } return res;}
开发者ID:Gaelan,项目名称:neovim,代码行数:54,
示例4: version_msg_wrap/* * Output a string for the version message. If it's going to wrap, output a * newline, unless the message is too long to fit on the screen anyway. * When "wrap" is TRUE wrap the string in []. */ static voidversion_msg_wrap(char_u *s, int wrap){ int len = (int)vim_strsize(s) + (wrap ? 2 : 0); if (!got_int && len < (int)Columns && msg_col + len >= (int)Columns && *s != '/n') msg_putchar('/n'); if (!got_int) { if (wrap) MSG_PUTS("["); MSG_PUTS(s); if (wrap) MSG_PUTS("]"); }}
开发者ID:mischief,项目名称:vim,代码行数:22,
示例5: 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,
示例6: pum_redraw/* * Redraw the popup menu, using "pum_first" and "pum_selected". */ voidpum_redraw(void){ int row = pum_row; int col; int attr_norm = highlight_attr[HLF_PNI]; int attr_select = highlight_attr[HLF_PSI]; int attr_scroll = highlight_attr[HLF_PSB]; int attr_thumb = highlight_attr[HLF_PST]; int attr; int i; int idx; char_u *s; char_u *p = NULL; int totwidth, width, w; int thumb_pos = 0; int thumb_heigth = 1; int round; int n; /* Never display more than we have */ if (pum_first > pum_size - pum_height) pum_first = pum_size - pum_height; if (pum_scrollbar) { thumb_heigth = pum_height * pum_height / pum_size; if (thumb_heigth == 0) thumb_heigth = 1; thumb_pos = (pum_first * (pum_height - thumb_heigth) + (pum_size - pum_height) / 2) / (pum_size - pum_height); } for (i = 0; i < pum_height; ++i) { idx = i + pum_first; attr = (idx == pum_selected) ? attr_select : attr_norm; /* prepend a space if there is room */#ifdef FEAT_RIGHTLEFT if (curwin->w_p_rl) { if (pum_col < curwin->w_wincol + curwin->w_width - 1) screen_putchar(' ', row, pum_col + 1, attr); } else#endif if (pum_col > 0) screen_putchar(' ', row, pum_col - 1, attr); /* Display each entry, use two spaces for a Tab. * Do this 3 times: For the main text, kind and extra info */ col = pum_col; totwidth = 0; for (round = 1; round <= 3; ++round) { width = 0; s = NULL; switch (round) { case 1: p = pum_array[idx].pum_text; break; case 2: p = pum_array[idx].pum_kind; break; case 3: p = pum_array[idx].pum_extra; break; } if (p != NULL) for ( ; ; MB_PTR_ADV(p)) { if (s == NULL) s = p; w = ptr2cells(p); if (*p == NUL || *p == TAB || totwidth + w > pum_width) { /* Display the text that fits or comes before a Tab. * First convert it to printable characters. */ char_u *st; int saved = *p; if (saved != NUL) *p = NUL; st = transstr(s); if (saved != NUL) *p = saved;#ifdef FEAT_RIGHTLEFT if (curwin->w_p_rl) { if (st != NULL) { char_u *rt = reverse_text(st); if (rt != NULL) { char_u *rt_start = rt; int size; size = vim_strsize(rt); if (size > pum_width)//.........这里部分代码省略.........
开发者ID:applidium,项目名称:Vim,代码行数:101,
示例7: do_intro_linestatic void do_intro_line(int row, char_u *mesg, int add_version, int attr){ char_u vers[20]; int col; char_u *p; int l; int clen;#ifdef MODIFIED_BY# define MODBY_LEN 150 char_u modby[MODBY_LEN]; if (*mesg == ' ') { vim_strncpy(modby, (char_u *)_("Modified by "), MODBY_LEN - 1); l = STRLEN(modby); vim_strncpy(modby + l, (char_u *)MODIFIED_BY, MODBY_LEN - l - 1); mesg = modby; }#endif // ifdef MODIFIED_BY // Center the message horizontally. col = vim_strsize(mesg); if (add_version) { STRCPY(vers, mediumVersion); if (highest_patch()) { // Check for 9.9x or 9.9xx, alpha/beta version if (isalpha((int)vers[3])) { int len = (isalpha((int)vers[4])) ? 5 : 4; sprintf((char *)vers + len, ".%d%s", highest_patch(), mediumVersion + len); } else { sprintf((char *)vers + 3, ".%d", highest_patch()); } } col += (int)STRLEN(vers); } col = (Columns - col) / 2; if (col < 0) { col = 0; } // Split up in parts to highlight <> items differently. for (p = mesg; *p != NUL; p += l) { clen = 0; for (l = 0; p[l] != NUL && (l == 0 || (p[l] != '<' && p[l - 1] != '>')); ++l) { if (has_mbyte) { clen += ptr2cells(p + l); l += (*mb_ptr2len)(p + l) - 1; } else { clen += byte2cells(p[l]); } } screen_puts_len(p, l, row, col, *p == '<' ? hl_attr(HLF_8) : attr); col += clen; } // Add the version number to the version line. if (add_version) { screen_puts(vers, row, col, 0); }}
开发者ID:MarcWeber,项目名称:neovim,代码行数:66,
示例8: pum_display//.........这里部分代码省略......... context_lines = 3; } else { context_lines = curwin->w_cline_row + curwin->w_cline_height - curwin->w_wrow; } pum_row = row + context_lines; if (size > above_row - pum_row) { pum_height = above_row - pum_row; } else { pum_height = size; } if ((p_ph > 0) && (pum_height > p_ph)) { pum_height = (int)p_ph; } } // don't display when we only have room for one line if ((pum_height < 1) || ((pum_height == 1) && (size > 1))) { return; } // If there is a preview window at the top avoid drawing over it. if (firstwin->w_p_pvw && (pum_row < firstwin->w_height) && (pum_height > firstwin->w_height + 4)) { pum_row += firstwin->w_height; pum_height -= firstwin->w_height; } // Compute the width of the widest match and the widest extra. for (i = 0; i < size; ++i) { w = vim_strsize(array[i].pum_text); if (max_width < w) { max_width = w; } if (array[i].pum_kind != NULL) { w = vim_strsize(array[i].pum_kind) + 1; if (kind_width < w) { kind_width = w; } } if (array[i].pum_extra != NULL) { w = vim_strsize(array[i].pum_extra) + 1; if (extra_width < w) { extra_width = w; } } } pum_base_width = max_width; pum_kind_width = kind_width; // if there are more items than room we need a scrollbar if (pum_height < size) { pum_scrollbar = 1; max_width++; } else { pum_scrollbar = 0; }
开发者ID:kranki,项目名称:neovim,代码行数:66,
示例9: while/// Translate a string into allocated memory, replacing special chars with/// printable chars. Returns NULL when out of memory.////// @param s////// @return translated stringchar_u *transstr(char_u *s){ char_u *res; char_u *p; int l, c; char_u hexbuf[11]; if (has_mbyte) { // Compute the length of the result, taking account of unprintable // multi-byte characters. size_t len = 0; p = s; while (*p != NUL) { if ((l = (*mb_ptr2len)(p)) > 1) { c = (*mb_ptr2char)(p); p += l; if (vim_isprintc(c)) { len += l; } else { transchar_hex(hexbuf, c); len += STRLEN(hexbuf); } } else { l = byte2cells(*p++); if (l > 0) { len += l; } else { // illegal byte sequence len += 4; } } } res = xmallocz(len); } else { res = xmallocz(vim_strsize(s)); } *res = NUL; p = s; while (*p != NUL) { if (has_mbyte && ((l = (*mb_ptr2len)(p)) > 1)) { c = (*mb_ptr2char)(p); if (vim_isprintc(c)) { // append printable multi-byte char STRNCAT(res, p, l); } else { transchar_hex(res + STRLEN(res), c); } p += l; } else { STRCAT(res, transchar_byte(*p++)); } } return res;}
开发者ID:Saneyan,项目名称:neovim,代码行数:67,
示例10: pum_display//.........这里部分代码省略......... } else { /* pum below "row" */ /* Leave two lines of context if possible */ if (curwin->w_cline_row + curwin->w_cline_height - curwin->w_wrow >= 3) context_lines = 3; else context_lines = curwin->w_cline_row + curwin->w_cline_height - curwin->w_wrow; pum_row = row + context_lines; if (size > above_row - pum_row) pum_height = above_row - pum_row; else pum_height = size; if (p_ph > 0 && pum_height > p_ph) pum_height = p_ph; } /* don't display when we only have room for one line */ if (pum_height < 1 || (pum_height == 1 && size > 1)) return; /* If there is a preview window at the top avoid drawing over it. */ if (firstwin->w_p_pvw && pum_row < firstwin->w_height && pum_height > firstwin->w_height + 4) { pum_row += firstwin->w_height; pum_height -= firstwin->w_height; } /* Compute the width of the widest match and the widest extra. */ for (i = 0; i < size; ++i) { w = vim_strsize(array[i].pum_text); if (max_width < w) max_width = w; if (array[i].pum_kind != NULL) { w = vim_strsize(array[i].pum_kind) + 1; if (kind_width < w) kind_width = w; } if (array[i].pum_extra != NULL) { w = vim_strsize(array[i].pum_extra) + 1; if (extra_width < w) extra_width = w; } } pum_base_width = max_width; pum_kind_width = kind_width; /* Calculate column */ if (curwin->w_p_rl) col = W_WINCOL(curwin) + W_WIDTH(curwin) - curwin->w_wcol - 1; else col = W_WINCOL(curwin) + curwin->w_wcol; /* if there are more items than room we need a scrollbar */ if (pum_height < size) { pum_scrollbar = 1; ++max_width; } else pum_scrollbar = 0; if (def_width < max_width) def_width = max_width;
开发者ID:pthrasher,项目名称:neovim,代码行数:66,
示例11: list_in_columns/* * List string items nicely aligned in columns. * When "size" is < 0 then the last entry is marked with NULL. * The entry with index "current" is inclosed in []. */ voidlist_in_columns(char_u **items, int size, int current){ int i; int ncol; int nrow; int item_count = 0; int width = 0; /* Find the length of the longest item, use that + 1 as the column * width. */ for (i = 0; size < 0 ? items[i] != NULL : i < size; ++i) { int l = (int)vim_strsize(items[i]) + (i == current ? 2 : 0); if (l > width) width = l; ++item_count; } width += 1; if (Columns < width) { /* Not enough screen columns - show one per line */ for (i = 0; i < item_count; ++i) { version_msg_wrap(items[i], i == current); if (msg_col > 0) msg_putchar('/n'); } return; } /* The rightmost column doesn't need a separator. * Sacrifice it to fit in one more column if possible. */ ncol = (int) (Columns + 1) / width; nrow = item_count / ncol + (item_count % ncol ? 1 : 0); /* i counts columns then rows. idx counts rows then columns. */ for (i = 0; !got_int && i < nrow * ncol; ++i) { int idx = (i / ncol) + (i % ncol) * nrow; if (idx < item_count) { int last_col = (i + 1) % ncol == 0; if (idx == current) msg_putchar('['); msg_puts(items[idx]); if (idx == current) msg_putchar(']'); if (last_col) { if (msg_col > 0) msg_putchar('/n'); } else { while (msg_col % width) msg_putchar(' '); } } else { if (msg_col > 0) msg_putchar('/n'); } }}
开发者ID:mischief,项目名称:vim,代码行数:75,
注:本文中的vim_strsize函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ vinit函数代码示例 C++ vim_strsave函数代码示例 |