Πέμπτη 30 Δεκεμβρίου 2021

Making the Karel Ide (part two)

Now the Karel Ide has a list from we can choose a word to paste in editor. Multiple Undo and Redo works. When we move the mouse pointer on the left half side with holding the left mouse button down, we select item, and we see help in the status line. Also the same list at the end has IDE operations (Load Save etc). These are not ready yet.

Version 10, Revision 51 of M2000 Interpreter are ready to install.

Happy New Year.



Title "IDE"
const KAREL_INSTRUCTIONS$="|MOVE|TURNLEFT|PICKBEEPER|PUTBEEPER|TURNOFF"
const KAREL_COMMAND$ = "|BEGINNING-OF-PROGRAM|END-OF-PROGRAM|BEGINNING-OF-EXECUTION|END-OF-EXECUTION|BEGIN|END|DEFINE|IF|ELSE|ITERATE|WHILE"
const LASTPART$="|TIMES|AS|DO|THEN"
const FLAGS$ = "|FRONT-IS-CLEAR|FRONT-IS-BLOCKED|LEFT-IS-CLEAR|LEFT-IS-BLOCKED|RIGHT-IS-CLEAR|RIGHT-IS-BLOCKED|BACK-IS-CLEAR|BACK-IS-BLOCKED|NEXT-TO-A-BEEPER|NOT-NEXT-TO-A-BEEPER|ANY-BEEPERS-IN-BEEPER-BAG|NO-BEEPERS-IN-BEEPER-BAG|FACING-NORTH|NOT-FACING-NORTH|FACING-SOUTH|NOT-FACING-SOUTH|FACING-EAST|NOT-FACING-EAST|FACING-WEST|NOT-FACING-WEST"
const that$ = {`'"[]*+.,=-"}+"{}!@#$%^&/\<>?~"
const crlf$={
}
tab$=chr$(9)
listtext$="Commands"+Replace$("|", crlf$+tab$,KAREL_COMMAND$+crlf$+"After Command"+LASTPART$+crlf$+"Instructions"+KAREL_INSTRUCTIONS$+crlf$+"Flags"+FLAGS$+crlf$+"IDE Operations|Load|Save|New|Run|Run Again")
Blocked=list:="Commands", "After Command", "Flags", "IDE Operations", "Instructions"
Declare IDE_Karel Form
Declare Karel_Pad EditBox Form IDE_Karel
Declare Karel_List ListBox Form IDE_Karel
Declare Karel_Status ListBox Form IDE_Karel
With IDE_Karel,"UseIcon", True, "UseReverse", True, "Quit" as Quit
With IDE_Karel, "Title" as Caption$, "Visible" as Visible, "TitleHeight" as tHeight, "Sizable", True
Method IDE_Karel,"MakeStandardInfo", 1
Method IDE_Karel, "FontAttr", "Verdana", 18, true '  size=12, bold=true
Method Karel_List, "FontAttr", "Verdana", 14, true '  size=12, bold=true
Method Karel_Pad, "FontAttr", "Verdana", 14, true '  size=12, bold=true
Method Karel_Status, "FontAttr", "Verdana", 12, true
Method Karel_List, "SetBarStyle", color(50, 100, 200), 5, 15
Method Karel_Pad, "SetBarStyle", color(50, 100, 200), 5, 15
With Karel_Pad, "NoWrap", True, "SelLength" as SelLength, "HighlightParagraph", True
With Karel_List, "ShowAlways", true, "Text", listtext$, "transparent", false , "maychange", false, "SkipFirstClick", true
With Karel_Status, "ShowAlways", true,"Text" as status$, "transparent", true, "HideCaret", True, "displaylines", 1
Method Karel_List, "Colors", color(240,240,255), 1
With Karel_List, "List" As List$(), "listindex" as ListIndex, "title", "IDE Menu", "HideCaret", True
With Karel_Pad, "Text" as Pad.Text$, "NoColor", False, "ShowAlways", True, "SpaceIndent", 3
With Karel_Pad, "ColorCollection1", KAREL_COMMAND$+"|"
With Karel_Pad, "ColorCollection3", LASTPART$+"|"
With Karel_Pad, "ColorCollection4", FLAGS$+"|", "Default", true
With Karel_Pad, "Seltext" as SelText$, "SelStart" as SelStart, "SelLength" as SelLength, "InsertTextNoRender" as Insert$
Module InnerControl (listbox) {
// control is the real control on form
// which our listbox "subclass it"
method listbox, "control" as control
with control, "dcolor", -Color(255,40,0), "CapColor", -color(11)
with control, "backcolor", -Color(240,240,255), "forecolor", -color(1)
}
InnerControl Karel_List
'InnerControl Karel_Status
With Karel_Pad, "WordCharRightButIncluded", "-", "StartSymbols", "123456789"+that$
With Karel_Pad, "WordCharLeft"," ", "WordCharRight", " ", "DropSym", "-", "EXTRAFRONT", "FLRBNAEflrbnae"+that$, "LineComment1","", "LineComment2", "", "CommentSymbols","", "ComSymbolsWidth", 0, "CommentLineLight", false, "MultiLineComment1", "","MultiLineComment2", ""
'With Karel_Pad, "WordCharLeft"," ", "WordCharRight", " ", "EXTRAFRONT","FLRBNAEflrbnae"
Method  Karel_Pad, "UserColorSet",0,,,0,-color(5), -#005588
With Karel_Pad, "ColorSet", -1
Pad.Text$={BEGINNING-OF-PROGRAM
            DEFINE MOVE-IF-YOU-CAN AS
               BEGIN
                  IF FRONT-IS-CLEAR THEN
                        MOVE
               END
               BEGINNING-OF-EXECUTION
                  MOVE-IF-YOU-CAN
                  TURNOFF
               END-OF-EXECUTION
            END-OF-PROGRAM
            }
Function Karel_Pad.PopUp {
status$="Select something  with arrows from the Menu"
Method Karel_Status,"Refresh"
Method Karel_List,"GetFocus"
}
msg$="Line:{0}, Position:{1}"+tab$+"| Undo: Ctrl+Z | Redo: Ctrl+Y| Replace: Mark Text then press F5| Shift F10 or Right Mouse Click Select from List"
Function Karel_Pad.Inform {
Read New L, P
status$=format$(msg$, L,P)
Method Karel_Status,"Refresh"
Method Karel_Pad,"Show"
}
Function Info$(x) {
select case x
case 7
=" (DEFINE User_Instruction AS  one statement or BEGIN statement(s) END)"
case 8
=" (IF flag THEN  one statement or BEGIN statement(s) END | optional ELSE )"
case 9
=" (After complete IF we can add this ELSE  one statement or BEGIN statement(s) END)"
case 10
=" (ITERATE positiveNumber TIMES  one statement or BEGIN statement(s) END)"
case 11
=" (WHILE flag DO  one statement or BEGIN statement(s) END"
case 1 to 6
=" (command)"
case 13 to 16
=" (last part of command)"
case 18 to 22
=" (built in instruction)"
case 24 to 43
=" (flags used in IF flag THEN and WHILE flag DO)"
case 45
=" from file"
case 46
= " to file"
case 47
=" (Save before erase the program)"
case 48 to 49
=" (Using a Karel World)"
case else
=" not defined yet"
end select
}
Function Karel_List.dblClick {
Read New Who
local w$=list$(Who)
if left$(w$,1)<>tab$ then exit
if sellength>0 then
Insert$=mid$(w$,2)
else
Seltext$=mid$(w$,2)
Method Karel_pad, "RemoveUndo", mid$(w$,2)
sellength=0
SelStart=SelStart+len(mid$(w$,2))
end if
Method Karel_Pad,"GetFocus"
}
Function Karel_List.Scroll {
Read New Who
local w$=list$(Who-1)
if left$(w$,1)<>tab$ then exit
status$=mid$(w$,2)+info$(Who-1)
Method Karel_Status,"Refresh"
}
Function Karel_List.Click {
call local Karel_List.Scroll()
}
Function Karel_List.Color {
Read New &rgb
rgb=#0000FF
}
Function Karel_List.Sep {
Read New &D
if exist(Blocked, List$(d)) then d=-1
}
Function IDE_Karel.Resize {
Layer IDE_Karel { cls Color(255, 160, 0) , 0}
With IDE_Karel, "Width" as NP.Width, "Height" as NP.Height, "TitleHeight" as tHeight
tHeight1=theight*1
local nw=max.data(NP.Width/3, 2000), pw=max.data(NP.Width-nw, 2000)
If NP.height>tHeight1+theight Then {
Method Karel_Pad,"move", twipsX*3, tHeight1, pw-twipsX*6, NP.Height-tHeight1-tHeight
Method Karel_List,"move", twipsX*3+pw, tHeight1, nw-twipsX*6, NP.Height-tHeight1-tHeight
Method Karel_Status, "move",twipsX*3,NP.Height-tHeight1+twipsY*3,Np.Width-twipsX*6, tHeight1-twipsY*6
With Karel_Pad, "NoWrap" as NoWrap
Method Karel_list, "Refresh"
Method Karel_Pad,"Resize"
}
}
Call Local IDE_Karel.Resize()
status$="Welcome"
after 300 {
// SO A LOCKED CAN'T GET FOCUS
With Karel_Status, "Locked", true
}
Method IDE_Karel,"Show", 1
Declare Karel_Pad Nothing
Declare IDE_Karel Nothing





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

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