updated for version 7.0022

This commit is contained in:
Bram Moolenaar
2004-12-12 11:33:30 +00:00
parent 293ee4d421
commit d8b0cf1cc5
20 changed files with 347 additions and 120 deletions

View File

@ -1,4 +1,4 @@
*eval.txt* For Vim version 7.0aa. Last change: 2004 Oct 24 *eval.txt* For Vim version 7.0aa. Last change: 2004 Dec 10
VIM REFERENCE MANUAL by Bram Moolenaar VIM REFERENCE MANUAL by Bram Moolenaar
@ -856,6 +856,7 @@ getcmdpos() Number return cursor position in command-line
getcwd() String the current working directory getcwd() String the current working directory
getfperm( {fname}) String file permissions of file {fname} getfperm( {fname}) String file permissions of file {fname}
getfsize( {fname}) Number size in bytes of file {fname} getfsize( {fname}) Number size in bytes of file {fname}
getfontname( [{name}]) String name of font being used
getftime( {fname}) Number last modification time of file getftime( {fname}) Number last modification time of file
getftype( {fname}) String description of type of file {fname} getftype( {fname}) String description of type of file {fname}
getline( {lnum}) String line {lnum} from current buffer getline( {lnum}) String line {lnum} from current buffer
@ -1633,6 +1634,20 @@ getfsize({fname}) *getfsize()*
If {fname} is a directory, 0 is returned. If {fname} is a directory, 0 is returned.
If the file {fname} can't be found, -1 is returned. If the file {fname} can't be found, -1 is returned.
getfontname([{name}]) *getfontname()*
Without an argument returns the name of the normal font being
used. Like what is used for the Normal highlight group
|hl-Normal|.
With an argument a check is done whether {name} is a valid
font name. If not then an empty string is returned.
Otherwise the actual font name is returned, or {name} if the
GUI does not support obtaining the real name.
Only works when the GUI is running, thus not you your vimrc or
Note that the GTK 2 GUI accepts any font name, thus checking
for a valid name does not work.
gvimrc file. Use the |GUIEnter| autocommand to use this
function just after the GUI has started.
getfperm({fname}) *getfperm()* getfperm({fname}) *getfperm()*
The result is a String, which is the read, write, and execute The result is a String, which is the read, write, and execute
permissions of the given file {fname}. permissions of the given file {fname}.

View File

@ -4803,6 +4803,7 @@ getcharmod() eval.txt /*getcharmod()*
getcmdline() eval.txt /*getcmdline()* getcmdline() eval.txt /*getcmdline()*
getcmdpos() eval.txt /*getcmdpos()* getcmdpos() eval.txt /*getcmdpos()*
getcwd() eval.txt /*getcwd()* getcwd() eval.txt /*getcwd()*
getfontname() eval.txt /*getfontname()*
getfperm() eval.txt /*getfperm()* getfperm() eval.txt /*getfperm()*
getfsize() eval.txt /*getfsize()* getfsize() eval.txt /*getfsize()*
getftime() eval.txt /*getftime()* getftime() eval.txt /*getftime()*
@ -4932,6 +4933,7 @@ hebrew hebrew.txt /*hebrew*
hebrew.txt hebrew.txt /*hebrew.txt* hebrew.txt hebrew.txt /*hebrew.txt*
help various.txt /*help* help various.txt /*help*
help-context help.txt /*help-context* help-context help.txt /*help-context*
help-tags tags 1
help-translated various.txt /*help-translated* help-translated various.txt /*help-translated*
help-xterm-window various.txt /*help-xterm-window* help-xterm-window various.txt /*help-xterm-window*
help.txt help.txt /*help.txt* help.txt help.txt /*help.txt*

View File

@ -3958,6 +3958,16 @@ expand_filename(eap, cmdlinep, errormsgp)
continue; continue;
} }
/* Wildcards won't be expanded below, the replacement is taken
* literally. But do expand "~/file", "~user/file" and "$HOME/file". */
if (vim_strchr(repl, '$') != NULL || vim_strchr(repl, '~') != NULL)
{
char_u *l = repl;
repl = expand_env_save(repl);
vim_free(l);
}
/* Need to escape white space et al. with a backslash. Don't do this /* Need to escape white space et al. with a backslash. Don't do this
* for shell commands (may have to use quotes instead). Don't do this * for shell commands (may have to use quotes instead). Don't do this
* for non-unix systems when there is a single argument (spaces don't * for non-unix systems when there is a single argument (spaces don't

View File

@ -546,6 +546,10 @@ gui_init()
if (!im_xim_isvalid_imactivate()) if (!im_xim_isvalid_imactivate())
EMSG(_("E599: Value of 'imactivatekey' is invalid")); EMSG(_("E599: Value of 'imactivatekey' is invalid"));
#endif #endif
/* When 'cmdheight' was set during startup it may not have taken
* effect yet. */
if (p_ch != 1L)
command_height(1L);
return; return;
} }
@ -741,6 +745,7 @@ set_guifontwide(name)
font = gui_mch_get_font(wide_name, FALSE); font = gui_mch_get_font(wide_name, FALSE);
if (font != NOFONT) if (font != NOFONT)
{ {
gui_mch_free_font(gui.wide_font);
gui.wide_font = font; gui.wide_font = font;
set_string_option_direct((char_u *)"gfw", -1, set_string_option_direct((char_u *)"gfw", -1,
wide_name, OPT_FREE); wide_name, OPT_FREE);

View File

@ -1209,6 +1209,11 @@ gui_mch_destroy_scrollbar(scrollbar_T *sb)
} }
#endif #endif
char_u *gui_mch_getfontname(GuiFont font)
{
return vim_strsave((char_u *)"default");
}
int gui_mch_init_font(char_u *font_name, int fontset) int gui_mch_init_font(char_u *font_name, int fontset)
{ {
/*D("gui_mch_init_font");*/ /*D("gui_mch_init_font");*/
@ -1227,12 +1232,22 @@ gui_mch_adjust_charsize()
} }
GuiFont GuiFont
gui_mch_get_font( char_u *name, int giveErrorIfMissing) gui_mch_get_font(char_u *name, int giveErrorIfMissing)
{ {
/*D("gui_mch_get_font");*/ /*D("gui_mch_get_font");*/
return NULL; return NULL;
} }
/*
* Return the name of font "font" in allocated memory.
* We always use the default font.
*/
char_u *
gui_mch_get_fontname(GuiFont font, char_u *name)
{
return vim_strsave((char_u *)"default");
}
void void
gui_mch_set_font(GuiFont font) gui_mch_set_font(GuiFont font)
{ {

View File

@ -2396,6 +2396,15 @@ error:
return (GuiFont)font; return (GuiFont)font;
} }
/*
* Return the name of font "font" in allocated memory.
*/
char_u *
gui_mch_get_fontname(GuiFont font, char_u *name)
{
return vim_strsave(((VimFont *)font)->name);
}
/* /*
* Set the current text font. * Set the current text font.
*/ */

