Class MEDIT

Name

MEDIT  --  Class are destined to control multi TEXTEDIT objects.

Synopsis

 mEdit()	--> MEDIT object
 mEdit_new()		--> MEDIT object

Description

Class are destined to control multi TEXTEDIT objects.

Attributes

<ClassName> MEDIT
<Tobj> Array, an array of TEXTEDIT objects
<TobjInfo> Array, an array of window information for every element <Tobj>
<Curwin> Numeric, the cureent window number.
<Clipboard> Array, an clipboard array.
<Find> FIND object, contain search information and options
<Opt> Map, the MEDIT configuration
  OCREATEBAK - Logical, if TRUE create .bak files, specified TE_CREATE_BAK
  OTABSIZE - Numeric, the tabulation size, specified TE_TABSIZE
  OAUTOSAVE - Logical, if TRUE save TEXEDIT objects automatical every OTIMEAUTOSAVE time, specified TE_AUTO_SAVE
  OTIMEAUTOSAVE - Numeric, the time autosave in minute, specified TE_TIME_AUTO_SAVE
  OSAVESTATUS - Logical, if TRUE autosave this options into file, specified TE_SAVE_STATUS
  OHYPHEN - Logical, if TRUE hyphen, specified TE_HYPHEN.
  OAUTOMARGIN - Logical, if TRUE auto margin boundary, specified TE_AUTO_MARGIN.
  OMARGINLEFT - Numeric, the left margin, specified TE_MARGIN_LEFT.
  OMARGINRIGHT - Numeric, the right margin, specified TE_MARGIN_RIGHT.
  OAUTOINDENT - Logical, if TRUE auto set new column position by position first letter of previouse line, specified TE_AUTO_IDENT.
  
<Templ> Map, the key is template, data - substring to replace.
<Tempmacro> Map, the key is template, data - macro values.
<UserFunc> String, the name user function.
<nTop> a MEDIT viewport coordinates (default - 0)
<nLeft> a MEDIT viewport coordinates (default - 0)
<nBot> a MEDIT viewport coordinates (default - maxrow())
<nRight> a MEDIT viewport coordinates (default - maxcol())
  
<Param> Array, array of file names to edit.
<Tab_size> Numeric, the tabulation size.
<bLine> Numeric, the line number by loading (default 1).
<bPos> Numeric, the column number by loading (default 1).
<wLine> Numeric, the line number in viewport by loading (default 1).
<wPos> Numeric, the column number in viewport by loading (default 1).
<Single_mode> Logical, if TRUE - the draw mode is SINGLE (default FALSE)
<Double_mode> Logical, if TRUE - the draw mode is DOUBLE (default FALSE).
<stLine> String, the status line text (default [ESC - menu]).
<oMenu> MENU object.
<AutoIndent> Logical, if TRUE auto identification new column position into new line by previose line (default TRUE)
  

Methods

APPLYHASH Evaluate the code block.
BACKSPACE Delete symbol.
CALLMENU Call and run menu.
CANCELBLOCK Unmark block.
CENTERLINE Centered line.
CHANGECHARSET Change charset.
CHOOSECODEPAGE Choose and set new codepage.
CLOSEWINDOW Close window.
COPYBLOCK Copy or move block to new position line and column.
COPYTOCLIPBOARD Copy block to clipboard.
CREATENEWWINDOW Create new TEXTEDIT object into new window.
DELETE Delete symbol.
DELETEBLOCK Remove block.
DELETEEND Delete string from current column to th end of string.
DELETEHOME Delete string from cuurent column to the start of string.
DELETELINE Delete line.
DRAWHEAD Draw border header.
EDITKEYS Edit MEDIT options.
EDITOPT Edit MEDIT options.
ENABLEBLOCKMENU Enable block menu items.
ENABLEMENU Enable menu items.
FINDNEXT Search continue to forward.
FINDPREV Search continue to backward.
FINDREPLACE Find and replace string or regular expression within current one or all windows.
FINDSTRING Find string or regular expression within current one or all windows.
FORMAT Format line or part of text.
GETREADONLY Get mode Read Only.
GOTO Run dialog "Go to line".
HELPEDIT Make help.
INITUSERMACRO Initiation users macros.
INSMACRO Insert text string(s) by after do macro expression.
INSTEMPLATE Insert text string(s) by template.
LISTFILES Show listing opened files.
LOADBLOCK Load block from file.
MARKBLOCK Start/stop to mark block.
MATCHSTRUCTURE Match structure within window.
MATCHSYMBOL Match symbol within window.
MEDIT MEDIT constructor.
MENU Create common menu for MEDIT object.
NEWLINE Goto new line of window.
NEXTWINDOW Change current window to next.
OPENFILE Open file into new window.
PASTEFROMCLIPBOARD Paste block from clipboard.
PREVWINDOW Change current window to previous.
PRINT Print file or marked block.
RELOADFILE Reload file.
REMOVEWINDOW Remove window
RUNME Key code handler()
SAVEBLOCK Save block to file.
SAVEFILE Save file.
SAVEOPTIONS Save MEDIT options.
SAVEPOS Save current line position.
SAVEWINS Save all windows that contained TEXEDIT objects.
SETDRAW Start/Stop lines drow mode.
SETHASH Set a code block associated with commands hash code value.
SETINSERTMODE Set insert mode.
SETOPTIONS Set editor options.
SHOWFILES Show listing of opened files.
UNDO Make "undo" operation.
WRITESTATUS Save MEDIT status.

