From d7551ec7b319231a9e4b7f3d2561faddff94e600 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Mon, 13 Oct 2008 09:23:59 +0000 Subject: [PATCH] 2008-10-13 11:22 UTC+0200 Viktor Szakats (harbour.01 syenar hu) * source/rtl/teditor.prg + Added :LineCount(), :ExitState() methods. * Changed to use hb_MemoWrit() to write text content to disk, to avoid Chr(26) to be appended. ! Fixed :InsertState() to also modify physical cursor state. ! Fixed :BrowseText() to not go into an infinite loop in view mode. * source/rtl/memofile.c ! Minor formatting. * ChangeLog ! Fixed yesterday's entry dates. --- harbour/ChangeLog | 19 +++++++++++++++++-- harbour/source/rtl/memofile.c | 2 +- harbour/source/rtl/teditor.prg | 17 ++++++++++++++++- 3 files changed, 34 insertions(+), 4 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 47fe527ea2..854dd21987 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,7 +8,22 @@ 2008-12-31 13:59 UTC+0100 Foo Bar (foo.bar foobar.org) */ -2008-10-11 20:54 UTC+0200 Viktor Szakats (harbour.01 syenar hu) +2008-10-13 11:22 UTC+0200 Viktor Szakats (harbour.01 syenar hu) + * source/rtl/teditor.prg + + Added :LineCount(), :ExitState() methods. + * Changed to use hb_MemoWrit() to write text content to + disk, to avoid Chr(26) to be appended. + ! Fixed :InsertState() to also modify physical cursor state. + ! Fixed :BrowseText() to not go into an infinite loop in + view mode. + + * source/rtl/memofile.c + ! Minor formatting. + + * ChangeLog + ! Fixed yesterday's entry dates. + +2008-10-12 20:54 UTC+0200 Viktor Szakats (harbour.01 syenar hu) * include/hbapierr.h ! Fixed previous casting fix. @@ -32,7 +47,7 @@ * harbour/source/vm/thread.c * do not destroy critical sections on exit -2008-10-11 16:59 UTC+0200 Viktor Szakats (harbour.01 syenar hu) +2008-10-12 16:59 UTC+0200 Viktor Szakats (harbour.01 syenar hu) * make_b32.mak * make_vc.mak * make_gcc.mak diff --git a/harbour/source/rtl/memofile.c b/harbour/source/rtl/memofile.c index 2aef582544..c16ab9f4d0 100644 --- a/harbour/source/rtl/memofile.c +++ b/harbour/source/rtl/memofile.c @@ -150,7 +150,7 @@ HB_FUNC( HB_MEMOWRIT ) HB_FUNC( MEMOWRIT ) { #ifdef HB_EXTENSION - hb_retl( hb_memowrit( hb_parinfo(0) == 3 && ISLOG( 3 ) ? hb_parl( 3 ) : TRUE ) ); + hb_retl( hb_memowrit( hb_parinfo( 0 ) == 3 && ISLOG( 3 ) ? hb_parl( 3 ) : TRUE ) ); #else hb_retl( hb_memowrit( TRUE ) ); #endif diff --git a/harbour/source/rtl/teditor.prg b/harbour/source/rtl/teditor.prg index d95188323a..21e2cfba6f 100644 --- a/harbour/source/rtl/teditor.prg +++ b/harbour/source/rtl/teditor.prg @@ -75,6 +75,7 @@ CREATE CLASS HBEditor METHOD LineLen( nRow ) // Return text length of line n METHOD SplitLine( nRow ) // If a line of text is longer than nWordWrapCol divides it into multiple lines METHOD GotoLine( nRow ) // Put line nRow at cursor position + METHOD LineCount() // Returns number of lines in text. METHOD GetText() // Returns aText as a string (for MemoEdit()) @@ -86,6 +87,7 @@ CREATE CLASS HBEditor METHOD MoveCursor( nKey ) // Move cursor inside text / window (needs a movement key) METHOD InsertState( lInsState ) // Changes lInsert value and insertion / overstrike mode of editor METHOD Edit( nPassedKey ) // Handles input (can receive a key in which case handles only this key and then exits) + METHOD ExitState() // Returns ::lEditExit METHOD KeyboardHook( nKey ) // Gets called every time there is a key not handled directly by HBEditor METHOD IdleHook() // Gets called every time there are no more keys to hanlde just before HBEditor blocks itself waiting for a char @@ -232,7 +234,7 @@ METHOD SaveFile() CLASS HBEditor IF !Empty( ::cFile ) - ::lDirty := !MemoWrit( ::cFile, ::GetText() ) + ::lDirty := !hb_MemoWrit( ::cFile, ::GetText() ) RETURN !::lDirty ENDIF @@ -325,6 +327,9 @@ METHOD GotoLine( nRow ) CLASS HBEditor RETURN Self +METHOD LineCount() CLASS HBEditor + RETURN ::naTextLen + // If a line of text is longer than nWordWrapCol divides it into multiple lines, // Used during text editing to reflow a paragraph METHOD SplitLine( nRow ) CLASS HBEditor @@ -628,6 +633,9 @@ METHOD InsertState( lInsState ) CLASS HBEditor IF ISLOGICAL( lInsState ) ::lInsert := lInsState Set( _SET_INSERT, lInsState ) + IF ::lEditAllow + SetCursor( iif( lInsState, SC_INSERT, SC_NORMAL ) ) + ENDIF ENDIF RETURN Self @@ -792,6 +800,9 @@ METHOD Edit( nPassedKey ) CLASS HBEditor RETURN Self +METHOD ExitState() CLASS HBEditor + RETURN ::lEditExit + // This in an empty method which can be used by classes subclassing HBEditor to be able // to handle particular keys. METHOD KeyboardHook( nKey ) CLASS HBEditor @@ -942,6 +953,10 @@ METHOD BrowseText( nPassedKey ) ENDIF ENDIF + IF nPassedKey != NIL + EXIT + ENDIF + ENDDO RETURN Self