Σάββατο 26 Ιανουαρίου 2019

Revision 5 Version 9.7

Revision 5
More work on syntax error for EditBox.

Revision 4
Some bugs from 9.6 (Rev >6) fixed. This revision will be a release for this language. Although I am looking to add an assembler or a C small compiler. I found either written in VB6, but I have to do a lot of work to make them useful for this language. I am thinking an inline compact C is better from assembler. We can call external dll with c functions, but inline code is more handy for small tasks.



I make a M2000 Pad for editing M2000 code in an EditBox with syntax color for M2000 (Is very difficult because M2000 has multiline strings using {} and blocks of code using {}, and syntax color procedure can find either, reading the statement before to determine to do something, and also happen as we type. I make the Editor, the Document under the Editor which hold the paragraphs, and the user control under the Editor which through events to Editor. Also Document through events for syntax color to Editor. There are two editors, one in main form (or console) of M2000, and the other is the EditBox control. The EditBox now has two procedures for syntax color, one programmable, and a second one fixed for M2000 programs. This is an example of an M2000 notepad for M2000 programs.

We can use all Fn keys from 1 to 12, Also some of them works with Shift key for more functions.
F1 used for setting on/off the word wrapping.
We can use insert Tabs using Ctrl Tab, and works for many lines (paragraphs) if we select them before the keystroke. We can use Ctrl+Shift+Tab for reverse function.
The Pad control (EditBox) has a property "UseTab", we can change this to handle spaces and not tabs for multiline indentation.
Menu consist of a group of 3 Combobox, with no field for input text by keyboard. We make them as group using the NenuGroup property.
We use a button as a label to display the current row/column

\\ notepad for M2000 programs (gsb files)
Show
Clear \\ Clear all variables/objects
Flush \\ Empty the stack
Title$="M2000 Pad"
Dir User
Title Title$, 0
Declare NotePad Form
Declare Pad EditBox Form NotePad
Declare File1 Combobox Form NotePad
Declare Edit1 Combobox Form NotePad
Declare Help1 Combobox Form NotePad
Declare Inform1 Button Form NotePad
Method Inform1, "Colors", 15, #FFA000
With Inform1, "Locked", true
Method Pad, "FontAttr", "Verdana", 12, true   '  size=12, bold=true
With Pad, "NoWrap", True, "SetM2000", True
With File1,"label","File", "listtext" As list$, "list" As list$() '
With Edit1,"label","Edit",  "Mark", Color(255,100,0)
With Help1,"label","Help",  "Mark", Color(255,100,0)
With NotePad,"UseIcon", True, "UseReverse", True
With NotePad, "Title" As Caption$, "Visible" As Visible, "TitleHeight" As tHeight, "Sizable", True
\\ call MakeStandardInfo, after setting Sizable to true to enable contol box's maximize button.
Method NotePad,"MakeStandardInfo", 1
With Pad, "Text" As Pad.Text$, "NoColor", False, "ShowAlways", True, "UseTab", True, "tabwidth", 6
Def TitleStr$(a$)=ucase$(left$(a$,1))+mid$(a$,2)
Filename$=Dir$+"Untitled.gsb"
Caption$=TitleStr$(File.Name$(Filename$)) +" - M2000 Pad"
Method NotePad,"move", 2000, 4000, 8000, 4000
Layer NotePad {Cls #FFA000}
With File1,"MenuStyle", True, "MenuWidth", 4000 
With Edit1,"MenuStyle", True, "MenuWidth", 4000 
With Help1,"MenuStyle", True, "MenuWidth", 4000 
With File1, "MenuEnabled" As mEnable()
For This {
 mi$="MenuItem"  \\ is a temporary variable only for For This Block
 Method File1, mi$,"Open",True
 Method File1, mi$,"Save",True
 Method File1, mi$,""    \\  only  a line here
 Method File1, mi$,"Close",True
 Method File1, mi$,"Quit",True
Rem Method File1, "Transparent"
 With File1, "MenuGroup","This"
 
 Method Edit1, mi$,"Cut",True
 Method Edit1, mi$,"Copy",True
 Method Edit1, mi$,"Paste",True
Rem Method Edit1, "Transparent"
 With Edit1, "MenuGroup","This"
 Method Help1, mi$,"About",True
Rem Method Help1, "Transparent"
 With Help1, "MenuGroup","This"
}
Document BackUp$="\\Write something..."
Pad.Text$=BackUp$ Function Notepad.Resize { Layer NotePad { Cls Color(255, 160, 0) ,0} With NotePad, "Width" As NP.Width, "Height" As NP.Height, "TitleHeight" As tHeight tHeight1=theight*2 Method File1,"move", twipsX*2, tHeight, twipsX*80, tHeight Method Edit1,"move", twipsX*2+twipsX*80, tHeight, twipsX*80, tHeight Method Help1,"move", twipsX*2+twipsX*160, tHeight, twipsX*80, tHeight        Method Inform1,"move", twipsX*2+twipsX*240, tHeight, twipsX*160, tHeight If NP.height>2000 Then { Method Pad,"move", twipsX*2, tHeight1, NP.Width-twipsX*5, NP.Height-tHeight1-twipsx*3 With Pad, "NoWrap" As NoWrap If Not NoWrap Then Method Pad,"Resize" } } Function Pad.Inform {       Read New L, P       With Inform1, "Caption", format$("{0}-{1}", L,P)       Method Pad,"Show" } Function Edit1.DblClick { Read New Edit1index Select Case Edit1index Case 0 Method Pad,"mn1sub" : Method Pad,"Resize" Case 1 Method Pad,"mn2sub" Case 2 Method Pad, "mn3sub" : Method Pad,"GetFocus" : Method Pad,"Resize" End Select } Function Pad.PopUp {       Read Local X, Y       Method Pad,"PopUpMenu", "",X , Y } Function File1.DblClick { Read New File1index Local cont, cont2, f$, NL$={ } File1index++ \\ Because we want some jumps..we use  On Goto \\ on Goto need here a block { On File1index Goto Open1, Save1, ExitNow, Save2, Unload Exitnow: Exit Open1: If Pad.Text$<>BackUp$ Then { If ask("Save Changes first?",Title$)=1 Then Goto Save1 } Layer NotePad { Open.file filename$,"c:\","Load M2000 (Gsb) File","gsb" } Method Pad,"GetFocus" Read f$ If f$<>"" Then Filename$=f$ If exist(F$) then { Clear BackUp$ Load.Doc BackUp$, f$ Caption$=TitleStr$(File.Name$(Filename$)) +" - M2000 Pad" Pad.Text$=BackUp$ } else Pad.text$="": Clear BackUp$ Method Pad, "Resize" End If Exit Save1: Layer NotePad { Save.As Filename$,"c:\","Save M2000 File","gsb" } if not cont2 then Method Pad,"GetFocus" Read f$ If f$="" Then Exit If lcase$(file.type$(f$))<>"gsb" then f$=f$+".gsb" If Exist(f$) Then If Ask(NL$+"Overwrite"+NL$+f$,Title$)<>1 Then Exit Try ok { Clear BackUp$ BackUp$=Pad.Text$ Save.Doc BackUp$, f$ filename$=f$ Caption$=TitleStr$(File.Name$(Filename$)) +" - M2000 Pad" } If ok else beep If not cont then Exit Save2: cont=True If Pad.Text$<>BackUp$ Then { If ask("Save Changes?",Title$)=1 Then Goto Save1 } Clear BackUp$ Pad.Text$="" If Cont2 then Method NotePad, "CloseNow" Else FileName$=Dir$+"Untitled.gsb" Caption$=TitleStr$(File.Name$(Filename$)) +" - M2000 Pad" Method Pad, "Resize" End If Exit Unload: Cont2=True : Goto Save2 } } Function Help1.DblClick { Local A, info$ Info$={ This is an example of a notepad for M2000 Programs written in M2000 and run in M2000 Environment } A=Ask(info$,Title$,"","") } Function Notepad.InfoClick { Read New X If X=0 then Call Local Help1.DblClick() } Call Local Notepad.Resize() \\ make this as the default control (get focus) With Pad,"Default",True \\ open As modal Method NotePad,"Show", 1 Declare Pad Nothing Declare NotePad Nothing Print "Done"

Δεν υπάρχουν σχόλια:

Δημοσίευση σχολίου

You can feel free to write any suggestion, or idea on the subject.