# Patch to add Chinese support for vim-4.2 # Should work for BIG5(tested) and GB(not tested) on cxterm, crxvt, # and DOS+ET # This Chinese version of vim includes some vi's features which are # not supported by celvis-1.3, such as line number, line wrap, and # large file editing. For additional features of vim, read the # document of vim itself. # Please send bugs and comment to: # wchwang@csie.nctu.edu.tw # File list: # - vim-4.2-Chinese-patch patch to apply to vim-4.2 # - vim-4.2.tar.gz vim-4.2 source # - cvim-dos.zip excutable for DOS # - cvim-djg.zip excutable for DOS, compiled by djgpp # - cvim-w32.zip excutable for win32(win95,NT) # # To apply this patch: # % cd vim-4.2/src # % patch < patch-file-name # diff -c ../src/charset.c ./charset.c *** ../src/charset.c Mon Jun 10 05:35:01 1996 --- ./charset.c Tue Oct 22 13:44:31 1996 *************** *** 325,333 **** --- 325,350 ---- char_u *s; { colnr_t col = 0; + #ifdef HZ + char_u *tmp_ptr; + #endif + #ifdef HZ + tmp_ptr = s; + #endif while (*s != NUL) + #ifdef HZ /* HZWRAP */ + { + #endif col += lbr_chartabsize(s++, col); + #ifdef HZ + if (curwin->w_p_wrap && + ((col+(curwin->w_p_nu? 8:0)-1) % (colnr_t)Columns) == + (colnr_t)Columns - 2 && + IsIdxHZ((int)s - (int)tmp_ptr, tmp_ptr) == 1 ) + col++; + } + #endif return (int)col; } *************** *** 483,491 **** --- 500,514 ---- int head; int ts = wp->w_buffer->b_p_ts; int c; + #ifdef HZ + char_u *tmp_ptr; + #endif vcol = 0; ptr = ml_get_buf(wp->w_buffer, pos->lnum, FALSE); + #ifdef HZ + tmp_ptr = ptr; + #endif /* * This function is used very often, do some speed optimizations. *************** *** 513,518 **** --- 536,548 ---- break; vcol += incr; + #ifdef HZ /* HZWRAP (ignore wrap mark for HZ char) */ + if (wp->w_p_wrap && + ((vcol+(wp->w_p_nu? 8:0)-1) % (colnr_t)Columns) == + (colnr_t)Columns - 2 && + IsIdxHZ((int)ptr - (int)tmp_ptr,tmp_ptr+1) == 1) + vcol++; + #endif } } else *************** *** 533,538 **** --- 563,575 ---- break; vcol += incr; + #ifdef HZ /* HZWRAP */ + if (wp->w_p_wrap && + ((vcol+(wp->w_p_nu? 8:0)-1) % (colnr_t)Columns) == + (colnr_t)Columns - 2 && + IsIdxHZ((int)ptr - (int)tmp_ptr, tmp_ptr+1) == 1 ) + vcol++; + #endif } } if (start != NULL) Only in .: charset.c.bak diff -c ../src/cmdcmds.c ./cmdcmds.c *** ../src/cmdcmds.c Tue Jun 18 06:24:54 1996 --- ./cmdcmds.c Tue Oct 22 13:45:12 1996 *************** *** 246,251 **** --- 246,258 ---- if (ptr[col] == NUL) break; vcol += chartabsize(ptr[col++], (colnr_t)vcol); + #ifdef HZ /* HZWRAP */ + if (curwin->w_p_wrap && + ((vcol+(curwin->w_p_nu?8:0)-1) % (colnr_t)Columns) == + (colnr_t)Columns - 2 && + IsIdxHZ(col, ptr) == 1 ) + vcol++; + #endif } if (new_line == NULL) /* out of memory */ break; Only in .: cmdcmds.c.bak diff -c ../src/edit.c ./edit.c *** ../src/edit.c Mon Jun 10 05:35:01 1996 --- ./edit.c Tue Oct 22 13:46:26 1996 *************** *** 603,608 **** --- 603,612 ---- #endif ) --curwin->w_cursor.col; + #ifdef HZ + if (IsIdxHZ(curwin->w_cursor.col,ml_get_curline()) == -1) + --curwin->w_cursor.col; + #endif if (State == REPLACE) replace_flush(); /* free replace stack */ State = NORMAL; *************** *** 1094,1099 **** --- 1098,1108 ---- undisplay_dollar(); if (gchar_cursor() != NUL) { + #ifdef HZ + tmp_ptr = ml_get(curwin->w_cursor.lnum); + if (IsIdxHZ(curwin->w_cursor.col, tmp_ptr) == 1 && tmp_ptr[curwin->w_cursor.col+1] != NUL) + ++curwin->w_cursor.col; + #endif start_arrow(&curwin->w_cursor); curwin->w_set_curswant = TRUE; ++curwin->w_cursor.col; *************** *** 1758,1765 **** --- 1767,1788 ---- /* try to advance to the cursor column */ temp = 0; ptr = ml_get(lnum); + #ifdef HZ + tmp_ptr = ptr; + #endif while ((colnr_t)temp < curwin->w_virtcol && *ptr) + #ifdef HZ + { + #endif temp += lbr_chartabsize(ptr++, (colnr_t)temp); + #ifdef HZ /* HZWRAP */ + if (curwin->w_p_wrap && + ((temp+(curwin->w_p_nu? 8:0)-1) % (colnr_t)Columns) == + (colnr_t)Columns - 2 && + IsIdxHZ((int)ptr - (int)tmp_ptr, tmp_ptr) == 1 ) + temp++; + } + #endif if ((colnr_t)temp > curwin->w_virtcol) --ptr; *************** *** 1858,1863 **** --- 1881,1928 ---- if (iswordchar(c) || !echeck_abbr(c)) { + #ifdef HZ + if (dollar_vcol) { + curs_columns(FALSE); + if (!curwin->w_p_wrap) + curwin->w_col -= curwin->w_leftcol; + if (curwin->w_col < Columns) { + if ( IsIdxHZ(curwin->w_cursor.col - + curbuf->b_op_start.col,hz_change_buf) == 1) + screen_msg((char_u *)" ", + curwin->w_winpos + curwin->w_row, + #ifdef RIGHTLEFT + curwin->w_p_rl? Columns-curwin->w_col-2 : + #endif + curwin->w_col); + else if ( IsIdxHZ(curwin->w_cursor.col - + curbuf->b_op_start.col,hz_change_buf) == -1 && + IsHiBitOn(c)) + screen_msg((char_u *)" ", + curwin->w_winpos + curwin->w_row, + #ifdef RIGHTLEFT + curwin->w_p_rl? Columns-curwin->w_col-3 : + #endif + curwin->w_col); + } + } + if (IsHiBitOn(c)) { + cc = vgetc(); + #ifdef RIGHTLEFT + if (revins) { + insert_special(cc, FALSE); + insert_special(c, FALSE); + } + else { + #endif + insert_special(c, FALSE); + insert_special(cc, FALSE); + #ifdef RIGHTLEFT + } + #endif + } + else + #endif insert_special(c, FALSE); need_redraw = TRUE; #ifdef RIGHTLEFT *************** *** 1981,1986 **** --- 2046,2058 ---- last_vcol = vcol; ++new_cursor_col; vcol += lbr_chartabsize(ptr + new_cursor_col, (colnr_t)vcol); + #ifdef HZ /* HZWRAP */ + if (curwin->w_p_wrap && + ((vcol+(curwin->w_p_nu?8:0)-1) % (colnr_t)Columns) == + (colnr_t)Columns - 2 && + IsIdxHZ(new_cursor_col+1, ptr) == 1 ) + vcol++; + #endif } vcol = last_vcol; *************** *** 2913,2918 **** --- 2985,3000 ---- return FAIL; curwin->w_set_curswant = TRUE; ++curwin->w_cursor.col; + #ifdef HZ + if (IsIdxHZ(curwin->w_cursor.col, ml_get_curline()) == -1) + { + if (*++ptr == NUL) { + --curwin->w_cursor.col; + return FAIL; + } + ++curwin->w_cursor.col; + } + #endif return OK; } *************** *** 2923,2928 **** --- 3005,3015 ---- return FAIL; curwin->w_set_curswant = TRUE; --curwin->w_cursor.col; + #ifdef HZ + if ( curwin->w_cursor.col > 0 && + IsIdxHZ(curwin->w_cursor.col, ml_get_curline()) == -1) + --curwin->w_cursor.col; + #endif return OK; } *************** *** 2939,2944 **** --- 3026,3036 ---- /* try to advance to the column we want to be at */ coladvance(curwin->w_curswant); + #ifdef HZ + if ( curwin->w_cursor.col > 0 && + IsIdxHZ(curwin->w_cursor.col, ml_get_curline()) == -1) + --curwin->w_cursor.col; + #endif if (op_type == NOP) cursupdate(); /* make sure curwin->w_topline is valid */ *************** *** 2958,2963 **** --- 3050,3061 ---- /* try to advance to the column we want to be at */ coladvance(curwin->w_curswant); + + #ifdef HZ + if (curwin->w_cursor.col > 0 && + IsIdxHZ(curwin->w_cursor.col, ml_get_curline()) == -1 ) + --curwin->w_cursor.col; + #endif if (op_type == NOP) cursupdate(); /* make sure curwin->w_topline is valid */ Only in .: edit.c.bak diff -c ../src/feature.h ./feature.h *** ../src/feature.h Mon Jun 10 05:34:58 1996 --- ./feature.h Tue Oct 22 11:44:22 1996 *************** *** 20,25 **** --- 20,30 ---- * ============== */ + /* HZ support */ + #if 1 + #define HZ + #endif + /* * DIGRAPHS When defined: Include digraph support. * In insert mode and on the command line you will be diff -c ../src/getchar.c ./getchar.c *** ../src/getchar.c Mon Jun 10 05:35:01 1996 --- ./getchar.c Tue Oct 22 13:47:11 1996 *************** *** 1336,1347 **** --- 1336,1369 ---- vcol += lbr_chartabsize(ptr + col, (colnr_t)vcol); ++col; + #ifdef HZ /* HZWRAP */ + if (curwin->w_p_wrap && + ((vcol+(curwin->w_p_nu? 8:0)-1) % + (colnr_t)Columns) == + (colnr_t)Columns - 2 && + IsIdxHZ(col,ptr) == 1) + vcol++; + #endif } if (curwin->w_p_nu) curwin->w_col += 8; } else + #ifdef HZ + { + char_u *tmp_ptr; + if (hz_exclusive && !dollar_vcol) { + delchar(FALSE); + updateline(); + } + #endif --curwin->w_col; + #ifdef HZ + tmp_ptr = ml_get_curline(); + if (IsIdxHZ(curwin->w_col,tmp_ptr) == -1) + --curwin->w_col; + } + #endif } else if (curwin->w_p_wrap && curwin->w_row) { Only in .: getchar.c.bak diff -c ../src/globals.h ./globals.h *** ../src/globals.h Mon Jun 10 05:34:58 1996 --- ./globals.h Tue Oct 22 11:44:22 1996 *************** *** 442,444 **** --- 442,453 ---- EXTERN char_u e_unknown[] INIT(="Unknown"); EXTERN char_u e_write[] INIT(="Error while writing"); EXTERN char_u e_zerocount[] INIT(="Zero count"); + #ifdef HZ + /* hz_exclusive and hz_next is for REPLACE mode editing */ + EXTERN int hz_exclusive INIT(=FALSE); + /* TRUE if a hz 2'nd byte must be deleted */ + EXTERN int hz_next INIT(=FALSE); + /* TRUE if next char is HZ 1'st byte, used in misccmds.c */ + EXTERN char_u *hz_change_buf; + /* point to the yank buf when do a CHANGE op */ + #endif diff -c ../src/gui.c ./gui.c *** ../src/gui.c Mon Jun 10 05:35:01 1996 --- ./gui.c Tue Oct 22 13:48:29 1996 *************** *** 1958,1968 **** --- 1958,1985 ---- { int max = 0; char_u *p; + #ifdef HZ + char_u *tmp_ptr; + #endif p = ml_get_curline(); + #ifdef HZ + tmp_ptr = p; + #endif if (p[0] != NUL) while (p[1] != NUL) /* Don't count last character */ + #ifdef HZ + { + #endif max += chartabsize(*p++, (colnr_t)max); + #ifdef HZ /* HZWRAP */ + if (curwin->w_p_wrap && + ((max+(curwin->w_p_nu? 8:0)-1) % (colnr_t)Columns) == + (colnr_t)Columns - 2 && + IsIdxHZ((int)p - (int)tmp_ptr, tmp_ptr) == 1 ) + max++; + } + #endif return max; } *************** *** 1987,1993 **** --- 2004,2021 ---- vcol = 0; p = ml_get_curline(); while (p[i] && i < curwin->w_cursor.col && vcol < curwin->w_leftcol) + #ifdef HZ + { + #endif vcol += chartabsize(p[i++], (colnr_t)vcol); + #ifdef HZ /* HZWRAP */ + if (curwin->w_p_wrap && + ((vcol+(curwin->w_p_nu? 8:0)-1) % (colnr_t)Columns) == + (colnr_t)Columns - 2 && + IsIdxHZ(i, p) == 1 ) + vcol++; + } + #endif if (vcol < curwin->w_leftcol) { /* *************** *** 1995,2001 **** --- 2023,2040 ---- * side of the screen. */ while (p[i] && vcol < curwin->w_leftcol) + #ifdef HZ + { + #endif vcol += chartabsize(p[i++], (colnr_t)vcol); + #ifdef HZ /* HZWRAP */ + if (curwin->w_p_wrap && + ((vcol+(curwin->w_p_nu? 8:0)-1) % (colnr_t)Columns) == + (colnr_t)Columns - 2 && + IsIdxHZ(i, p) == 1 ) + vcol++; + } + #endif curwin->w_cursor.col = i; curwin->w_set_curswant = TRUE; ret_val = TRUE; *************** *** 2003,2009 **** --- 2042,2059 ---- while (p[i] && i <= curwin->w_cursor.col && vcol <= curwin->w_leftcol + Columns) + #ifdef HZ + { + #endif vcol += chartabsize(p[i++], (colnr_t)vcol); + #ifdef HZ /* HZWRAP */ + if (curwin->w_p_wrap && + ((vcol+(curwin->w_p_nu? 8:0)-1) % (colnr_t)Columns) == + (colnr_t)Columns - 2 && + IsIdxHZ(i, p) == 1 ) + vcol++; + } + #endif if (vcol > curwin->w_leftcol + Columns) { /* Only in .: gui.c.bak diff -c ../src/linefunc.c ./linefunc.c *** ../src/linefunc.c Mon Jun 10 05:35:01 1996 --- ./linefunc.c Tue Oct 22 13:48:54 1996 *************** *** 30,37 **** --- 30,43 ---- int idx; register char_u *ptr; register colnr_t col; + #ifdef HZ + char_u *tmp_ptr; + #endif ptr = ml_get_curline(); + #ifdef HZ + tmp_ptr = ptr; + #endif /* try to advance to the specified column */ idx = -1; *************** *** 42,47 **** --- 48,60 ---- /* Count a tab for what it's worth (if list mode not on) */ col += lbr_chartabsize(ptr, col); ++ptr; + #ifdef HZ /* HZWRAP */ + if (curwin->w_p_wrap && + ((col+(curwin->w_p_nu? 8:0)-1) % (colnr_t)Columns) == + (colnr_t)Columns - 2 && + IsIdxHZ((int)ptr - (int)tmp_ptr, tmp_ptr) == 1 ) + col++; + #endif } /* * in insert mode it is allowed to be one char beyond the end of the line Only in .: linefunc.c.bak diff -c ../src/macros.h ./macros.h *** ../src/macros.h Mon Jun 10 05:34:58 1996 --- ./macros.h Tue Oct 22 11:44:22 1996 *************** *** 66,68 **** --- 66,72 ---- * it work fast. */ #define isbreak(c) (breakat_flags[(char_u)(c)]) + + #ifdef HZ + #define IsHiBitOn(byte) ((byte) & 0x80) + #endif diff -c ../src/misccmds.c ./misccmds.c *** ../src/misccmds.c Fri Jun 14 06:40:49 1996 --- ./misccmds.c Tue Oct 22 14:02:54 1996 *************** *** 1026,1031 **** --- 1026,1045 ---- p = newp + col; vim_memmove(p + extra, oldp + col, (size_t)(oldlen - col)); *p = c; + #ifdef HZ + if ( State == REPLACE ) { + if ( hz_next || IsIdxHZ(col,oldp) == 1) { + newp[col+1] = ' '; + hz_exclusive = TRUE; + } + else + hz_exclusive = FALSE; + if ( IsIdxHZ(col+1,oldp) == 1) + hz_next = TRUE; + else + hz_next = FALSE; + } + #endif ml_replace(lnum, newp, FALSE); /* *************** *** 1123,1128 **** --- 1137,1146 ---- */ if (fixpos && curwin->w_cursor.col > 0 && col == oldlen - 1) --curwin->w_cursor.col; + #ifdef HZ + if (fixpos && IsIdxHZ(curwin->w_cursor.col, newp) == -1) + --curwin->w_cursor.col; + #endif CHANGED; return OK; *************** *** 3710,3715 **** --- 3728,3736 ---- colnr_t col; colnr_t maybe; colnr_t firsttry; + #ifdef HZ + char_u *tmp_ptr; + #endif realpos = curwin->w_cursor; *************** *** 3722,3727 **** --- 3743,3751 ---- col = pos->col; that = ml_get_curline(); + #ifdef HZ + tmp_ptr = that; + #endif maybe = get_indent(); /* XXX */ if (maybe == 0) *************** *** 3733,3738 **** --- 3757,3769 ---- amount += lbr_chartabsize(that, (colnr_t)amount); col--; that++; + #ifdef HZ /* HZWRAP */ + if (curwin->w_p_wrap && + ((amount+(curwin->w_p_nu?8:0)-1) % (colnr_t)Columns) == + (colnr_t)Columns - 2 && + IsIdxHZ((int)that - (int)tmp_ptr, tmp_ptr) == 1 ) + amount++; + #endif } that++; *************** *** 3749,3764 **** --- 3780,3816 ---- { amount += lbr_chartabsize(that, (colnr_t)amount); that++; + #ifdef HZ /* HZWRAP */ + if (curwin->w_p_wrap && + ((amount+(curwin->w_p_nu?8:0)-1) % (colnr_t)Columns) == + (colnr_t)Columns - 2 && + IsIdxHZ((int)that - (int)tmp_ptr, tmp_ptr) == 1 ) + amount++; + #endif } while (*that && !vim_iswhite(*that) && *that != '(') { amount += lbr_chartabsize(that, (colnr_t)amount); that++; + #ifdef HZ /* HZWRAP */ + if (curwin->w_p_wrap && + ((amount+(curwin->w_p_nu? 8:0)-1) % Columns) == + Columns - 2 && + IsIdxHZ((int)that - (int)tmp_ptr, tmp_ptr) == 1 ) + amount++; + #endif } while (vim_iswhite(*that)) { amount += lbr_chartabsize(that, (colnr_t)amount); that++; + #ifdef HZ /* HZWRAP */ + if ( curwin->w_p_wrap && + ((amount+(curwin->w_p_nu?8:0)-1) % (colnr_t)Columns) == + (colnr_t)Columns - 2 && + IsIdxHZ((int)that - (int)tmp_ptr, tmp_ptr) == 1 ) + amount++; + #endif } if (! *that) amount = firsttry; *************** *** 3903,3905 **** --- 3955,4017 ---- #endif } + #ifdef HZ /* functions for HZ */ + int + IsIdxHZ( idx, text ) + int idx; + char_u* text; + { + int i ; + int s = 0; /* 0: ASCII; 1: HZ-1st-byte; -1: HZ-2nd-byte */ + + if (idx > (int)STRLEN(text)) + return 0 ; + + for (i = 0 ; i <= idx; i++ ) { + if (s == 1) /* previous byte was HZ-1st-byte */ + s = -1; + else if ( IsHiBitOn( text[i] ) ) + s = 1; + else + s = 0; + } + return s ; + } + + int + IsTabIdxHZ( idx, text ) + int idx; + char_u* text; + { + int i,col ; + int s = 0; /* 0: ASCII; 1: HZ-1st-byte; -1: HZ-2nd-byte */ + + if (idx > linetabsize(text)) + return 0 ; + for (i = col = 0 ; col <= idx;i++) { + if (s == 1) { /* previous byte was HZ-1st-byte */ + s = -1; + col += lbr_chartabsize(&(text[i]), col); + /* HZWRAP */ + if (curwin->w_p_wrap && IsHiBitOn(text[i+1]) && + ((col+(curwin->w_p_nu? 8:0)-1) % (colnr_t)Columns) == + (colnr_t)Columns - 2 ) + col++; + } + else if ( IsHiBitOn( text[i] ) ) { + s = 1; + col += lbr_chartabsize(&(text[i]), col); + } + else { + s = 0; + col += lbr_chartabsize(&(text[i]), col); + /* HZWRAP */ + if (curwin->w_p_wrap && IsHiBitOn(text[i+1]) && + ((col+(curwin->w_p_nu? 8:0)-1) % (colnr_t)Columns) == + (colnr_t)Columns - 2 ) + col++; + } + } + return s ; + } + #endif Only in .: misccmds.c.bak diff -c ../src/normal.c ./normal.c *** ../src/normal.c Tue Jun 18 04:47:19 1996 --- ./normal.c Tue Oct 22 11:44:23 1996 *************** *** 92,97 **** --- 92,100 ---- int type = 0; /* type of operation */ int dir = FORWARD; /* search direction */ int nchar = NUL; /* next command char */ + #ifdef HZ + int nchar1 = NUL; + #endif int finish_op; linenr_t Prenum1; char_u *searchbuff = NULL; /* buffer for search string */ *************** *** 199,204 **** --- 202,213 ---- ++no_mapping; ++allow_keys; /* no mapping for nchar, but allow key codes */ nchar = vgetc(); + #ifdef HZ + if (IsHiBitOn(nchar) && c == 'r') + nchar1 = vgetc(); + else + nchar1 = NUL; + #endif #ifdef HAVE_LANGMAP /* adjust chars > 127: tTfFr should leave lang of nchar unchanged! */ LANGMAP_ADJUST(nchar, vim_strchr((char_u *)"tTfFr", c) == NULL); *************** *** 1341,1348 **** --- 1350,1367 ---- */ if (c != Ctrl('V') && (nchar == '\r' || nchar == '\n')) { + while (Prenum1--) /* delete the characters */ + #ifdef HZ + { + ptr = ml_get_buf(curbuf, curwin->w_cursor.lnum, TRUE); + if (IsIdxHZ(curwin->w_cursor.col, ptr) == 1) + delchar(FALSE); + #endif delchar(FALSE); + #ifdef HZ + } + #endif /* replacing the last character of a line is different */ if (curwin->w_cursor.col > 0 && gchar_cursor() == NUL) { *************** *** 1364,1376 **** --- 1383,1420 ---- * released the line. At the same time we let know that the * line will be changed. */ + #ifdef HZ + int IsHZ=FALSE; + #endif ptr = ml_get_buf(curbuf, curwin->w_cursor.lnum, TRUE); + #ifdef HZ + if (IsIdxHZ(curwin->w_cursor.col, ptr) == 1) + IsHZ=TRUE; + else + IsHZ=FALSE; + #endif ptr[curwin->w_cursor.col] = nchar; if (p_sm && (nchar == ')' || nchar == '}' || nchar == ']')) showmatch(); ++curwin->w_cursor.col; + #ifdef HZ + if (IsHZ) { + if (nchar1 != NUL) { + ptr[curwin->w_cursor.col] = nchar1; + ++curwin->w_cursor.col; + } + else + delchar(FALSE); + } + else if (nchar1 != NUL) + ins_char(nchar1); + #endif } --curwin->w_cursor.col; /* cursor on the last replaced char */ + #ifdef HZ + if (nchar1 != NUL) + --curwin->w_cursor.col; + #endif } curwin->w_set_curswant = TRUE; CHANGED; *************** *** 1461,1466 **** --- 1505,1515 ---- { if (!lineempty(curwin->w_cursor.lnum)) inc_cursor(); + #ifdef HZ + ptr = ml_get_curline(); + if (IsIdxHZ(curwin->w_cursor.col, ptr) == -1 && curwin->w_cursor.col < STRLEN(ptr)) + ++curwin->w_cursor.col; + #endif command_busy = edit(c, FALSE, Prenum1); } } *************** *** 2495,2500 **** --- 2544,2554 ---- case YANK: if (!op_empty) (void)do_yank(FALSE, !gui_yank); + #ifdef HZ + if (IsIdxHZ(curwin->w_cursor.col,ml_get_curline()) == -1) + --curwin->w_cursor.col; + #endif + break; case CHANGE: diff -c ../src/ops.c ./ops.c *** ../src/ops.c Wed Jun 12 19:15:08 1996 --- ./ops.c Tue Oct 22 13:52:03 1996 *************** *** 955,960 **** --- 955,964 ---- if ((l > curwin->w_cursor.col) && !lineempty(curwin->w_cursor.lnum)) inc_cursor(); + #ifdef HZ + if (IsIdxHZ(curwin->w_cursor.col,ml_get_curline()) == -1) + inc_cursor(); + #endif #ifdef LISPINDENT if (op_motion_type == MLINE) *************** *** 1057,1062 **** --- 1061,1075 ---- beep_flush(); return FAIL; } + #ifdef HZ + if (!op_block_mode) { + pnew = ml_get(curbuf->b_op_end.lnum); + if (IsIdxHZ(curbuf->b_op_end.col, pnew) == 1 && (op_is_VIsual || + curbuf->b_op_end.col - 1 + op_inclusive == STRLEN(pnew) - 2) ) { + ++curbuf->b_op_end.col; + } + } + #endif if (!deleting) /* do_delete() already set y_current */ get_yank_buffer(TRUE); *************** *** 1079,1084 **** --- 1092,1098 ---- --yanklines; } + y_current->y_size = yanklines; y_current->y_type = yanktype; /* set the yank buffer type */ y_current->y_array = (char_u **)lalloc((long_u)(sizeof(char_u *) * *************** *** 1099,1104 **** --- 1113,1124 ---- if (op_block_mode) { y_current->y_type = MBLOCK; /* set the yank buffer type */ + #ifdef HZ + if (IsTabIdxHZ(op_end_vcol, ml_get(yankendlnum)) == 1) { + ++op_end_vcol; + ++curbuf->b_op_end.col; + } + #endif for ( ; lnum <= yankendlnum; ++lnum) { block_prep(&bd, lnum, FALSE); *************** *** 1118,1123 **** --- 1138,1151 ---- pnew += bd.endspaces; *pnew = NUL; + #ifdef HZ + pnew = ml_get(lnum); + if (IsTabIdxHZ(op_end_vcol,pnew) == 1) + y_current->y_array[i-1] + [bd.startspaces + bd.endspaces + bd.textlen-1] = ' '; + if (IsTabIdxHZ(op_start_vcol,pnew) == -1) + y_current->y_array[i-1][0] = ' '; + #endif } } else *************** *** 1206,1211 **** --- 1234,1242 ---- vim_free(y_current->y_array); y_current = curr; } + if (vim_strchr(p_cpo, CPO_DOLLAR) != NULL && op_type == CHANGE && + curbuf->b_op_end.lnum == curwin->w_cursor.lnum && !op_is_VIsual) + hz_change_buf = curr->y_array[0]; if (mess) /* Display message about yank? */ { if (yanktype == MCHAR && !op_block_mode) *************** *** 1356,1361 **** --- 1387,1398 ---- } else getvcol(curwin, &curwin->w_cursor, &col, NULL, NULL); + #ifdef HZ + if (IsIdxHZ(curwin->w_cursor.col,ml_get_curline()) == -1) { + ++col; + ++curwin->w_cursor.col; + } + #endif for (i = 0; i < y_size; ++i) { bd.startspaces = 0; *************** *** 1379,1384 **** --- 1416,1428 ---- incr = lbr_chartabsize(ptr, (colnr_t)vcol); vcol += incr; ++bd.textcol; + #ifdef HZ /* HZWRAP */ + if (curwin->w_p_wrap && + ((vcol+(curwin->w_p_nu?8:0)-1) % (colnr_t)Columns) == + (colnr_t)Columns - 2 && + IsIdxHZ((int)ptr - (int)oldp + 1, oldp) == 1 ) + vcol++; + #endif } if (vcol < col) /* line too short, padd with spaces */ { *************** *** 1396,1405 **** --- 1440,1460 ---- newp = alloc_check((unsigned)totlen + oldlen + 1); if (newp == NULL) break; + #ifdef HZ + if (IsIdxHZ(bd.textcol,oldp) == -1) { + /* replace the char with two blanks, keep shape of block */ + /* + oldp[bd.textcol-1] = oldp[bd.textol] = ' '; + */ + /* or just paste to next char, destroy the shape */ + ++bd.textcol; + } + #endif /* copy part up to cursor to new line */ ptr = newp; vim_memmove(ptr, oldp, (size_t)bd.textcol); ptr += bd.textcol; + /* may insert some spaces before the new text */ copy_spaces(ptr, (size_t)bd.startspaces); ptr += bd.startspaces; *************** *** 1441,1446 **** --- 1496,1508 ---- ++curwin->w_cursor.col; ++curbuf->b_op_end.col; } + #ifdef HZ + if (IsIdxHZ(col,ml_get(lnum)) == -1) { + ++col; + ++curwin->w_cursor.col; + ++curbuf->b_op_end.col; + } + #endif } new_cursor = curwin->w_cursor; } *************** *** 1471,1476 **** --- 1533,1542 ---- ml_replace(lnum, newp, FALSE); /* put cursor on last putted char */ curwin->w_cursor.col += (colnr_t)(totlen - 1); + #ifdef HZ + if (IsIdxHZ(curwin->w_cursor.col,newp) == -1) + --curwin->w_cursor.col; + #endif } curbuf->b_op_end = curwin->w_cursor; updateline(); *************** *** 2136,2141 **** --- 2202,2210 ---- int incr = 0; char_u *pend; char_u *pstart; + #ifdef HZ + char_u *tmp_ptr; + #endif bd->startspaces = 0; bd->endspaces = 0; *************** *** 2143,2148 **** --- 2212,2220 ---- bd->textcol = 0; vcol = 0; pstart = ml_get(lnum); + #ifdef HZ + tmp_ptr = pstart; + #endif while (vcol < op_start_vcol && *pstart) { /* Count a tab for what it's worth (if list mode not on) */ *************** *** 2150,2155 **** --- 2222,2234 ---- vcol += incr; ++pstart; ++bd->textcol; + #ifdef HZ /* HZWRAP */ + if (curwin->w_p_wrap && + ((vcol+(curwin->w_p_nu? 8:0)-1) % (colnr_t)Columns) == + (colnr_t)Columns - 2 && + IsIdxHZ((int)pstart - (int)tmp_ptr, tmp_ptr) == 1 ) + vcol++; + #endif } if (vcol < op_start_vcol) /* line too short */ { *************** *** 2176,2181 **** --- 2255,2267 ---- incr = lbr_chartabsize(pend, (colnr_t)vcol); vcol += incr; ++pend; + #ifdef HZ /* HZWRAP */ + if (curwin->w_p_wrap && + ((vcol+(curwin->w_p_nu?8:0)-1) % (colnr_t)Columns) == + (colnr_t)Columns - 2 && + IsIdxHZ((int)pend - (int)tmp_ptr, tmp_ptr) == 1 ) + vcol++; + #endif } if (vcol < op_end_vcol && !is_del) /* line too short */ { Only in .: ops.c.bak Common subdirectories: ../src/proto and ./proto diff -c ../src/proto.h ./proto.h *** ../src/proto.h Mon Jun 10 05:34:58 1996 --- ./proto.h Tue Oct 22 11:44:23 1996 *************** *** 100,104 **** --- 100,108 ---- # if defined(USE_GUI) extern int OpenPTY __ARGS((char **ttyn)); /* from pty.c */ # endif + #ifdef HZ + int IsIdxHZ __PARMS((int idx, char_u *text)); + int IsTabIdxHZ __PARMS((int idx, char_u *text)); + #endif #endif /* PROTO */ diff -c ../src/screen.c ./screen.c *** ../src/screen.c Tue Jun 18 04:02:27 1996 --- ./screen.c Tue Oct 22 14:02:38 1996 *************** *** 685,690 **** --- 685,694 ---- int fromcol, tocol; /* start/end of inverting */ int noinvcur = FALSE; /* don't invert the cursor */ FPOS *top, *bot; + #ifdef HZ + char_u *tmp_ptr; + int hz_pending = FALSE; + #endif if (startrow > endrow) /* past the end already! */ return startrow; *************** *** 697,702 **** --- 701,707 ---- tocol = MAXCOL; canopt = TRUE; + /* * handle visual active in this window */ *************** *** 726,731 **** --- 731,746 ---- if ((int)to > tocol) tocol = to; ++tocol; + #ifdef HZ + if (IsTabIdxHZ(tocol,ml_get_buf(wp->w_buffer, lnum, FALSE)) + == -1) { + ++tocol; + } + if (IsTabIdxHZ(fromcol,ml_get_buf(wp->w_buffer, lnum, FALSE)) + == -1) { + ++fromcol; + } + #endif if (wp->w_curswant == MAXCOL) tocol = MAXCOL; *************** *** 741,746 **** --- 756,771 ---- { getvcol(wp, bot, NULL, NULL, (colnr_t *)&tocol); ++tocol; + #ifdef HZ + if ( + #ifndef MSDOS + lt(curwin->w_cursor, VIsual) && + #endif + IsTabIdxHZ(tocol,ml_get_buf(wp->w_buffer, lnum, FALSE)) + == -1) { + ++tocol; + } + #endif } if (VIsual_mode == 'V') /* linewise */ *************** *** 755,760 **** --- 780,791 ---- #ifndef MSDOS if (!highlight_match && *T_VI == NUL && lnum == curwin->w_cursor.lnum && wp == curwin) + #ifdef HZ + /* reverse cursor in visual mode, not needed now */ + /* + if (!lt(curwin->w_cursor, VIsual) && VIsual_mode != Ctrl('V')) + */ + #endif noinvcur = TRUE; #endif *************** *** 788,797 **** --- 819,835 ---- } ptr = ml_get_buf(wp->w_buffer, lnum, FALSE); + #ifdef HZ + tmp_ptr = ptr; + #endif if (!wp->w_p_wrap) /* advance to first character to be displayed */ { while ((colnr_t)vcol < wp->w_leftcol && *ptr) vcol += win_chartabsize(wp, *ptr++, (colnr_t)vcol); + #ifdef HZ /* HZWRAP */ + /* do not need to fix win_chartabsize(), + since w->w_p_wrap is FALSE here */ + #endif if ((colnr_t)vcol > wp->w_leftcol) { n_spaces = vcol - wp->w_leftcol; /* begin with some spaces */ *************** *** 838,848 **** --- 876,901 ---- { if (!canopt) /* Visual or match highlighting in this line */ { + #ifdef HZ + if (hz_pending) { + start_highlight(); + hz_pending = FALSE; + } + #endif if (((vcol == fromcol && !(noinvcur && (colnr_t)vcol == wp->w_virtcol)) || (noinvcur && (colnr_t)vcol == wp->w_virtcol + 1 && vcol >= fromcol)) && vcol < tocol) + #ifdef HZ + { + if ( IsIdxHZ((int)ptr - (int)tmp_ptr,tmp_ptr) != -1) + #endif start_highlight(); /* start highlighting */ + #ifdef HZ + else + hz_pending = TRUE; + } + #endif else if (attributes && (vcol == tocol || (noinvcur && (colnr_t)vcol == wp->w_virtcol))) stop_highlight(); /* stop highlighting */ *************** *** 884,889 **** --- 937,955 ---- c = ' '; n_spaces--; } + #ifdef HZ /* HZWRAP */ + else if (col == Columns - 1 && wp->w_p_wrap && + IsIdxHZ((int)ptr - (int)tmp_ptr,tmp_ptr) == 1 + #ifdef RIGHTLEFT + && !wp->w_p_rl + || + wp->w_p_rl && col == 0 && wp->w_p_wrap && + IsIdxHZ((int)ptr - (int)tmp_ptr,tmp_ptr) == 1 + #endif + ) { + c = ' '; + } + #endif else { c = *ptr++; *************** *** 894,899 **** --- 960,968 ---- { n_spaces = win_lbr_chartabsize(wp, ptr - 1, (colnr_t)vcol, NULL) - 1; + #ifdef HZ /* HZWRAP */ + /* do not need to fix win_lbr_chartabsize() here */ + #endif if (vim_iswhite(c)) c = ' '; } *************** *** 1032,1037 **** --- 1101,1119 ---- screenp += Columns - 1; } #endif + #if defined(HZ) && !defined(MSDOS) /* HZWRAP, strange behavior for line wrap */ + /* not work for showbreak and rightleft */ + if (IsHiBitOn(c) && !VIsual_active && STRLEN(p_sbr) == 0 + #ifdef RIGHTLEFT + && !wp->w_p_rl + #endif + ) { + *screenp = c; + screen_char(screenp,screen_row,col); + screenp[1] = *ptr; + screen_char(screenp+1,screen_row,col+1); + } + #endif } /* *************** *** 1059,1067 **** --- 1141,1184 ---- screen_row - 1, (int)Columns); screen_start(); } + #ifdef HZ + if (!wp->w_p_wrap && ((col == (wp->w_p_nu? 8:0) && + IsIdxHZ((int)ptr - (int)tmp_ptr - 1,tmp_ptr) == -1) || + (col == Columns - 1 && + IsIdxHZ((int)ptr - (int)tmp_ptr - 1,tmp_ptr) == 1) ) + #ifdef RIGHTLEFT + && !wp->w_p_rl || + !wp->w_p_wrap && wp->w_p_rl && ((col == 0 && + IsIdxHZ((int)ptr - (int)tmp_ptr - 1,tmp_ptr) == 1) || + (col == (wp->w_p_nu? (Columns - 9):(Columns - 1)) && + IsIdxHZ((int)ptr - (int)tmp_ptr - 1,tmp_ptr) == -1) ) + #endif + ) + c = ' '; + #endif *screenp = c; *(screenp + Columns) = attributes; + #if defined(RIGHTLEFT) && defined(HZ) + /* normal cases */ + if ( wp->w_p_rl && col == 0 && wp->w_p_wrap && + IsIdxHZ((int)ptr - (int)tmp_ptr,tmp_ptr) == 1 + || /* line wrap */ + wp->w_p_nu && col >= Columns-8 && vcol < Columns - 8 + || /* line number */ + (col == (wp->w_p_nu? (Columns - 9):(Columns - 1)) && + IsIdxHZ((int)ptr - (int)tmp_ptr - 1,tmp_ptr) == -1) ) + /* char wrap */ + screen_char(screenp, screen_row, col); + /* exchange HZ's 1st and 2nd byte */ + else if (wp->w_p_rl && + IsIdxHZ((int)ptr - (int)tmp_ptr - 1,tmp_ptr) == 1) + screen_char(screenp, screen_row, col-1); + else if (wp->w_p_rl && + IsIdxHZ((int)ptr - (int)tmp_ptr - 1,tmp_ptr) == -1) + screen_char(screenp, screen_row, col+1); + else /* other normal cases */ + #endif screen_char(screenp, screen_row, col); } #ifdef RIGHTLEFT *************** *** 1107,1112 **** --- 1224,1238 ---- curwin->w_col -= curwin->w_leftcol; if (curwin->w_col < Columns) { + #ifdef HZ + if ( IsTabIdxHZ(curwin->w_virtcol, ml_get_curline()) == -1) { + screen_msg((char_u *)" ", curwin->w_winpos + curwin->w_row, + #ifdef RIGHTLEFT + curwin->w_p_rl ? (int)Columns - curwin->w_col : + #endif + curwin->w_col-1); + } + #endif screen_msg((char_u *)"$", curwin->w_winpos + curwin->w_row, #ifdef RIGHTLEFT curwin->w_p_rl ? (int)Columns - 1 - curwin->w_col : *************** *** 2308,2313 **** --- 2434,2456 ---- /* screen has to be redrawn with new curwin->w_leftcol */ redraw_later(NOT_VALID); } + #ifdef HZ + else if ( (int)endcol - (int)(curwin->w_leftcol + Columns) + 1 == 0 && + IsIdxHZ(curwin->w_cursor.col, ml_get_curline()) == 1) + { + /* far off, put cursor in middle of window */ + if (p_ss == 0) + new_leftcol = curwin->w_col - Columns / 2; + else + new_leftcol = curwin->w_leftcol + p_ss; + if (new_leftcol < 0) + curwin->w_leftcol = 0; + else + curwin->w_leftcol = new_leftcol; + /* screen has to be redrawn with new curwin->w_leftcol */ + redraw_later(NOT_VALID); + } + #endif curwin->w_col -= curwin->w_leftcol; } /* Cursor past end of screen */ Only in .: screen.c.bak diff -c ../src/search.c ./search.c *** ../src/search.c Mon Jun 10 05:35:01 1996 --- ./search.c Tue Oct 22 11:44:24 1996 *************** *** 1745,1750 **** --- 1745,1754 ---- if (c == ' ' || c == '\t' || c == NUL) return 0; + #ifdef HZ + if (IsIdxHZ(curwin->w_cursor.col,ml_get_curline()) != 0) + return 1; + #endif if (iswordchar(c)) return 1; diff -c ../src/undo.c ./undo.c *** ../src/undo.c Mon Jun 10 05:35:01 1996 --- ./undo.c Tue Oct 22 11:44:24 1996 *************** *** 297,302 **** --- 297,305 ---- u_undoredo(); } u_undo_end(); + #ifdef HZ + updateScreen(NOT_VALID); + #endif } void *************** *** 318,323 **** --- 321,329 ---- curbuf->b_u_curhead = curbuf->b_u_curhead->uh_prev; } u_undo_end(); + #ifdef HZ + updateScreen(NOT_VALID); + #endif } /*