View File

@ -384,7 +384,7 @@ gui_mch_open()//{{{
vmw->menuBar()->insertItem("&KVim", vmw->w->menu); vmw->menuBar()->insertItem("&KVim", vmw->w->menu);
#endif #endif
if (startfont!=NULL) if (startfont!=NULL)
gui_mch_init_font((char_u*)startfont->latin1(),0); gui_mch_init_font((char_u*)startfont->latin1(), FALSE);
if (startsize!=NULL) if (startsize!=NULL)
vmw->resize(startsize->width(), startsize->height()); vmw->resize(startsize->width(), startsize->height());
@ -558,9 +558,9 @@ char_u *gui_mch_font_dialog (char_u *oldval)//{{{
gui_mch_init_font(char_u * font_name, int fontset)//{{{ gui_mch_init_font(char_u * font_name, int fontset)//{{{
{ {
QString fontname; QString fontname;
GuiFont font=NULL; GuiFont font = NULL;
if (font_name==NULL) if (font_name == NULL)
{ {
#if 0 #if 0
#if QT_VERSION>=300 #if QT_VERSION>=300
@ -589,31 +589,30 @@ gui_mch_init_font(char_u * font_name, int fontset)//{{{
font = new QFont(); font = new QFont();
font->fromString( fontname ); font->fromString( fontname );
*/ */
#ifdef FEAT_XFONTSET
if (fontset)
font = gui_mch_get_fontset(font_name, TRUE, TRUE);
if (font == NULL)
#endif
font = gui_mch_get_font(font_name, FALSE);
if (font == NULL)
return FAIL;
if (fontname.contains('*') && fontname.contains('-'))
return FAIL;
gui_mch_free_font(gui.norm_font); gui_mch_free_font(gui.norm_font);
#ifdef FEAT_XFONTSET #ifdef FEAT_XFONTSET
gui_mch_free_fontset(gui.fontset); gui_mch_free_fontset(gui.fontset);
gui.fontset = NOFONTSET;
if (fontset) if (fontset)
font = gui_mch_get_fontset(font_name,TRUE,TRUE); {
gui.fontset = font;
gui.norm_font = NOFONT;
}
else
#endif #endif
if (font == NULL) {
font = gui_mch_get_font(font_name,FALSE);
gui.norm_font = font; gui.norm_font = font;
#ifdef FEAT_XFONTSET
gui.fontset=NOFONTSET;
#endif
}
#ifdef FEAT_XFONTSET
else {
gui.fontset=font;
gui.norm_font=NOFONT;
}
#endif
if (font == NULL)
return FAIL;
if (fontname.contains('*') && fontname.contains('-'))
return FAIL;
/* Compute the width of the character cell. Some fonts include /* Compute the width of the character cell. Some fonts include
* double-width characters. Use the width of ASCII characters to find * double-width characters. Use the width of ASCII characters to find
@ -660,6 +659,20 @@ gui_mch_get_font(char_u * name, int report_error)//{{{
return (GuiFont) myFont; return (GuiFont) myFont;
}//}}} }//}}}
/*
* Return the name of font "font" in allocated memory.
* Don't know how to get the actual name, thus use the provided name.
*/
char_u *
gui_mch_get_fontname(font, name)
GuiFont font;
char_u *name;
{
if (name == NULL)
return NULL;
return vim_strsave(name);
}
/* /*
* Set the current text font. * Set the current text font.
* Since we create all GC on demand, we use just gui.current_font to * Since we create all GC on demand, we use just gui.current_font to

View File

@ -548,7 +548,7 @@ char_u **new_fnames_from_AEDesc(AEDesc *theList, long *numFiles, OSErr *error)
/* Caller is able to clean up */ /* Caller is able to clean up */
/* TODO: Should be clean up or not? For safety. */ /* TODO: Should be clean up or not? For safety. */
#ifdef USE_SIOUX #ifdef USE_SIOUX
printf("aevt_odoc: AEGetNthPtr error: %d\n", newError); printf("aevt_odoc: AEGetNthPtr error: %ld\n", (long)newError);
#endif #endif
return(fnames); return(fnames);
} }
@ -1130,7 +1130,7 @@ HandleODocAE(const AppleEvent *theAEvent, AppleEvent *theReply, long refCon)
if (error) if (error)
{ {
#ifdef USE_SIOUX #ifdef USE_SIOUX
printf("aevt_odoc: AEGetParamDesc error: %d\n", error); printf("aevt_odoc: AEGetParamDesc error: %ld\n", (long)error);
#endif #endif
return(error); return(error);
} }
@ -1144,15 +1144,16 @@ HandleODocAE(const AppleEvent *theAEvent, AppleEvent *theReply, long refCon)
if (error) if (error)
{ {
#ifdef USE_SIOUX #ifdef USE_SIOUX
printf("aevt_odoc: AEGetParamPtr error: %d\n", error); printf("aevt_odoc: AEGetParamPtr error: %ld\n", (long)error);
#endif #endif
return(error); return(error);
} }
#ifdef USE_SIOUX #ifdef USE_SIOUX
printf("aevt_odoc: lineNum: %d, startRange %d, endRange %d, [date %lx]\n", printf("aevt_odoc: lineNum: %d, startRange %ld, endRange %ld, [date %lx]\n",
thePosition.lineNum, thePosition.startRange, thePosition.endRange, (int)thePosition.lineNum,
thePosition.theDate); (long)thePosition.startRange, (long)thePosition.endRange,
(long)thePosition.theDate);
#endif #endif
/* /*
error = AEGetParamDesc(theAEvent, keyAEPosition, typeChar, &thePosition); error = AEGetParamDesc(theAEvent, keyAEPosition, typeChar, &thePosition);
@ -1209,7 +1210,7 @@ HandleODocAE(const AppleEvent *theAEvent, AppleEvent *theReply, long refCon)
{ {
if (thePosition.lineNum >= 0) if (thePosition.lineNum >= 0)
{ {
lnum = thePosition.lineNum; lnum = thePosition.lineNum + 1;
/* oap->motion_type = MLINE; /* oap->motion_type = MLINE;
setpcmark();*/ setpcmark();*/
if (lnum < 1L) if (lnum < 1L)
@ -1217,6 +1218,7 @@ HandleODocAE(const AppleEvent *theAEvent, AppleEvent *theReply, long refCon)
else if (lnum > curbuf->b_ml.ml_line_count) else if (lnum > curbuf->b_ml.ml_line_count)
lnum = curbuf->b_ml.ml_line_count; lnum = curbuf->b_ml.ml_line_count;
curwin->w_cursor.lnum = lnum; curwin->w_cursor.lnum = lnum;
curwin->w_cursor.col = 0;
/* beginline(BL_SOL | BL_FIX);*/ /* beginline(BL_SOL | BL_FIX);*/
} }
else else
@ -1225,9 +1227,32 @@ HandleODocAE(const AppleEvent *theAEvent, AppleEvent *theReply, long refCon)
/* Update the screen display */ /* Update the screen display */
update_screen(NOT_VALID); update_screen(NOT_VALID);
#ifdef FEAT_VISUAL
/* Select the text if possible */
if (gotPosition)
{
VIsual_active = TRUE;
VIsual_select = FALSE;
if (thePosition.lineNum < 0)
{
VIsual_mode = 'v';
VIsual = curwin->w_cursor;
goto_byte(thePosition.endRange);
}
else
{
VIsual_mode = 'V';
VIsual = curwin->w_cursor;
VIsual.col = 0;
}
}
#endif
setcursor(); setcursor();
out_flush(); out_flush();
/* Fake mouse event to wake from stall */
PostEvent(mouseUp, 0);
finished: finished:
AEDisposeDesc(&theList); /* dispose what we allocated */ AEDisposeDesc(&theList); /* dispose what we allocated */
@ -1235,7 +1260,7 @@ HandleODocAE(const AppleEvent *theAEvent, AppleEvent *theReply, long refCon)
if (error) if (error)
{ {
#ifdef USE_SIOUX #ifdef USE_SIOUX
printf("aevt_odoc: HandleUnusedParms error: %d\n", error); printf("aevt_odoc: HandleUnusedParms error: %ld\n", (long)error);
#endif #endif
return(error); return(error);
} }
@ -2513,6 +2538,8 @@ gui_mac_mouse_wheel(EventHandlerCallRef nextHandler, EventRef theEvent,
kEventPriorityLow)) kEventPriorityLow))
goto bail; goto bail;
ReleaseEvent(bogusEvent);
if (noErr == GetWindowBounds(gui.VimWindow, kWindowContentRgn, &bounds)) if (noErr == GetWindowBounds(gui.VimWindow, kWindowContentRgn, &bounds))
{ {
point.h -= bounds.left; point.h -= bounds.left;
@ -3028,6 +3055,10 @@ receiveHandler(WindowRef theWindow, void* handlerRefCon, DragRef theDrag)
count = j; count = j;
gui_handle_drop(x, y, modifiers, fnames, count); gui_handle_drop(x, y, modifiers, fnames, count);
/* Fake mouse event to wake from stall */
PostEvent(mouseUp, 0);
return noErr; return noErr;
} }
@ -3433,6 +3464,7 @@ gui_mch_init_font(font_name, fontset)
FontInfo font_info; FontInfo font_info;
short font_id; short font_id;
GuiFont font; GuiFont font;
char_u used_font_name[512];
if (font_name == NULL) if (font_name == NULL)
{ {
@ -3443,23 +3475,26 @@ gui_mch_init_font(font_name, fontset)
{ {
/* Then pickup the standard application font */ /* Then pickup the standard application font */
font_id = GetAppFont(); font_id = GetAppFont();
STRCPY(used_font_name, "default");
} }
else
STRCPY(used_font_name, "Monaco");
font = (suggestedSize << 16) + ((long) font_id & 0xFFFF); font = (suggestedSize << 16) + ((long) font_id & 0xFFFF);
} }
#if defined(USE_CARBONIZED) && defined(MACOS_X) #if defined(USE_CARBONIZED) && defined(MACOS_X)
else if (STRCMP(font_name, "*") == 0) else if (STRCMP(font_name, "*") == 0)
{ {
char_u *new_p_guifont, font_name[512]; char_u *new_p_guifont;
font = gui_mac_select_font(font_name); font = gui_mac_select_font(used_font_name);
if (font == NOFONT) if (font == NOFONT)
return FAIL; return FAIL;
/* Set guifont to the name of the selected font. */ /* Set guifont to the name of the selected font. */
new_p_guifont = alloc(STRLEN(font_name) + 1); new_p_guifont = alloc(STRLEN(used_font_name) + 1);
if (new_p_guifont != NULL) if (new_p_guifont != NULL)
{ {
STRCPY(new_p_guifont, font_name); STRCPY(new_p_guifont, used_font_name);
vim_free(p_guifont); vim_free(p_guifont);
p_guifont = new_p_guifont; p_guifont = new_p_guifont;
/* Replace spaces in the font name with underscores. */ /* Replace spaces in the font name with underscores. */
@ -3474,12 +3509,17 @@ gui_mch_init_font(font_name, fontset)
else else
{ {
font = gui_mac_find_font(font_name); font = gui_mac_find_font(font_name);
STRNCPY(used_font_name, font_name, sizeof(used_font_name));
used_font_name[sizeof(used_font_name) - 1] = NUL;
if (font == NOFONT) if (font == NOFONT)
return FAIL; return FAIL;
} }
gui.norm_font = font; gui.norm_font = font;
hl_set_font_name(used_font_name);
TextSize(font >> 16); TextSize(font >> 16);
TextFont(font & 0xFFFF); TextFont(font & 0xFFFF);
@ -3529,6 +3569,20 @@ gui_mch_get_font(name, giveErrorIfMissing)
return font; return font;
} }
/*
* Return the name of font "font" in allocated memory.
* Don't know how to get the actual name, thus use the provided name.
*/
char_u *
gui_mch_get_fontname(font, name)
GuiFont font;
char_u *name;
{
if (name == NULL)
return NULL;
return vim_strsave(name);
}
/* /*
* Set the current text font. * Set the current text font.
*/ */

View File

@ -2986,6 +2986,7 @@ gui_mch_init_font(char_u *vim_font_name, int fontset)
vim_free( font_name ); vim_free( font_name );
return( FAIL ); return( FAIL );
} }
gui_mch_free_font( gui.norm_font ); gui_mch_free_font( gui.norm_font );
gui.norm_font = font_tag; gui.norm_font = font_tag;
} }
@ -3046,6 +3047,20 @@ gui_mch_get_font(char_u *vim_font_name, int report_error)
return( FAIL ); return( FAIL );
} }
/*
* Return the name of font "font" in allocated memory.
* Don't know how to get the actual name, thus use the provided name.
*/
char_u *
gui_mch_get_fontname(font, name)
GuiFont font;
char_u *name;
{
if (name == NULL)
return NULL;
return vim_strsave(name);
}
void void
gui_mch_set_font(GuiFont font) gui_mch_set_font(GuiFont font)
{ {

View File

@ -1052,6 +1052,20 @@ gui_mch_get_font(name, giveErrorIfMissing)
return handle; return handle;
} }
/*
* Return the name of font "font" in allocated memory.
* Don't know how to get the actual name, thus use the provided name.
*/
char_u *
gui_mch_get_fontname(font, name)
GuiFont font;
char_u *name;
{
if (name == NULL)
return NULL;
return vim_strsave(name);
}
/* /*
* Set the current text font. * Set the current text font.
*/ */

