how to build code editor in less than 1000lines
That's exaggerated, 26 lines should be enough:
GuiMenu equ @Files, &New..., &Open..., &Save, &Build, -, E&xit, @Edit, Cut, Copy, Paste, @Options, Settings, @Help, &About
GuiParas equ "Editor demo", x100, y50, w900, h600 ; menu and paras are optional, if omitted, title is filename
include \masm32\MasmBasic\Res\MbGui.asm ; part of MasmBasic
GuiControl MyEdit, "RichEdit", wCL$(), font -16 ; use Unicode commandline and a big font (use MakeFont for special needs)
GuiControl MyStatus, "statusbar", "Ready, Готовы, 準備, ..."
Event Menu
Switch_ MenuID
Case_ 0: SetWin$ hMyEdit=0 ; pass a nullpointer to clear the control
Case_ 1
.if wFileOpen$("Unicode text=*.txu|Plain text=*.txt|Rich text=*.as?;*.rtf|All files=*.*", "Select a file", "Добро_пожаловать.txu")
SetWin$ hMyEdit=wFileRead$(wFileOpen$()) ; do not use wSetWin$
.endif
Case_ 2
.if FileSave$("Plain text=*.txt|Rich text=*.as?;*.rtf|All files=*.*")
.if MbOfn.nFilterIndex==2
FileWrite FileSave$(), stream:hMyEdit ; rich text
.else
FileWrite FileSave$(), Win$(hMyEdit) ; normal text
.endif
.endif
Case_ 3
FileWrite "tmpBuild.asm", Win$(hMyEdit)
Launch Cat$("build.bat tmpBuild.asm"
Case_ 4 .. 9
MsgBox 0, Str$("Menu #%i not yet implemented", MenuID), "Hi", MB_OK
Endsw_
GuiEndIt depends a bit on your needs, of course:
RichMasm is a bit over 20,000 lines now