static 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; } }
/* * print the changelist */ void ex_changes(exarg_T *eap) { int i; char_u *name; /* Highlight title */ MSG_PUTS_TITLE(_("\nchange line col text")); for (i = 0; i < curbuf->b_changelistlen && !got_int; ++i) { if (curbuf->b_changelist[i].lnum != 0) { msg_putchar('\n'); if (got_int) break; sprintf((char *)IObuff, "%c %3d %5ld %4d ", i == curwin->w_changelistidx ? '>' : ' ', i > curwin->w_changelistidx ? i - curwin->w_changelistidx : curwin->w_changelistidx - i, (long)curbuf->b_changelist[i].lnum, curbuf->b_changelist[i].col); msg_outtrans(IObuff); name = mark_line(&curbuf->b_changelist[i], 17); if (name == NULL) break; msg_outtrans_attr(name, hl_attr(HLF_D)); vim_free(name); ui_breakcheck(); } out_flush(); } if (curwin->w_changelistidx == curbuf->b_changelistlen) MSG_PUTS("\n>"); }
/* * Convert the Farsi VIM into Farsi 3342 standard. */ void conv_to_pstd(void) { char_u *ptr; int lnum, llen, i; /* * Following line contains Farsi encoded character. */ do_cmdline_cmd((char_u *)"%s/\232/\202\231/g"); for (lnum = 1; lnum <= curbuf->b_ml.ml_line_count; ++lnum) { ptr = ml_get((linenr_T)lnum); llen = (int)STRLEN(ptr); for ( i = 0; i < llen; i++) { ptr[i] = toF_TyA(ptr[i]); } } /* Assume the screen has been messed up: clear it and redraw. */ redraw_later(CLEAR); MSG_ATTR(farsi_text_2, hl_attr(HLF_S)); }
static void show_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) vim_free(name); } } out_flush(); /* show one line at a time */ } }
/// Convert the Farsi VIM into Farsi 3342 standard. static void conv_to_pstd(void) { char_u *ptr; int lnum, llen, i; // Following line contains Farsi encoded character. do_cmdline_cmd("%s/\232/\202\231/ge"); for (lnum = 1; lnum <= curbuf->b_ml.ml_line_count; lnum++) { ptr = ml_get((linenr_T)lnum); llen = (int)STRLEN(ptr); for (i = 0; i < llen; i++) { ptr[i] = toF_TyA(ptr[i]); } } // Assume the screen has been messed up: clear it and redraw. redraw_later(CLEAR); msg_attr((const char *)farsi_text_2, hl_attr(HLF_S)); }
/* * print the jumplist */ void ex_jumps(exarg_T *eap) { int i; char_u *name; cleanup_jumplist(); /* Highlight title */ MSG_PUTS_TITLE(_("\n jump line col file/text")); for (i = 0; i < curwin->w_jumplistlen && !got_int; ++i) { if (curwin->w_jumplist[i].fmark.mark.lnum != 0) { if (curwin->w_jumplist[i].fmark.fnum == 0) fname2fnum(&curwin->w_jumplist[i]); name = fm_getname(&curwin->w_jumplist[i].fmark, 16); if (name == NULL) /* file name not available */ continue; msg_putchar('\n'); if (got_int) { vim_free(name); break; } sprintf((char *)IObuff, "%c %2d %5ld %4d ", i == curwin->w_jumplistidx ? '>' : ' ', i > curwin->w_jumplistidx ? i - curwin->w_jumplistidx : curwin->w_jumplistidx - i, curwin->w_jumplist[i].fmark.mark.lnum, curwin->w_jumplist[i].fmark.mark.col); msg_outtrans(IObuff); msg_outtrans_attr(name, curwin->w_jumplist[i].fmark.fnum == curbuf->b_fnum ? hl_attr(HLF_D) : 0); vim_free(name); ui_breakcheck(); } out_flush(); } if (curwin->w_jumplistidx == curwin->w_jumplistlen) MSG_PUTS("\n>"); }
/// Convert the Farsi 3342 standard into Farsi VIM. void conv_to_pvim(void) { char_u *ptr; int lnum, llen, i; for (lnum = 1; lnum <= curbuf->b_ml.ml_line_count; ++lnum) { ptr = ml_get((linenr_T)lnum); llen = (int)STRLEN(ptr); for (i = 0; i < llen - 1; i++) { if (canF_Ljoin(ptr[i]) && canF_Rjoin(ptr[i + 1])) { ptr[i] = toF_leading(ptr[i]); i++; while (canF_Rjoin(ptr[i]) && i < llen) { ptr[i] = toF_Rjoin(ptr[i]); if (F_isterm(ptr[i]) || !F_isalpha(ptr[i])) { break; } i++; } if (!F_isalpha(ptr[i]) || !canF_Rjoin(ptr[i])) { ptr[i - 1] = toF_ending(ptr[i - 1]); } } else { ptr[i] = toF_TyA(ptr[i]); } } } // Following lines contains Farsi encoded character. do_cmdline_cmd((char_u *)"%s/\202\231/\232/g"); do_cmdline_cmd((char_u *)"%s/\201\231/\370\334/g"); // Assume the screen has been messed up: clear it and redraw. redraw_later(CLEAR); MSG_ATTR(farsi_text_1, hl_attr(HLF_S)); }
static 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); } }
/* * Give an introductory message about Vim. * Only used when starting Vim on an empty file, without a file name. * Or with the ":intro" command (for Sven :-). */ void intro_message( int colon) /* TRUE for ":intro" */ { int i; int row; int blanklines; int sponsor; char *p; static char *(lines[]) = { N_("VIM - Vi IMproved"), "", N_("version "), N_("by Bram Moolenaar et al."), #ifdef MODIFIED_BY " ", #endif N_("Vim is open source and freely distributable"), "", N_("Help poor children in Uganda!"), N_("type :help iccf<Enter> for information "), "", N_("type :q<Enter> to exit "), N_("type :help<Enter> or <F1> for on-line help"), #ifdef FEAT_GUI_MACVIM // TODO: Don't steal the show from version7 help? N_("type :help macvim<Enter> for MacVim help "), #else N_("type :help version7<Enter> for version info"), #endif NULL, "", N_("Running in Vi compatible mode"), N_("type :set nocp<Enter> for Vim defaults"), N_("type :help cp-default<Enter> for info on this"), }; #ifdef FEAT_GUI static char *(gui_lines[]) = { NULL, NULL, NULL, NULL, #ifdef MODIFIED_BY NULL, #endif NULL, NULL, NULL, N_("menu Help->Orphans for information "), NULL, N_("Running modeless, typed text is inserted"), N_("menu Edit->Global Settings->Toggle Insert Mode "), N_(" for two modes "), NULL, NULL, NULL, N_("menu Edit->Global Settings->Toggle Vi Compatible"), N_(" for Vim defaults "), }; #endif /* blanklines = screen height - # message lines */ blanklines = (int)Rows - ((sizeof(lines) / sizeof(char *)) - 1); if (!p_cp) blanklines += 4; /* add 4 for not showing "Vi compatible" message */ #if defined(WIN3264) && !defined(FEAT_GUI_W32) if (mch_windows95()) blanklines -= 3; /* subtract 3 for showing "Windows 95" message */ #endif #ifdef FEAT_WINDOWS /* Don't overwrite a statusline. Depends on 'cmdheight'. */ if (p_ls > 1) blanklines -= Rows - topframe->fr_height; #endif if (blanklines < 0) blanklines = 0; /* Show the sponsor and register message one out of four times, the Uganda * message two out of four times. */ sponsor = (int)time(NULL); sponsor = ((sponsor & 2) == 0) - ((sponsor & 4) == 0); /* start displaying the message lines after half of the blank lines */ row = blanklines / 2; if ((row >= 2 && Columns >= 50) || colon) { for (i = 0; i < (int)(sizeof(lines) / sizeof(char *)); ++i) { p = lines[i]; #ifdef FEAT_GUI if (p_im && gui.in_use && gui_lines[i] != NULL) p = gui_lines[i]; #endif if (p == NULL) { if (!p_cp) break; continue; } if (sponsor != 0) { if (strstr(p, "children") != NULL) p = sponsor < 0 ? N_("Sponsor Vim development!") : N_("Become a registered Vim user!"); else if (strstr(p, "iccf") != NULL) p = sponsor < 0 ? N_("type :help sponsor<Enter> for information ") : N_("type :help register<Enter> for information "); else if (strstr(p, "Orphans") != NULL) p = N_("menu Help->Sponsor/Register for information "); } if (*p != NUL) do_intro_line(row, (char_u *)_(p), i == 2, 0); ++row; } #if defined(WIN3264) && !defined(FEAT_GUI_W32) if (mch_windows95()) { do_intro_line(++row, (char_u *)_("WARNING: Windows 95/98/ME detected"), FALSE, hl_attr(HLF_E)); do_intro_line(++row, (char_u *)_("type :help windows95<Enter> for info on this"), FALSE, 0); } #endif } /* Make the wait-return message appear just below the text. */ if (colon) msg_row = row; }
/* * Recursively show the mappings associated with the menus under the given one */ static void show_menus_recursive(vimmenu_T *menu, int modes, int depth) { int i; int bit; if (menu != NULL && (menu->modes & modes) == 0x0) return; if (menu != NULL) { msg_putchar('\n'); if (got_int) /* "q" hit for "--more--" */ return; for (i = 0; i < depth; i++) MSG_PUTS(" "); if (menu->priority) { msg_outnum((long)menu->priority); MSG_PUTS(" "); } /* Same highlighting as for directories!? */ msg_outtrans_attr(menu->name, hl_attr(HLF_D)); } if (menu != NULL && menu->children == NULL) { for (bit = 0; bit < MENU_MODES; bit++) if ((menu->modes & modes & (1 << bit)) != 0) { msg_putchar('\n'); if (got_int) /* "q" hit for "--more--" */ return; for (i = 0; i < depth + 2; i++) MSG_PUTS(" "); msg_putchar(menu_mode_chars[bit]); if (menu->noremap[bit] == REMAP_NONE) msg_putchar('*'); else if (menu->noremap[bit] == REMAP_SCRIPT) msg_putchar('&'); else msg_putchar(' '); if (menu->silent[bit]) msg_putchar('s'); else msg_putchar(' '); if ((menu->modes & menu->enabled & (1 << bit)) == 0) msg_putchar('-'); else msg_putchar(' '); MSG_PUTS(" "); if (*menu->strings[bit] == NUL) msg_puts_attr((char_u *)"<Nop>", hl_attr(HLF_8)); else msg_outtrans_special(menu->strings[bit], FALSE); } } else { if (menu == NULL) { menu = root_menu; depth--; } else menu = menu->children; /* recursively show all children. Skip PopUp[nvoci]. */ for (; menu != NULL && !got_int; menu = menu->next) if (!menu_is_hidden(menu->dname)) show_menus_recursive(menu, modes, depth + 1); } }