View File

@ -1240,14 +1240,29 @@ gui_mch_get_font(
int giveErrorIfMissing) int giveErrorIfMissing)
{ {
LOGFONT lf; LOGFONT lf;
GuiFont font; GuiFont font = NOFONT;
get_logfont(&lf, name, NULL); if (get_logfont(&lf, name, NULL, giveErrorIfMissing) == OK)
font = get_font_handle(&lf); font = get_font_handle(&lf);
if (font == NOFONT && giveErrorIfMissing) if (font == NOFONT && giveErrorIfMissing)
EMSG2(_(e_font), name); EMSG2(_(e_font), name);
return font; return font;
} }
/*
* Return the name of font "font" in allocated memory.
* Don't know how to get the actual name, thus use the provided name.
*/
char_u *
gui_mch_get_fontname(font, name)
GuiFont font;
char_u *name;
{
if (name == NULL)
return NULL;
return vim_strsave(name);
}
void void
gui_mch_free_font(GuiFont font) gui_mch_free_font(GuiFont font)
{ {
@ -2600,21 +2615,65 @@ gui_mch_exit(int rc)
#endif #endif
} }
static char_u *
logfont2name(LOGFONT lf)
{
char *p;
char *res;
char *charset_name;
charset_name = charset_id2name((int)lf.lfCharSet);
res = alloc((unsigned)(strlen(lf.lfFaceName) + 20
+ (charset_name == NULL ? 0 : strlen(charset_name) + 2)));
if (res != NULL)
{
p = res;
/* make a normal font string out of the lf thing:*/
sprintf((char *)p, "%s:h%d", lf.lfFaceName, pixels_to_points(
lf.lfHeight < 0 ? -lf.lfHeight : lf.lfHeight, TRUE));
while (*p)
{
if (*p == ' ')
*p = '_';
++p;
}
#ifndef MSWIN16_FASTTEXT
if (lf.lfItalic)
STRCAT(p, ":i");
if (lf.lfWeight >= FW_BOLD)
STRCAT(p, ":b");
#endif
if (lf.lfUnderline)
STRCAT(p, ":u");
if (lf.lfStrikeOut)
STRCAT(p, ":s");
if (charset_name != NULL)
{
STRCAT(p, ":c");
STRCAT(p, charset_name);
}
}
return res;
}
/* /*
* Initialise vim to use the font with the given name. Return FAIL if the font * Initialise vim to use the font with the given name.
* could not be loaded, OK otherwise. * Return FAIL if the font could not be loaded, OK otherwise.
*/ */
int int
gui_mch_init_font(char_u *font_name, int fontset) gui_mch_init_font(char_u *font_name, int fontset)
{ {
LOGFONT lf; LOGFONT lf;
GuiFont font = NOFONT; GuiFont font = NOFONT;
char_u *p;
/* Load the font */ /* Load the font */
if (get_logfont(&lf, font_name, NULL)) if (get_logfont(&lf, font_name, NULL, TRUE) == OK)
font = get_font_handle(&lf); font = get_font_handle(&lf);
if (font == NOFONT) if (font == NOFONT)
return FAIL; return FAIL;
if (font_name == NULL) if (font_name == NULL)
font_name = lf.lfFaceName; font_name = lf.lfFaceName;
#if defined(FEAT_MBYTE_IME) || defined(GLOBAL_IME) #if defined(FEAT_MBYTE_IME) || defined(GLOBAL_IME)
@ -2627,46 +2686,21 @@ gui_mch_init_font(char_u *font_name, int fontset)
gui.norm_font = font; gui.norm_font = font;
current_font_height = lf.lfHeight; current_font_height = lf.lfHeight;
GetFontSize(font); GetFontSize(font);
hl_set_font_name(lf.lfFaceName);
/* When setting 'guifont' to "*" replace it with the actual font name. */ p = logfont2name(lf);
if (STRCMP(font_name, "*") == 0 && STRCMP(p_guifont, "*") == 0) if (p != NULL)
{ {
char *charset_name; hl_set_font_name(p);
char_u *p;
charset_name = charset_id2name((int)lf.lfCharSet); /* When setting 'guifont' to "*" replace it with the actual font name.
p = alloc((unsigned)(strlen(lf.lfFaceName) + 20 * */
+ (charset_name == NULL ? 0 : strlen(charset_name) + 2))); if (STRCMP(font_name, "*") == 0 && STRCMP(p_guifont, "*") == 0)
if (p != NULL)
{ {
/* make a normal font string out of the lf thing:*/
sprintf((char *)p, "%s:h%d", lf.lfFaceName, pixels_to_points(
lf.lfHeight < 0 ? -lf.lfHeight : lf.lfHeight, TRUE));
vim_free(p_guifont); vim_free(p_guifont);
p_guifont = p; p_guifont = p;
while (*p)
{
if (*p == ' ')
*p = '_';
++p;
}
#ifndef MSWIN16_FASTTEXT
if (lf.lfItalic)
STRCAT(p, ":i");
if (lf.lfWeight >= FW_BOLD)
STRCAT(p, ":b");
#endif
if (lf.lfUnderline)
STRCAT(p, ":u");
if (lf.lfStrikeOut)
STRCAT(p, ":s");
if (charset_name != NULL)
{
STRCAT(p, ":c");
STRCAT(p, charset_name);
}
} }
else
vim_free(p);
} }
#ifndef MSWIN16_FASTTEXT #ifndef MSWIN16_FASTTEXT

