Compare commits

...

2 Commits

Author SHA1 Message Date
Bram Moolenaar
94073167e3 patch 8.0.1451: difficult to set the python home directories properly
Problem:    It is difficult to set the python home directory properly for
            Python 2.7 and 3.5 since both use $PYTHONHOME.
Solution:   Add the 'pythonhome' and 'pythonthreehome' options. (Kazuki
            Sakamoto, closes #1266)
2018-01-31 21:49:05 +01:00
Bram Moolenaar
1dd45fb4f3 patch 8.0.1450: GUI: endless loop when stopping cursor blinking
Problem:    Endless loop when gui_mch_stop_blink() is called while blink_state
            is BLINK_OFF. (zdohnal)
Solution:   Avoid calling gui_update_cursor() recursively.
2018-01-31 21:10:01 +01:00
19 changed files with 115 additions and 32 deletions

View File

@@ -5965,6 +5965,20 @@ A jump table for the options with a short description can be found at |Q_op|.
DYNAMIC_PYTHON_DLL, which was specified at compile time. DYNAMIC_PYTHON_DLL, which was specified at compile time.
Environment variables are expanded |:set_env|. Environment variables are expanded |:set_env|.
This option cannot be set from a |modeline| or in the |sandbox|, for This option cannot be set from a |modeline| or in the |sandbox|, for
security reasons.
*'pythonhome'*
'pythonhome' string (default "")
global
{not in Vi}
{only available when compiled with the |+python/dyn|
feature}
Specifies the name of the Python 2.x home directory. When 'pythonhome'
and the PYTHONHOME environment variable are not set, PYTHON_HOME,
which was specified at compile time, will be used for the Python 2.x
home directory.
Environment variables are expanded |:set_env|.
This option cannot be set from a |modeline| or in the |sandbox|, for
security reasons. security reasons.
*'pythonthreedll'* *'pythonthreedll'*
@@ -5977,6 +5991,20 @@ A jump table for the options with a short description can be found at |Q_op|.
DYNAMIC_PYTHON3_DLL, which was specified at compile time. DYNAMIC_PYTHON3_DLL, which was specified at compile time.
Environment variables are expanded |:set_env|. Environment variables are expanded |:set_env|.
This option cannot be set from a |modeline| or in the |sandbox|, for This option cannot be set from a |modeline| or in the |sandbox|, for
security reasons.
*'pythonthreehome'*
'pythonthreehome' string (default "")
global
{not in Vi}
{only available when compiled with the |+python3/dyn|
feature}
Specifies the name of the Python 3 home directory. When
'pythonthreehome' and the PYTHONHOME environment variable are not set,
PYTHON3_HOME, which was specified at compile time, will be used for
the Python 3 home directory.
Environment variables are expanded |:set_env|.
This option cannot be set from a |modeline| or in the |sandbox|, for
security reasons. security reasons.
*'pyxversion'* *'pyx'* *'pyxversion'* *'pyx'*

View File

@@ -839,7 +839,9 @@ Short explanation of each option: *option-list*
'prompt' 'prompt' enable prompt in Ex mode 'prompt' 'prompt' enable prompt in Ex mode
'pumheight' 'ph' maximum height of the popup menu 'pumheight' 'ph' maximum height of the popup menu
'pythondll' name of the Python 2 dynamic library 'pythondll' name of the Python 2 dynamic library
'pythonhome' name of the Python 2 home directory
'pythonthreedll' name of the Python 3 dynamic library 'pythonthreedll' name of the Python 3 dynamic library
'pythonthreehome' name of the Python 3 home directory
'pyxversion' 'pyx' Python version used for pyx* commands 'pyxversion' 'pyx' Python version used for pyx* commands
'quoteescape' 'qe' escape characters used in a string 'quoteescape' 'qe' escape characters used in a string
'readonly' 'ro' disallow writing the buffer 'readonly' 'ro' disallow writing the buffer

View File

@@ -1354,10 +1354,18 @@ if exists("&pythondll")
call append("$", "pythondll\tname of the Python 2 dynamic library") call append("$", "pythondll\tname of the Python 2 dynamic library")
call <SID>OptionG("pythondll", &pythondll) call <SID>OptionG("pythondll", &pythondll)
endif endif
if exists("&pythonhome")
call append("$", "pythonhome\tname of the Python 2 home directory")
call <SID>OptionG("pythonhome", &pythonhome)
endif
if exists("&pythonthreedll") if exists("&pythonthreedll")
call append("$", "pythonthreedll\tname of the Python 3 dynamic library") call append("$", "pythonthreedll\tname of the Python 3 dynamic library")
call <SID>OptionG("pythonthreedll", &pythonthreedll) call <SID>OptionG("pythonthreedll", &pythonthreedll)
endif endif
if exists("&pythonthreehome")
call append("$", "pythonthreehome\tname of the Python 3 home directory")
call <SID>OptionG("pythonthreehome", &pythonthreehome)
endif
if exists("&rubydll") if exists("&rubydll")
call append("$", "rubydll\tname of the Ruby dynamic library") call append("$", "rubydll\tname of the Ruby dynamic library")
call <SID>OptionG("rubydll", &rubydll) call <SID>OptionG("rubydll", &rubydll)

View File

@@ -1124,7 +1124,7 @@ gui_update_cursor(
shape->blinkoff); shape->blinkoff);
if (shape->blinkwait == 0 || shape->blinkon == 0 if (shape->blinkwait == 0 || shape->blinkon == 0
|| shape->blinkoff == 0) || shape->blinkoff == 0)
gui_mch_stop_blink(); gui_mch_stop_blink(FALSE);
#ifdef FEAT_TERMINAL #ifdef FEAT_TERMINAL
if (shape_bg != INVALCOLOR) if (shape_bg != INVALCOLOR)
{ {
@@ -2982,7 +2982,7 @@ gui_wait_for_chars(long wtime, int tb_change_cnt)
* for showmatch() */ * for showmatch() */
gui_mch_start_blink(); gui_mch_start_blink();
retval = gui_wait_for_chars_or_timer(wtime); retval = gui_wait_for_chars_or_timer(wtime);
gui_mch_stop_blink(); gui_mch_stop_blink(TRUE);
return retval; return retval;
} }
@@ -3029,7 +3029,7 @@ gui_wait_for_chars(long wtime, int tb_change_cnt)
retval = gui_wait_for_chars_or_timer(-1L); retval = gui_wait_for_chars_or_timer(-1L);
} }
gui_mch_stop_blink(); gui_mch_stop_blink(TRUE);
return retval; return retval;
} }

