]> granicus.if.org Git - vim/commitdiff
patch 8.0.0396: 'balloonexpr' only works synchronously v8.0.0396
authorBram Moolenaar <Bram@vim.org>
Wed, 1 Mar 2017 19:32:44 +0000 (20:32 +0100)
committerBram Moolenaar <Bram@vim.org>
Wed, 1 Mar 2017 19:32:44 +0000 (20:32 +0100)
Problem:    'balloonexpr' only works synchronously.
Solution:   Add balloon_show(). (Jusufadis Bakamovic, closes #1449)

runtime/doc/eval.txt
src/evalfunc.c
src/os_unix.c
src/os_win32.c
src/version.c

index f2ec3063dd7f07be2ffbf286f372e4fdd891ae25..272c5ea1f838b328abcd80a41532634474f6f6d5 100644 (file)
@@ -1981,19 +1981,20 @@ argidx()                        Number  current index in the argument list
 arglistid([{winnr} [, {tabnr}]]) Number        argument list id
 argv({nr})                     String  {nr} entry of the argument list
 argv()                         List    the argument list
-assert_equal({exp}, {act} [, {msg}])     none  assert {exp} is equal to {act}
-assert_exception({error} [, {msg}])      none  assert {error} is in v:exception
-assert_fails({cmd} [, {error}])          none  assert {cmd} fails
-assert_false({actual} [, {msg}])         none  assert {actual} is false
+assert_equal({exp}, {act} [, {msg}])  none  assert {exp} is equal to {act}
+assert_exception({error} [, {msg}])   none  assert {error} is in v:exception
+assert_fails({cmd} [, {error}])              none  assert {cmd} fails
+assert_false({actual} [, {msg}])      none  assert {actual} is false
 assert_inrange({lower}, {upper}, {actual} [, {msg}])
                                none    assert {actual} is inside the range
-assert_match({pat}, {text} [, {msg}])    none  assert {pat} matches {text}
+assert_match({pat}, {text} [, {msg}])   none  assert {pat} matches {text}
 assert_notequal({exp}, {act} [, {msg}])  none  assert {exp} is not equal {act}
 assert_notmatch({pat}, {text} [, {msg}]) none  assert {pat} not matches {text}
-assert_true({actual} [, {msg}])          none  assert {actual} is true
+assert_true({actual} [, {msg}])                 none  assert {actual} is true
 asin({expr})                   Float   arc sine of {expr}
 atan({expr})                   Float   arc tangent of {expr}
 atan2({expr1}, {expr2})                Float   arc tangent of {expr1} / {expr2}
+balloon_show({msg})            none    show {msg} inside the balloon
 browse({save}, {title}, {initdir}, {default})
                                String  put up a file requester
 browsedir({title}, {initdir})  String  put up a directory requester
@@ -2619,6 +2620,25 @@ atan2({expr1}, {expr2})                                  *atan2()*
 <                      2.356194
                {only available when compiled with the |+float| feature}
 
+balloon_show({msg})                                     *balloon_show()*
+                Show {msg} inside the balloon.
+                Example: >
+                       func GetBalloonContent()
+                          " initiate getting the content
+                          return ''
+                       endfunc
+                       set balloonexpr=GetBalloonContent()
+
+                       func BalloonCallback(result)
+                          call balloon_show(a:result)
+                       endfunc
+<
+               The intended use is that fetching the content of the balloon
+               is initiated from 'balloonexpr'.  It will invoke an
+               asynchronous method, in which a callback invokes
+               balloon_show().  The 'balloonexpr' itself can return an
+               empty string or a placeholder.
+                {only available when compiled with the +beval feature}
 
                                                        *browse()*
 browse({save}, {title}, {initdir}, {default})
index a470ff996f504647b2897bc1615f89e12e79639f..70b90ad175355c082fe96e8fb625aa0dafe5fc5e 100644 (file)
@@ -58,6 +58,9 @@ static void f_asin(typval_T *argvars, typval_T *rettv);
 static void f_atan(typval_T *argvars, typval_T *rettv);
 static void f_atan2(typval_T *argvars, typval_T *rettv);
 #endif
+#ifdef FEAT_BEVAL
+static void f_balloon_show(typval_T *argvars, typval_T *rettv);
+#endif
 static void f_browse(typval_T *argvars, typval_T *rettv);
 static void f_browsedir(typval_T *argvars, typval_T *rettv);
 static void f_bufexists(typval_T *argvars, typval_T *rettv);
@@ -483,6 +486,9 @@ static struct fst
 #ifdef FEAT_FLOAT
     {"atan",           1, 1, f_atan},
     {"atan2",          2, 2, f_atan2},
+#endif
+#ifdef FEAT_BEVAL
+    {"balloon_show",   1, 1, f_balloon_show},
 #endif
     {"browse",         4, 4, f_browse},
     {"browsedir",      2, 2, f_browsedir},
@@ -1362,6 +1368,17 @@ f_atan2(typval_T *argvars, typval_T *rettv)
 }
 #endif
 
+/*
+ * "balloon_show()" function
+ */
+#ifdef FEAT_BEVAL
+    static void
+f_balloon_show(typval_T *argvars, typval_T *rettv UNUSED)
+{
+    gui_mch_post_balloon(balloonEval, get_tv_string_chk(&argvars[0]));
+}
+#endif
+
 /*
  * "browse(save, title, initdir, default)" function
  */
index 48359d31ea1217cd93616e0708c96f98f023f9a5..6220044b683d03e348a4c79da910c987109198db 100644 (file)
@@ -467,6 +467,12 @@ mch_inchar(
        if ((wait_time < 0 || wait_time > 100L) && channel_any_readahead())
            wait_time = 10L;
 #endif
+#ifdef FEAT_BEVAL
+       if (p_beval && wait_time > 100L)
+           /* The 'balloonexpr' may indirectly invoke a callback while waiting
+            * for a character, need to check often. */
+           wait_time = 100L;
+#endif
 
        /*
         * We want to be interrupted by the winch signal
index adbb199b9dfb45eafd0828e450e599b1066d8596..a3048427cd28b603f2fe46cace8844193fa4cc43 100644 (file)
@@ -1467,6 +1467,12 @@ WaitForChar(long msec)
                    dwWaitTime = 10;
            }
 #endif
+#ifdef FEAT_BEVAL
+           if (p_beval && dwWaitTime > 100)
+               /* The 'balloonexpr' may indirectly invoke a callback while
+                * waiting for a character, need to check often. */
+               dwWaitTime = 100;
+#endif
 #ifdef FEAT_MZSCHEME
            if (mzthreads_allowed() && p_mzq > 0
                                    && (msec < 0 || (long)dwWaitTime > p_mzq))
index 796162be8862595de57262cd86fbcb73492072fe..0c9731d3fc8b8f662232a3eb47d3c598c24323c0 100644 (file)
@@ -764,6 +764,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    396,
 /**/
     395,
 /**/