[jVi-cvs] jvi/src/com/raelity/jvi Options.java, 1.77, 1.78 Normal.java, 1.98, 1.99 ViBuffer.java, 1
Brought to you by:
err
From: Ernie R. <er...@us...> - 2010-01-29 07:27:31
|
Update of /cvsroot/jvi/jvi/src/com/raelity/jvi In directory sfp-cvsdas-3.v30.ch3.sourceforge.com:/tmp/cvs-serv1868/jvi/src/com/raelity/jvi Modified Files: Options.java Normal.java ViBuffer.java ViManager.java Search.java Log Message: - For 'Q' and 'gq' commands invoke platform's reformat - Fix bug in '[m' flavor of commands. Also avoid cursor motion (nice). Index: ViManager.java =================================================================== RCS file: /cvsroot/jvi/jvi/src/com/raelity/jvi/ViManager.java,v retrieving revision 1.227 retrieving revision 1.228 diff -C2 -d -r1.227 -r1.228 *** ViManager.java 28 Jan 2010 03:55:07 -0000 1.227 --- ViManager.java 29 Jan 2010 07:27:23 -0000 1.228 *************** *** 107,111 **** // 1.0.0.beta3 is NB vers 0.9.7.5 // ! public static final jViVersion version = new jViVersion("1.2.7.x22"); private static final String DEBUG_AT_HOME = "com.raelity.jvi.DEBUG"; --- 107,111 ---- // 1.0.0.beta3 is NB vers 0.9.7.5 // ! public static final jViVersion version = new jViVersion("1.2.7.x23"); private static final String DEBUG_AT_HOME = "com.raelity.jvi.DEBUG"; Index: ViBuffer.java =================================================================== RCS file: /cvsroot/jvi/jvi/src/com/raelity/jvi/ViBuffer.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** ViBuffer.java 22 Jan 2010 21:20:52 -0000 1.11 --- ViBuffer.java 29 Jan 2010 07:27:23 -0000 1.12 *************** *** 67,74 **** ! /** platform indent algorithm */ public void reindent(int line, int count); /** @return the line number, 1 based, corresponding to the offset */ public int getLineNumber(int offset); --- 67,77 ---- ! /** platform indent algorithm */ public void reindent(int line, int count); + /** platform indent algorithm */ + public void reformat(int line, int count); + /** @return the line number, 1 based, corresponding to the offset */ public int getLineNumber(int offset); Index: Options.java =================================================================== RCS file: /cvsroot/jvi/jvi/src/com/raelity/jvi/Options.java,v retrieving revision 1.77 retrieving revision 1.78 diff -C2 -d -r1.77 -r1.78 *** Options.java 28 Jan 2010 03:55:07 -0000 1.77 --- Options.java 29 Jan 2010 07:27:22 -0000 1.78 *************** *** 681,691 **** "are used."); ! G.p_fp = createStringOption(formatProgram, "fmt -w " + twMagic); setupOptionDesc(processList, formatProgram, "'formatprg' 'fp'", ! "The name of an external program used to format lines selected " + ! "with 'gq' operator (default \"fmt\"). The program must take " + ! "input on stdin and produce output to stdout. In Unix, " + ! "\"fmt\" is such a program. " + twMagic + " in the string is " + ! "substituted by the value of textwidth option. "); ///////////////////////////////////////////////////////////////////// --- 681,695 ---- "are used."); ! G.p_fp = createStringOption(formatProgram, ""); setupOptionDesc(processList, formatProgram, "'formatprg' 'fp'", ! "External program to use for \"qq\" or \"Q\" command (default \"\")." ! + " When this option is empty the internal formatting functions" ! + " are used." ! + "\n\n When specified, the program must take input on stdin and" ! + " send output to stdout. In Unix, \"fmt\" is such a program." ! + twMagic + " in the string is" ! + " substituted by the value of textwidth option. " ! + "\n\nTypically set to \"fmt -w #TEXT-WIDTH#\" to use external program." ! ); ///////////////////////////////////////////////////////////////////// Index: Normal.java =================================================================== RCS file: /cvsroot/jvi/jvi/src/com/raelity/jvi/Normal.java,v retrieving revision 1.98 retrieving revision 1.99 diff -C2 -d -r1.98 -r1.99 *** Normal.java 28 Jan 2010 03:55:07 -0000 1.98 --- Normal.java 29 Jan 2010 07:27:22 -0000 1.99 *************** *** 606,614 **** // If ever want to support exmode, then better support // map so that 'Q' can be mapped ! if (G.VIsual_active) ! Util.vim_beep(); ! else { ! nv_operator(ca); // so both 'gq' and 'Q' map to same operator ! } break; --- 606,611 ---- // If ever want to support exmode, then better support // map so that 'Q' can be mapped ! ! nv_operator(ca); // so both 'gq' and 'Q' map to same operator break; *************** *** 1790,1797 **** } ! static void op_format(OPARG oap) { do_op("op_format"); // NEESDWORK: hook into platform's format (if available) ! op_colon(oap); } --- 1787,1799 ---- } ! static void op_format(final OPARG oap) { do_op("op_format"); // NEESDWORK: hook into platform's format (if available) ! Misc.runUndoable(new Runnable() { ! public void run() { ! G.curbuf.reformat(G.curwin.w_cursor.getLine(), ! oap.line_count); ! } ! }); } *************** *** 3090,3096 **** int c; cap.oap.motion_type = MCHAR; cap.oap.inclusive = false; ! old_pos = G.curwin.w_cursor.copy(); //#ifdef FEAT_VIRTUALEDIT ... --- 3092,3099 ---- int c; + final ViFPOS cursor = G.curwin.w_cursor.copy(); cap.oap.motion_type = MCHAR; cap.oap.inclusive = false; ! old_pos = cursor.copy(); //#ifdef FEAT_VIRTUALEDIT ... *************** *** 3174,3178 **** for ( ; n > 0; --n) { ! if ((pos = Search.findmatchlimit(cap.oap, findc, (cap.cmdchar == '[') ? FM_BACKWARD : FM_FORWARD, 0)) == null) { --- 3177,3181 ---- for ( ; n > 0; --n) { ! if ((pos = Search.findmatchlimit(cursor, cap.oap, findc, (cap.cmdchar == '[') ? FM_BACKWARD : FM_FORWARD, 0)) == null) { *************** *** 3187,3194 **** } prev_pos = new_pos == null ? null : new_pos.copy(); ! G.curwin.w_cursor.set(pos);// G.curwin.w_cursor = *pos; new_pos = pos; } ! G.curwin.w_cursor.set(old_pos); /* --- 3190,3198 ---- } prev_pos = new_pos == null ? null : new_pos.copy(); ! cursor.set(pos);// G.curwin.w_cursor = *pos; new_pos = pos; + //LOG.log(FINER, "prev {0}, new {1}", new Object[] {prev_pos, new_pos}); } ! cursor.set(old_pos); /* *************** *** 3205,3212 **** n = cap.count1; /* found a match: we were inside a method */ ! if (prev_pos == null) { pos = prev_pos; ! G.curwin.w_cursor.set(prev_pos); if (norm) --n; --- 3209,3216 ---- n = cap.count1; /* found a match: we were inside a method */ ! if (prev_pos != null) { pos = prev_pos; ! cursor.set(prev_pos); if (norm) --n; *************** *** 3218,3222 **** for (;;) { ! if ((findc == '{' ? dec_cursor() : inc_cursorV7()) < 0) { /* if not found anything, that's an error */ --- 3222,3226 ---- for (;;) { ! if ((findc == '{' ? dec(cursor) : incV7(cursor)) < 0) { /* if not found anything, that's an error */ *************** *** 3226,3230 **** break; } ! c = gchar_cursor(); if (c == '{' || c == '}') { --- 3230,3234 ---- break; } ! c = gchar_pos(cursor); if (c == '{' || c == '}') { *************** *** 3233,3237 **** if ((c == findc && norm) || (n == 1 && !norm)) { ! new_pos = G.curwin.w_cursor.copy(); pos = new_pos; n = 0; --- 3237,3241 ---- if ((c == findc && norm) || (n == 1 && !norm)) { ! new_pos = cursor.copy(); pos = new_pos; n = 0; *************** *** 3241,3254 **** else if (new_pos == null) { ! new_pos = G.curwin.w_cursor.copy(); pos = new_pos; } /* found start/end of other method: go to match */ ! else if ((pos = Search.findmatchlimit(cap.oap, findc, (cap.cmdchar == '[') ? FM_BACKWARD : FM_FORWARD, 0)) == null) n = 0; else ! G.curwin.w_cursor.set(pos); // G.curwin.w_cursor = *pos; break; } --- 3245,3259 ---- else if (new_pos == null) { ! new_pos = cursor.copy(); pos = new_pos; } /* found start/end of other method: go to match */ ! else if ((pos = Search.findmatchlimit(cursor, ! cap.oap, findc, (cap.cmdchar == '[') ? FM_BACKWARD : FM_FORWARD, 0)) == null) n = 0; else ! cursor.set(pos); // G.curwin.w_cursor = *pos; break; } *************** *** 3256,3265 **** --n; } ! G.curwin.w_cursor.set(old_pos); ! if (pos == null && new_pos == null) clearopbeep(cap.oap); } if (pos != null) { setpcmark(); G.curwin.w_cursor.set(pos); // G.curwin.w_cursor = *pos; --- 3261,3271 ---- --n; } ! cursor.set(old_pos); ! if (pos == null && new_pos != null) clearopbeep(cap.oap); } if (pos != null) { + // up to this point, w_cursor should no have been changed. setpcmark(); G.curwin.w_cursor.set(pos); // G.curwin.w_cursor = *pos; *************** *** 4821,4824 **** --- 4827,4831 ---- // //Misc + private static int dec(ViFPOS fpos) { return Misc.dec(fpos); } private static int dec_cursor() { return Misc.dec_cursor(); } private static int decl(ViFPOS pos) { return Misc.decl(pos); } Index: Search.java =================================================================== RCS file: /cvsroot/jvi/jvi/src/com/raelity/jvi/Search.java,v retrieving revision 1.52 retrieving revision 1.53 diff -C2 -d -r1.52 -r1.53 *** Search.java 9 Dec 2009 05:39:48 -0000 1.52 --- Search.java 29 Jan 2010 07:27:23 -0000 1.53 *************** *** 2009,2013 **** static ViFPOS findmatchlimit(OPARG oap, char initc, int flags, int maxtravel) { ! //ViFPOS pos; // current search position int pos_lnum; int pos_col; --- 2009,2017 ---- static ViFPOS findmatchlimit(OPARG oap, char initc, int flags, int maxtravel) { ! return findmatchlimit(G.curwin.w_cursor.copy(), oap, initc, flags, maxtravel); ! } ! static ViFPOS findmatchlimit(ViFPOS cursor, ! OPARG oap, char initc, int flags, int maxtravel) ! { int pos_lnum; int pos_col; *************** *** 2038,2044 **** assert initc != 0; ! //pos = G.curwin.w_cursor.copy(); ! pos_lnum = G.curwin.w_cursor.getLine(); ! pos_col = G.curwin.w_cursor.getColumn(); linep = Util.ml_get(pos_lnum); --- 2042,2049 ---- assert initc != 0; ! // pos_lnum = G.curwin.w_cursor.getLine(); ! // pos_col = G.curwin.w_cursor.getColumn(); ! pos_lnum = cursor.getLine(); ! pos_col = cursor.getColumn(); linep = Util.ml_get(pos_lnum); |