Method MEDIT:APPLYHASH()

 ApplyHash(<nHashCode>)	--> nResult

ApplyHash() evaluates the code block associeated with hash code <nHashCode> that is contained whithin SetHash() dictionary and returns <nResult>.

Method MEDIT:BACKSPACE()

 Backspace([<nWin>])	--> .T.

Backspace() is called method Backspace() for TEXTEDIT object <::Tobj[nWin]>.

Method MEDIT:CALLMENU()

 CallMenu(<nChoice>)	--> .T.

CallMenu() is called and ran menu object <::oMenu> that was created within method Menu().

Method MEDIT:CANCELBLOCK()

 CancelBlock([<nWin>])	--> .T.

CancelBlock() is called method CancelBlock() for TEXTEDIT object <::Tobj[nWin]> .

Method MEDIT:CENTERLINE()

 CenterLine([<nWin>])	--> .T.

CenterLine() is called method CenterLine() for TEXTEDIT object <::Tobj[nWin]>.

Method MEDIT:CHANGECHARSET()

 ChangeCharset(<nWin>, <sCharset>)	--> .T. || .F.

ChangeCharset() is called corresponding method SetCharset() for <::Tobj[nWin]>

Method MEDIT:CHOOSECODEPAGE()

 ChooseCodePage()	--> NIL

ChooseCodePage() is ran dialog "Choose code page" and converted editor buffer <::Tobj[::Curwin]> to choosed code page.

All existing code page reading from directory CLIPROOT()+"/charsets"

Method MEDIT:CLOSEWINDOW()

 CloseWindow([<nWin>])	--> .T.

CloseWindow() is saved file, closed window <nWin> and removed it from are <::Tobj> listing.

Method MEDIT:COPYBLOCK()

 CopyBlock([<nWin>][,<lCopy>])	--> .T.

CopyBlock() is called method CopyBlock() or MoveBlock() for TEXTEDIT object <::Tobj[nWin]>.

Method MEDIT:COPYTOCLIPBOARD()

 CopyToClipboard([<nWin>])	--> .T.

CopyToClipboard() is called method CopyToClipboard() for TEXTEDIT object <::Tobj[nWin]>.

Method MEDIT:CREATENEWWINDOW()

 CreateNewWindow()	--> .T.

CreateNewWindow() is created new TEXTEDIT object into new window.

New window will be created with coordinates <::nTop>, <::nLeft>, <::nBot>, <::nRight> and will be add to listing TEXEDIT objects <::Tobj>. This window will be current and take focus.

Method MEDIT:DELETE()

 Delete([<nWin>])	--> .T.

Delete() is called method DelRight() for TEXTEDIT object <::Tobj[nWin]>.

Method MEDIT:DELETEBLOCK()

 DeleteBlock([<nWin>])	--> .T.

DeleteBlock() is called method DeleteBlock() for TEXTEDIT object <::Tobj[nWin]>.

Method MEDIT:DELETEEND()

 DeleteEnd([<nWin>])	--> .T.

DeleteEnd() is called method DelEnd() for TEXTEDIT object <::Tobj[nWin]>.

