From c70f55fbbcc3ff218dc553fa01a2d53e2ad8c36d Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Sun, 19 Jun 2011 15:21:42 +0000 Subject: [PATCH] 2011-06-19 17:18 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) * contrib/xhb/xhbtedit.prg ! fixed to handle some of the "extended" keys without build-time hacks, so selection/copy/paste should now work (I don't have Ins/Del keys, so can't test it all) * formatting + contrib/xhb/xhbmemo.prg * contrib/xhb/xhb.hbp * contrib/xhb/xhb.hbx + added XHB_MEMOEDIT() function, completing commit 2011-05-25 19:35 UTC+0200 --- harbour/ChangeLog | 14 +- harbour/contrib/xhb/xhb.hbp | 1 + harbour/contrib/xhb/xhb.hbx | 2 + harbour/contrib/xhb/xhbmemo.prg | 535 +++++++++++++++++++++++++++++++ harbour/contrib/xhb/xhbtedit.prg | 333 +++++++++---------- 5 files changed, 723 insertions(+), 162 deletions(-) create mode 100644 harbour/contrib/xhb/xhbmemo.prg diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 4fc7e15e98..fa5f3017bf 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,10 +16,22 @@ The license applies to all entries newer than 2009-04-28. */ +2011-06-19 17:18 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) + * contrib/xhb/xhbtedit.prg + ! fixed to handle some of the "extended" keys without build-time hacks, + so selection/copy/paste should now work (I don't have Ins/Del keys, + so can't test it all) + * formatting + + + contrib/xhb/xhbmemo.prg + * contrib/xhb/xhb.hbp + * contrib/xhb/xhb.hbx + + added XHB_MEMOEDIT() function, completing commit 2011-05-25 19:35 UTC+0200 + 2011-06-19 08:06 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) * contrib/hbqt/qtcore/qth/HBQString.qth * contrib/hbqt/qtcore/qth/QByteArray.qth - ! Commented out: duplicate ( from Harbour's POW ) function + ! Commented out: duplicate ( from Harbour's POW ) function calls which were generating warnings "Unreachable code". 2011-06-19 11:27 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) diff --git a/harbour/contrib/xhb/xhb.hbp b/harbour/contrib/xhb/xhb.hbp index 39f15a473a..157d8a8423 100644 --- a/harbour/contrib/xhb/xhb.hbp +++ b/harbour/contrib/xhb/xhb.hbp @@ -101,6 +101,7 @@ xhbcomp.prg xhberr.prg xhbfunp.prg xhbinkey.prg +xhbmemo.prg xhbmt.prg xhbtedit.prg xhbver.prg diff --git a/harbour/contrib/xhb/xhb.hbx b/harbour/contrib/xhb/xhb.hbx index 5d14d65c60..636bd0cea0 100644 --- a/harbour/contrib/xhb/xhb.hbx +++ b/harbour/contrib/xhb/xhb.hbx @@ -426,6 +426,7 @@ DYNAMIC XHB_INDEX DYNAMIC XHB_LESS DYNAMIC XHB_LESSEQ DYNAMIC XHB_LIB +DYNAMIC XHB_MEMOEDIT DYNAMIC XHB_MEMOWRIT DYNAMIC XHB_MINUS DYNAMIC XHB_MOD @@ -440,6 +441,7 @@ DYNAMIC XHB_SAVESCREEN DYNAMIC XHB_SETTRACE DYNAMIC XHB_SETTRACEFILE DYNAMIC XHB_SETTRACESTACK +DYNAMIC XHB_TMEMOEDITOR DYNAMIC XHB_TRIM DYNAMIC XHB__KEYBOARD DYNAMIC _ARRAY diff --git a/harbour/contrib/xhb/xhbmemo.prg b/harbour/contrib/xhb/xhbmemo.prg new file mode 100644 index 0000000000..e92d829062 --- /dev/null +++ b/harbour/contrib/xhb/xhbmemo.prg @@ -0,0 +1,535 @@ +/* + * $Id$ + */ + +/* + * Harbour Project source code: + * xhb_MemoEdit() function + * + * Copyright 2000 Maurilio Longo + * www - http://www.harbour-project.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/). + * + * As a special exception, the Harbour Project gives permission for + * additional uses of the text contained in its release of Harbour. + * + * The exception is that, if you link the Harbour libraries with other + * files to produce an executable, this does not by itself cause the + * resulting executable to be covered by the GNU General Public License. + * Your use of that executable is in no way restricted on account of + * linking the Harbour library code into it. + * + * This exception does not however invalidate any other reasons why + * the executable file might be covered by the GNU General Public License. + * + * This exception applies only to the code released by the Harbour + * Project under the name Harbour. If you copy code from other + * Harbour Project or Free Software Foundation releases into a copy of + * Harbour, as the General Public License permits, the exception does + * not apply to the code that you add in this way. To avoid misleading + * anyone as to the status of such modified files, you must delete + * this exception notice from them. + * + * If you write modifications of your own for Harbour, it is your choice + * whether to permit this exception to apply to your modifications. + * If you do not wish that, delete this exception notice. + * + */ + +#include "common.ch" +#include "hbclass.ch" +#include "memoedit.ch" +#include "inkey.ch" + + +//-------------------------------------------------------------------// +// +// A specialized HBEditor which can simulate MemoEdit() behaviour +// +CREATE CLASS XHB_TMemoEditor FROM XHBEditor + + VAR xUserFunction // User Function called to change default MemoEdit() behaviour + + VAR aEditKeys + VAR aAsciiKeys + VAR aConfigurableKeys + VAR aMouseKeys + VAR aExtKeys // Extended keys. For HB_EXT_INKEY use only. + + METHOD MemoInit( xUDF ) // This method is called after ::New() returns to perform ME_INIT actions + METHOD Edit() // Calls ::Super:Edit(nKey) but is needed to handle configurable keys + METHOD KeyboardHook( nKey ) // Gets called every time there is a key not handled directly by HBEditor + + METHOD ExistUdf() INLINE HB_IsString( ::xUserFunction ) + METHOD HandleUdf( nKey, nUdfReturn, lEdited ) // Handles requests returned to MemoEdit() by udf + METHOD CallUdf( nMode ) // Call user function. ( old xDo ) + +ENDCLASS + +//-------------------------------------------------------------------// + +METHOD MemoInit( xUDF ) CLASS XHB_TMemoEditor + + LOCAL nUdfReturn + + DEFAULT xUDF TO NIL + + ::aEditKeys := { K_DOWN,; + K_UP,; + K_LEFT,; + K_RIGHT,; + K_CTRL_LEFT,; + K_CTRL_RIGHT,; + K_HOME,; + K_END,; + K_CTRL_HOME,; + K_CTRL_END,; + K_PGUP,; + K_PGDN,; + K_CTRL_PGUP,; + K_CTRL_PGDN,; + K_RETURN,; + K_ENTER,; + K_DEL,; + K_BS,; + K_CTRL_BS,; + K_TAB,; + K_SH_TAB } + + ::aAsciiKeys := Array( 255 - 31 ) // asc codes greater than space. + AEval( ::aAsciiKeys, {| c, i | iif( Empty( c ), ::aAsciiKeys[ i ] := i + 31, ) } ) + + // Save/Init object internal representation of user function + // + ::xUserFunction := xUDF + + + // NOTE: K_ALT_W is not compatible with clipper exit memo and save key, + // but I cannot discriminate K_CTRL_W and K_CTRL_END from harbour + // code. + // + +#ifdef HB_EXT_INKEY + /* CTRL_V in not same as K_INS, this works as paste selected text to clipboard. */ + ::aConfigurableKeys := { K_CTRL_N, K_CTRL_Y, K_CTRL_T, K_CTRL_B, K_CTRL_W, K_CTRL_RET } + ::aExtKeys := { K_ALT_W, K_CTRL_A, K_CTRL_C, K_CTRL_V, K_SH_INS, K_CTRL_X, K_SH_DOWN, K_SH_UP, K_SH_DEL, K_SH_RIGHT, K_SH_LEFT, K_SH_END, K_SH_HOME } +#else + /* CTRL_V is same as K_INS, so it has special treatment in memoedit. */ + ::aConfigurableKeys := { K_CTRL_N, K_CTRL_Y, K_CTRL_T, K_CTRL_B, K_CTRL_W } + ::aExtKeys := {} +#endif + + + ::aMouseKeys := { K_LBUTTONUP, K_MWFORWARD, K_MWBACKWARD } + + + IF ::ExistUdf() + /* Keep calling user function until it returns 0 + 05/08/2004 - + Clipper 5.2 memoedit() treats a NIL as ME_DEFAULT + */ + DO WHILE AScan( { ME_DEFAULT, NIL }, nUdfReturn := ::CallUdf( ME_INIT ) ) == 0 + + // At this time there is no input from user of MemoEdit() only handling + // of values returned by ::xUserFunction, so I pass these value on both + // parameters of ::HandleUdf() + // + ::HandleUdf( nUdfReturn, nUdfReturn, .F. ) + + ENDDO + + ENDIF + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD Edit() CLASS XHB_TMemoEditor + + LOCAL nKey, nUdfReturn, nNextKey + + // If I have an user function I need to trap configurable keys and ask to + // user function if handle them the standard way or not + // + + IF NextKey() == 0 .AND. ::ExistUdf() + ::CallUdf( ME_IDLE ) + ENDIF + + nNextKey := 0 + + DO WHILE !::lExitEdit + + IF nNextKey == 0 + nKey := Inkey( 0 ) + ELSE + nKey := nNextKey + nNextKey := 0 + ENDIF + + IF nNextKey == 0 .AND. ( ::bKeyBlock := Setkey( nKey ) ) != NIL + + Eval( ::bKeyBlock, ::ProcName, ::ProcLine, ReadVar() ) + + /* 2006/SEP/15 - E.F. - After Setkey() is executed, if exist nextkey, + * I need trap this nextkey to memoedit process + * first and the on the next loop. + */ + nNextKey := NextKey() + + IF nNextKey != 0 + Inkey() + ENDIF + + ENDIF + + /* 24/10/2005 - + Taken from clipper norton guide: + + The user function: , a user-defined function + specified as an argument, handles key exceptions and reconfigures + special keys. The user function is called at various times by + MEMOEDIT(), most often in response to keys it does not recognize. + Keys that instigate a key exception are all available control keys, + function keys, and Alt keys. Since these keys are not processed by + MEMOEDIT(), they can be reconfigured. Some of these keys have a + default action assigned to them. In the user function, you perform + various actions, depending on the current MEMOEDIT() mode, then + RETURN a value telling MEMOEDIT() what to do next. + + When the user function argument is specified, MEMOEDIT() defines two + classes of keys: nonconfigurable and key exceptions. When a + nonconfigurable key is pressed, MEMOEDIT() executes it, otherwise a + key exception is generated and the user function is called. When + there are no keys left in the keyboard buffer for MEMOEDIT() to + process, the user function is called once again. + */ + + IF ::bKeyBlock == NIL + + IF ( AScan( ::aEditKeys, nKey ) > 0 .OR.; + AScan( ::aAsciiKeys, nKey ) > 0 .OR.; + AScan( ::aConfigurableKeys, nKey ) > 0 .OR.; + AScan( ::aExtKeys, nKey ) > 0 .OR.; + ( nKey == K_INS .AND. !::ExistUdf() ) .OR.; + ( nKey == K_ESC .AND. !::ExistUdf() ) ) + + ::Super:Edit( nKey ) + + ELSEIF AScan( ::aConfigurableKeys, nKey ) == 0 .AND.; + AScan( ::aExtKeys, nKey ) == 0 .AND.; + ( nKey > 255 .OR. nKey < 0 ) .OR.; + ( nKey == K_INS .AND. ::lEditAllow .AND. ::ExistUdf() ) .OR.; + ( nKey == K_ESC .AND. ::ExistUdf() ) + + ::KeyboardHook( nKey ) + + ENDIF + + ENDIF + + IF ::ExistUdf() + + IF AScan( ::aEditKeys, nKey ) > 0 .OR.; + AScan( ::aAsciiKeys, nKey ) > 0 .OR.; + AScan( ::aConfigurableKeys, nKey ) > 0 .OR.; + AScan( ::aExtKeys, nKey ) > 0 .OR.; + nKey == K_F1 + + IF NextKey() == 0 .AND.; + AScan( ::aConfigurableKeys, nKey ) == 0 .AND. nKey != K_F1 + + nUdfReturn := ::CallUdf( ME_IDLE ) + + ELSE + + IF AScan( ::aConfigurableKeys, nKey ) == 0 + nUdfReturn := ::CallUdf( iif( ::lChanged, ME_UNKEYX, ME_UNKEY ) ) + ELSE + nUdfReturn := ::CallUdf( ME_UNKEY ) + ENDIF + + + ENDIF + + ::HandleUdf( nKey, nUdfReturn, ::bKeyBlock == NIL ) + + ENDIF + + ENDIF + + ENDDO + + RETURN Self + + +//-------------------------------------------------------------------// +// +// I come here if I have an unknown key and it is not a configurable key +// if there is an user function I leave to it its handling +// +METHOD KeyboardHook( nKey ) CLASS XHB_TMemoEditor + + LOCAL nUdfReturn + + IF ::ExistUdf() + nUdfReturn := ::CallUdf( iif( ::lChanged, ME_UNKEYX, ME_UNKEY ) ) + ::HandleUdf( nKey, nUdfReturn, .F. ) + ENDIF + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD HandleUdf( nKey, nUdfReturn, lEdited ) CLASS XHB_TMemoEditor + + + /* 05/08/2004 - + A little trick to be able to handle a nUdfReturn with value of NIL + like it had a value of ME_DEFAULT + */ + DEFAULT nUdfReturn TO ME_DEFAULT + DEFAULT lEdited TO .F. + + // I won't reach this point during ME_INIT since ME_DEFAULT ends + // initialization phase of MemoEdit() + // + SWITCH nUdfReturn + + CASE ME_DEFAULT // (0) + + // HBEditor is not able to handle keys with a value higher than 256 or lower than 1 + // + if !lEdited .AND.; + ( AScan( ::aAsciiKeys, nKey ) > 0 .OR.; + AScan( { K_ALT_W, K_CTRL_W }, nKey ) > 0 .OR.; + AScan( ::aExtKeys, nKey ) > 0 .OR.; + nKey == K_ESC .OR.; + nKey == K_INS .OR.; + AScan( ::aMouseKeys, nKey ) > 0 ) + + ::Super:Edit( nKey ) + + endif + exit + + CASE ME_IGNORE // (32) + + // Ignore unknow key, only check insert state. + ::DisplayInsert( ::lInsert() ) + exit + + CASE ME_DATA // (33) + + if !lEdited .AND.; + ( AScan( ::aAsciiKeys, nKey ) > 0 .OR.; + AScan( ::aExtKeys, nKey ) > 0 .OR.; + nKey == K_ESC .OR.; + nKey== K_INS ) + + ::Super:Edit( nKey ) + + endif + exit + + CASE ME_TOGGLEWRAP // (34) + ::lWordWrap := ! ::lWordWrap + exit + + CASE ME_TOGGLESCROLL // (35) + ::lVerticalScroll := ! ::lVerticalScroll + exit + + CASE ME_WORDRIGHT // (100) + ::WordRight() + exit + + CASE ME_BOTTOMRIGHT // (101) + ::Bottom() + ::End() + exit + + CASE ME_PASTE // (110) + // see inkey.ch + exit + + OTHERWISE // ME_UNKEY (1 TO 31) + + /* 2006/AUG/02 - E.F. - (NG) Process requested action corresponding to + * key value. + */ + nKey := nUdfReturn + +#ifdef HB_EXT_INKEY + IF ! lEdited .AND. ( ( nKey >= 1 .AND. nKey <= 31 ) .OR.; + ( nKey >= 513 .AND. nKey <= 538 ) .OR. AScan( ::aExtKeys, nKey ) > 0 ) + ::Super:Edit( nKey ) + ENDIF + EXIT +#else + IF ! lEdited .AND. nKey >= 1 .AND. nKey <= 31 + ::Super:Edit( nKey ) + ENDIF + EXIT +#endif + + ENDSWITCH + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD CallUdf( nMode ) CLASS XHB_TMemoEditor + + LOCAL nCurRow := ::Row() + LOCAL nCurCol := ::Col() + LOCAL xResult + + IF ::ExistUdf() + // Latest parameter, , is an xHarbour extension, maybe + // should be guarded as such with some ifdef + xResult := Do( ::xUserFunction, nMode, ::nRow, ::nCol - 1, Self ) + + ::SetPos( nCurRow, nCurCol ) + + ENDIF + + RETURN xResult + +//-------------------------------------------------------------------// +// Prg Level Call of MemoEdit() +//-------------------------------------------------------------------// + +FUNCTION xhb_MemoEdit( cString,; + nTop, nLeft,; + nBottom, nRight,; + lEditMode,; + xUDF,; + nLineLength,; + nTabSize,; + nTextBuffRow,; + nTextBuffColumn,; + nWindowRow,; + nWindowColumn ) + + LOCAL oEd + + DEFAULT cString TO "" + DEFAULT nTop TO 0 + DEFAULT nLeft TO 0 + DEFAULT nBottom TO MaxRow() + DEFAULT nRight TO MaxCol() + DEFAULT lEditMode TO .T. + DEFAULT nLineLength TO NIL + /* 24/10/2005 - + NG says 4, but clipper 5.2e inserts 3 spaces when pressing K_TAB + */ + DEFAULT nTabSize TO 3 + DEFAULT nTextBuffRow TO 1 + DEFAULT nTextBuffColumn TO 0 + DEFAULT nWindowRow TO 0 + DEFAULT nWindowColumn TO nTextBuffColumn + + // 2006/JUL/22 - E.F. Check argument types. + // + IF !HB_IsNil( cString ) .AND. ! HB_IsString( cString ) .AND. ! HB_IsMemo( cString ) + Throw( ErrorNew( "BASE", 0, 1127, " Argument type error", Procname() ) ) + ENDIF + IF !HB_IsNil( nTop ) .AND. !HB_IsNumeric( nTop ) + Throw( ErrorNew( "BASE", 0, 1127, " Argument type error", Procname() ) ) + ENDIF + IF !HB_IsNil( nLeft ) .AND. !HB_IsNumeric( nLeft ) + Throw( ErrorNew( "BASE", 0, 1127, " Argument type error", Procname() ) ) + ENDIF + IF !HB_IsNil( nRight ) .AND. !HB_IsNumeric( nRight ) + Throw( ErrorNew( "BASE", 0, 1127, " Argument type error", Procname() ) ) + ENDIF + IF !HB_IsNil( nBottom ) .AND. !HB_IsNumeric( nBottom ) + Throw( ErrorNew( "BASE", 0, 1127, " Argument type error", Procname() ) ) + ENDIF + IF !HB_IsNil( lEditMode ) .AND. !HB_IsLogical( lEditMode ) + Throw( ErrorNew( "BASE", 0, 1127, " Argument type error", Procname() ) ) + ENDIF + IF !HB_IsNil( xUDF ) .AND. ( !HB_IsString( xUDF ) .AND. !HB_IsLogical( xUDF ) ) + Throw( ErrorNew( "BASE", 0, 1127, " Argument type error", Procname() ) ) + ENDIF + IF !HB_IsNil( nLineLength ) .AND. !HB_IsNumeric( nLineLength ) + Throw( ErrorNew( "BASE", 0, 1127, " Argument type error", Procname() ) ) + ENDIF + IF !HB_IsNil( nTabSize ) .AND. !HB_IsNumeric( nTabSize ) + Throw( ErrorNew( "BASE", 0, 1127, " Argument type error", Procname() ) ) + ENDIF + IF !HB_IsNil( nTextBuffRow ) .AND. !HB_IsNumeric( nTextBuffRow ) + Throw( ErrorNew( "BASE", 0, 1127, " Argument type error", Procname() ) ) + ENDIF + IF !HB_IsNil( nTextBuffColumn ) .AND. !HB_IsNumeric( nTextBuffColumn ) + Throw( ErrorNew( "BASE", 0, 1127, " Argument type error", Procname() ) ) + ENDIF + IF !HB_IsNil( nWindowRow ) .AND. !HB_IsNumeric( nWindowRow ) + Throw( ErrorNew( "BASE", 0, 1127, " Argument type error", Procname() ) ) + ENDIF + IF !HB_IsNil( nWindowColumn ) .AND. !HB_IsNumeric( nWindowColumn ) + Throw( ErrorNew( "BASE", 0, 1127, " Argument type error", Procname() ) ) + ENDIF + + + // 2006/JUL/22 - E.F. To avoid run time error. + IF nTop > nBottom .OR. nLeft > nRight + Throw( ErrorNew( "BASE", 0, 1127, " Argument error", Procname() ) ) + ENDIF + + IF HB_IsString( xUDF ) .AND. Empty( xUDF ) + xUDF := NIL + ENDIF + + /* 24/10/2005 - + Clipper MemoEdit() converts Tabs into spaces + */ + oEd := XHB_TMemoEditor():New( StrTran( cString, Chr( K_TAB ), Space( nTabSize ) ),; + nTop, nLeft, nBottom, nRight,; + lEditMode,; + nLineLength,; + nTabSize,; + nTextBuffRow,; + nTextBuffColumn,; + nWindowRow,; + nWindowColumn ) + + oEd:ProcName := ProcName( 1 ) + oEd:ProcLine := ProcLine( 1 ) + + oEd:MemoInit( xUDF ) + oEd:RefreshWindow() + + // 2006/AUG/06 - E.F. Clipper's in .T. or. F. is samething. + // + IF !Hb_IsLogical( xUDF ) //.OR. cUserFunction == .T. + + oEd:Edit() + + IF oEd:lSaved + cString := oEd:GetText( .T. ) // Clipper inserts Soft CR + ENDIF + + ELSE + // 2006/JUL/24 - E.F. - If xUDF is in .F. or .T. cause diplay memo content and exit, + // so we have to repos the cursor at bottom of memoedit + // screen after that. + SetPos( Min( nBottom, MaxRow() ), 0 ) + ENDIF + + RETURN cString diff --git a/harbour/contrib/xhb/xhbtedit.prg b/harbour/contrib/xhb/xhbtedit.prg index 328408f191..611f0d4ce6 100644 --- a/harbour/contrib/xhb/xhbtedit.prg +++ b/harbour/contrib/xhb/xhbtedit.prg @@ -183,12 +183,12 @@ METHOD DelText() // Clear aText METHOD AddText( cString, lAtPos ) // Add text at the cursor METHOD GetTextIndex() // Return current cursor position in text. - + METHOD SetTextSelection( cAction, nCount ) // Start or modify the current selection. METHOD GetTextSelection( lSoftCr ) // Return the current selection. METHOD DelTextSelection() // Delete the current selection METHOD ClrTextSelection() // Clear the current selection. - + METHOD RefreshWindow() // Redraw a window METHOD RefreshLine( lRefreshColSel ) // Redraw a line METHOD RefreshColumn() // Redraw a column of text @@ -226,7 +226,7 @@ METHOD Left() METHOD WordLeft() METHOD Home() - + METHOD K_Ascii( nKey ) METHOD K_Return() METHOD K_Del() @@ -322,7 +322,7 @@ METHOD New( cString, nTop, nLeft, nBottom, nRight, lEditMode, nLineLength, nTabS ENDIF // set correct insert state - if ::lEditAllow + IF ::lEditAllow // Force to redraw INS message ::InsertState( ! Set( _SET_INSERT ) ) ::InsertState( ! Set( _SET_INSERT ) ) @@ -350,12 +350,12 @@ METHOD New( cString, nTop, nLeft, nBottom, nRight, lEditMode, nLineLength, nTabS // 2006/JUL/20 - E.F. - We should not replace SoftCR with chr(32). // See Text2Array function for more details. /* - * if chr( 141 ) $ cString + * IF chr( 141 ) $ cString * acsn := chr( 32 ) + chr( 141 ) + chr( 10 ) * cString := STRTRAN( cString, acsn, " " ) * acsn := chr( 141 ) + chr( 10 ) * cString := STRTRAN( cString, acsn, " " ) - * endif + * ENDIF */ @@ -367,7 +367,7 @@ METHOD New( cString, nTop, nLeft, nBottom, nRight, lEditMode, nLineLength, nTabS // ::aText := Text2Array( cString, nLineLength ) - if ::LastRow() == 0 + IF ::LastRow() == 0 AAdd( ::aText, HBTextLine():New() ) ENDIF @@ -463,7 +463,7 @@ METHOD RefreshWindow() CLASS XHBEditor // //ScrollFixed( ::nTop, ::nLeft, ::nBottom, ::nRight ) - for i := 0 TO Min( ::nNumRows - 1, ::LastRow() - 1 ) + FOR i := 0 TO Min( ::nNumRows - 1, ::LastRow() - 1 ) // 2006/JUL/23 - E.F. Adjusted to avoid out of bound. // Don't replace ::GetLine(nRow) by ::aText[nRow]:cText here, @@ -472,7 +472,7 @@ METHOD RefreshWindow() CLASS XHBEditor PadR( iif( ::nFirstRow + i <= ::LastRow(), SubStr( ::GetLine( ::nFirstRow + i ), ::nFirstCol, ::nNumCols ),Space(::nNumCols ) ) , ::nNumCols ), ; ::LineColor( ::nFirstRow + i ) ) - next + NEXT ScrollFixed( ::nTop + i, ::nLeft, ::nBottom, ::nRight ) @@ -492,7 +492,7 @@ METHOD LineColor( nRow ) CLASS XHBEditor LOCAL cColor - if ::lSelActive .AND. ( ( nRow >= ::nRowSelStart ) .AND. ( nRow <= ::nRowSelEnd ) ) .AND. ; + IF ::lSelActive .AND. ( ( nRow >= ::nRowSelStart ) .AND. ( nRow <= ::nRowSelEnd ) ) .AND. ; ::nRowSelStart > 0 .AND. ::nRowSelEnd > 0 cColor := hb_ColorIndex( ::cColorSpec, CLR_ENHANCED ) ELSE @@ -510,7 +510,7 @@ METHOD ColColor() CLASS XHBEditor LOCAL cColor - if ::lSelActive .AND. ::nColSelStart > 0 .AND. ::nColSelEnd > 0 .AND. ; + IF ::lSelActive .AND. ::nColSelStart > 0 .AND. ::nColSelEnd > 0 .AND. ; ::nColSelStart <= ::nColSelEnd cColor := hb_ColorIndex( ::cColorSpec, CLR_ENHANCED ) ELSE @@ -733,7 +733,7 @@ METHOD Edit( nPassedKey ) CLASS XHBEditor ENDIF ENDIF - Switch nKey + SWITCH nKey CASE K_LBUTTONUP CASE K_MWFORWARD CASE K_MWBACKWARD @@ -742,63 +742,25 @@ METHOD Edit( nPassedKey ) CLASS XHBEditor #ifdef HB_EXT_INKEY - CASE K_SH_DOWN - if ::nRow <= ::LastRow() - ::SetTextSelection( "ROW", + 1 ) - ENDIF - EXIT - - CASE K_SH_UP - if ::nRow > 1 - ::SetTextSelection( "ROW", - 1 ) - ENDIF - EXIT - - CASE K_SH_RIGHT - if ::nCol < ::nWordWrapCol + 1 - ::SetTextSelection( "COL", + 1 ) - ENDIF - EXIT - - CASE K_SH_END - if ::nCol < ::nWordWrapCol + 1 - ::SetTextSelection( "END" ) - ENDIF - EXIT - - CASE K_SH_LEFT - if ::nCol > 1 - ::SetTextSelection( "COL", - 1 ) - ENDIF - EXIT - - CASE K_SH_HOME - if ::nCol > 1 - ::SetTextSelection( "HOME" ) - ENDIF - EXIT - CASE K_CTRL_A // Select all ::SetTextSelection( "ALL" ) EXIT CASE K_CTRL_C // Copy - hb_gtInfo( GTI_CLIPBOARDDATA, ::GetTextSelection() ) + hb_gtInfo( HB_GTI_CLIPBOARDDATA, ::GetTextSelection() ) //::ClrTextSelection() EXIT CASE K_CTRL_X // Cut - CASE K_SH_DEL // Cut - hb_gtInfo( GTI_CLIPBOARDDATA, ::GetTextSelection() ) - if ::lEditAllow + hb_gtInfo( HB_GTI_CLIPBOARDDATA, ::GetTextSelection() ) + IF ::lEditAllow ::DelTextSelection() ENDIF EXIT CASE K_CTRL_V // Paste - CASE K_SH_INS // Paste - if ::lEditAllow - ::AddText( StrTran( hb_gtInfo( GTI_CLIPBOARDDATA ), Chr(0 ), Chr(32 ) ), .T. ) + IF ::lEditAllow + ::AddText( StrTran( hb_gtInfo( HB_GTI_CLIPBOARDDATA ), Chr( 0 ), " " ), .T. ) ::ClrTextSelection() ENDIF EXIT @@ -817,7 +779,7 @@ METHOD Edit( nPassedKey ) CLASS XHBEditor EXIT CASE K_CTRL_B // Reformat paragraph - if ::lEditAllow + IF ::lEditAllow ::ClrTextSelection() ::ReformParagraph() // 2006/JUL/29 -E.F. Added. ENDIF @@ -833,9 +795,8 @@ METHOD Edit( nPassedKey ) CLASS XHBEditor EXIT #endif - CASE K_CTRL_N - if ::lEditAllow // Clipper compatibility + IF ::lEditAllow // Clipper compatibility ::ClrTextSelection() ::lChanged := .T. ::Home() @@ -846,7 +807,7 @@ METHOD Edit( nPassedKey ) CLASS XHBEditor EXIT CASE K_CTRL_T - if ::lEditAllow + IF ::lEditAllow ::ClrTextSelection() ::lChanged := .T. ::DelWordRight() @@ -855,13 +816,13 @@ METHOD Edit( nPassedKey ) CLASS XHBEditor EXIT CASE K_CTRL_Y - if ::lEditAllow // Clipper compatibility + IF ::lEditAllow // Clipper compatibility ::lChanged := .T. ::ClrTextSelection() - if ::LastRow() > 1 .AND. ::nRow < ::LastRow() + IF ::LastRow() > 1 .AND. ::nRow < ::LastRow() ::RemoveLine( ::nRow ) ::RefreshWindow() - if ::LastRow() > 0 + IF ::LastRow() > 0 ::Home() ::RefreshLine() ENDIF @@ -875,8 +836,14 @@ METHOD Edit( nPassedKey ) CLASS XHBEditor EXIT CASE K_DOWN - ::ClrTextSelection() - ::Down() + IF hb_bitAnd( hb_gtInfo( HB_GTI_KBDSHIFTS ), HB_GTI_KBD_SHIFT ) != 0 + IF ::nRow <= ::LastRow() + ::SetTextSelection( "ROW", +1 ) + ENDIF + ELSE + ::ClrTextSelection() + ::Down() + ENDIF EXIT CASE K_PGDN @@ -890,8 +857,14 @@ METHOD Edit( nPassedKey ) CLASS XHBEditor EXIT CASE K_UP - ::ClrTextSelection() - ::Up() + IF hb_bitAnd( hb_gtInfo( HB_GTI_KBDSHIFTS ), HB_GTI_KBD_SHIFT ) != 0 + IF ::nRow > 1 + ::SetTextSelection( "ROW", -1 ) + ENDIF + ELSE + ::ClrTextSelection() + ::Up() + ENDIF EXIT CASE K_PGUP @@ -905,8 +878,14 @@ METHOD Edit( nPassedKey ) CLASS XHBEditor EXIT CASE K_RIGHT - ::ClrTextSelection() - ::Right() + IF hb_bitAnd( hb_gtInfo( HB_GTI_KBDSHIFTS ), HB_GTI_KBD_SHIFT ) != 0 + IF ::nCol < ::nWordWrapCol + 1 + ::SetTextSelection( "COL", +1 ) + ENDIF + ELSE + ::ClrTextSelection() + ::Right() + ENDIF EXIT CASE K_CTRL_RIGHT @@ -915,8 +894,14 @@ METHOD Edit( nPassedKey ) CLASS XHBEditor EXIT CASE K_LEFT - ::ClrTextSelection() - ::Left() + IF hb_bitAnd( hb_gtInfo( HB_GTI_KBDSHIFTS ), HB_GTI_KBD_SHIFT ) != 0 + IF ::nCol > 1 + ::SetTextSelection( "COL", -1 ) + ENDIF + ELSE + ::ClrTextSelection() + ::Left() + ENDIF EXIT CASE K_CTRL_LEFT @@ -925,8 +910,14 @@ METHOD Edit( nPassedKey ) CLASS XHBEditor EXIT CASE K_HOME - ::ClrTextSelection() - ::Home() + IF hb_bitAnd( hb_gtInfo( HB_GTI_KBDSHIFTS ), HB_GTI_KBD_SHIFT ) != 0 + IF ::nCol > 1 + ::SetTextSelection( "HOME" ) + ENDIF + ELSE + ::ClrTextSelection() + ::Home() + ENDIF EXIT CASE K_CTRL_HOME @@ -935,8 +926,14 @@ METHOD Edit( nPassedKey ) CLASS XHBEditor EXIT CASE K_END - ::ClrTextSelection() - ::End() + IF hb_bitAnd( hb_gtInfo( HB_GTI_KBDSHIFTS ), HB_GTI_KBD_SHIFT ) != 0 + IF ::nCol < ::nWordWrapCol + 1 + ::SetTextSelection( "END" ) + ENDIF + ELSE + ::ClrTextSelection() + ::End() + ENDIF EXIT CASE K_ESC @@ -950,30 +947,44 @@ METHOD Edit( nPassedKey ) CLASS XHBEditor EXIT CASE K_INS - // 2006/JUL/22 - E.F. - Insert is allowed only in edit mode. - if ::lEditAllow - ::ClrTextSelection() - ::InsertState( !::lInsert ) + IF hb_bitAnd( hb_gtInfo( HB_GTI_KBDSHIFTS ), HB_GTI_KBD_SHIFT ) != 0 + IF ::lEditAllow + ::AddText( StrTran( hb_gtInfo( HB_GTI_CLIPBOARDDATA ), Chr( 0 ), " " ), .T. ) + ::ClrTextSelection() + ENDIF + ELSE + // 2006/JUL/22 - E.F. - Insert is allowed only in edit mode. + IF ::lEditAllow + ::ClrTextSelection() + ::InsertState( !::lInsert ) + ENDIF ENDIF EXIT #ifdef HB_EXT_INKEY CASE K_DEL - if ::lSelActive .AND. ::lEditAllow + IF ::lSelActive .AND. ::lEditAllow ::DelTextSelection() - elseif ::lEditAllow // Clipper compatibility + ELSEIF ::lEditAllow // Clipper compatibility ::K_Del() ENDIF EXIT #else CASE K_DEL - if ::lEditAllow // Clipper compatibility - ::K_Del() + IF hb_bitAnd( hb_gtInfo( HB_GTI_KBDSHIFTS ), HB_GTI_KBD_SHIFT ) != 0 + hb_gtInfo( HB_GTI_CLIPBOARDDATA, ::GetTextSelection() ) + IF ::lEditAllow + ::DelTextSelection() + ENDIF + ELSE + IF ::lEditAllow // Clipper compatibility + ::K_Del() + ENDIF ENDIF EXIT #endif CASE K_TAB - if ::lEditAllow // Clipper compatibility + IF ::lEditAllow // Clipper compatibility ::ClrTextSelection() ::K_Tab() ENDIF @@ -981,7 +992,7 @@ METHOD Edit( nPassedKey ) CLASS XHBEditor CASE K_BS ::ClrTextSelection() - if ::lEditAllow // Clipper compatibility + IF ::lEditAllow // Clipper compatibility ::K_Bs() ELSE // 2006/JUL/22 - E.F. - Clipper backspace in read only is same as left movement. @@ -996,7 +1007,7 @@ METHOD Edit( nPassedKey ) CLASS XHBEditor OTHERWISE IF nKey >= K_SPACE .AND. nKey < 256 - if ::lEditAllow + IF ::lEditAllow ::ClrTextSelection() ::K_Ascii( nKey ) ENDIF @@ -1007,7 +1018,7 @@ METHOD Edit( nPassedKey ) CLASS XHBEditor ::KeyboardHook( nKey ) ENDIF - endswitch + ENDSWITCH ENDDO @@ -1029,7 +1040,7 @@ METHOD Down() CLASS XHBEditor IF ::nFirstRow < ::LastRow() .AND. ::LastRow() > ::nNumRows ::nFirstRow ++ ::nRow ++ - if ::nRow > ::LastRow() + IF ::nRow > ::LastRow() ::nRow -- ENDIF ::RefreshWindow() @@ -1054,12 +1065,12 @@ METHOD PageDown() CLASS XHBEditor ::Bottom() ELSE ::nFirstRow += nJump - if ::nFirstRow > ::LastRow() + IF ::nFirstRow > ::LastRow() ::nFirstRow := ::LastRow() ENDIF ::nRow += nJump - if ::nRow > ::LastRow() + IF ::nRow > ::LastRow() ::nRow := ::LastRow() ENDIF ::RefreshWindow() @@ -1106,7 +1117,7 @@ METHOD Up() CLASS XHBEditor IF ::nFirstRow > 1 ::nFirstRow -- ::nRow -- - if ::nRow < 1 + IF ::nRow < 1 ::nRow := 1 ENDIF ::RefreshWindow() @@ -1130,12 +1141,12 @@ METHOD PageUp() CLASS XHBEditor ::GoToLine( 1 ) ELSE ::nFirstRow -= nJump - if ::nFirstRow < 1 + IF ::nFirstRow < 1 ::nFirstRow := 1 ENDIF ::nRow -= nJump - if ::nRow < 1 + IF ::nRow < 1 ::nRow := 1 ENDIF ::RefreshWindow() @@ -1191,7 +1202,7 @@ METHOD Right() CLASS XHBEditor ::GotoPos( ::nRow, ::nCol + 1, .T. ) ENDIF ELSE - if ::nCol < Max( ::nNumCols, ::nWordWrapCol + 1 ) + IF ::nCol < Max( ::nNumCols, ::nWordWrapCol + 1 ) //::GotoCol( ::nCol + 1 ) ::GotoPos( ::nRow, ::nCol + 1 , .T. ) ENDIF @@ -1224,7 +1235,7 @@ METHOD WordRight() CLASS XHBEditor DO while ::nCol <= nMaxCol .AND. !Empty( ::GetCol( ::nRow, ::nCol ) ) ::Right() - if ::nCol > nMaxCol .OR. ; + IF ::nCol > nMaxCol .OR. ; ( !::lWordWrap .AND. ::nCol >= nMaxCol ) EXIT ENDIF @@ -1232,7 +1243,7 @@ METHOD WordRight() CLASS XHBEditor DO while ::nCol <= nMaxCol .AND. Empty( ::GetCol( ::nRow, ::nCol ) ) ::Right() - if ::nCol > nMaxCol .OR. ; + IF ::nCol > nMaxCol .OR. ; ( !::lWordWrap .AND. ::nCol >= nMaxCol ) EXIT ENDIF @@ -1250,11 +1261,11 @@ METHOD WordRight() CLASS XHBEditor // mod = move to next line // - If ::lRightScroll - if ::lWordWrap + IF ::lRightScroll + IF ::lWordWrap // 2006/JUL/21 - E.F. - If cursor reach rightmost position // go to the next line. - if ::nCol > nMaxCol .AND. ::nRow < ::LastRow() + IF ::nCol > nMaxCol .AND. ::nRow < ::LastRow() ::Down() ::Home() IF Empty( ::GetCol( ::nRow, ::nCol ) ) @@ -1262,17 +1273,17 @@ METHOD WordRight() CLASS XHBEditor ENDIF // 2006/JUL/21 - E.F. - If cursor stop at empty char and it is the // last reachable position go back to the previous word. - elseif ::nCol >= nMaxCol .AND. ::nRow == ::LastRow() + ELSEIF ::nCol >= nMaxCol .AND. ::nRow == ::LastRow() IF !Empty( ::GetCol( ::nRow, ::nCol ) ) ::end() ENDIF ::WordLeft() - elseif ::nCol == 1 .AND. Empty( ::GetCol( ::nRow, ::nCol ) ) + ELSEIF ::nCol == 1 .AND. Empty( ::GetCol( ::nRow, ::nCol ) ) ::WordRight() ENDIF ELSE // 2006/JUL/21 - E.F. - If cursor reach rightmost position go to back to prior word. - if ::nCol > nMaxCol + IF ::nCol > nMaxCol ::Wordleft() ENDIF ENDIF @@ -1326,7 +1337,7 @@ METHOD WordLeft() CLASS XHBEditor DispBegin() // to minimize flicker - if ::lWordWrap .AND. ::nCol == 1 .AND. ::nRow > 1 + IF ::lWordWrap .AND. ::nCol == 1 .AND. ::nRow > 1 ::Up() ::End() DO while ::nCol == 1 .AND. ::nRow > 1 .AND. Empty( ::GetCol( ::nRow,::nCol ) ) @@ -1358,10 +1369,10 @@ METHOD WordLeft() CLASS XHBEditor ::nCol < ::LineLen( ::nRow ) .AND. ; Empty( ::GetCol( ::nRow,::nCol ) ) ::WordRight() - elseif ::lWordWrap .AND. ::nCol = 1 .AND. ::nRow = 1 .AND. ; + ELSEIF ::lWordWrap .AND. ::nCol = 1 .AND. ::nRow = 1 .AND. ; Empty( ::GetCol( ::nRow,::nCol ) ) ::WordRight() - elseif ::lWordWrap .AND. ::nCol = 1 .AND. ::nRow > 1 + ELSEIF ::lWordWrap .AND. ::nCol = 1 .AND. ::nRow > 1 DO While ::nCol = 1 .AND. ::nRow > 1 .AND. Empty( ::GetCol( ::nRow, ::nCol ) ) ::up() IF !::IsEmptyLine( ::nRow ) @@ -1441,14 +1452,14 @@ METHOD K_Ascii( nKey ) CLASS XHBEditor // Always remeber the cursor position is always 1 ahead of buffer // So adding 1 below - Pritpal Bedi // - if ::nCol > ::LineLen( ::nRow ) + 1 // At end of line, add room + IF ::nCol > ::LineLen( ::nRow ) + 1 // At end of line, add room ::aText[ ::nRow ]:cText += Space( ::nCol - ::LineLen( ::nRow ) ) ::lChanged := .T. ENDIF // insert char if in insert mode or at end of current line // - if ::lInsert .OR. ( ::nCol > ::LineLen( ::nRow ) ) + IF ::lInsert .OR. ( ::nCol > ::LineLen( ::nRow ) ) ::aText[ ::nRow ]:cText := Stuff( ::aText[ ::nRow ]:cText, ::nCol, 0, Chr( nKey ) ) ::lChanged := .T. ELSE @@ -1488,7 +1499,7 @@ METHOD K_Bs() CLASS XHBEditor IF ( ::lWordWrap ) - if ::nRow > 1 .AND. ::nRow <= ::LastRow() + IF ::nRow > 1 .AND. ::nRow <= ::LastRow() // 2006/JUL/21 - E.F. - Determine new ::nCol position. // @@ -1638,15 +1649,15 @@ METHOD K_Tab() CLASS XHBEditor ENDIF // insert char if in insert mode or at end of current line - if ::nCol < ::nWordWrapCol - ::nTabWidth - ::nTabWidth - if ::lInsert .OR. ( ::nCol == ::LineLen( ::nRow ) ) + IF ::nCol < ::nWordWrapCol - ::nTabWidth - ::nTabWidth + IF ::lInsert .OR. ( ::nCol == ::LineLen( ::nRow ) ) ::aText[ ::nRow ]:cText := Stuff( ::aText[ ::nRow ]:cText, ::nCol, 0, Space( ::nTabWidth ) ) ENDIF ::lChanged := .T. ::lRightScroll := .F. //prevent auto linewrap for i := 1 to ::nTabWidth - if ::nCol < ::nWordWrapCol - ::nTabWidth - ::nTabWidth + IF ::nCol < ::nWordWrapCol - ::nTabWidth - ::nTabWidth ::Right() ::RefreshLine() ELSE @@ -1655,15 +1666,15 @@ METHOD K_Tab() CLASS XHBEditor next ::lRightScroll := .T. // wrap lines - if ::LineLen( ::nRow ) > ::nWordWrapCol + IF ::LineLen( ::nRow ) > ::nWordWrapCol lHardCR := .F. // should already by .F., but just to be safe, and it is a tiny line of code... - if ::aText[ ::nRow ]:lSoftCR + IF ::aText[ ::nRow ]:lSoftCR IF !::aText[ ::nRow+1 ]:lSoftCR // the next line has a hard return, keep it lHardCR := .T. ENDIF - if ::nRow == ::LastRow() - 1 // if next to last line of array, last line MUST have HR + IF ::nRow == ::LastRow() - 1 // if next to last line of array, last line MUST have HR lHardCR := .T. ENDIF @@ -1693,11 +1704,11 @@ METHOD K_Return() CLASS XHBEditor /* * IF ::lInsert * IF ::nRow == ::LastRow() -* if ::nCol > ::LineLen( ::nRow ) +* IF ::nCol > ::LineLen( ::nRow ) * ::AddLine( "", .F. ) * else * ::InsertLine( Substr( ::aText[ ::nRow ]:cText, ::nCol ), .F., ::nRow + 1 ) -* endif +* ENDIF * ELSEIF ::aText[ ::nRow ]:lSoftCR * ::aText[ ::nRow + 1 ]:cText := Substr( ::aText[ ::nRow ]:cText, ::nCol ) +" "+ ::aText[ ::nRow + 1 ]:cText * ::SplitLine( ::nRow + 1 ) @@ -1838,7 +1849,7 @@ METHOD GetLine( nRow ) CLASS XHBEditor DEFAULT nRow TO ::nRow IF nRow <= ::LastRow() .AND. nRow > 0 - if ::lEditAllow .OR. Empty( ::nTabWidth ) + IF ::lEditAllow .OR. Empty( ::nTabWidth ) return ::aText[ nRow ]:cText ELSE RETURN HB_TabExpand( ::aText[ nRow ]:cText, ::nTabWidth ) @@ -1920,7 +1931,7 @@ METHOD DelWordRight() CLASS XHBEditor ::aText[ ::nRow ]:cText := Stuff( ::aText[ ::nRow ]:cText, ::nCol, + nSpacesPre + nCutCol, " " ) - if ::lWordWrap .AND. ::aText[ ::nRow ]:lSoftCR + IF ::lWordWrap .AND. ::aText[ ::nRow ]:lSoftCR ::SplitLine( ::nRow ) ELSE ::aText[::nRow]:lSoftCR := .F. @@ -2426,7 +2437,7 @@ METHOD GetText( lSoftCr ) CLASS XHBEditor cSoft := Chr( 141 ) + Chr( 10 ) ENDIF - if ::lWordWrap + IF ::lWordWrap AEval( ::aText, { | cItem | cString += cItem:cText + iif( cItem:lSoftCR, cSoft, cEOL ) }, , ::LastRow() - 1 ) ELSE AEval( ::aText, { | cItem | cString += cItem:cText + cEOL }, , ::LastRow() - 1 ) @@ -2463,9 +2474,9 @@ METHOD GetTextSelection( lSoftCr ) CLASS XHBEditor cSoft := Chr( 141 ) + Chr( 10 ) ENDIF - if ::nRowSelStart > 0 .AND. ::nRowSelEnd > 0 + IF ::nRowSelStart > 0 .AND. ::nRowSelEnd > 0 - if ::nRowSelStart > ::nRowSelEnd + IF ::nRowSelStart > ::nRowSelEnd nRowSelStart := ::nRowSelEnd nRowSelEnd := ::nRowSelStart ELSE @@ -2478,7 +2489,7 @@ METHOD GetTextSelection( lSoftCr ) CLASS XHBEditor NEXT ENDIF - if ::nColSelStart > 0 .AND. ::nColSelEnd > 0 + IF ::nColSelStart > 0 .AND. ::nColSelEnd > 0 cString += SubStr( ::aText[ ::nRow ]:cText, ::nColSelStart, ::nColSelEnd - ::nColSelStart + 1 ) + iif( ::lWordWrap .AND. ::aText[ ::nRow ]:lSoftCR, cSoft, cEOL ) ENDIF @@ -2510,12 +2521,12 @@ METHOD SetTextSelection( cAction, nCount ) CLASS XHBEditor ::nRowSelStart := ::nRow ::nRowSelEnd := ::nRowSelStart ::RefreshLine() - if ::nRow < ::LastRow() + IF ::nRow < ::LastRow() ::GotoLine( ::nRow + 1 ) ENDIF ELSEIF nCount < 0 // Shift-UP - if ::nRow > 1 + IF ::nRow > 1 ::GotoLine( ::nRow - 1 ) ENDIF ::nRowSelStart := ::nRow @@ -2526,9 +2537,9 @@ METHOD SetTextSelection( cAction, nCount ) CLASS XHBEditor ELSEIF cAction == "COL" IF nCount > 0 // Shift Right - if ::nCol < ::nWordWrapCol + 1 + IF ::nCol < ::nWordWrapCol + 1 ::GotoCol( ::nCol + 1 ) - if ::nColSelStart == 0 + IF ::nColSelStart == 0 ::nColSelRow := ::nRow ::nColSelStart := Max( 1, ::nCol - 1 ) ENDIF @@ -2536,8 +2547,8 @@ METHOD SetTextSelection( cAction, nCount ) CLASS XHBEditor ::RefreshLine( .T. ) ENDIF ELSEIF nCount < 0 // Shift Left - if ::nCol > 1 - if ::nColSelStart = 0 .AND. ::nColSelEnd = 0 + IF ::nCol > 1 + IF ::nColSelStart = 0 .AND. ::nColSelEnd = 0 ::nColSelEnd := ::nColSelStart := ::nCol ENDIF ::GotoCol( ::nCol - 1 ) @@ -2553,7 +2564,7 @@ METHOD SetTextSelection( cAction, nCount ) CLASS XHBEditor ELSEIF cAction == "END" - if ::nColSelStart == 0 + IF ::nColSelStart == 0 ::nColSelRow := ::nRow ::nColSelStart := Max( 1, ::nCol - 1 ) ENDIF @@ -2584,16 +2595,16 @@ METHOD SetTextSelection( cAction, nCount ) CLASS XHBEditor IF nCount > 0 // Shift-Down - if ::nRowSelStart == 0 + IF ::nRowSelStart == 0 ::nRowSelStart := ::nRow - elseif ::nRowSelEnd > ::nRow + ELSEIF ::nRowSelEnd > ::nRow ::Clrtextselection() ::lSelActive := .T. ::nRowSelEnd := ::nRowSelStart := ::nRow - 1 ENDIF - if ::nRow >= ::nRowSelStart .AND. ::nRow <= ::nRowSelEnd - if ::nColSelStart > 0 .AND. ::nColSelEnd > 0 + IF ::nRow >= ::nRowSelStart .AND. ::nRow <= ::nRowSelEnd + IF ::nColSelStart > 0 .AND. ::nColSelEnd > 0 ::nRowSelStart := ::nRow ELSE ::nRowSelStart := ::nRow + 1 @@ -2604,7 +2615,7 @@ METHOD SetTextSelection( cAction, nCount ) CLASS XHBEditor ::nColSelStart := ::nColSelEnd := 0 - if ::nRowSelEnd == ::LastRow() + IF ::nRowSelEnd == ::LastRow() //::nRowSelEnd := ::LastRow()-1 /* 2006/SEP/17 - E.F. - At this point we need add a new line to be able to select the last row. @@ -2616,7 +2627,7 @@ METHOD SetTextSelection( cAction, nCount ) CLASS XHBEditor ENDIF ENDIF ::RefreshLine() - if ::nRow < ::LastRow() + IF ::nRow < ::LastRow() ::GotoLine( ::nRow + 1 ) ENDIF @@ -2633,8 +2644,8 @@ METHOD SetTextSelection( cAction, nCount ) CLASS XHBEditor ::nRowSelEnd := ::nRow ::RefreshLine() - elseif ::nRowSelEnd - ::nRowSelStart > 1 .AND. ; - ::nColSelStart > 0 .AND. ::nColSelEnd > 0 + ELSEIF ::nRowSelEnd - ::nRowSelStart > 1 .AND. ; + ::nColSelStart > 0 .AND. ::nColSelEnd > 0 ::Clrtextselection() ::lSelActive := .T. @@ -2645,12 +2656,12 @@ METHOD SetTextSelection( cAction, nCount ) CLASS XHBEditor ENDIF - if ::nRow > 1 + IF ::nRow > 1 ::GotoLine( ::nRow - 1 ) ENDIF - if ::nRow >= ::nRowSelStart .AND. ::nRow <= ::nRowSelEnd - if ::nRowSelEnd - ::nRowSelStart > 0 + IF ::nRow >= ::nRowSelStart .AND. ::nRow <= ::nRowSelEnd + IF ::nRowSelEnd - ::nRowSelStart > 0 ::nRowSelEnd := ::nRow - 1 ELSE ::nRowSelEnd := ::nRow @@ -2659,7 +2670,7 @@ METHOD SetTextSelection( cAction, nCount ) CLASS XHBEditor ::nRowSelStart := ::nRow ENDIF - if ::nRow == 1 .AND. ::nRowSelStart == 1 .AND. ::nRowSelEnd == 1 + IF ::nRow == 1 .AND. ::nRowSelStart == 1 .AND. ::nRowSelEnd == 1 ::Clrtextselection() ENDIF @@ -2670,14 +2681,14 @@ METHOD SetTextSelection( cAction, nCount ) CLASS XHBEditor ELSEIF cAction == "COL" IF nCount > 0 // Shift-Right - if ::nCol < ::nWordWrapCol + 1 + IF ::nCol < ::nWordWrapCol + 1 ::GotoCol( ::nCol + 1 ) - if ::nColSelStart == 0 + IF ::nColSelStart == 0 ::nColSelRow := ::nRow ::nColSelStart := Max( 1, ::nCol - 1 ) ENDIF ::nColSelEnd := Max( ::nColSelStart, ::nCol - 1 ) - if ::nColSelStart == ::nColSelEnd + IF ::nColSelStart == ::nColSelEnd ::nColSelStart := ::nColSelEnd := Max( 1, ::nCol - 1 ) ::nColSelRow := 0 ENDIF @@ -2686,23 +2697,23 @@ METHOD SetTextSelection( cAction, nCount ) CLASS XHBEditor ELSEIF nCount < 0 // Shift-Left - if ::nCol > 1 + IF ::nCol > 1 ::GotoCol( ::nCol - 1 ) - if ::nColSelEnd == 0 + IF ::nColSelEnd == 0 ::nColSelRow := ::nRow ::nColSelEnd := Max( ::nColSelEnd, ::nCol ) ENDIF - if ::nColSelStart <= ::nCol - 1 + IF ::nColSelStart <= ::nCol - 1 ::nColSelEnd := Min( ::nColSelEnd, ::nCol - 1 ) ELSE ::nColSelStart := Max( 1, ::nCol ) ENDIF - if ::nCol = 1 .AND. ::nColSelStart == ::nColSelEnd + IF ::nCol = 1 .AND. ::nColSelStart == ::nColSelEnd ::lSelActive := .F. ENDIF ::RefreshLine( .T. ) ELSE - if ::nColSelEnd == ::nColSelStart + IF ::nColSelEnd == ::nColSelStart ::nColSelStart := ::nColSelEnd := 0 ::nColSelRow := 0 ENDIF @@ -2713,7 +2724,7 @@ METHOD SetTextSelection( cAction, nCount ) CLASS XHBEditor ELSEIF cAction == "END" - if ::nColSelStart == 0 + IF ::nColSelStart == 0 ::nColSelStart := Max( 1, ::nCol - 1 ) ENDIF ::End() @@ -2740,7 +2751,7 @@ METHOD SetTextSelection( cAction, nCount ) CLASS XHBEditor METHOD ClrTextSelection() CLASS XHBEditor - if ::lSelActive + IF ::lSelActive ::lSelActive := .F. ::nRowSelStart := ::nRowSelEnd := 0 ::nColSelRow := 0 @@ -2783,12 +2794,12 @@ METHOD DelTextSelection() CLASS XHBEditor RETURN Self ENDIF - if ::lSelActive + IF ::lSelActive // if only rows are selected - if ::nRowSelStart > 0 .AND. ::nRowSelEnd > 0 + IF ::nRowSelStart > 0 .AND. ::nRowSelEnd > 0 - if ::nRowSelStart > ::nRowSelEnd + IF ::nRowSelStart > ::nRowSelEnd nRowSelStart := ::nRowSelEnd nRowSelEnd := ::nRowSelStart ELSE @@ -2814,10 +2825,10 @@ METHOD DelTextSelection() CLASS XHBEditor ELSE - if ::nColSelStart > 0 .AND. ::nColSelEnd > 0 - // if empty( nRowSelStart ) + IF ::nColSelStart > 0 .AND. ::nColSelEnd > 0 + // IF empty( nRowSelStart ) // nRowSelStart := ::nColSelRow - // endif + // ENDIF cText := ::aText[::nRow]:cText ::aText[::nRow]:cText := Stuff( cText, ::nColSelStart, ::nColSelEnd - ::nColSelStart + 1, "" ) ::RefreshLine() @@ -2831,7 +2842,7 @@ METHOD DelTextSelection() CLASS XHBEditor ENDIF // 3/03/2008 8:26a.m. added next 4 lines to fix array out of bounds RTL - if ::nRow > ::LastRow() + IF ::nRow > ::LastRow() ::Addline( "", .F. ) ::GoBottom() ENDIF @@ -2920,7 +2931,7 @@ METHOD LoadText( cString ) CLASS XHBEditor ::aText := Text2Array( cString, iif( ::lWordWrap, ::nNumCols, nil ) ) - if ::LastRow() == 0 + IF ::LastRow() == 0 AAdd( ::aText, HBTextLine():New() ) ENDIF @@ -2942,7 +2953,7 @@ METHOD LoadFile( cFileName ) CLASS XHBEditor ::aText := Text2Array( cString, iif( ::lWordWrap, ::nNumCols, nil ) ) - if ::LastRow() == 0 + IF ::LastRow() == 0 AAdd( ::aText, HBTextLine():New() ) ENDIF @@ -3135,9 +3146,9 @@ METHOD BrowseText( nPassedKey, lHandleOneKey ) CLASS XHBEditor If I'm on a readonly editor don't call KeyboardHook() because it calls HandleUserKey() which calls Edit() which sees this is a readonly editor and calls again BrowseText() which.., - if ! oSelf:MoveCursor( nKey ) + IF ! oSelf:MoveCursor( nKey ) oSelf:KeyboardHook( nKey ) - endif + ENDIF */ ENDIF