comparison src/normal.c @ 12515:972ea22c946f v8.0.1136

patch 8.0.1136: W_WIDTH() is always the same commit https://github.com/vim/vim/commit/0263146b5dbbb6c120ce2e7720256503b864425d Author: Bram Moolenaar <Bram@vim.org> Date: Fri Sep 22 15:20:32 2017 +0200 patch 8.0.1136: W_WIDTH() is always the same Problem: W_WIDTH() is always the same. Solution: Expand the macro.
author Christian Brabandt <cb@256bit.org>
date Fri, 22 Sep 2017 15:30:06 +0200
parents 3f16cf18386c
children f62696bd1a9f
comparison
equal deleted inserted replaced
12514:55f1b7ff0467 12515:972ea22c946f
4446 oap->motion_type = MCHAR; 4446 oap->motion_type = MCHAR;
4447 oap->inclusive = (curwin->w_curswant == MAXCOL); 4447 oap->inclusive = (curwin->w_curswant == MAXCOL);
4448 4448
4449 col_off1 = curwin_col_off(); 4449 col_off1 = curwin_col_off();
4450 col_off2 = col_off1 - curwin_col_off2(); 4450 col_off2 = col_off1 - curwin_col_off2();
4451 width1 = W_WIDTH(curwin) - col_off1; 4451 width1 = curwin->w_width - col_off1;
4452 width2 = W_WIDTH(curwin) - col_off2; 4452 width2 = curwin->w_width - col_off2;
4453 if (width2 == 0) 4453 if (width2 == 0)
4454 width2 = 1; /* avoid divide by zero */ 4454 width2 = 1; /* avoid divide by zero */
4455 4455
4456 if (curwin->w_width != 0) 4456 if (curwin->w_width != 0)
4457 { 4457 {
4632 if (!curwin->w_p_wrap) 4632 if (!curwin->w_p_wrap)
4633 { 4633 {
4634 int val, step = 6; 4634 int val, step = 6;
4635 4635
4636 if (mod_mask & (MOD_MASK_SHIFT | MOD_MASK_CTRL)) 4636 if (mod_mask & (MOD_MASK_SHIFT | MOD_MASK_CTRL))
4637 step = W_WIDTH(curwin); 4637 step = curwin->w_width;
4638 val = curwin->w_leftcol + (cap->arg == MSCR_RIGHT ? -step : +step); 4638 val = curwin->w_leftcol + (cap->arg == MSCR_RIGHT ? -step : +step);
4639 if (val < 0) 4639 if (val < 0)
4640 val = 0; 4640 val = 0;
4641 4641
4642 gui_do_horiz_scroll(val, TRUE); 4642 gui_do_horiz_scroll(val, TRUE);
4884 set_fraction(curwin); 4884 set_fraction(curwin);
4885 break; 4885 break;
4886 4886
4887 /* "zH" - scroll screen right half-page */ 4887 /* "zH" - scroll screen right half-page */
4888 case 'H': 4888 case 'H':
4889 cap->count1 *= W_WIDTH(curwin) / 2; 4889 cap->count1 *= curwin->w_width / 2;
4890 /* FALLTHROUGH */ 4890 /* FALLTHROUGH */
4891 4891
4892 /* "zh" - scroll screen to the right */ 4892 /* "zh" - scroll screen to the right */
4893 case 'h': 4893 case 'h':
4894 case K_LEFT: 4894 case K_LEFT:
4901 leftcol_changed(); 4901 leftcol_changed();
4902 } 4902 }
4903 break; 4903 break;
4904 4904
4905 /* "zL" - scroll screen left half-page */ 4905 /* "zL" - scroll screen left half-page */
4906 case 'L': cap->count1 *= W_WIDTH(curwin) / 2; 4906 case 'L': cap->count1 *= curwin->w_width / 2;
4907 /* FALLTHROUGH */ 4907 /* FALLTHROUGH */
4908 4908
4909 /* "zl" - scroll screen to the left */ 4909 /* "zl" - scroll screen to the left */
4910 case 'l': 4910 case 'l':
4911 case K_RIGHT: 4911 case K_RIGHT:
4945 if (hasFolding(curwin->w_cursor.lnum, NULL, NULL)) 4945 if (hasFolding(curwin->w_cursor.lnum, NULL, NULL))
4946 col = 0; /* like the cursor is in col 0 */ 4946 col = 0; /* like the cursor is in col 0 */
4947 else 4947 else
4948 #endif 4948 #endif
4949 getvcol(curwin, &curwin->w_cursor, NULL, NULL, &col); 4949 getvcol(curwin, &curwin->w_cursor, NULL, NULL, &col);
4950 n = W_WIDTH(curwin) - curwin_col_off(); 4950 n = curwin->w_width - curwin_col_off();
4951 if ((long)col + p_siso < n) 4951 if ((long)col + p_siso < n)
4952 col = 0; 4952 col = 0;
4953 else 4953 else
4954 col = col + p_siso - n + 1; 4954 col = col + p_siso - n + 1;
4955 if (curwin->w_leftcol != col) 4955 if (curwin->w_leftcol != col)
8071 case K_KHOME: 8071 case K_KHOME:
8072 oap->motion_type = MCHAR; 8072 oap->motion_type = MCHAR;
8073 oap->inclusive = FALSE; 8073 oap->inclusive = FALSE;
8074 if (curwin->w_p_wrap && curwin->w_width != 0) 8074 if (curwin->w_p_wrap && curwin->w_width != 0)
8075 { 8075 {
8076 int width1 = W_WIDTH(curwin) - curwin_col_off(); 8076 int width1 = curwin->w_width - curwin_col_off();
8077 int width2 = width1 + curwin_col_off2(); 8077 int width2 = width1 + curwin_col_off2();
8078 8078
8079 validate_virtcol(); 8079 validate_virtcol();
8080 i = 0; 8080 i = 0;
8081 if (curwin->w_virtcol >= (colnr_T)width1 && width2 > 0) 8081 if (curwin->w_virtcol >= (colnr_T)width1 && width2 > 0)
8085 i = curwin->w_leftcol; 8085 i = curwin->w_leftcol;
8086 /* Go to the middle of the screen line. When 'number' or 8086 /* Go to the middle of the screen line. When 'number' or
8087 * 'relativenumber' is on and lines are wrapping the middle can be more 8087 * 'relativenumber' is on and lines are wrapping the middle can be more
8088 * to the left. */ 8088 * to the left. */
8089 if (cap->nchar == 'm') 8089 if (cap->nchar == 'm')
8090 i += (W_WIDTH(curwin) - curwin_col_off() 8090 i += (curwin->w_width - curwin_col_off()
8091 + ((curwin->w_p_wrap && i > 0) 8091 + ((curwin->w_p_wrap && i > 0)
8092 ? curwin_col_off2() : 0)) / 2; 8092 ? curwin_col_off2() : 0)) / 2;
8093 coladvance((colnr_T)i); 8093 coladvance((colnr_T)i);
8094 if (flag) 8094 if (flag)
8095 { 8095 {
8137 if (curwin->w_p_wrap && curwin->w_width != 0) 8137 if (curwin->w_p_wrap && curwin->w_width != 0)
8138 { 8138 {
8139 curwin->w_curswant = MAXCOL; /* so we stay at the end */ 8139 curwin->w_curswant = MAXCOL; /* so we stay at the end */
8140 if (cap->count1 == 1) 8140 if (cap->count1 == 1)
8141 { 8141 {
8142 int width1 = W_WIDTH(curwin) - col_off; 8142 int width1 = curwin->w_width - col_off;
8143 int width2 = width1 + curwin_col_off2(); 8143 int width2 = width1 + curwin_col_off2();
8144 8144
8145 validate_virtcol(); 8145 validate_virtcol();
8146 i = width1 - 1; 8146 i = width1 - 1;
8147 if (curwin->w_virtcol >= (colnr_T)width1) 8147 if (curwin->w_virtcol >= (colnr_T)width1)
8169 else if (nv_screengo(oap, FORWARD, cap->count1 - 1) == FAIL) 8169 else if (nv_screengo(oap, FORWARD, cap->count1 - 1) == FAIL)
8170 clearopbeep(oap); 8170 clearopbeep(oap);
8171 } 8171 }
8172 else 8172 else
8173 { 8173 {
8174 i = curwin->w_leftcol + W_WIDTH(curwin) - col_off - 1; 8174 i = curwin->w_leftcol + curwin->w_width - col_off - 1;
8175 coladvance((colnr_T)i); 8175 coladvance((colnr_T)i);
8176 8176
8177 /* Make sure we stick in this column. */ 8177 /* Make sure we stick in this column. */
8178 validate_virtcol(); 8178 validate_virtcol();
8179 curwin->w_curswant = curwin->w_virtcol; 8179 curwin->w_curswant = curwin->w_virtcol;
9563 int initial) /* when TRUE adjust position for 'selectmode' */ 9563 int initial) /* when TRUE adjust position for 'selectmode' */
9564 { 9564 {
9565 colnr_T start, end; 9565 colnr_T start, end;
9566 9566
9567 if (VIsual_mode != Ctrl_V 9567 if (VIsual_mode != Ctrl_V
9568 || (!initial && oap->end.col < W_WIDTH(curwin))) 9568 || (!initial && oap->end.col < curwin->w_width))
9569 return; 9569 return;
9570 9570
9571 oap->block_mode = TRUE; 9571 oap->block_mode = TRUE;
9572 9572
9573 #ifdef FEAT_MBYTE 9573 #ifdef FEAT_MBYTE