Method MEDIT:DELETEHOME()

 DeleteHome([<nWin>])	--> .T.

DeleteHome() is called method DelHome() for TEXTEDIT object <::Tobj[nWin]>.

Method MEDIT:DELETELINE()

 DeleteLine([<nWin>])	--> .T.

DeleteLine() is called method DeleteLine() for TEXTEDIT object <::Tobj[nWin]>.

Method MEDIT:DRAWHEAD()

 DrawHead()	--> .T.

DrawHead() is drow title for each TEXTEDIT object. Title include next information: file name, read only mode, share mode, SET_INSERT mode, window number.

Method MEDIT:EDITKEYS()

 EditOpt()	--> .T.

EditOpt() is made dialog to edit MEDIT options <::Opt>.

Method MEDIT:EDITOPT()

 EditOpt()	--> .T.

EditOpt() is made dialog to edit MEDIT options <::Opt>.

Method MEDIT:ENABLEBLOCKMENU()

 EnableBlockMenu()	--> .T.

EnableBlockMenu() called method MenuItem:EnableStatus() to every items of MENU object that be called block methods.

The status enable specify TRUE if block will be makked.

Method MEDIT:ENABLEMENU()

 EnableMenu()	--> .T.

EnableMenu() called method MenuItem:EnableStatus() to every items of MENU object that be created winthin method Medit:Menu().

The status enable specify TRUE if will be opened or created even though file.

Method MEDIT:FINDNEXT()

 FindNext([<nWin>])	--> .T.

FindNext() is called method FindNext() for TEXTEDIT object <::Tobj[nWin]> with find options <::Find>.

Method MEDIT:FINDPREV()

 FindPrev([<nWin>])	--> .T.

FindPrev() is called method FindPrev() for TEXTEDIT object <::Tobj[nWin]> with find options <::Find>.

Method MEDIT:FINDREPLACE()

 FindReplace([<nWin>])	--> .T.

FindReplace() is called method Replace() for TEXTEDIT object <::Tobj[nWin]> with find options <::Find>.

Method MEDIT:FINDSTRING()

 FindString([<nWin>])	--> .T.

FindString() is called method Find() for TEXTEDIT object <::Tobj[nWin]> with find options <::Find>.

Method MEDIT:FORMAT()

 Format([<nWin>][,<lMode>])	--> .T.

Format() is called method FormatLine() or FormatPart() for TEXTEDIT object <::Tobj[nWin]> with parameters that specified <::Opt>.

Method MEDIT:GETREADONLY()

 GetReadOnly(<nWin>)	--> lMode

GetReadOnly() is get read only mode for TEXTEDIT objects <::Tobj[nWin]>.

If <nWin> is NIL, then SetReadOnly() returns FALSE.

Method MEDIT:GOTO()

 Goto()	--> nNewLine

Goto() read new line number and if it number between 1 and <::Lines> called method TextEdit:GotoLine() for current TEXTEDIT object.

Method MEDIT:HELPEDIT()

 HelpEdit()	--> NIL

HelpEdit() read help for text editor from file CLIPROOT()+"/doc/edit.html"

Method MEDIT:INITUSERMACRO()

 InitUserMacro(<sIniFileName>)	--> .T. || .F.

IniUserMacro() is read file <sIniFileName> and try loaded it. The format .ini file is:

[Label] UFUNC = <UserFuncName> The name user function UFILE = <UserFuncFileName> The full name file .po that contained user function <UserFuncName> [UALLWINS= <lAll>] If .T. user function take object MEDIT, other its take current TEXTEDIT object. (Default is .F.) [UHOTKEY = <HotKeyCode>] The name hot key code into <inkey.ch> [UCOMMAND= <CommandName>] The command name.(Default <UserFuncName>) [UMENUSTR= <MenuString>] The menu items string. (Default <UserFuncName>) [UMENUMSG= <MenuMsg>] The message menu item.

The all users macro will be added to <::oMenu> object into item "Macro".

The function <UserFuncName> take one parameters MEDIT or TEXTEDIT object and can be returns logical value. If users function returns TRUE, then key code processed. If users function return FALSE, then key code can be processed of standart handler RunMe().

Method MEDIT:INSMACRO()

 InsMacro([<nWin>])	--> .T.

InsMacro() is called method InsMacro() for TEXTEDIT object <::Tobj[nWin]> with templates array <::TemplMacro>.