View File

@ -2096,7 +2096,7 @@ mch_print_init(prt_settings_T *psettings, char_u *jobname, int forceit)
* Initialise the font according to 'printfont' * Initialise the font according to 'printfont'
*/ */
memset(&fLogFont, 0, sizeof(fLogFont)); memset(&fLogFont, 0, sizeof(fLogFont));
if (!get_logfont(&fLogFont, p_pfn, prt_dlg.hDC)) if (get_logfont(&fLogFont, p_pfn, prt_dlg.hDC, TRUE) == FAIL)
{ {
EMSG2(_("E613: Unknown printer font: %s"), p_pfn); EMSG2(_("E613: Unknown printer font: %s"), p_pfn);
mch_print_cleanup(); mch_print_cleanup();
@ -3161,11 +3161,16 @@ init_logfont(LOGFONT *lf)
return OK; return OK;
} }
/*
* Get font info from "name" into logfont "lf".
* Return OK for a valid name, FAIL otherwise.
*/
int int
get_logfont( get_logfont(
LOGFONT *lf, LOGFONT *lf,
char_u *name, char_u *name,
HDC printer_dc) HDC printer_dc,
int verbose)
{ {
char_u *p; char_u *p;
int i; int i;
@ -3173,7 +3178,7 @@ get_logfont(
*lf = s_lfDefault; *lf = s_lfDefault;
if (name == NULL) if (name == NULL)
return 1; return OK;
if (STRCMP(name, "*") == 0) if (STRCMP(name, "*") == 0)
{ {
@ -3191,7 +3196,7 @@ get_logfont(
if (ChooseFont(&cf)) if (ChooseFont(&cf))
goto theend; goto theend;
#else #else
return 0; return FAIL;
#endif #endif
} }
@ -3201,7 +3206,7 @@ get_logfont(
for (p = name; *p && *p != ':'; p++) for (p = name; *p && *p != ':'; p++)
{ {
if (p - name + 1 > LF_FACESIZE) if (p - name + 1 > LF_FACESIZE)
return 0; /* Name too long */ return FAIL; /* Name too long */
lf->lfFaceName[p - name] = *p; lf->lfFaceName[p - name] = *p;
} }
if (p != name) if (p != name)
@ -3229,7 +3234,7 @@ get_logfont(
did_replace = TRUE; did_replace = TRUE;
} }
if (!did_replace || init_logfont(lf) == FAIL) if (!did_replace || init_logfont(lf) == FAIL)
return 0; return FAIL;
} }
while (*p == ':') while (*p == ':')
@ -3273,7 +3278,7 @@ get_logfont(
p += strlen(cp->name); p += strlen(cp->name);
break; break;
} }
if (cp->name == NULL) if (cp->name == NULL && verbose)
{ {
sprintf((char *)IObuff, _("E244: Illegal charset name \"%s\" in font name \"%s\""), p, name); sprintf((char *)IObuff, _("E244: Illegal charset name \"%s\" in font name \"%s\""), p, name);
EMSG(IObuff); EMSG(IObuff);
@ -3282,11 +3287,14 @@ get_logfont(
break; break;
} }
default: default:
sprintf((char *)IObuff, if (verbose)
_("E245: Illegal char '%c' in font name \"%s\""), {
p[-1], name); sprintf((char *)IObuff,
EMSG(IObuff); _("E245: Illegal char '%c' in font name \"%s\""),
break; p[-1], name);
EMSG(IObuff);
}
return FAIL;
} }
while (*p == ':') while (*p == ':')
p++; p++;
@ -3304,7 +3312,7 @@ theend:
mch_memmove(lastlf, lf, sizeof(LOGFONT)); mch_memmove(lastlf, lf, sizeof(LOGFONT));
} }
return 1; return OK;
} }
#endif /* defined(FEAT_GUI) || defined(FEAT_PRINTER) */ #endif /* defined(FEAT_GUI) || defined(FEAT_PRINTER) */