View File

@@ -893,14 +893,14 @@ gui_mch_set_blinking(long waittime, long on, long off)
* Stop the cursor blinking. Show the cursor if it wasn't shown. * Stop the cursor blinking. Show the cursor if it wasn't shown.
*/ */
void void
gui_mch_stop_blink(void) gui_mch_stop_blink(int may_call_gui_update_cursor)
{ {
if (blink_timer) if (blink_timer)
{ {
timeout_remove(blink_timer); timeout_remove(blink_timer);
blink_timer = 0; blink_timer = 0;
} }
if (blink_state == BLINK_OFF) if (blink_state == BLINK_OFF && may_call_gui_update_cursor)
{ {
gui_update_cursor(TRUE, FALSE); gui_update_cursor(TRUE, FALSE);
gui_mch_flush(); gui_mch_flush();
@@ -975,7 +975,7 @@ leave_notify_event(GtkWidget *widget UNUSED,
gpointer data UNUSED) gpointer data UNUSED)
{ {
if (blink_state != BLINK_NONE) if (blink_state != BLINK_NONE)
gui_mch_stop_blink(); gui_mch_stop_blink(TRUE);
return FALSE; return FALSE;
} }
@@ -1006,7 +1006,7 @@ focus_out_event(GtkWidget *widget UNUSED,
gui_focus_change(FALSE); gui_focus_change(FALSE);
if (blink_state != BLINK_NONE) if (blink_state != BLINK_NONE)
gui_mch_stop_blink(); gui_mch_stop_blink(TRUE);
return TRUE; return TRUE;
} }
@@ -1145,7 +1145,7 @@ key_press_event(GtkWidget *widget UNUSED,
#if GTK_CHECK_VERSION(3,0,0) #if GTK_CHECK_VERSION(3,0,0)
is_key_pressed = TRUE; is_key_pressed = TRUE;
gui_mch_stop_blink(); gui_mch_stop_blink(TRUE);
#endif #endif
gui.event_time = event->time; gui.event_time = event->time;
@@ -6677,7 +6677,7 @@ gui_mch_wait_for_chars(long wtime)
if (gui.in_focus) if (gui.in_focus)
gui_mch_start_blink(); gui_mch_start_blink();
else else
gui_mch_stop_blink(); gui_mch_stop_blink(TRUE);
focus = gui.in_focus; focus = gui.in_focus;
} }

View File

@@ -5156,8 +5156,9 @@ gui_mch_set_blinking(long wait, long on, long off)
* Stop the cursor blinking. Show the cursor if it wasn't shown. * Stop the cursor blinking. Show the cursor if it wasn't shown.
*/ */
void void
gui_mch_stop_blink(void) gui_mch_stop_blink(int may_call_gui_update_cursor)
{ {
if (may_call_gui_update_cursor)
gui_update_cursor(TRUE, FALSE); gui_update_cursor(TRUE, FALSE);
/* TODO: TODO: TODO: TODO: */ /* TODO: TODO: TODO: TODO: */
/* gui_w32_rm_blink_timer(); /* gui_w32_rm_blink_timer();

View File

@@ -383,7 +383,7 @@ gui_ph_handle_window_cb(PtWidget_t *widget, void *data, PtCallbackInfo_t *info)
else else
{ {
gui_focus_change(FALSE); gui_focus_change(FALSE);
gui_mch_stop_blink(); gui_mch_stop_blink(TRUE);
} }
break; break;
@@ -2273,11 +2273,11 @@ gui_mch_start_blink(void)
} }
void void
gui_mch_stop_blink(void) gui_mch_stop_blink(int may_call_gui_update_cursor)
{ {
PtSetResource(gui_ph_timer_cursor, Pt_ARG_TIMER_INITIAL, 0, 0); PtSetResource(gui_ph_timer_cursor, Pt_ARG_TIMER_INITIAL, 0, 0);
if (blink_state == BLINK_OFF) if (blink_state == BLINK_OFF && may_call_gui_update_cursor)
gui_update_cursor(TRUE, FALSE); gui_update_cursor(TRUE, FALSE);
blink_state = BLINK_NONE; blink_state = BLINK_NONE;

View File

@@ -638,10 +638,10 @@ gui_mswin_rm_blink_timer(void)
* Stop the cursor blinking. Show the cursor if it wasn't shown. * Stop the cursor blinking. Show the cursor if it wasn't shown.
*/ */
void void
gui_mch_stop_blink(void) gui_mch_stop_blink(int may_call_gui_update_cursor)
{ {
gui_mswin_rm_blink_timer(); gui_mswin_rm_blink_timer();
if (blink_state == BLINK_OFF) if (blink_state == BLINK_OFF && may_call_gui_update_cursor)
{ {
gui_update_cursor(TRUE, FALSE); gui_update_cursor(TRUE, FALSE);
gui_mch_flush(); gui_mch_flush();
@@ -2111,7 +2111,7 @@ gui_mch_wait_for_chars(int wtime)
if (gui.in_focus) if (gui.in_focus)
gui_mch_start_blink(); gui_mch_start_blink();
else else
gui_mch_stop_blink(); gui_mch_stop_blink(TRUE);
focus = gui.in_focus; focus = gui.in_focus;
} }

View File

@@ -2746,7 +2746,7 @@ gui_mch_wait_for_chars(long wtime)
if (gui.in_focus) if (gui.in_focus)
gui_mch_start_blink(); gui_mch_start_blink();
else else
gui_mch_stop_blink(); gui_mch_stop_blink(TRUE);
focus = gui.in_focus; focus = gui.in_focus;
} }
@@ -3105,14 +3105,14 @@ gui_mch_set_blinking(long waittime, long on, long off)
* Stop the cursor blinking. Show the cursor if it wasn't shown. * Stop the cursor blinking. Show the cursor if it wasn't shown.
*/ */
void void
gui_mch_stop_blink(void) gui_mch_stop_blink(int may_call_gui_update_cursor)
{ {
if (blink_timer != (XtIntervalId)0) if (blink_timer != (XtIntervalId)0)
{ {
XtRemoveTimeOut(blink_timer); XtRemoveTimeOut(blink_timer);
blink_timer = (XtIntervalId)0; blink_timer = (XtIntervalId)0;
} }
if (blink_state == BLINK_OFF) if (blink_state == BLINK_OFF && may_call_gui_update_cursor)
gui_update_cursor(TRUE, FALSE); gui_update_cursor(TRUE, FALSE);
blink_state = BLINK_NONE; blink_state = BLINK_NONE;
} }

View File

@@ -912,6 +912,8 @@ python_loaded(void)
} }
#endif #endif
static char *py_home_buf = NULL;
static int static int
Python_Init(void) Python_Init(void)
{ {
@@ -929,10 +931,15 @@ Python_Init(void)
} }
#endif #endif
if (*p_pyhome != NUL)
{
/* The string must not change later, make a copy in static memory. */
py_home_buf = (char *)vim_strsave(p_pyhome);
if (py_home_buf != NULL)
Py_SetPythonHome(py_home_buf);
}
#ifdef PYTHON_HOME #ifdef PYTHON_HOME
# ifdef DYNAMIC_PYTHON else if (mch_getenv((char_u *)"PYTHONHOME") == NULL)
if (mch_getenv((char_u *)"PYTHONHOME") == NULL)
# endif
Py_SetPythonHome(PYTHON_HOME); Py_SetPythonHome(PYTHON_HOME);
#endif #endif

View File

@@ -842,6 +842,8 @@ python3_loaded(void)
} }
#endif #endif
static wchar_t *py_home_buf = NULL;
static int static int
Python3_Init(void) Python3_Init(void)
{ {
@@ -857,11 +859,18 @@ Python3_Init(void)
init_structs(); init_structs();
if (*p_py3home != NUL)
{
size_t len = mbstowcs(NULL, (char *)p_py3home, 0) + 1;
/* The string must not change later, make a copy in static memory. */
py_home_buf = (wchar_t *)alloc(len * sizeof(wchar_t));
if (py_home_buf != NULL && mbstowcs(
py_home_buf, (char *)p_py3home, len) != (size_t)-1)
Py_SetPythonHome(py_home_buf);
}
#ifdef PYTHON3_HOME #ifdef PYTHON3_HOME
# ifdef DYNAMIC_PYTHON3 else if (mch_getenv((char_u *)"PYTHONHOME") == NULL)
if (mch_getenv((char_u *)"PYTHONHOME") == NULL)
# endif
Py_SetPythonHome(PYTHON3_HOME); Py_SetPythonHome(PYTHON3_HOME);
#endif #endif

View File

@@ -2246,6 +2246,15 @@ static struct vimoption options[] =
#else #else
(char_u *)NULL, PV_NONE, (char_u *)NULL, PV_NONE,
{(char_u *)NULL, (char_u *)0L} {(char_u *)NULL, (char_u *)0L}
#endif
SCRIPTID_INIT},
{"pythonthreehome", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
#if defined(FEAT_PYTHON3)
(char_u *)&p_py3home, PV_NONE,
{(char_u *)"", (char_u *)0L}
#else
(char_u *)NULL, PV_NONE,
{(char_u *)NULL, (char_u *)0L}
#endif #endif
SCRIPTID_INIT}, SCRIPTID_INIT},
{"pythondll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, {"pythondll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
@@ -2255,6 +2264,15 @@ static struct vimoption options[] =
#else #else
(char_u *)NULL, PV_NONE, (char_u *)NULL, PV_NONE,
{(char_u *)NULL, (char_u *)0L} {(char_u *)NULL, (char_u *)0L}
#endif
SCRIPTID_INIT},
{"pythonhome", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
#if defined(FEAT_PYTHON)
(char_u *)&p_pyhome, PV_NONE,
{(char_u *)"", (char_u *)0L}
#else
(char_u *)NULL, PV_NONE,
{(char_u *)NULL, (char_u *)0L}
#endif #endif
SCRIPTID_INIT}, SCRIPTID_INIT},
{"pyxversion", "pyx", P_NUM|P_VI_DEF|P_SECURE, {"pyxversion", "pyx", P_NUM|P_VI_DEF|P_SECURE,

View File

@@ -696,9 +696,15 @@ EXTERN char_u *p_perldll; /* 'perldll' */
#if defined(DYNAMIC_PYTHON3) #if defined(DYNAMIC_PYTHON3)
EXTERN char_u *p_py3dll; /* 'pythonthreedll' */ EXTERN char_u *p_py3dll; /* 'pythonthreedll' */
#endif #endif
#ifdef FEAT_PYTHON3
EXTERN char_u *p_py3home; /* 'pythonthreehome' */
#endif
#if defined(DYNAMIC_PYTHON) #if defined(DYNAMIC_PYTHON)
EXTERN char_u *p_pydll; /* 'pythondll' */ EXTERN char_u *p_pydll; /* 'pythondll' */
#endif #endif
#ifdef FEAT_PYTHON
EXTERN char_u *p_pyhome; /* 'pythonhome' */
#endif
#if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) #if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3)
EXTERN long p_pyx; /* 'pyxversion' */ EXTERN long p_pyx; /* 'pyxversion' */
#endif #endif

View File

@@ -4,7 +4,7 @@ void gui_mch_free_all(void);
int gui_mch_is_blinking(void); int gui_mch_is_blinking(void);
int gui_mch_is_blink_off(void); int gui_mch_is_blink_off(void);
void gui_mch_set_blinking(long waittime, long on, long off); void gui_mch_set_blinking(long waittime, long on, long off);
void gui_mch_stop_blink(void); void gui_mch_stop_blink(int may_call_gui_update_cursor);
void gui_mch_start_blink(void); void gui_mch_start_blink(void);
int gui_mch_early_init_check(int give_message); int gui_mch_early_init_check(int give_message);
int gui_mch_init_check(void); int gui_mch_init_check(void);
@@ -25,7 +25,7 @@ int gui_mch_maximized(void);
void gui_mch_unmaximize(void); void gui_mch_unmaximize(void);
void gui_mch_newfont(void); void gui_mch_newfont(void);
void gui_mch_set_shellsize(int width, int height, int min_width, int min_height, int base_width, int base_height, int direction); void gui_mch_set_shellsize(int width, int height, int min_width, int min_height, int base_width, int base_height, int direction);
void gui_gtk_get_screen_size_of_win(GtkWidget *win, int *width, int *height); void gui_gtk_get_screen_size_of_win(GtkWidget *wid, int *width, int *height);
void gui_mch_get_screen_dimensions(int *screen_w, int *screen_h); void gui_mch_get_screen_dimensions(int *screen_w, int *screen_h);
void gui_mch_settitle(char_u *title, char_u *icon); void gui_mch_settitle(char_u *title, char_u *icon);
void gui_mch_enable_menu(int showit); void gui_mch_enable_menu(int showit);

View File

@@ -17,7 +17,7 @@ short gui_mch_get_mac_menu_item_index(vimmenu_T *menu, vimmenu_T *parent);
int gui_mch_is_blinking(void); int gui_mch_is_blinking(void);
int gui_mch_is_blink_off(void); int gui_mch_is_blink_off(void);
void gui_mch_set_blinking(long wait, long on, long off); void gui_mch_set_blinking(long wait, long on, long off);
void gui_mch_stop_blink(void); void gui_mch_stop_blink(int may_call_gui_update_cursor);
void gui_mch_start_blink(void); void gui_mch_start_blink(void);
void gui_mch_getmouse(int *x, int *y); void gui_mch_getmouse(int *x, int *y);
void gui_mch_setmouse(int x, int y); void gui_mch_setmouse(int x, int y);

View File

@@ -44,7 +44,7 @@ int gui_mch_is_blinking(void);
int gui_mch_is_blink_off(void); int gui_mch_is_blink_off(void);
void gui_mch_set_blinking(long wait, long on, long off); void gui_mch_set_blinking(long wait, long on, long off);
void gui_mch_start_blink(void); void gui_mch_start_blink(void);
void gui_mch_stop_blink(void); void gui_mch_stop_blink(int may_call_gui_update_cursor);
void gui_mch_beep(void); void gui_mch_beep(void);
void gui_mch_flash(int msec); void gui_mch_flash(int msec);
void gui_mch_flush(void); void gui_mch_flush(void);

View File

@@ -3,7 +3,7 @@ int gui_mch_set_rendering_options(char_u *s);
int gui_mch_is_blinking(void); int gui_mch_is_blinking(void);
int gui_mch_is_blink_off(void); int gui_mch_is_blink_off(void);
void gui_mch_set_blinking(long wait, long on, long off); void gui_mch_set_blinking(long wait, long on, long off);
void gui_mch_stop_blink(void); void gui_mch_stop_blink(int may_call_gui_update_cursor);
void gui_mch_start_blink(void); void gui_mch_start_blink(void);
LRESULT WINAPI vim_WindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); LRESULT WINAPI vim_WindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
void gui_mch_new_colors(void); void gui_mch_new_colors(void);

View File

@@ -57,7 +57,7 @@ void gui_x11_menu_cb(Widget w, XtPointer client_data, XtPointer call_data);
int gui_mch_is_blinking(void); int gui_mch_is_blinking(void);
int gui_mch_is_blink_off(void); int gui_mch_is_blink_off(void);
void gui_mch_set_blinking(long waittime, long on, long off); void gui_mch_set_blinking(long waittime, long on, long off);
void gui_mch_stop_blink(void); void gui_mch_stop_blink(int may_call_gui_update_cursor);
void gui_mch_start_blink(void); void gui_mch_start_blink(void);
guicolor_T gui_mch_get_rgb(guicolor_T pixel); guicolor_T gui_mch_get_rgb(guicolor_T pixel);
void gui_x11_callbacks(Widget textArea, Widget vimForm); void gui_x11_callbacks(Widget textArea, Widget vimForm);

View File

@@ -771,6 +771,10 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
1451,
/**/
1450,
/**/ /**/
1449, 1449,
/**/ /**/