Method MEDIT:INSTEMPLATE()

 InsTemplate([<nWin>])	--> .T.

InsTemplate() is called method InsTempl() for TEXTEDIT object <::Tobj[nWin]> with templates array <::Templ>.

Method MEDIT:LISTFILES()

 ListFiles()	--> nCurWindow

ListFiles() is made dialog to choose opened files. It is are listing TEXTEDIT objects.

If window not choosed, ListFiles() returns the number cuurent window.

Method MEDIT:LOADBLOCK()

 LoadBlock([<nWin>])	--> .T.

LoadBlock() is choosed file and called method LoadBlock() for TEXTEDIT object <::Tobj[nWin]>.

Method MEDIT:MARKBLOCK()

 MarkBlock([<nWin>][,<lMode>])	--> .T.

MarkBlock() is called methods BeginBlock or EndBlock() for TEXTEDIT object <::Tobj[nWin]> .

Method MEDIT:MATCHSTRUCTURE()

 MatchStructure([<nWin>][,<ldirect>])	--> .T.

MatchStructure() is called method MatchStruct() for TEXTEDIT object <::Tobj[nWin]>.

Method MEDIT:MATCHSYMBOL()

 MatchSymbol([<nWin>][,<lDirect>])	--> .T.

MatchSymbol() is called method Identity() for TEXTEDIT object <::Tobj[nWin]>.

Method MEDIT:MEDIT()

 mEdit([<aParam>],[<nTop>],[<nLeft>],[<nBot>],[<nRight>],[<sUserFunc>],[<nTabSize>],[<nBline>],[<nBpos>],[<nWline>],[<nWpos>])	--> MEDIT object
 mEdit_New([<aParam>],[<nTop>],[<nLeft>],[<nBot>],[<nRight>],[<sUserFunc>],[<nTabSize>],[<nBline>],[<nBpos>],[<nWline>],[<nWpos>])		--> MEDIT object

Medit_new() is constructs and returns new MEDIT object. That class can be used to create, for example, multiwindow text editors.

Medit() is equal to Medit_new(), but it activate method Runme() at once.

Method MEDIT:MENU()

 Menu()	--> oMenu

Menu() created new MENU object to control MEDIT object.

Menu() is calls automaticaly from one of constructors.

Method MEDIT:NEWLINE()

 NewLine([<nWin>])	--> .T.

NewLine() is called method InsertLine() if Set(_SET_INSERT) is TRUE and method NewLine()for TEXTEDIT object <::Tobj[nWin]>.

Method MEDIT:NEXTWINDOW()

 NextWindow()	--> .T.

NextWindow() is changed current window to next. <::Curwin> increased by one.

Method MEDIT:OPENFILE()

 OpenFile()	--> .T. || .F.

OpenFile() is ran file dialog and loaded to new TEXTEDIT object selected file within new window..

New window will be created with coordinates <::nTop>, <::nLeft>, <::nBot>, <::nRight> and will be add to listing TEXEDIT objects <::Tobj>. This window will be current and take focus.

Method MEDIT:PASTEFROMCLIPBOARD()

 PasteFromClipboard([<nWin>])	--> .T.

PasteFromClipboard() is called method PasteFromClipboard() for TEXTEDIT object <::Tobj[nWin]>.

Method MEDIT:PREVWINDOW()

 PrevWindow()	--> .T.

PrevWindow() is changed current window to previous. <::Curwin> decreased by one.

Method MEDIT:PRINT()

 Print([<nWin>][, <lBlock>])	--> .T.

Print() is printed file or if <lBlock> is TRUE marked block.

Method MEDIT:RELOADFILE()

 ReloadFile([<nWin>])	--> .T.

ReloadFile() is called method LoadFile() for TEXTEDIT object <::Tobj[nWin]> with find options <::Find>.

Method MEDIT:REMOVEWINDOW()

 RemoveWindow([<@nWin>]) --> NIL

RemoveWindow() is removed TEXTEDIT object with number <nWin> from listing <::Tobj> and decreased <nWin> by one.

Method MEDIT:RUNME()

 RunMe() --> NIL

RunMe() is started key code handler of MEDIT object. It processed key code and made corresponding of this key MEDIT command.

Method MEDIT:SAVEBLOCK()

 SaveBlock([<nWin>])	--> .T.

