+ tests/stripeol.hb
+ added script to strip spaces at EOL
* contrib/gtalleg/tests/test.prg
* contrib/gtwvg/tests/demoxbp.prg
* contrib/gtwvg/tests/wvgactivex.prg
* contrib/gtwvg/tests/wvgxbp.prg
* contrib/gtwvg/wvgclass.prg
* contrib/hbamf/tests/tstendin.prg
* contrib/hbbz2/tests/test.prg
* contrib/hbcairo/tests/fancytxt.prg
* contrib/hbcairo/tests/table.prg
* contrib/hbct/ctrand.prg
* contrib/hbct/doc/en/addascii.txt
* contrib/hbct/doc/en/atadjust.txt
* contrib/hbct/doc/en/count.txt
* contrib/hbct/doc/en/ct.txt
* contrib/hbct/doc/en/ctc.txt
* contrib/hbct/doc/en/ctmath.txt
* contrib/hbct/doc/en/ctmath2.txt
* contrib/hbct/doc/en/ctpad.txt
* contrib/hbct/doc/en/ctstr.txt
* contrib/hbct/doc/en/datetime.txt
* contrib/hbct/doc/en/dattime2.txt
* contrib/hbct/doc/en/exponent.txt
* contrib/hbct/doc/en/finan.txt
* contrib/hbct/doc/en/ftoc.txt
* contrib/hbct/doc/en/justify.txt
* contrib/hbct/doc/en/keyset.txt
* contrib/hbct/doc/en/misc1.txt
* contrib/hbct/doc/en/num1.txt
* contrib/hbct/doc/en/numat.txt
* contrib/hbct/doc/en/numconv.txt
* contrib/hbct/doc/en/pos1.txt
* contrib/hbct/doc/en/pos2.txt
* contrib/hbct/doc/en/posdiff.txt
* contrib/hbct/doc/en/print.txt
* contrib/hbct/doc/en/range.txt
* contrib/hbct/doc/en/relation.txt
* contrib/hbct/doc/en/remove.txt
* contrib/hbct/doc/en/replace.txt
* contrib/hbct/doc/en/screen1.txt
* contrib/hbct/doc/en/strdiff.txt
* contrib/hbct/doc/en/strswap.txt
* contrib/hbct/doc/en/token1.txt
* contrib/hbct/doc/en/token2.txt
* contrib/hbct/doc/en/trig.txt
* contrib/hbct/doc/en/video.txt
* contrib/hbct/doc/en/wordtoch.txt
* contrib/hbct/getinfo.prg
* contrib/hbfimage/tests/fitest.prg
* contrib/hbgd/gdimage.prg
* contrib/hbgd/tests/counter.prg
* contrib/hbgd/tests/gdtest.prg
* contrib/hbgd/tests/gdtestcl.prg
* contrib/hbgd/tests/test_out.prg
* contrib/hbide/idetags.prg
* contrib/hblzf/tests/test2.prg
* contrib/hbmisc/doc/en/ht_conv.txt
* contrib/hbmisc/fcomma.prg
* contrib/hbmisc/fileread.prg
* contrib/hbmisc/hbedit.prg
* contrib/hbnf/anomatch.prg
* contrib/hbnf/calendar.prg
* contrib/hbnf/clrsel.prg
* contrib/hbnf/dispmsg.prg
* contrib/hbnf/doc/en/aading.txt
* contrib/hbnf/doc/en/aavg.txt
* contrib/hbnf/doc/en/acctadj.txt
* contrib/hbnf/doc/en/acctmnth.txt
* contrib/hbnf/doc/en/acctqtr.txt
* contrib/hbnf/doc/en/acctweek.txt
* contrib/hbnf/doc/en/acctyear.txt
* contrib/hbnf/doc/en/adessort.txt
* contrib/hbnf/doc/en/aemaxlen.txt
* contrib/hbnf/doc/en/aeminlen.txt
* contrib/hbnf/doc/en/amedian.txt
* contrib/hbnf/doc/en/anomatch.txt
* contrib/hbnf/doc/en/any2any.txt
* contrib/hbnf/doc/en/aredit.txt
* contrib/hbnf/doc/en/asum.txt
* contrib/hbnf/doc/en/at2.txt
* contrib/hbnf/doc/en/bitclr.txt
* contrib/hbnf/doc/en/bitset.txt
* contrib/hbnf/doc/en/blink.txt
* contrib/hbnf/doc/en/byt2bit.txt
* contrib/hbnf/doc/en/byt2hex.txt
* contrib/hbnf/doc/en/byteand.txt
* contrib/hbnf/doc/en/byteneg.txt
* contrib/hbnf/doc/en/bytenot.txt
* contrib/hbnf/doc/en/bytexor.txt
* contrib/hbnf/doc/en/calendar.txt
* contrib/hbnf/doc/en/chdir.txt
* contrib/hbnf/doc/en/cntryset.txt
* contrib/hbnf/doc/en/color2n.txt
* contrib/hbnf/doc/en/d2e.txt
* contrib/hbnf/doc/en/datecnfg.txt
* contrib/hbnf/doc/en/dayofyr.txt
* contrib/hbnf/doc/en/daytobow.txt
* contrib/hbnf/doc/en/dfile.txt
* contrib/hbnf/doc/en/diskfunc.txt
* contrib/hbnf/doc/en/dispc.txt
* contrib/hbnf/doc/en/dispmsg.txt
* contrib/hbnf/doc/en/dosver.txt
* contrib/hbnf/doc/en/e2d.txt
* contrib/hbnf/doc/en/easter.txt
* contrib/hbnf/doc/en/elapsed.txt
* contrib/hbnf/doc/en/findith.txt
* contrib/hbnf/doc/en/floptst.txt
* contrib/hbnf/doc/en/ftattr.txt
* contrib/hbnf/doc/en/ftidle.txt
* contrib/hbnf/doc/en/ftisprn.txt
* contrib/hbnf/doc/en/ftround.txt
* contrib/hbnf/doc/en/fttext.txt
* contrib/hbnf/doc/en/gcd.txt
* contrib/hbnf/doc/en/getenvrn.txt
* contrib/hbnf/doc/en/hex2dec.txt
* contrib/hbnf/doc/en/iamidle.txt
* contrib/hbnf/doc/en/isbit.txt
* contrib/hbnf/doc/en/isbiton.txt
* contrib/hbnf/doc/en/isshare.txt
* contrib/hbnf/doc/en/kspeed.txt
* contrib/hbnf/doc/en/linked.txt
* contrib/hbnf/doc/en/madd.txt
* contrib/hbnf/doc/en/menutonf.txt
* contrib/hbnf/doc/en/metaph.txt
* contrib/hbnf/doc/en/miltime.txt
* contrib/hbnf/doc/en/month.txt
* contrib/hbnf/doc/en/netpv.txt
* contrib/hbnf/doc/en/nooccur.txt
* contrib/hbnf/doc/en/ntow.txt
* contrib/hbnf/doc/en/nwlstat.txt
* contrib/hbnf/doc/en/nwsem.txt
* contrib/hbnf/doc/en/nwuid.txt
* contrib/hbnf/doc/en/ontick.txt
* contrib/hbnf/doc/en/origin.txt
* contrib/hbnf/doc/en/page.txt
* contrib/hbnf/doc/en/pchr.txt
* contrib/hbnf/doc/en/peek.txt
* contrib/hbnf/doc/en/pending.txt
* contrib/hbnf/doc/en/poke.txt
* contrib/hbnf/doc/en/popadder.txt
* contrib/hbnf/doc/en/proper.txt
* contrib/hbnf/doc/en/prtesc.txt
* contrib/hbnf/doc/en/putkey.txt
* contrib/hbnf/doc/en/qtr.txt
* contrib/hbnf/doc/en/rand1.txt
* contrib/hbnf/doc/en/savearr.txt
* contrib/hbnf/doc/en/scregion.txt
* contrib/hbnf/doc/en/setdate.txt
* contrib/hbnf/doc/en/setkeys.txt
* contrib/hbnf/doc/en/setlastk.txt
* contrib/hbnf/doc/en/settime.txt
* contrib/hbnf/doc/en/sinkey.txt
* contrib/hbnf/doc/en/sleep.txt
* contrib/hbnf/doc/en/sqzn.txt
* contrib/hbnf/doc/en/sysmem.txt
* contrib/hbnf/doc/en/tbwhile.txt
* contrib/hbnf/doc/en/tempfile.txt
* contrib/hbnf/doc/en/vertmenu.txt
* contrib/hbnf/doc/en/vidcur.txt
* contrib/hbnf/doc/en/vidmode.txt
* contrib/hbnf/doc/en/wda.txt
* contrib/hbnf/doc/en/week.txt
* contrib/hbnf/doc/en/workdays.txt
* contrib/hbnf/doc/en/woy.txt
* contrib/hbnf/doc/en/xbox.txt
* contrib/hbnf/doc/en/year.txt
* contrib/hbnf/ftround.prg
* contrib/hbnf/metaph.prg
* contrib/hbnf/nwsem.prg
* contrib/hbnf/nwuid.prg
* contrib/hbnf/pending.prg
* contrib/hbnf/popadder.prg
* contrib/hbnf/scregion.prg
* contrib/hbnf/tbwhile.prg
* contrib/hbnf/workdays.prg
* contrib/hbodbc/browodbc.prg
* contrib/hbqt/tests/browqt.prg
* contrib/hbqt/tests/dbfbrowserclass.prg
* contrib/hbqt/tests/testbrow.prg
* contrib/hbsqlit3/tests/blob.prg
* contrib/hbsqlit3/tests/sl3_test.prg
* contrib/hbxbp/tests/demoxbp.prg
* contrib/hbxbp/tests/dialogqt.prg
* contrib/hbxbp/xbpdataref.prg
* contrib/hbxbp/xbpmenubar.prg
* contrib/hbxbp/xbpprintdialog.prg
* contrib/hbxbp/xbpprinter.prg
* contrib/hbxbp/xbprtf.prg
* contrib/hbxbp/xbpscrollbar.prg
* contrib/xhb/cstruct.prg
* contrib/xhb/hblog.prg
* contrib/xhb/hterrsys.prg
* contrib/xhb/htjlist.prg
* contrib/xhb/sprintf.prg
* contrib/xhb/stream.prg
* contrib/xhb/tcgi.prg
* contrib/xhb/tedit.prg
* contrib/xhb/tfile.prg
* contrib/xhb/thtm.prg
* contrib/xhb/trpc.prg
* contrib/xhb/trpccli.prg
* contrib/xhb/ttable.prg
* contrib/xhb/txml.prg
* contrib/xhb/xcstr.prg
* contrib/xhb/xhberr.prg
* contrib/xhb/xhbmt.prg
* doc/cmpopt.txt
* doc/en/dbstrux.txt
* examples/hbapollo/array.prg
* examples/hbvpdf/hbvpdf.prg
* examples/hbvpdf/hbvpdft.prg
* examples/hbxlsxml/xlsxml_s.prg
* examples/hbxlsxml/xlsxml_y.prg
* examples/httpsrv/cgifunc.prg
* examples/httpsrv/cookie.prg
* examples/httpsrv/modules/cookie.prg
* examples/httpsrv/modules/info.prg
* examples/httpsrv/modules/showcounter.prg
* examples/httpsrv/modules/tableservletdb.prg
* examples/httpsrv/modules/testajax.prg
* examples/httpsrv/session.prg
* examples/httpsrv/uhttpd.prg
* include/hbclass.ch
* include/hbtrace.ch
* src/debug/dbgtinp.prg
* src/debug/debugger.prg
* src/debug/tbrwtext.prg
* src/rdd/usrrdd/rdds/hscdx.prg
* src/rtl/hbi18n2.prg
* src/rtl/valtoexp.prg
* formatting, fixed indentation, cleanups, deleting system specific information,
optimizing out platform dependent code, using hb_ntos()
545 lines
14 KiB
Plaintext
545 lines
14 KiB
Plaintext
/*
|
|
* $Id$
|
|
*/
|
|
|
|
#include "inkey.ch"
|
|
#include "setcurs.ch"
|
|
#include "fileio.ch"
|
|
#include "box.ch"
|
|
|
|
|
|
#define IIFNIL( isnil, notnil ) iif(notnil==NIL, isnil, notnil)
|
|
|
|
#define EDIT_LOWER 0 // convert to lowercase
|
|
#define EDIT_UPPER 1 // convert to uppercase
|
|
#define EDIT_SAME 2 // no convertion
|
|
|
|
#define EDIT_HARD 13 // hard cariage
|
|
#define EDIT_SOFT 141 // soft cariage
|
|
|
|
#define EDIT_EDIT .T. // full edit mode
|
|
#define EDIT_VIEW .F. // view only mode
|
|
|
|
// The editor structure
|
|
//
|
|
#define E_EDIT 1 // pointer returned be ED_NEW
|
|
#define E_TOP 2 // position on the screen
|
|
#define E_LEFT 3
|
|
#define E_BOTTOM 4
|
|
#define E_RIGHT 5
|
|
#define E_TITLE 6 // title
|
|
#define E_COLOR 7 // used colors set
|
|
#define E_FRAME 8 // frame around the editor
|
|
#define E_LINELEN 9 // maximal line length
|
|
#define E_MODE 10 // editor mode (edit/view)
|
|
#define E_INSERT 11 // insert state
|
|
#define E_CARGO 12 // cargo slot
|
|
#define E_STRUCT_LEN 12
|
|
|
|
STATIC s_nESize := 4096 // default buffer size
|
|
|
|
//
|
|
**
|
|
//
|
|
|
|
//---------------------------------------------------------
|
|
//03-06-93 07:52pm
|
|
//
|
|
// nTop, nLeft, nBottom, nRight - position on the screen
|
|
// nLength - the line length
|
|
// cFrame - the frame to be drawed around the editor
|
|
// cTitle - comment displayed in upper, left corner
|
|
// cColor - colors used to draw the editor
|
|
// nSize - the size of memory buffer that holds the edited text - the buffer
|
|
// will not grow at current design
|
|
// nEscape - the character code used as a marker of color highlighing
|
|
// For example if its value is 126 '~' then the following text:
|
|
// normal text ~2text in bold~1 back to normal text
|
|
// will be displayed with 'text in bold' highlighted using the second
|
|
// color specified by 'cColor' parameter
|
|
//
|
|
FUNCTION EditorNew( nTop, nLeft, nBottom, nRight, nLength, ;
|
|
cFrame, cTitle, cColor, nSize, nEscape )
|
|
LOCAL pEdit, oEdit
|
|
|
|
IF ! HB_ISNUMERIC( nLength )
|
|
nLength := 80
|
|
ENDIF
|
|
|
|
pEdit := ED_New( nLength, 4, IIFNIL(s_nESize, nSize), nEscape )
|
|
IF ! Empty( pEdit )
|
|
oEdit := ARRAY( E_STRUCT_LEN )
|
|
oEdit[E_EDIT] := pEdit
|
|
oEdit[E_TOP] := nTop
|
|
oEdit[E_LEFT] := nLeft
|
|
oEdit[E_BOTTOM] := nBottom
|
|
oEdit[E_RIGHT] := nRight
|
|
oEdit[E_LINELEN] := nLength
|
|
oEdit[E_FRAME] := IIFNIL( B_DOUBLE, cFrame )
|
|
oEdit[E_TITLE] := cTitle
|
|
oEdit[E_COLOR] := IIFNIL( "W/N,W+/N,W+/R,GR+/N,G+/N", cColor )
|
|
oEdit[E_MODE] := EDIT_VIEW
|
|
|
|
ED_Config( pEdit, nTop, nLeft, nBottom, nRight, 0, 0 )
|
|
ENDIF
|
|
|
|
RETURN oEdit
|
|
|
|
//---------------------------------------------------------
|
|
//03-06-93 09:16pm
|
|
//
|
|
PROCEDURE EditorKill( oEdit )
|
|
|
|
oEdit[E_EDIT] := NIL
|
|
|
|
RETURN
|
|
|
|
//---------------------------------------------------------
|
|
//03-06-93 10:20pm
|
|
//
|
|
FUNCTION EditorCargo( oEdit, xCargo )
|
|
LOCAL _xCargo:=oEdit[E_CARGO]
|
|
|
|
IF PCount() >= 2
|
|
oEdit[E_CARGO] := xCargo
|
|
ENDIF
|
|
|
|
RETURN _xCargo
|
|
|
|
//---------------------------------------------------------
|
|
//19-07-93 01:08am
|
|
//
|
|
FUNCTION EditorTitle( oEdit, cTitle )
|
|
LOCAL _cTitle := oEdit[ E_TITLE ]
|
|
|
|
IF HB_ISSTRING( cTitle )
|
|
oEdit[ E_TITLE ] := cTitle
|
|
ENDIF
|
|
|
|
RETURN _cTitle
|
|
|
|
//---------------------------------------------------------
|
|
//04-06-93 02:18am
|
|
//
|
|
// Sets
|
|
// EDIT_EDIT - full edit mode
|
|
// EDIT_VIEW - view only mode (no changes in text are allowed)
|
|
//
|
|
FUNCTION EditorMode( oEdit, lMode )
|
|
LOCAL _lMode := oEdit[ E_MODE ]
|
|
|
|
IF HB_ISLOGICAL( lMode )
|
|
oEdit[ E_MODE ] := lMode
|
|
ENDIF
|
|
|
|
RETURN _lMode
|
|
|
|
//---------------------------------------------------------
|
|
//28-05-92 09:31am
|
|
//
|
|
FUNCTION EditorSize( nSize )
|
|
LOCAL _nSize := s_nESize
|
|
|
|
IF nSize != NIL
|
|
s_nESize := nSize
|
|
ENDIF
|
|
|
|
RETURN _nSize
|
|
|
|
//---------------------------------------------------------
|
|
//28-02-92 10:57pm
|
|
//
|
|
// Appends passed text to the text already stored in editor
|
|
//
|
|
PROCEDURE EditorAddText( oEdit, cText )
|
|
|
|
ED_AddText( oEdit[ E_EDIT ], cText )
|
|
|
|
RETURN
|
|
|
|
//---------------------------------------------------------
|
|
//05-03-92 10:21pm
|
|
//
|
|
// Sets new text in editor
|
|
//
|
|
PROCEDURE EditorSetText( oEdit, cText )
|
|
|
|
ED_SetText( oEdit[ E_EDIT ], cText )
|
|
|
|
RETURN
|
|
|
|
//---------------------------------------------------------
|
|
//05-03-92 10:23pm
|
|
//
|
|
// Inserts passed text into editor starting from passed line number
|
|
//
|
|
PROCEDURE EditorInsText( oEdit, cText, nLine )
|
|
LOCAL nNum := IIFNIL( ED_LCount(oEdit[E_EDIT]), nLine )
|
|
|
|
ED_InsText( oEdit[ E_EDIT ], cText, nNum )
|
|
|
|
RETURN
|
|
|
|
//---------------------------------------------------------
|
|
//02-03-92 07:53pm
|
|
//
|
|
// Retrieves the text from editor
|
|
// nCarret - specifies if soft carriage return (141/10) should be replaced by
|
|
// hard carriage returns (13/10)
|
|
//
|
|
FUNCTION EditorGetText( oEdit, nCarret )
|
|
|
|
IF ! HB_ISNUMERIC( nCarret )
|
|
nCarret := EDIT_HARD
|
|
ENDIF
|
|
|
|
RETURN ED_GetText( oEdit[E_EDIT], nCarret )
|
|
|
|
//---------------------------------------------------------
|
|
//04-03-92 02:35pm
|
|
//
|
|
// Returns the line count stored in editor
|
|
//
|
|
FUNCTION EditorLCount( oEdit )
|
|
|
|
RETURN ED_LCount( oEdit[E_EDIT] )
|
|
|
|
//---------------------------------------------------------
|
|
//06-03-92 07:09pm
|
|
//
|
|
// Returns the specified line of text from the editor
|
|
//
|
|
FUNCTION EditorGetLine( oEdit, nLine )
|
|
|
|
RETURN ED_GetLine( oEdit[E_EDIT], nLine )
|
|
|
|
//---------------------------------------------------------
|
|
//06-03-92 07:10pm
|
|
//
|
|
// Returns the next line of text
|
|
//
|
|
// It can be used:
|
|
// nLCount :=EditorLCount( oEdit )
|
|
// cLine :=EditorGetLine( oEdit, 1 )
|
|
// FOR i:=2 TO nLCount
|
|
// cLine :=EditorNextLine( oEdit )
|
|
// NEXT
|
|
//
|
|
FUNCTION EditorNextLine( oEdit )
|
|
|
|
RETURN ED_GetNext(oEdit[E_EDIT])
|
|
|
|
//---------------------------------------------------------
|
|
//03-06-93 10:11pm
|
|
//
|
|
// Edit the specified file
|
|
//
|
|
// xInput - the filename to edit or a handle to a file retrned by FOPEN
|
|
// cOutput - the name of the file created in 'save' operation
|
|
// nLineLen - the line length
|
|
// nHelp - the index into help subsystem
|
|
// lPrint - specifies if edited file can be printed
|
|
// lConv - it was used to convert some unprintable characters
|
|
// nEscape - the code of color escape character
|
|
// lSave - specifies if edited file can be saved under a different name
|
|
//
|
|
FUNCTION EditorFile( xInput, cOutput, nLineLen, ;
|
|
lConv, nEscape, lSave )
|
|
LOCAL nHandle, nLen, oEdit, lSaved, lClose := .F.
|
|
LOCAL nSize
|
|
|
|
IF ! HB_ISLOGICAL( lSave )
|
|
lSave := .T.
|
|
ENDIF
|
|
|
|
IF HB_ISSTRING(xInput)
|
|
nHandle := FOPEN( xInput )
|
|
lClose := .T.
|
|
ELSE
|
|
nHandle := xInput
|
|
ENDIF
|
|
|
|
IF nHandle > 0
|
|
nLen := MAX( FileLength( nHandle ), s_nESize )
|
|
ELSE
|
|
nLen := s_nESize
|
|
ENDIF
|
|
|
|
nSize := iif( nLen < 8192, nLen*2, INT(nLen*1.5) )
|
|
oEdit := EditorNew( 01,00,23,79, nLineLen, "--- ", cOutput, , ;
|
|
nSize, nEscape )
|
|
|
|
IF nHandle > 0
|
|
ED_ReadText( oEdit[E_EDIT], nHandle, 0, nLen, ;
|
|
iif( lConv==NIL, .F., lConv ) )
|
|
IF lClose
|
|
FCLOSE( nHandle )
|
|
ENDIF
|
|
ELSE
|
|
EditorSetText( oEdit, " " )
|
|
ENDIF
|
|
|
|
EditorCargo( oEdit, cOutput )
|
|
|
|
lSaved := EditorEdit( oEdit, EDIT_EDIT, .F. )
|
|
EditorKill( oEdit )
|
|
|
|
RETURN lSaved
|
|
|
|
//---------------------------------------------------------
|
|
//06-07-93 06:05pm
|
|
//
|
|
// Reads a text from a file into the editor
|
|
//
|
|
// oEditor - existing editor
|
|
// nHandle - handle to an open file to read from
|
|
// nOffset - the starting offset
|
|
// nLen - the number of characters to read
|
|
// lConv - specifies if some unprintable characters should be converted
|
|
// (NOTE: it was used to allow display charcters with ASCII code 27 and 26)
|
|
//
|
|
FUNCTION EditorRead( oEditor, nHandle, nOffset, nLen, lConv )
|
|
|
|
RETURN ED_ReadText( oEditor[E_EDIT], nHandle, nOffset, nLen, ;
|
|
iif( lConv==NIL, .T., lConv ) )
|
|
|
|
//---------------------------------------------------------
|
|
//03-06-93 08:31pm
|
|
//
|
|
// Start the editor
|
|
//
|
|
// oEdit - the editor object
|
|
// lEdit - .T. = edit allowed, .F. = view only mode
|
|
// lFrame - specifies if the frame around the editor should be displayed
|
|
// nHelp - the help index into help subsystem
|
|
//
|
|
FUNCTION EditorEdit( oEdit, lEdit, lFrame )
|
|
LOCAL nRow, nCol := 0, nKey, bKey, oBox, nCursor, nState
|
|
LOCAL nTop, nLeft, nBottom, nRight
|
|
LOCAL lSaveAllowed, lSaved := .F.
|
|
|
|
oBox := SAVEBOX( oEdit[E_TOP], oEdit[E_LEFT], ;
|
|
oEdit[E_BOTTOM], oEdit[E_RIGHT], ;
|
|
oEdit[E_COLOR], oEdit[E_FRAME] )
|
|
|
|
oEdit[E_INSERT] := SET( _SET_INSERT )
|
|
// SayInsert()
|
|
nCursor := SetCursor( iif(oEdit[E_INSERT], SC_NORMAL, SC_SPECIAL1) )
|
|
IF HB_ISLOGICAL( lEdit )
|
|
oEdit[E_MODE] := lEdit
|
|
ENDIF
|
|
lSaveAllowed :=( SETKEY(K_F2) == NIL )
|
|
// IF lSaveAllowed
|
|
// DisplayHelp( 73 ) //F2-save
|
|
// ENDIF
|
|
|
|
nTop := oEdit[ E_TOP ] + 1
|
|
nLeft := oEdit[ E_LEFT ] + 1
|
|
nBottom := oEdit[ E_BOTTOM ] - 1
|
|
nRight := oEdit[ E_RIGHT ] - 1
|
|
IF lFrame != NIL .AND. ! lFrame
|
|
nLeft--
|
|
nBottom++
|
|
nRight++
|
|
ENDIF
|
|
nState := oEdit[ E_RIGHT ] - 8
|
|
|
|
/* The position of the editor can be changed (in a windowed environment)
|
|
then it sets current position of editor.
|
|
It also sets the current editor as the working one. This means that
|
|
all next ED_* functions will used the editor handle specified
|
|
by oEditor[E_EDIT] - it is tricky solution to speed access (we
|
|
don't need to pass the editor handle with every ED_*() call
|
|
(Well... this editor was created when AT-286 computers worked in
|
|
its full glory :)
|
|
*/
|
|
ED_Config( oEdit[ E_EDIT ], nTop, nLeft, nBottom, nRight, 0, 0 )
|
|
|
|
DO WHILE .T.
|
|
nRow := ED_Stabilize( oEdit[ E_EDIT ] ) //displays all visible lines
|
|
// It don't uses incremantal stabilization for performance reasons
|
|
|
|
IF nRow != ED_Row( oEdit[ E_EDIT ] )
|
|
nRow := ED_Row( oEdit[ E_EDIT ] )
|
|
@ oEdit[ E_TOP ], nState SAY STRZERO( nRow, 4 )
|
|
ENDIF
|
|
IF nCol != ED_Col( oEdit[ E_EDIT ] )
|
|
nCol := ED_Col( oEdit[ E_EDIT ] )
|
|
@ oEdit[ E_TOP ], nState + 5 SAY STRZERO( nCol, 3 )
|
|
ENDIF
|
|
SETPOS( nTop + ED_WinRow( oEdit[ E_EDIT ] ), nLeft + ED_WinCol( oEdit[ E_EDIT ] ) )
|
|
|
|
// nKey := WaitForKey()
|
|
nKey := INKEY( 0 )
|
|
|
|
DO CASE
|
|
CASE nKey >= 32 .AND. nKey < 256
|
|
IF oEdit[ E_MODE ]
|
|
ED_PutChar( oEdit[ E_EDIT ], nKey, oEdit[E_INSERT] )
|
|
ENDIF
|
|
|
|
CASE nKey == K_F2 .AND. lSaveAllowed
|
|
lSaved := EditorSave( oEdit ) //save the copy of edited buffer
|
|
|
|
CASE EditorMove( oEdit[ E_EDIT ], nKey )
|
|
|
|
CASE nKey == K_DOWN
|
|
IF ! ED_Down( oEdit[ E_EDIT ] )
|
|
SCROLL( nTop, nLeft, nBottom, nRight, 1 )
|
|
ENDIF
|
|
|
|
CASE nKey == K_UP
|
|
IF ! ED_Up( oEdit[ E_EDIT ] )
|
|
SCROLL( nTop, nLeft, nBottom, nRight, -1 )
|
|
ENDIF
|
|
|
|
CASE nKey == K_ESC
|
|
EXIT
|
|
|
|
OTHERWISE
|
|
bKey := SETKEY( nKey )
|
|
IF HB_ISBLOCK( bKey )
|
|
EVAL( bKey, oEdit )
|
|
ELSE
|
|
IF oEdit[E_MODE]
|
|
EditorKeys( oEdit, nKey )
|
|
ENDIF
|
|
ENDIF
|
|
ENDCASE
|
|
ENDDO
|
|
|
|
SetCursor( nCursor )
|
|
RESTBOX( oBox )
|
|
// HELPREST.
|
|
|
|
RETURN lSaved
|
|
|
|
|
|
//
|
|
**
|
|
//
|
|
|
|
//---------------------------------------------------------
|
|
//03-06-93 08:35pm
|
|
//
|
|
STATIC PROCEDURE EditorKeys( oEdit, nKey )
|
|
LOCAL i
|
|
|
|
DO CASE
|
|
CASE nKey == K_CTRL_Y
|
|
ED_DelLine( oEdit[ E_EDIT ] )
|
|
|
|
CASE nKey == K_CTRL_T
|
|
ED_DelWord( oEdit[ E_EDIT ] )
|
|
|
|
CASE nKey == K_DEL
|
|
ED_DelChar( oEdit[ E_EDIT ] )
|
|
|
|
CASE nKey == K_BS
|
|
ED_BSpace( oEdit[ E_EDIT ], oEdit[E_INSERT] )
|
|
|
|
CASE nKey == K_RETURN
|
|
ED_Return( oEdit[ E_EDIT ], oEdit[E_INSERT] )
|
|
|
|
CASE nKey == K_TAB
|
|
// ED_Tab( oEdit[ E_EDIT ], oEdit[E_INSERT] )
|
|
FOR i := 1 TO 4
|
|
ED_PutChar( oEdit[ E_EDIT ], 32, oEdit[E_INSERT] )
|
|
NEXT
|
|
|
|
CASE nKey == K_INS
|
|
oEdit[E_INSERT] := !oEdit[E_INSERT]
|
|
SET( _SET_INSERT, oEdit[E_INSERT] )
|
|
SetCursor( iif(oEdit[E_INSERT], SC_NORMAL, SC_SPECIAL1) )
|
|
// SayInsert()
|
|
|
|
ENDCASE
|
|
|
|
RETURN
|
|
|
|
//---------------------------------------------------------
|
|
//04-06-93 02:06am
|
|
//
|
|
STATIC FUNCTION EditorMove( pEdit, nKey )
|
|
LOCAL lMoved := .T.
|
|
|
|
DO CASE
|
|
CASE nKey == K_PGDN ; ED_PgDown( pEdit )
|
|
CASE nKey == K_PGUP ; ED_PgUp( pEdit )
|
|
CASE nKey == K_CTRL_PGUP ; ED_Top( pEdit )
|
|
CASE nKey == K_CTRL_PGDN ; ED_Bottom( pEdit )
|
|
CASE nKey == K_RIGHT ; ED_Right( pEdit )
|
|
CASE nKey == K_LEFT ; ED_Left( pEdit )
|
|
CASE nKey == K_HOME ; ED_Home( pEdit )
|
|
CASE nKey == K_CTRL_HOME ; ED_Home( pEdit )
|
|
CASE nKey == K_END ; ED_End( pEdit )
|
|
CASE nKey == K_CTRL_END ; ED_End( pEdit )
|
|
CASE nKey == K_CTRL_RIGHT // ; ED_NWord( pEdit ) //there are some problems with it
|
|
CASE nKey == K_CTRL_LEFT ; ED_PWord( pEdit )
|
|
OTHERWISE ; lMoved := .F.
|
|
ENDCASE
|
|
|
|
RETURN lMoved
|
|
|
|
//---------------------------------------------------------
|
|
//03-06-93 10:23pm
|
|
//
|
|
STATIC FUNCTION EditorSave( oEdit )
|
|
LOCAL nHandle, cFile
|
|
|
|
cFile := EditorCargo( oEdit )
|
|
IF EMPTY( cFile )
|
|
cFile := "testfile.txt" //GetFileName( 10, 10 )
|
|
ENDIF
|
|
|
|
IF EMPTY( cFile )
|
|
RETURN .F.
|
|
ENDIF
|
|
|
|
nHandle := FCREATE( cFile, FC_NORMAL )
|
|
IF nHandle > 0
|
|
FWRITE( nHandle, EditorGetText( oEdit ) )
|
|
|
|
FCLOSE( nHandle )
|
|
ENDIF
|
|
|
|
RETURN nHandle > 0
|
|
|
|
//---------------------------------------------------------
|
|
*09/29/91 08:40pm
|
|
*
|
|
FUNCTION SaveBox( top, left, bott, right, kolor, patt )
|
|
LOCAL cBox, cClr, nBottom, nRight
|
|
|
|
IF PCOUNT() > 4
|
|
cClr := SETCOLOR( kolor )
|
|
cBox := SAVESCREEN( top, left, bott, right)
|
|
@ top, left, bott, right BOX patt
|
|
ELSE
|
|
cClr := SETCOLOR()
|
|
cBox := SAVESCREEN( top, left, bott, right )
|
|
nBottom := bott
|
|
nRight := right
|
|
ENDIF
|
|
|
|
RETURN { top, left, nBottom, nRight, cBox, cClr }
|
|
|
|
|
|
//---------------------------------------------------------
|
|
*09/29/91 08:42pm
|
|
*
|
|
PROCEDURE RestBox( oBox )
|
|
|
|
RESTSCREEN( oBox[ 1 ], oBox[ 2 ], oBox[ 3 ], oBox[ 4 ], oBox[ 5 ] )
|
|
SETCOLOR( oBox[ 6 ] )
|
|
|
|
RETURN
|
|
|
|
STATIC FUNCTION FileLength( nH )
|
|
LOCAL nPos := FSEEK( nH, 0, FS_RELATIVE )
|
|
LOCAL nLen := FSEEK( nH, 0, FS_END )
|
|
|
|
FSEEK( nH, nPos, FS_SET )
|
|
|
|
RETURN nLen
|