diff options
author | dundargoc <33953936+dundargoc@users.noreply.github.com> | 2021-09-17 16:38:16 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-17 07:38:16 -0700 |
commit | 867e8885991ae450019c18aa5e42546bd4b62c2c (patch) | |
tree | f130aaed5d3f46ce994871efad7e33f3dd3ef9b8 /src/nvim/normal.c | |
parent | 1ec3d37192194d6961621f17fc5a185356586339 (diff) | |
download | rneovim-867e8885991ae450019c18aa5e42546bd4b62c2c.tar.gz rneovim-867e8885991ae450019c18aa5e42546bd4b62c2c.tar.bz2 rneovim-867e8885991ae450019c18aa5e42546bd4b62c2c.zip |
refactor(style): switch-case formatting, "uncrustify:indent-off" #15669
* refactor: disable formatting for attribute in macro
* fixup: disable/enable uncrustify with uncrustify:indent-off/on
* fixup: stop indenting contents inside braces in case
* fixup: remove case brace if no variable declaration
Diffstat (limited to 'src/nvim/normal.c')
-rw-r--r-- | src/nvim/normal.c | 312 |
1 files changed, 155 insertions, 157 deletions
diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 51e6827636..b8a62a8fea 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -2473,60 +2473,58 @@ bool do_mouse(oparg_T *oap, int c, int dir, long count, bool fixindent) in_tab_line = true; c1 = tab_page_click_defs[mouse_col].tabnr; switch (tab_page_click_defs[mouse_col].type) { - case kStlClickDisabled: { - break; - } + case kStlClickDisabled: + break; case kStlClickTabClose: { - tabpage_T *tp; + tabpage_T *tp; - // Close the current or specified tab page. - if (c1 == 999) { - tp = curtab; - } else { - tp = find_tabpage(c1); - } - if (tp == curtab) { - if (first_tabpage->tp_next != NULL) { - tabpage_close(false); - } - } else if (tp != NULL) { - tabpage_close_other(tp, false); + // Close the current or specified tab page. + if (c1 == 999) { + tp = curtab; + } else { + tp = find_tabpage(c1); + } + if (tp == curtab) { + if (first_tabpage->tp_next != NULL) { + tabpage_close(false); } - break; + } else if (tp != NULL) { + tabpage_close_other(tp, false); } - case kStlClickTabSwitch: { - if ((mod_mask & MOD_MASK_MULTI_CLICK) == MOD_MASK_2CLICK) { - // double click opens new page - end_visual_mode(); - tabpage_new(); - tabpage_move(c1 == 0 ? 9999 : c1 - 1); - } else { - // Go to specified tab page, or next one if not clicking - // on a label. - goto_tabpage(c1); + break; + } + case kStlClickTabSwitch: + if ((mod_mask & MOD_MASK_MULTI_CLICK) == MOD_MASK_2CLICK) { + // double click opens new page + end_visual_mode(); + tabpage_new(); + tabpage_move(c1 == 0 ? 9999 : c1 - 1); + } else { + // Go to specified tab page, or next one if not clicking + // on a label. + goto_tabpage(c1); - // It's like clicking on the status line of a window. - if (curwin != old_curwin) { - end_visual_mode(); - } + // It's like clicking on the status line of a window. + if (curwin != old_curwin) { + end_visual_mode(); } - break; } + break; case kStlClickFuncRun: { - typval_T argv[] = { - { - .v_lock = VAR_FIXED, - .v_type = VAR_NUMBER, - .vval = { - .v_number = (varnumber_T)tab_page_click_defs[mouse_col].tabnr - }, + typval_T argv[] = { + { + .v_lock = VAR_FIXED, + .v_type = VAR_NUMBER, + .vval = { + .v_number = (varnumber_T)tab_page_click_defs[mouse_col].tabnr }, - { - .v_lock = VAR_FIXED, - .v_type = VAR_NUMBER, - .vval = { - .v_number = (((mod_mask & MOD_MASK_MULTI_CLICK) - == MOD_MASK_4CLICK) + }, + { + .v_lock = VAR_FIXED, + .v_type = VAR_NUMBER, + .vval = { + .v_number = (((mod_mask & MOD_MASK_MULTI_CLICK) + == MOD_MASK_4CLICK) ? 4 : ((mod_mask & MOD_MASK_MULTI_CLICK) == MOD_MASK_3CLICK) @@ -2535,43 +2533,43 @@ bool do_mouse(oparg_T *oap, int c, int dir, long count, bool fixindent) == MOD_MASK_2CLICK) ? 2 : 1) - }, }, - { - .v_lock = VAR_FIXED, - .v_type = VAR_STRING, - .vval = { .v_string = (char_u *)(which_button == MOUSE_LEFT + }, + { + .v_lock = VAR_FIXED, + .v_type = VAR_STRING, + .vval = { .v_string = (char_u *)(which_button == MOUSE_LEFT ? "l" : which_button == MOUSE_RIGHT ? "r" : which_button == MOUSE_MIDDLE ? "m" : "?") }, + }, + { + .v_lock = VAR_FIXED, + .v_type = VAR_STRING, + .vval = { + .v_string = (char_u[]) { + (char_u)(mod_mask & MOD_MASK_SHIFT ? 's' : ' '), + (char_u)(mod_mask & MOD_MASK_CTRL ? 'c' : ' '), + (char_u)(mod_mask & MOD_MASK_ALT ? 'a' : ' '), + (char_u)(mod_mask & MOD_MASK_META ? 'm' : ' '), + NUL + } }, - { - .v_lock = VAR_FIXED, - .v_type = VAR_STRING, - .vval = { - .v_string = (char_u[]) { - (char_u)(mod_mask & MOD_MASK_SHIFT ? 's' : ' '), - (char_u)(mod_mask & MOD_MASK_CTRL ? 'c' : ' '), - (char_u)(mod_mask & MOD_MASK_ALT ? 'a' : ' '), - (char_u)(mod_mask & MOD_MASK_META ? 'm' : ' '), - NUL - } - }, - } - }; - typval_T rettv; - funcexe_T funcexe = FUNCEXE_INIT; - funcexe.firstline = curwin->w_cursor.lnum; - funcexe.lastline = curwin->w_cursor.lnum; - funcexe.evaluate = true; - (void)call_func((char_u *)tab_page_click_defs[mouse_col].func, -1, - &rettv, ARRAY_SIZE(argv), argv, &funcexe); - tv_clear(&rettv); - break; - } + } + }; + typval_T rettv; + funcexe_T funcexe = FUNCEXE_INIT; + funcexe.firstline = curwin->w_cursor.lnum; + funcexe.lastline = curwin->w_cursor.lnum; + funcexe.evaluate = true; + (void)call_func((char_u *)tab_page_click_defs[mouse_col].func, -1, + &rettv, ARRAY_SIZE(argv), argv, &funcexe); + tv_clear(&rettv); + break; + } } } return true; @@ -4701,42 +4699,42 @@ dozet: case 'w': // "zw": add wrong word to word list case 'G': // "zG": add good word to temp word list case 'W': // "zW": add wrong word to temp word list - { - char_u *ptr = NULL; - size_t len; + { + char_u *ptr = NULL; + size_t len; - if (checkclearop(cap->oap)) { - break; - } - if (VIsual_active && !get_visual_text(cap, &ptr, &len)) { - return; - } - if (ptr == NULL) { - pos_T pos = curwin->w_cursor; - - /* Find bad word under the cursor. When 'spell' is - * off this fails and find_ident_under_cursor() is - * used below. */ - emsg_off++; - len = spell_move_to(curwin, FORWARD, true, true, NULL); - emsg_off--; - if (len != 0 && curwin->w_cursor.col <= pos.col) { - ptr = ml_get_pos(&curwin->w_cursor); - } - curwin->w_cursor = pos; - } + if (checkclearop(cap->oap)) { + break; + } + if (VIsual_active && !get_visual_text(cap, &ptr, &len)) { + return; + } + if (ptr == NULL) { + pos_T pos = curwin->w_cursor; - if (ptr == NULL && (len = find_ident_under_cursor(&ptr, FIND_IDENT)) == 0) { - return; + /* Find bad word under the cursor. When 'spell' is + * off this fails and find_ident_under_cursor() is + * used below. */ + emsg_off++; + len = spell_move_to(curwin, FORWARD, true, true, NULL); + emsg_off--; + if (len != 0 && curwin->w_cursor.col <= pos.col) { + ptr = ml_get_pos(&curwin->w_cursor); } - assert(len <= INT_MAX); - spell_add_word(ptr, (int)len, - nchar == 'w' || nchar == 'W' - ? SPELL_ADD_BAD : SPELL_ADD_GOOD, - (nchar == 'G' || nchar == 'W') ? 0 : (int)cap->count1, - undo); + curwin->w_cursor = pos; } - break; + + if (ptr == NULL && (len = find_ident_under_cursor(&ptr, FIND_IDENT)) == 0) { + return; + } + assert(len <= INT_MAX); + spell_add_word(ptr, (int)len, + nchar == 'w' || nchar == 'W' + ? SPELL_ADD_BAD : SPELL_ADD_GOOD, + (nchar == 'G' || nchar == 'W') ? 0 : (int)cap->count1, + undo); + } + break; case '=': // "z=": suggestions for a badly spelled word if (!checkclearop(cap->oap)) { @@ -7055,19 +7053,19 @@ static void nv_g_cmd(cmdarg_T *cap) break; case 'M': { - const char_u *const ptr = get_cursor_line_ptr(); + const char_u *const ptr = get_cursor_line_ptr(); - oap->motion_type = kMTCharWise; - oap->inclusive = false; - i = (int)mb_string2cells_len(ptr, STRLEN(ptr)); - if (cap->count0 > 0 && cap->count0 <= 100) { - coladvance((colnr_T)(i * cap->count0 / 100)); - } else { - coladvance((colnr_T)(i / 2)); - } - curwin->w_set_curswant = true; + oap->motion_type = kMTCharWise; + oap->inclusive = false; + i = (int)mb_string2cells_len(ptr, STRLEN(ptr)); + if (cap->count0 > 0 && cap->count0 <= 100) { + coladvance((colnr_T)(i * cap->count0 / 100)); + } else { + coladvance((colnr_T)(i / 2)); } - break; + curwin->w_set_curswant = true; + } + break; case '_': /* "g_": to the last non-blank character in the line or <count> lines @@ -7099,57 +7097,57 @@ static void nv_g_cmd(cmdarg_T *cap) case '$': case K_END: case K_KEND: { - int col_off = curwin_col_off(); - - oap->motion_type = kMTCharWise; - oap->inclusive = true; - if (curwin->w_p_wrap - && curwin->w_width_inner != 0) { - curwin->w_curswant = MAXCOL; // so we stay at the end - if (cap->count1 == 1) { - int width1 = curwin->w_width_inner - col_off; - int width2 = width1 + curwin_col_off2(); + int col_off = curwin_col_off(); - validate_virtcol(); - i = width1 - 1; - if (curwin->w_virtcol >= (colnr_T)width1) { - i += ((curwin->w_virtcol - width1) / width2 + 1) - * width2; - } - coladvance((colnr_T)i); + oap->motion_type = kMTCharWise; + oap->inclusive = true; + if (curwin->w_p_wrap + && curwin->w_width_inner != 0) { + curwin->w_curswant = MAXCOL; // so we stay at the end + if (cap->count1 == 1) { + int width1 = curwin->w_width_inner - col_off; + int width2 = width1 + curwin_col_off2(); - // Make sure we stick in this column. - validate_virtcol(); - curwin->w_curswant = curwin->w_virtcol; - curwin->w_set_curswant = false; - if (curwin->w_cursor.col > 0 && curwin->w_p_wrap) { - /* - * Check for landing on a character that got split at - * the end of the line. We do not want to advance to - * the next screen line. - */ - if (curwin->w_virtcol > (colnr_T)i) { - --curwin->w_cursor.col; - } - } - } else if (nv_screengo(oap, FORWARD, cap->count1 - 1) == false) { - clearopbeep(oap); - } - } else { - if (cap->count1 > 1) { - // if it fails, let the cursor still move to the last char - (void)cursor_down(cap->count1 - 1, false); + validate_virtcol(); + i = width1 - 1; + if (curwin->w_virtcol >= (colnr_T)width1) { + i += ((curwin->w_virtcol - width1) / width2 + 1) + * width2; } - i = curwin->w_leftcol + curwin->w_width_inner - col_off - 1; coladvance((colnr_T)i); // Make sure we stick in this column. validate_virtcol(); curwin->w_curswant = curwin->w_virtcol; curwin->w_set_curswant = false; + if (curwin->w_cursor.col > 0 && curwin->w_p_wrap) { + /* + * Check for landing on a character that got split at + * the end of the line. We do not want to advance to + * the next screen line. + */ + if (curwin->w_virtcol > (colnr_T)i) { + --curwin->w_cursor.col; + } + } + } else if (nv_screengo(oap, FORWARD, cap->count1 - 1) == false) { + clearopbeep(oap); + } + } else { + if (cap->count1 > 1) { + // if it fails, let the cursor still move to the last char + (void)cursor_down(cap->count1 - 1, false); } + i = curwin->w_leftcol + curwin->w_width_inner - col_off - 1; + coladvance((colnr_T)i); + + // Make sure we stick in this column. + validate_virtcol(); + curwin->w_curswant = curwin->w_virtcol; + curwin->w_set_curswant = false; } - break; + } + break; /* * "g*" and "g#", like "*" and "#" but without using "\<" and "\>" |