From: Rod O. <rod...@us...> - 2008-08-18 18:11:39
|
Update of /cvsroot/win32forth/win32forth/src/console In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv11872 Modified Files: CommandWindow.f NewConsole.f Log Message: Rod: fixed text wrapping during type - no more spurious characters Index: NewConsole.f =================================================================== RCS file: /cvsroot/win32forth/win32forth/src/console/NewConsole.f,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** NewConsole.f 17 Aug 2008 20:59:02 -0000 1.20 --- NewConsole.f 18 Aug 2008 18:10:50 -0000 1.21 *************** *** 1,5 **** \ $Id$ ! \ NewConsole.f Console window to replace w32fConsole.dll Needs src\console\CommandWindow.f --- 1,26 ---- \ $Id$ ! \ NewConsole.f - Console window to replace w32fConsole.dll by Rod Oakford ! \ ! \ This console has all the functionality of the old console plus additional features. ! \ ! \ n wrap: cmd wraps text output from type. (The command line is not wrapped, just scrolled) ! \ 0 (false) - no text wrapping ! \ Any positive number wraps the text after column n ! \ True (or any negative number) wraps the text after the last visible column ! \ ! \ font SetFont: cmd sets the font for the console which can be a variable character width font ! \ font NewFont ! \ s" Courier" SetFaceName: NewFont ! \ 20 height: NewFont ! \ NewFont SetFont: cmd ! ! \ green blue FGBG! makes the foreground green and background blue ! \ black white FGBG! normal colours for the console ! \ BigCursor: cmd sets the caret to the average character width ! \ SmallCursor: cmd sets the caret width to 1 pixel ! \ 1 SetLeftMargin: cmd left and right margins can be set ! \ 8 SetRightMargin: cmd would allow the big caret to show at the end of the command line ! Needs src\console\CommandWindow.f *************** *** 183,234 **** ; \ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ ! \ \\\\\ Text wrapping \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ - Create buffer2 512 allot - true value WrapText? - 40 value n1 \ max no. chars that fit on first line - 20 value w \ max no. chars that fit on subsequent whole lines - - : UpToCR ( a n - a n n ) 2dup 13 scan 10 scan 10 skip nip over swap - ; - : AddToBuffer ( a n - a n ) dup>r buffer2 +place r> /string ; - : WrapText ( a n -- a n ) - WrapText? 0= ?exit - buffer2 4 erase - UpToCR dup>r n1 ( 2 + ) > - IF - r>drop 2dup n1 min AddToBuffer - crlf$ count buffer2 +place - ELSE - 2dup r> min AddToBuffer - THEN - BEGIN - dup - WHILE - UpToCR dup>r w ( 2 + ) > - IF - r>drop 2dup w min AddToBuffer - crlf$ count buffer2 +place - ELSE - 2dup r> min AddToBuffer - THEN - - REPEAT - 2drop - buffer2 count - buffer2 +null - ; - : c_type ( a n -- ) KeysOff: cmd \ send key strokes to key buffer ! VisibleCols: cmd dup to w ! cmd.X - to n1 ! WrapText OverwriteTextAtXY: cmd PauseForMessages KeysOn: cmd ; - \ : c_type ( a n -- ) OverwriteTextAtXY: cmd ; : c_emit ( c -- ) sp@ 1 c_type drop ; : c_cr ( -- ) cr: cmd ; --- 204,219 ---- ; + \ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ ! \ \\\\\ Deferred I/O words \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ : c_type ( a n -- ) KeysOff: cmd \ send key strokes to key buffer ! OverwriteTextAtXY: cmd PauseForMessages KeysOn: cmd ; : c_emit ( c -- ) sp@ 1 c_type drop ; : c_cr ( -- ) cr: cmd ; Index: CommandWindow.f =================================================================== RCS file: /cvsroot/win32forth/win32forth/src/console/CommandWindow.f,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** CommandWindow.f 15 Aug 2008 11:29:03 -0000 1.13 --- CommandWindow.f 18 Aug 2008 18:10:50 -0000 1.14 *************** *** 733,738 **** ;M :M OverwriteTextAtXY: ( a n -- ) dup CheckTextBuffer \ one line at a time ! BEGIN 2dup 2dup 13 scan nip dup>r - dup>r OverwriteLineAtXY: self r> r> WHILE CR: self /string 13 skip 10 skip REPEAT 3drop --- 733,743 ---- ;M + int wrap + :M wrap: ( n -- ) to wrap ;M \ false: no wrapping, true: wrap after last visible column, positve value: wrap after this column + + : AdjustCount ( n -- n ) wrap IF wrap 0< IF VisibleCols: self ELSE wrap THEN X - min 0 max THEN ; + :M OverwriteTextAtXY: ( a n -- ) dup CheckTextBuffer \ one line at a time ! BEGIN dup>r 2dup 2dup 13 scan nip - AdjustCount dup>r OverwriteLineAtXY: self r@ 2r> - \ chars inserted, chars remaining WHILE CR: self /string 13 skip 10 skip REPEAT 3drop *************** *** 1201,1205 **** 100000 to MaxText 0 to head ! \ 0 to tail 1 to CaretWidth 13 to CaretHeight --- 1206,1210 ---- 100000 to MaxText 0 to head ! -1 to wrap 1 to CaretWidth 13 to CaretHeight |