SaveBlock() is choosed file name and called method SaveBlock() for TEXTEDIT object <::Tobj[nWin]>.

Method MEDIT:SAVEFILE()

 SaveFile([<sFileName>]) --> .T. || .F.

SaveFile() is saved current TEXTEDIT editor buffer (<::Tobj[::Curwin]>) into file <sFileName>. If <sFileName> not specified, then text saved into file with old name specified into TEXTEDIT object attribute <::Path>+<::FileName>.

If option <::Opt:OCREATEBAK> is TRUE, then before saving would be create .bak file.

Method MEDIT:SAVEOPTIONS()

 Save_options()	--> .T.

Save_options() is saved MEDIT options <::Opt> to file getenv("HOME")+"/.clip/.edit". Every user can have own file options.

Method MEDIT:SAVEPOS()

 SavePos([<nWin>])	--> .T.

SavePos() is saved current line position of TEXTEDIT object <::Tobj[nWin]> .

Method MEDIT:SAVEWINS()

 SaveWins()	--> .T. || .F.

SaveWins() is tryed to save to files all TEXEDIT objects from <::Tobj>.

If all objects was be saved, SaveWins return TRUE, in other FALSE.

Method MEDIT:SETDRAW()

 SetDraw([<nWin>][,<lDrawMode>]) --> .T.

SetDraw() is set/unset single/double line draw mode.

Method MEDIT:SETHASH()

 SetHash(<nHashCode>[, <bData>]) --> bPreviouse

SetHash() is sets a new code block associated with code <nHashCode>. When replacing an existing code block definition, it returns previous code block, in other returns current one. Its associated hash code will be evaluated ApplyHash() methods.

If <bData> is NIL, SetHash() returns old block code and remove hashcommand/code block definition.

A default hash code is cursor moves(K_UP, K_DOWN, K_LEFT, K_RIGHT, K_PGUP, K_PGDN, K_HOME, K_END ....) associates with corresponded methods Left(), Right(), Up(), Down() and more.

Method MEDIT:SETINSERTMODE()

 SetInsertMode([<lMode>])	--> .T.

SetInsertMode() is sets new insert mode.

Method MEDIT:SETOPTIONS()

 Set_options()	--> .T.

Set_options() is setted options <::Opt> by default or read its from saved file.

Options file have name: getenv("HOME")+"/.clip/.edit" If this file exist, options reading from it.

For more information about saved options see description of Save_options().

Method MEDIT:SHOWFILES()

 ShowFiles()	--> .T.

ShowFiles() is showed opened files and choose some one to edit.

Method MEDIT:UNDO()

 Undo([<nWin>])	--> .T.

Undo() is called method Undo() for TEXTEDIT object <::Tobj[nWin]> .

Method MEDIT:WRITESTATUS()

 WriteStatus()	--> .T. || .F.

WriteStatus() is saved MEDIT status to file "edit."+getenv("USER"). Every user can have own file options into many directories.

To status file wrote next information:

- the number current window;

- the history opened files;

- the history for FIND and REPLACE operations;

- the information about editing files: full file name, current position line and column into editor buffer, current position line and column into viewport and more.

Example:

  #include <inkey.ch>
 #include <edit.ch>
 
 /* create new MEDIT object */
 me := medit_new()
 
 /* get standart HASH command for MEDIT object */
 mekeys := HK_get("edit")
 
 /* create users HASH command */
 keys := map()
 keys[K_F2] := HASH_Save
 keys[K_F3] := HASH_Open
 keys[K_ESC] := HASH_Quit
 
 /* set code block to users HASH command */
 me:SetHash(HASH_Save, {|oMe, nKey| oMe:SaveFile(), ME_CONTINUE})
 me:SetHash(HASH_Open, {|oMe, nKey| oMe:OpenFile(), ME_CONTINUE})
 me:SetHash(HASH_Quit, {|oMe, nKey| oMe:CloseWindow(), ME_EXIT})
 
 
 /* make command */
 ret := ME_CONTINUE
 do while ret != ME_EXIT
 nKey := inkey(0)
 if nKey $ keys
 hKey := keys[nKey]
 elseif nKey $ mekeys
 hKey := mekeys[nKey]
 else
 hKey := nKey
 endif
 ret := me:applyHash(hKey)
 enddo
 
 

Platforms

No dependies of platform.