Mercurial > vim
comparison src/ex_cmds2.c @ 12865:ebb4f6c93598 v8.0.1309
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
commit https://github.com/vim/vim/commit/51b0f3701ecb440aa72ab6017c1df6940c0e0f6f
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Nov 18 18:52:04 2017 +0100
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Problem: Cannot use 'balloonexpr' in a terminal.
Solution: Add 'balloonevalterm' and add code to handle mouse movements in a
terminal. Initial implementation for Unix with GUI.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sat, 18 Nov 2017 19:00:06 +0100 |
parents | 116b7394b8af |
children | 1a450ce6980c |
comparison
equal
deleted
inserted
replaced
12864:e98532b79dba | 12865:ebb4f6c93598 |
---|---|
1091 # if defined(FEAT_TIMERS) || defined(PROTO) | 1091 # if defined(FEAT_TIMERS) || defined(PROTO) |
1092 static timer_T *first_timer = NULL; | 1092 static timer_T *first_timer = NULL; |
1093 static long last_timer_id = 0; | 1093 static long last_timer_id = 0; |
1094 | 1094 |
1095 static long | 1095 static long |
1096 timer_time_left(timer_T *timer, proftime_T *now) | 1096 proftime_time_left(proftime_T *due, proftime_T *now) |
1097 { | 1097 { |
1098 # ifdef WIN3264 | 1098 # ifdef WIN3264 |
1099 LARGE_INTEGER fr; | 1099 LARGE_INTEGER fr; |
1100 | 1100 |
1101 if (now->QuadPart > timer->tr_due.QuadPart) | 1101 if (now->QuadPart > due->QuadPart) |
1102 return 0; | 1102 return 0; |
1103 QueryPerformanceFrequency(&fr); | 1103 QueryPerformanceFrequency(&fr); |
1104 return (long)(((double)(timer->tr_due.QuadPart - now->QuadPart) | 1104 return (long)(((double)(due->QuadPart - now->QuadPart) |
1105 / (double)fr.QuadPart) * 1000); | 1105 / (double)fr.QuadPart) * 1000); |
1106 # else | 1106 # else |
1107 if (now->tv_sec > timer->tr_due.tv_sec) | 1107 if (now->tv_sec > due->tv_sec) |
1108 return 0; | 1108 return 0; |
1109 return (timer->tr_due.tv_sec - now->tv_sec) * 1000 | 1109 return (due->tv_sec - now->tv_sec) * 1000 |
1110 + (timer->tr_due.tv_usec - now->tv_usec) / 1000; | 1110 + (due->tv_usec - now->tv_usec) / 1000; |
1111 # endif | 1111 # endif |
1112 } | 1112 } |
1113 | 1113 |
1114 /* | 1114 /* |
1115 * Insert a timer in the list of timers. | 1115 * Insert a timer in the list of timers. |
1217 { | 1217 { |
1218 timer_next = timer->tr_next; | 1218 timer_next = timer->tr_next; |
1219 | 1219 |
1220 if (timer->tr_id == -1 || timer->tr_firing || timer->tr_paused) | 1220 if (timer->tr_id == -1 || timer->tr_firing || timer->tr_paused) |
1221 continue; | 1221 continue; |
1222 this_due = timer_time_left(timer, &now); | 1222 this_due = proftime_time_left(&timer->tr_due, &now); |
1223 if (this_due <= 1) | 1223 if (this_due <= 1) |
1224 { | 1224 { |
1225 int save_timer_busy = timer_busy; | 1225 int save_timer_busy = timer_busy; |
1226 int save_vgetc_busy = vgetc_busy; | 1226 int save_vgetc_busy = vgetc_busy; |
1227 int save_did_emsg = did_emsg; | 1227 int save_did_emsg = did_emsg; |
1269 * called while inside the callback (tr_id == -1). */ | 1269 * called while inside the callback (tr_id == -1). */ |
1270 if (timer->tr_repeat != 0 && timer->tr_id != -1 | 1270 if (timer->tr_repeat != 0 && timer->tr_id != -1 |
1271 && timer->tr_emsg_count < 3) | 1271 && timer->tr_emsg_count < 3) |
1272 { | 1272 { |
1273 profile_setlimit(timer->tr_interval, &timer->tr_due); | 1273 profile_setlimit(timer->tr_interval, &timer->tr_due); |
1274 this_due = timer_time_left(timer, &now); | 1274 this_due = proftime_time_left(&timer->tr_due, &now); |
1275 if (this_due < 1) | 1275 if (this_due < 1) |
1276 this_due = 1; | 1276 this_due = 1; |
1277 if (timer->tr_repeat > 0) | 1277 if (timer->tr_repeat > 0) |
1278 --timer->tr_repeat; | 1278 --timer->tr_repeat; |
1279 } | 1279 } |
1289 } | 1289 } |
1290 | 1290 |
1291 if (did_one) | 1291 if (did_one) |
1292 redraw_after_callback(need_update_screen); | 1292 redraw_after_callback(need_update_screen); |
1293 | 1293 |
1294 #ifdef FEAT_BEVALTERM | |
1295 if (bevalexpr_due_set) | |
1296 { | |
1297 this_due = proftime_time_left(&bevalexpr_due, &now); | |
1298 if (this_due <= 1) | |
1299 { | |
1300 bevalexpr_due_set = FALSE; | |
1301 | |
1302 if (balloonEval == NULL) | |
1303 { | |
1304 balloonEval = (BalloonEval *)alloc(sizeof(BalloonEval)); | |
1305 balloonEvalForTerm = TRUE; | |
1306 } | |
1307 if (balloonEval != NULL) | |
1308 general_beval_cb(balloonEval, 0); | |
1309 } | |
1310 else if (this_due > 0 && (next_due == -1 || next_due > this_due)) | |
1311 next_due = this_due; | |
1312 } | |
1313 #endif | |
1314 | |
1294 return current_id != last_timer_id ? 1 : next_due; | 1315 return current_id != last_timer_id ? 1 : next_due; |
1295 } | 1316 } |
1296 | 1317 |
1297 /* | 1318 /* |
1298 * Find a timer by ID. Returns NULL if not found; | 1319 * Find a timer by ID. Returns NULL if not found; |
1356 | 1377 |
1357 dict_add_nr_str(dict, "id", timer->tr_id, NULL); | 1378 dict_add_nr_str(dict, "id", timer->tr_id, NULL); |
1358 dict_add_nr_str(dict, "time", (long)timer->tr_interval, NULL); | 1379 dict_add_nr_str(dict, "time", (long)timer->tr_interval, NULL); |
1359 | 1380 |
1360 profile_start(&now); | 1381 profile_start(&now); |
1361 remaining = timer_time_left(timer, &now); | 1382 remaining = proftime_time_left(&timer->tr_due, &now); |
1362 dict_add_nr_str(dict, "remaining", (long)remaining, NULL); | 1383 dict_add_nr_str(dict, "remaining", (long)remaining, NULL); |
1363 | 1384 |
1364 dict_add_nr_str(dict, "repeat", | 1385 dict_add_nr_str(dict, "repeat", |
1365 (long)(timer->tr_repeat < 0 ? -1 : timer->tr_repeat + 1), NULL); | 1386 (long)(timer->tr_repeat < 0 ? -1 : timer->tr_repeat + 1), NULL); |
1366 dict_add_nr_str(dict, "paused", (long)(timer->tr_paused), NULL); | 1387 dict_add_nr_str(dict, "paused", (long)(timer->tr_paused), NULL); |