View File

@ -800,6 +800,8 @@ catch_sigint SIGDEFARG(sigarg)
static RETSIGTYPE static RETSIGTYPE
catch_sigpwr SIGDEFARG(sigarg) catch_sigpwr SIGDEFARG(sigarg)
{ {
/* this is not required on all systems, but it doesn't hurt anybody */
signal(SIGPWR, (RETSIGTYPE (*)())catch_sigpwr);
/* /*
* I'm not sure we get the SIGPWR signal when the system is really going * I'm not sure we get the SIGPWR signal when the system is really going
* down or when the batteries are almost empty. Just preserve the swap * down or when the batteries are almost empty. Just preserve the swap
@ -904,9 +906,31 @@ deathtrap SIGDEFARG(sigarg)
#endif #endif
#ifdef SIGHASARG #ifdef SIGHASARG
/* When SIGHUP is blocked: postpone its effect and return here. This /* When SIGHUP, SIGQUIT, etc. are blocked: postpone the effect and return
* avoids that a non-reentrant function is interrupted, e.g., free(). */ * here. This avoids that a non-reentrant function is interrupted, e.g.,
if (entered == 0 && sigarg == SIGHUP && !handle_sighup(SIGHUP_RCV)) * free(). Calling free() again may then cause a crash. */
if (entered == 0
&& (0
# ifdef SIGHUP
|| sigarg == SIGHUP
# endif
# ifdef SIGQUIT
|| sigarg == SIGQUIT
# endif
# ifdef SIGTERM
|| sigarg == SIGTERM
# endif
# ifdef SIGPWR
|| sigarg == SIGPWR
# endif
# ifdef SIGUSR1
|| sigarg == SIGUSR1
# endif
# ifdef SIGUSR2
|| sigarg == SIGUSR2
# endif
)
&& !handle_signal(sigarg))
SIGRETURN; SIGRETURN;
#endif #endif
@ -1181,33 +1205,39 @@ catch_signals(func_deadly, func_other)
} }
/* /*
* Handling of SIGHUP: * Handling of SIGHUP, SIGQUIT and SIGTERM:
* "when" == SIGHUP_RCV: when busy, postpone, otherwise return TRUE * "when" == a signal: when busy, postpone, otherwise return TRUE
* "when" == SIGHUP_BLOCK: Going to be busy, block SIGHUP * "when" == SIGNAL_BLOCK: Going to be busy, block signals
* "when" == SIGHUP_UNBLOCK: Going wait, unblock SIGHUP * "when" == SIGNAL_UNBLOCK: Going wait, unblock signals
* Returns TRUE when Vim should exit. * Returns TRUE when Vim should exit.
*/ */
int int
handle_sighup(when) handle_signal(sig)
int when; int sig;
{ {
static int got_sighup = FALSE; static int got_signal = 0;
static int blocked = FALSE; static int blocked = TRUE;
switch (when) switch (sig)
{ {
case SIGHUP_RCV: if (!blocked) case SIGNAL_BLOCK: blocked = TRUE;
break;
case SIGNAL_UNBLOCK: blocked = FALSE;
if (got_signal != 0)
{
kill(getpid(), got_signal);
got_signal = 0;
}
break;
default: if (!blocked)
return TRUE; /* exit! */ return TRUE; /* exit! */
got_sighup = TRUE; got_signal = sig;
got_int = TRUE; /* break any loops */ #ifdef SIGPWR
break; if (sig != SIGPWR)
#endif
case SIGHUP_BLOCK: blocked = TRUE; got_int = TRUE; /* break any loops */
break;
case SIGHUP_UNBLOCK: blocked = FALSE;
if (got_sighup)
kill(getpid(), SIGHUP);
break; break;
} }
return FALSE; return FALSE;

View File

@ -14,7 +14,6 @@ void gui_mch_destroy_scrollbar __ARGS((scrollbar_T *sb));
char_u *gui_mch_browse __ARGS((int saving, char_u *title, char_u *dflt, char_u *ext, char_u *initdir, char_u *filter)); char_u *gui_mch_browse __ARGS((int saving, char_u *title, char_u *dflt, char_u *ext, char_u *initdir, char_u *filter));
char_u *gui_mch_browsedir __ARGS((char_u *title, char_u *initdir)); char_u *gui_mch_browsedir __ARGS((char_u *title, char_u *initdir));
int gui_mch_dialog __ARGS((int type, char_u *title, char_u *message, char_u *buttons, int def_but, char_u *textfield)); int gui_mch_dialog __ARGS((int type, char_u *title, char_u *message, char_u *buttons, int def_but, char_u *textfield));
int gui_mch_dialog __ARGS((int type, char_u *title, char_u *message, char_u *buttons, int def_but, char_u *textfield));
void gui_mch_show_popupmenu __ARGS((vimmenu_T *menu)); void gui_mch_show_popupmenu __ARGS((vimmenu_T *menu));
void gui_make_popup __ARGS((char_u *path_name)); void gui_make_popup __ARGS((char_u *path_name));
void gui_mch_find_dialog __ARGS((exarg_T *eap)); void gui_mch_find_dialog __ARGS((exarg_T *eap));

View File

@ -21,6 +21,7 @@ GuiFontset gui_mch_get_fontset __ARGS((char_u *name, int report_error, int fixed
char_u *gui_mch_font_dialog __ARGS((char_u *oldval)); char_u *gui_mch_font_dialog __ARGS((char_u *oldval));
int gui_mch_init_font __ARGS((char_u *font_name, int fontset)); int gui_mch_init_font __ARGS((char_u *font_name, int fontset));
GuiFont gui_mch_get_font __ARGS((char_u *name, int report_error)); GuiFont gui_mch_get_font __ARGS((char_u *name, int report_error));
char_u *gui_mch_get_fontname __ARGS((GuiFont font, char_u *name));
void gui_mch_set_font __ARGS((GuiFont font)); void gui_mch_set_font __ARGS((GuiFont font));
void gui_mch_set_fontset __ARGS((GuiFontset fontset)); void gui_mch_set_fontset __ARGS((GuiFontset fontset));
void gui_mch_free_font __ARGS((GuiFont font)); void gui_mch_free_font __ARGS((GuiFont font));

View File

@ -61,6 +61,7 @@ void gui_mch_show_toolbar __ARGS((int showit));
int gui_mch_init_font __ARGS((char_u *vim_font_name, int fontset)); int gui_mch_init_font __ARGS((char_u *vim_font_name, int fontset));
int gui_mch_adjust_charsize __ARGS((void)); int gui_mch_adjust_charsize __ARGS((void));
GuiFont gui_mch_get_font __ARGS((char_u *vim_font_name, int report_error)); GuiFont gui_mch_get_font __ARGS((char_u *vim_font_name, int report_error));
char_u *gui_mch_get_fontname __ARGS((GuiFont font, char_u *name));
void gui_mch_set_font __ARGS((GuiFont font)); void gui_mch_set_font __ARGS((GuiFont font));
void gui_mch_free_font __ARGS((GuiFont font)); void gui_mch_free_font __ARGS((GuiFont font));
/* vim: set ft=c : */ /* vim: set ft=c : */

View File

@ -14,6 +14,7 @@ void gui_mch_set_scrollbar_pos __ARGS((scrollbar_T *sb, int x, int y, int w, int
void gui_mch_create_scrollbar __ARGS((scrollbar_T *sb, int orient)); void gui_mch_create_scrollbar __ARGS((scrollbar_T *sb, int orient));
int gui_mch_adjust_charsize __ARGS((void)); int gui_mch_adjust_charsize __ARGS((void));
GuiFont gui_mch_get_font __ARGS((char_u *name, int giveErrorIfMissing)); GuiFont gui_mch_get_font __ARGS((char_u *name, int giveErrorIfMissing));
char_u *gui_mch_get_fontname __ARGS((GuiFont font, char_u *name));
void gui_mch_free_font __ARGS((GuiFont font)); void gui_mch_free_font __ARGS((GuiFont font));
guicolor_T gui_mch_get_color __ARGS((char_u *name)); guicolor_T gui_mch_get_color __ARGS((char_u *name));
int gui_mch_haskey __ARGS((char_u *name)); int gui_mch_haskey __ARGS((char_u *name));
@ -51,6 +52,7 @@ int gui_mch_maximized __ARGS((void));
void gui_mch_newfont __ARGS((void)); void gui_mch_newfont __ARGS((void));
void gui_mch_settitle __ARGS((char_u *title, char_u *icon)); void gui_mch_settitle __ARGS((char_u *title, char_u *icon));
void mch_set_mouse_shape __ARGS((int shape)); void mch_set_mouse_shape __ARGS((int shape));
char_u *gui_mch_browsedir __ARGS((char_u *title, char_u *initdir));
char_u *gui_mch_browse __ARGS((int saving, char_u *title, char_u *dflt, char_u *ext, char_u *initdir, char_u *filter)); char_u *gui_mch_browse __ARGS((int saving, char_u *title, char_u *dflt, char_u *ext, char_u *initdir, char_u *filter));
int get_cmd_args __ARGS((char *prog, char *cmdline, char ***argvp, char **tofree)); int get_cmd_args __ARGS((char *prog, char *cmdline, char ***argvp, char **tofree));
void gui_mch_prepare __ARGS((int *argc, char **argv)); void gui_mch_prepare __ARGS((int *argc, char **argv));

View File

@ -14,6 +14,7 @@ void gui_mch_set_scrollbar_pos __ARGS((scrollbar_T *sb, int x, int y, int w, int
void gui_mch_create_scrollbar __ARGS((scrollbar_T *sb, int orient)); void gui_mch_create_scrollbar __ARGS((scrollbar_T *sb, int orient));
int gui_mch_adjust_charsize __ARGS((void)); int gui_mch_adjust_charsize __ARGS((void));
GuiFont gui_mch_get_font __ARGS((char_u *name, int giveErrorIfMissing)); GuiFont gui_mch_get_font __ARGS((char_u *name, int giveErrorIfMissing));
char_u *gui_mch_get_fontname __ARGS((GuiFont font, char_u *name));
void gui_mch_free_font __ARGS((GuiFont font)); void gui_mch_free_font __ARGS((GuiFont font));
guicolor_T gui_mch_get_color __ARGS((char_u *name)); guicolor_T gui_mch_get_color __ARGS((char_u *name));
int gui_mch_haskey __ARGS((char_u *name)); int gui_mch_haskey __ARGS((char_u *name));

View File

@ -11,7 +11,7 @@ void mch_didjmp __ARGS((void));
void mch_suspend __ARGS((void)); void mch_suspend __ARGS((void));
void mch_init __ARGS((void)); void mch_init __ARGS((void));
void reset_signals __ARGS((void)); void reset_signals __ARGS((void));
int handle_sighup __ARGS((int when)); int handle_signal __ARGS((int sig));
int mch_check_win __ARGS((int argc, char **argv)); int mch_check_win __ARGS((int argc, char **argv));
int mch_input_isatty __ARGS((void)); int mch_input_isatty __ARGS((void));
int mch_can_restore_title __ARGS((void)); int mch_can_restore_title __ARGS((void));

View File

@ -1843,12 +1843,11 @@ typedef int VimClipboard; /* This is required for the prototypes. */
# include <XSUB.h> # include <XSUB.h>
#endif #endif
/* values for handle_sighup() */ /* values for handle_signal() that are not a signal */
#define SIGHUP_RCV 1 #define SIGNAL_BLOCK -1
#define SIGHUP_BLOCK 2 #define SIGNAL_UNBLOCK -2
#define SIGHUP_UNBLOCK 3
#ifndef UNIX #ifndef UNIX
# define handle_sighup(x) /* nothing */ # define handle_signal(x) 0
#endif #endif
#endif /* VIM__H */ #endif /* VIM__H */