Mercurial > vim
comparison src/main.c @ 18104:e59ff7b5d7a7 v8.1.2047
patch 8.1.2047: cannot check the current state
Commit: https://github.com/vim/vim/commit/0e57dd859ecb1e8a3b91509d2f4343e839340eb8
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Sep 16 22:56:03 2019 +0200
patch 8.1.2047: cannot check the current state
Problem: Cannot check the current state.
Solution: Add the state() function.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 16 Sep 2019 23:00:04 +0200 |
parents | 0d9ec3a2821f |
children | b456bba1276a |
comparison
equal
deleted
inserted
replaced
18103:71bc51a0d8d8 | 18104:e59ff7b5d7a7 |
---|---|
1029 } | 1029 } |
1030 | 1030 |
1031 | 1031 |
1032 // When TRUE in a safe state when starting to wait for a character. | 1032 // When TRUE in a safe state when starting to wait for a character. |
1033 static int was_safe = FALSE; | 1033 static int was_safe = FALSE; |
1034 static oparg_T *current_oap = NULL; | |
1034 | 1035 |
1035 /* | 1036 /* |
1036 * Trigger SafeState if currently in a safe state for main_loop(). | 1037 * Return TRUE if an operator was started but not finished yet. |
1038 * Includes typing a count or a register name. | |
1037 */ | 1039 */ |
1038 static void | 1040 int |
1039 may_trigger_safestate_main(oparg_T *oap) | 1041 op_pending(void) |
1040 { | 1042 { |
1041 may_trigger_safestate( | 1043 return !(current_oap != NULL |
1042 !finish_op | 1044 && !finish_op |
1043 && oap->prev_opcount > 0 | 1045 && current_oap->prev_opcount == 0 |
1044 && oap->prev_count0 == 0 | 1046 && current_oap->prev_count0 == 0 |
1045 && oap->op_type == OP_NOP | 1047 && current_oap->op_type == OP_NOP |
1046 && oap->regname == NUL | 1048 && current_oap->regname == NUL); |
1047 && restart_edit == 0); | |
1048 } | 1049 } |
1049 | 1050 |
1050 /* | 1051 /* |
1051 * Trigger SafeState if currently in s safe state, that is "safe" is TRUE and | 1052 * Trigger SafeState if currently in s safe state, that is "safe" is TRUE and |
1052 * there is no typeahead. | 1053 * there is no typeahead. |
1098 void | 1099 void |
1099 main_loop( | 1100 main_loop( |
1100 int cmdwin, /* TRUE when working in the command-line window */ | 1101 int cmdwin, /* TRUE when working in the command-line window */ |
1101 int noexmode) /* TRUE when return on entering Ex mode */ | 1102 int noexmode) /* TRUE when return on entering Ex mode */ |
1102 { | 1103 { |
1103 oparg_T oa; /* operator arguments */ | 1104 oparg_T oa; // operator arguments |
1104 volatile int previous_got_int = FALSE; /* "got_int" was TRUE */ | 1105 oparg_T *prev_oap; // operator arguments |
1106 volatile int previous_got_int = FALSE; // "got_int" was TRUE | |
1105 #ifdef FEAT_CONCEAL | 1107 #ifdef FEAT_CONCEAL |
1106 /* these are static to avoid a compiler warning */ | 1108 // these are static to avoid a compiler warning |
1107 static linenr_T conceal_old_cursor_line = 0; | 1109 static linenr_T conceal_old_cursor_line = 0; |
1108 static linenr_T conceal_new_cursor_line = 0; | 1110 static linenr_T conceal_new_cursor_line = 0; |
1109 static int conceal_update_lines = FALSE; | 1111 static int conceal_update_lines = FALSE; |
1110 #endif | 1112 #endif |
1113 | |
1114 prev_oap = current_oap; | |
1115 current_oap = &oa; | |
1111 | 1116 |
1112 #if defined(FEAT_X11) && defined(FEAT_XCLIPBOARD) | 1117 #if defined(FEAT_X11) && defined(FEAT_XCLIPBOARD) |
1113 /* Setup to catch a terminating error from the X server. Just ignore | 1118 /* Setup to catch a terminating error from the X server. Just ignore |
1114 * it, restore the state and continue. This might not always work | 1119 * it, restore the state and continue. This might not always work |
1115 * properly, but at least we don't exit unexpectedly when the X server | 1120 * properly, but at least we don't exit unexpectedly when the X server |
1274 curbuf->b_last_changedtick = CHANGEDTICK(curbuf); | 1279 curbuf->b_last_changedtick = CHANGEDTICK(curbuf); |
1275 } | 1280 } |
1276 | 1281 |
1277 // If nothing is pending and we are going to wait for the user to | 1282 // If nothing is pending and we are going to wait for the user to |
1278 // type a character, trigger SafeState. | 1283 // type a character, trigger SafeState. |
1279 may_trigger_safestate_main(&oa); | 1284 may_trigger_safestate(!op_pending() && restart_edit == 0); |
1280 | 1285 |
1281 #if defined(FEAT_DIFF) | 1286 #if defined(FEAT_DIFF) |
1282 // Updating diffs from changed() does not always work properly, | 1287 // Updating diffs from changed() does not always work properly, |
1283 // esp. updating folds. Do an update just before redrawing if | 1288 // esp. updating folds. Do an update just before redrawing if |
1284 // needed. | 1289 // needed. |
1428 * Otherwise, get and execute a normal mode command. | 1433 * Otherwise, get and execute a normal mode command. |
1429 */ | 1434 */ |
1430 if (exmode_active) | 1435 if (exmode_active) |
1431 { | 1436 { |
1432 if (noexmode) /* End of ":global/path/visual" commands */ | 1437 if (noexmode) /* End of ":global/path/visual" commands */ |
1433 return; | 1438 goto theend; |
1434 do_exmode(exmode_active == EXMODE_VIM); | 1439 do_exmode(exmode_active == EXMODE_VIM); |
1435 } | 1440 } |
1436 else | 1441 else |
1437 { | 1442 { |
1438 #ifdef FEAT_TERMINAL | 1443 #ifdef FEAT_TERMINAL |
1455 #endif | 1460 #endif |
1456 normal_cmd(&oa, TRUE); | 1461 normal_cmd(&oa, TRUE); |
1457 } | 1462 } |
1458 } | 1463 } |
1459 } | 1464 } |
1465 | |
1466 theend: | |
1467 current_oap = prev_oap; | |
1460 } | 1468 } |
1461 | 1469 |
1462 | 1470 |
1463 #if defined(USE_XSMP) || defined(FEAT_GUI) || defined(PROTO) | 1471 #if defined(USE_XSMP) || defined(FEAT_GUI) || defined(PROTO) |
1464 /* | 1472 /* |