March 28, 2024, 05:17:30 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Colorize text in real-time

Started by aurelCB, August 19, 2008, 02:16:51 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

aurelCB

Hi Sapero...
I do like you said-download headers for EBasic and find scintilla in iclude folder.
Excellent stuff.
SCI_GETLINECOUNT work fine but SCI_GETLINE dont ,just crush Cbasic or
i recive error message Illegal Assignment on line 109.Where is the cach?

def w:window
DEF abscript[32766]:ISTRING
DEF start,smax:INT
DEF text:string
def null:pointer
null=0
declare "user32",CreateWindowExA(ex:int,class:string,name:string,style:int,x:int,y:int,x1:int,y1:int,parent:window,id:int,hinstance:int,ed:int),int
DECLARE "kernel32", GetExeHandle alias GetModuleHandleA(name:int),INT
declare "user32.dll",xmsg alias SendMessageA(wnd:int, message:int, wparam:int, lparam:pointer ),int
declare "kernel32", LoadLibrary alias  LoadLibraryA( lp:string ),int
declare "kernel32", FreeLibrary( hnd:int )

const SCE_IB_DEFAULT = 0
const SCE_IB_LINECOMMENT = 1
const SCE_IB_BLOCKCOMMENT = 2
const SCE_IB_NUMBER = 3
const SCE_IB_KEYWORD = 4
const SCE_IB_TYPE = 5
const SCE_IB_SETID = 6
const SCE_IB_PREPROCESSOR = 7
const SCE_IB_STRING = 8
const SCE_IB_OPERATOR = 9
const SCE_IB_IDENTIFIER = 10
const SCE_IB_LABEL = 11
const SCE_IB_ASM = 12
const SCI_MARGIN_SYMBOL = 2227

const SCLEX_IBASIC = 30

const SCI_SETLEXER = 4001
const SCI_STYLESETFORE = 2051
const SCI_STYLESETBACK = 2052
const SCI_STYLECLEARALL = 2050
const SCI_SETKEYWORDS = 4005
const SCI_STYLESETFONT = 2056
const SCI_STYLESETSIZE = 2055
const SCI_SETMARGINWIDTHN = 2242
'const SCI_GETLINECOUNT=2154
const SCI_GETLINE = 2153
const SCI_GETLINECOUNT = 2154

def i:int
Window w, 0, 0, 600, 480, @minbox, 0, "Scintilla based editor", handler
'menu
MENU w,"T,File,0,0","I,New,0,11","I,Open,0,7","I,Save,0,6","I,Exit,0,1"
INSERTMENU w,1,"T,Edit,0,0","I,Undo,0,2","I,Cut,0,3","I,Copy,0,4","I,Paste,0,5"
INSERTMENU w,2,"T,Execute,0,0","I,Run Script,0,8"
INSERTMENU w,3,"T,Build,0,0","I,Start Build,0,22"
INSERTMENU w,4,"T,Help,0,0","I,Help,0,9","I,About,0,21"
setwindowcolor w,rgb(220,220,230)
def hlibsci, hsci:int

const IDC_SCI = 100
const IDC_SCI_CREATE = 2024+IDC_SCI

hlibsci = LoadLibrary( "SciLexer.dll" )
'create RichEdit Scintilla control-replace CONTROLEX command from EBasic
hsci=CreateWindowExA(0,"scintilla","",0x50000000|@border,10,30,570,390,w,IDC_SCI_CREATE,GetExeHandle(0),0)

SENDMESSAGE(w, SCI_SETLEXER, SCLEX_IBASIC, 1, IDC_SCI)
SENDMESSAGE(w, SCI_STYLESETFORE, SCE_IB_DEFAULT,100, IDC_SCI)
SENDMESSAGE(w, SCI_STYLESETBACK, SCE_IB_DEFAULT, 0xFFFFFF, IDC_SCI)
SENDMESSAGE(w, SCI_STYLECLEARALL, 0, 1, IDC_SCI)

for i = 0 to 12
SENDMESSAGE (w, SCI_STYLESETFONT, i, "Courier New", IDC_SCI)
SENDMESSAGE (w, SCI_STYLESETSIZE, i, 10, IDC_SCI)
next i

SENDMESSAGE(w, SCI_SETKEYWORDS, 0,"wait defnum defstr closewin", IDC_SCI ):'red
SENDMESSAGE(w, SCI_SETKEYWORDS, 1,"win setfont wincolor let", IDC_SCI ):'blue
SENDMESSAGE(w, SCI_SETKEYWORDS, 2,"circle rect line pixel", IDC_SCI ):'lightblue
SENDMESSAGE(w, SCI_SETKEYWORDS, 3,"sub endsub text clear$", IDC_SCI ):'brown
'next line set margin for line numbers (40 is Lparam)
SENDMESSAGE(w, SCI_SETMARGINWIDTHN, 0, 40, IDC_SCI)
SENDMESSAGE(w, SCI_STYLESETFORE, SCE_IB_LINECOMMENT, 0x008800, IDC_SCI )
SENDMESSAGE(w, SCI_STYLESETFORE, SCE_IB_BLOCKCOMMENT, 0x008800, IDC_SCI )
SENDMESSAGE(w, SCI_STYLESETFORE, SCE_IB_NUMBER, 0x555555, IDC_SCI)
SENDMESSAGE(w, SCI_STYLESETFORE, SCE_IB_KEYWORD, 0x0000FF, IDC_SCI)
SENDMESSAGE(w, SCI_STYLESETFORE, SCE_IB_TYPE, 0xFF0000, IDC_SCI)
SENDMESSAGE(w, SCI_STYLESETFORE, SCE_IB_SETID,rgb(245,127,0), IDC_SCI )
SENDMESSAGE(w, SCI_STYLESETFORE, SCE_IB_PREPROCESSOR, 0x000088, IDC_SCI)
SENDMESSAGE(w, SCI_STYLESETFORE, SCE_IB_STRING, 0x880088, IDC_SCI )
SENDMESSAGE(w, SCI_STYLESETFORE, SCE_IB_OPERATOR, 0x884400, IDC_SCI)
SENDMESSAGE(w, SCI_STYLESETFORE, SCE_IB_IDENTIFIER, 0x000000, IDC_SCI )
SENDMESSAGE(w, SCI_STYLESETFORE, SCE_IB_LABEL, 0xAAAAAA, IDC_SCI)
SENDMESSAGE(w, SCI_STYLESETFORE, SCE_IB_ASM, 0x555555, IDC_SCI )
'SetControlText w, IDC_SCI, "endtype window @minix $include 0123 #ifstr _asm //comment"
'setfocus w

waituntil w.hwnd = 0
Freelibrary (hlibsci)
end


sub handler
select @CLASS
case @IDCLOSEWINDOW
closewindow w

CASE @IDMENUPICK
SELECT @MENUNUM
CASE 8:'Quit
start=1
'recive message from scintila-number of written lines in control
smax = Sendmessage ( w, SCI_GETLINECOUNT,0,smax,IDC_SCI )
messagebox w,"GetLineCount:"+str$(smax),"Message from control"
'recive message from scintila - get script line-error illegal assignment on line
abscript[start] =Sendmessage( w, SCI_GETLINE ,0,abscript[start],IDC_SCI)
messagebox w,"Get Script :"+abscript[start],"Message from control"


ENDSELECT
endselect
return

sapero

Sendmessage( w, SCI_GETLINE ,0,abscript,IDC_SCI)
messagebox w,"Get Script :"+abscript,"Message from control"


Say, how would you write string into single character? -> abscript[start]
http://scintilla.sourceforge.net/ScintillaDoc.html#SCI_GETLINE

aurelCB

Hi Sapero this is original code without scintilla:
def w:window
DEF abscript[32766]:STRING
DEF start,smax:INT
DEF text:string


def i:int
Window w, 0, 0, 600, 480, @minbox, 0, "Without Scintilla", handler
Setwindowcolor w,rgb(220,220,230)
'menu
MENU w,"T,File,0,0","I,New,0,11","I,Open,0,7","I,Save,0,6","I,Exit,0,1"
INSERTMENU w,1,"T,Edit,0,0","I,Undo,0,2","I,Cut,0,3","I,Copy,0,4","I,Paste,0,5"
INSERTMENU w,2,"T,Execute,0,0","I,Run Script,0,8"
INSERTMENU w,3,"T,Build,0,0","I,Start Build,0,22"
INSERTMENU w,4,"T,Help,0,0","I,Help,0,9","I,About,0,21"
Setwindowcolor w,rgb(220,220,230)
CONTROL w,"RE,,10,10,570,390,0x50B010C4,1"
SETFONT w,"Courier New",10, 400,0,1
'-------------------------------
SETCONTROLTEXT w, 1,"Zero Line" +chr$(10)+"First Line"+chr$(10)+"Second Line"




waituntil w = 0
end


sub handler
select @CLASS
case @IDCLOSEWINDOW
closewindow w

CASE @IDMENUPICK
SELECT @MENUNUM
CASE 8:'Quit
start=2
'recive message from scintila-number of written lines in control
smax = CONTROLCMD ( w, 1, @RTGETLINECOUNT )
smax=smax-1:'down by one
messagebox w,"GetLineCount:"+str$(smax),"Message from control"
'recive message from scintila - get script line-error illegal assignment on line
abscript[start] = CONTROLCMD( w,1, @rtgetline ,start)
messagebox w,"Get Script :"+ abscript[start],"Code from control"


ENDSELECT
endselect
return


And here is finaly working example with scintilla.
I do not know that SCI_GETLINE need different shape of SENDMESSAGE ,i think that is same like
SCI_GETLINECOUNT.
Problem with start is solved ,variable start must be Wparam and string abscript[start] is Lparam.
def w:window
DEF abscript[32766]:STRING
DEF start,smax:INT
DEF text:string
'def null:pointer
'null=0
declare "user32",CreateWindowExA(ex:int,class:string,name:string,style:int,x:int,y:int,x1:int,y1:int,parent:window,id:int,hinstance:int,ed:int),int
DECLARE "kernel32", GetExeHandle alias GetModuleHandleA(name:int),INT
'declare "user32.dll",xmsg alias SendMessageA(wnd:int, message:int, wparam:int, lparam:pointer ),int
declare "kernel32", LoadLibrary alias  LoadLibraryA( lp:string ),int
declare "kernel32", FreeLibrary( hnd:int )

const SCE_IB_DEFAULT = 0
const SCE_IB_LINECOMMENT = 1
const SCE_IB_BLOCKCOMMENT = 2
const SCE_IB_NUMBER = 3
const SCE_IB_KEYWORD = 4
const SCE_IB_TYPE = 5
const SCE_IB_SETID = 6
const SCE_IB_PREPROCESSOR = 7
const SCE_IB_STRING = 8
const SCE_IB_OPERATOR = 9
const SCE_IB_IDENTIFIER = 10
const SCE_IB_LABEL = 11
const SCE_IB_ASM = 12
const SCI_MARGIN_SYMBOL = 2227

const SCLEX_IBASIC = 30

const SCI_SETLEXER = 4001
const SCI_STYLESETFORE = 2051
const SCI_STYLESETBACK = 2052
const SCI_STYLECLEARALL = 2050
const SCI_SETKEYWORDS = 4005
const SCI_STYLESETFONT = 2056
const SCI_STYLESETSIZE = 2055
const SCI_SETMARGINWIDTHN = 2242
'const SCI_GETLINECOUNT=2154
const SCI_GETLINE = 2153
const SCI_GETLINECOUNT = 2154
const SCI_GETCURLINE= 2027

def i:int
Window w, 0, 0, 600, 480, @minbox, 0, "Scintilla based editor", handler
'menu
MENU w,"T,File,0,0","I,New,0,11","I,Open,0,7","I,Save,0,6","I,Exit,0,1"
INSERTMENU w,1,"T,Edit,0,0","I,Undo,0,2","I,Cut,0,3","I,Copy,0,4","I,Paste,0,5"
INSERTMENU w,2,"T,Execute,0,0","I,Run Script,0,8"
INSERTMENU w,3,"T,Build,0,0","I,Start Build,0,22"
INSERTMENU w,4,"T,Help,0,0","I,Help,0,9","I,About,0,21"
setwindowcolor w,rgb(220,220,230)
def hlibsci, hsci:int

const IDC_SCI = 100
const IDC_SCI_CREATE = 2024+IDC_SCI

hlibsci = LoadLibrary( "SciLexer.dll" )
'create RichEdit Scintilla control-replace CONTROLEX command from EBasic
hsci=CreateWindowExA(0,"scintilla","",0x50000000|@border,10,30,570,390,w,IDC_SCI_CREATE,GetExeHandle(0),0)

SENDMESSAGE(w, SCI_SETLEXER, SCLEX_IBASIC, 1, IDC_SCI)
SENDMESSAGE(w, SCI_STYLESETFORE, SCE_IB_DEFAULT,100, IDC_SCI)
SENDMESSAGE(w, SCI_STYLESETBACK, SCE_IB_DEFAULT, 0xFFFFFF, IDC_SCI)
SENDMESSAGE(w, SCI_STYLECLEARALL, 0, 1, IDC_SCI)

for i = 0 to 12
SENDMESSAGE (w, SCI_STYLESETFONT, i, "Courier New", IDC_SCI)
SENDMESSAGE (w, SCI_STYLESETSIZE, i, 10, IDC_SCI)
next i

SENDMESSAGE(w, SCI_SETKEYWORDS, 0,"wait defnum defstr closewin", IDC_SCI ):'red
SENDMESSAGE(w, SCI_SETKEYWORDS, 1,"win setfont wincolor let", IDC_SCI ):'blue
SENDMESSAGE(w, SCI_SETKEYWORDS, 2,"circle rect line pixel", IDC_SCI ):'lightblue
SENDMESSAGE(w, SCI_SETKEYWORDS, 3,"sub endsub text clear$", IDC_SCI ):'brown
'next line set margin for line numbers (40 is Lparam)
SENDMESSAGE(w, SCI_SETMARGINWIDTHN, 0, 40, IDC_SCI)
SENDMESSAGE(w, SCI_STYLESETFORE, SCE_IB_LINECOMMENT, 0x008800, IDC_SCI )
SENDMESSAGE(w, SCI_STYLESETFORE, SCE_IB_BLOCKCOMMENT, 0x008800, IDC_SCI )
SENDMESSAGE(w, SCI_STYLESETFORE, SCE_IB_NUMBER, 0x555555, IDC_SCI)
SENDMESSAGE(w, SCI_STYLESETFORE, SCE_IB_KEYWORD, 0x0000FF, IDC_SCI)
SENDMESSAGE(w, SCI_STYLESETFORE, SCE_IB_TYPE, 0xFF0000, IDC_SCI)
SENDMESSAGE(w, SCI_STYLESETFORE, SCE_IB_SETID,rgb(245,127,0), IDC_SCI )
SENDMESSAGE(w, SCI_STYLESETFORE, SCE_IB_PREPROCESSOR, 0x000088, IDC_SCI)
SENDMESSAGE(w, SCI_STYLESETFORE, SCE_IB_STRING, 0x880088, IDC_SCI )
SENDMESSAGE(w, SCI_STYLESETFORE, SCE_IB_OPERATOR, 0x884400, IDC_SCI)
SENDMESSAGE(w, SCI_STYLESETFORE, SCE_IB_IDENTIFIER, 0x000000, IDC_SCI )
SENDMESSAGE(w, SCI_STYLESETFORE, SCE_IB_LABEL, 0xAAAAAA, IDC_SCI)
SENDMESSAGE(w, SCI_STYLESETFORE, SCE_IB_ASM, 0x555555, IDC_SCI )

SETCONTROLTEXT w, IDC_SCI,"Zero Line" +chr$(10)+"First Line"+chr$(10)+"Second Line"
'setfocus w

waituntil w.hwnd = 0
Freelibrary (hlibsci)
end


sub handler
select @CLASS
case @IDCLOSEWINDOW
closewindow w

CASE @IDMENUPICK
SELECT @MENUNUM
CASE 8:'Quit
'recive message from scintila-number of written lines in control
smax = Sendmessage ( w, SCI_GETLINECOUNT,1,smax,IDC_SCI )
messagebox w,"GetLineCount:"+str$(smax),"Message from control"
'retrive zero based index
start=smax-1:'start is 2
'send message to scintila - get text line
Sendmessage( w, SCI_GETLINE ,start,abscript[start],IDC_SCI)
messagebox w,"Get Script :"+ abscript[start],"Script from control"


ENDSELECT
endselect
return

Thanks again,and i learn something new! :)
regards
zlatko

aurelCB

Hi ...
I know that this topic is little bit old.
But one thing bugging me.
I dont know which command in scintilla create field on the right side of line numbers .
This field I need for markers.

Any advice...?
Thanks advance

Aurel

sapero

It's a margin, use SCI_SETMARGINWIDTHN. There may be up to 5 margins.

aurelCB

Thanks Sapero....
But how add second margin becose i already have one for numbers?

sapero

5 margins are there, you need to resize one:sendmessage(win, SCI_SETMARGINWIDTHN, margin_index, width, controlid)
If you set width to zero, the margin will be not visible. Please also read scintilla documentation http://scintilla.sourceforge.net/ScintillaDoc.html#SCI_SETMARGINWIDTHN

aurelCB

September 27, 2009, 10:02:01 AM #32 Last Edit: September 27, 2009, 11:41:14 PM by aurelCB
Ufff...
I read scintilal doc and must be work but not.Thanks for link...
I currently have this:
'const SC_MARGIN_SYMBOL = 0
'const SC_MARGIN_NUMBER = 1

SendMessage(w1,SCI_SETMARGINTYPEN,0,SC_MARGIN_NUMBER,IDC_SCI)
SendMessage(w1,SCI_SETMARGINTYPEN,2,SC_MARGIN_SYMBOL,IDC_SCI)

SendMessage(w1,SCI_SETMARGINMASKN,2,2,IDC_SCI)
SendMessage(w1,SCI_SETMARGINWIDTHN,0,40,IDC_SCI)
SendMessage(w1,SCI_SETMARGINWIDTHN,2,24,IDC_SCI)
    SendMessage(w1,SCI_SETFOLDMARGINCOLOUR,1,rgb(00,00,0),IDC_SCI)
'makers --------------------------------------------------
    'SendMessage(w1, SCI_MARKERDELETEALL, 2 ,0,IDC_SCI)
'SendMessage(w1, SCI_MARKERADD, 1, 0,IDC_SCI)
    SendMessage(w1, SCI_MARKERDEFINE, 2, SC_MARK_SHORTARROW,IDC_SCI )
SendMessage(w1, SCI_MARKERSETFORE, 2, RGB(80,0,0),IDC_SCI)
SendMessage(w1, SCI_MARKERSETBACK, 2, RGB(255,0,0),IDC_SCI)

SendMessage(w1, SCI_MARKERADD, 2, 0,IDC_SCI)


Exactly same order of using messages have one C++ example wich i find on 'Code Project' page.
But this dont work.I also try same thing in Free Basic and also dont work.Weird...

aurelCB

Hi ...
I finaly get one part of problem.I find scintilla example on PureBasic forum
which explain how add next margin for marker but
marker still is not visible :-[
here is right part which open second margin:
; Margins PB
SendMessage(w1, SCI_SETMARGINTYPEN, 0, SC_MARGIN_NUMBER,IDC_SCI)
SendMessage(w1, SCI_SETMARGINMASKN, 2, SC_MASK_FOLDERS,IDC_SCI)
SendMessage(w1, SCI_SETMARGINWIDTHN, 0, 40,IDC_SCI)
SendMessage(w1, SCI_SETMARGINWIDTHN, 2, 20,IDC_SCI)
SendMessage(w1, SCI_SETMARGINSENSITIVEN, 2, 1,IDC_SCI)


And just is missing part for properly add marker to margin...

sapero

September 28, 2009, 12:46:00 PM #34 Last Edit: September 28, 2009, 01:29:09 PM by sapero
Aurel, if you expect to have fast and accurate reply, you need to be precise with your questions. I have posted some examples with scintilla control, configured to display VisualStudio like markers. Go to Aurora forum and search for CHM maker. Download the zip, and open the mdichild.src file. Scroll down to InitMdiChild subroutine, and find this:data->sci->SetMarginTypeN(0, SC_MARGIN_NUMBER)In next two lines I'm just presetting width of two margins (SetMarginWidthN) and finally is a call to SciInitFolding subroutine, where all the markers are defined. Do not follow InitHtmlSyntax subroutine because it sets only language specific keywords.
You just need to convert each line:
aurora: sci->MarkerDefine (SC_MARKNUM_FOLDEROPEN, SC_MARK_BOXMINUS);
cbasic: SendMessage(w1, SCI_MarkerDefine, SC_MARKNUM_FOLDEROPEN, SC_MARK_BOXMINUS, controlID)

in other words:
convert sci->X(Y, Z);
to SendMessage(w1, SCI_X, Y, Z, IDC_SCI)

aurelCB

Sapero you are the man....like always i completly forget for your CHM maker. :-[
Of course i have latest version.
Sorry if i'm not quite precise about question(language beriere always bugging me ::)).
Yes this is great replay. ;)
Thanks a lot...

aurelCB

Sorry Sapero if i bothering you but your suggestion like:
SendMessage(w1, SCI_MarkerDefine, 0, SC_MARKNUM_FOLDEROPEN, SC_MARK_BOXMINUS, controlID)
Make error : Wrong  number of arguments!
In PB code i see something like this:
; Choose folding icons
Scintilla(sciptr, #SCI_MARKERDEFINE, #SC_MARKNUM_FOLDEROPEN, #SC_MARK_CIRCLEMINUS)

and this:
; Choose folding icon colours
Scintilla(sciptr, #SCI_MARKERSETFORE, #SC_MARKNUM_FOLDER, $FFFFFF)


But dont worry i will find the way(I hope),must work... 8)

sapero

Yup, sorry for the additional 0, updated!

aurelCB

September 30, 2009, 04:56:57 AM #38 Last Edit: September 30, 2009, 05:59:18 AM by aurelCB
No problem...for that
But i'm really confusing.
I study again your code in CHM maker and PB code and scintilla doc.
I dont wanna margin with folding style i need margin with markers such a arrow,roundrect and
similiar for point to errors in line.
So i dont understand which scintilla command show marker in margin.
I ceate nonfolding margin like scintila doc says and try add marker on line 1 with SCI_MARKERADD
but without sucsess?
; Margins PB
SendMessage(w1, SCI_SETMARGINTYPEN, 0, SC_MARGIN_NUMBER,IDC_SCI)
SendMessage(w1, SCI_SETMARGINWIDTHN, 0, 46,IDC_SCI)
SendMessage(w1, SCI_SETMARGINTYPEN, 1, SC_MARGIN_SYMBOL,IDC_SCI)
SendMessage(w1, SCI_SETMARGINWIDTHN, 1, 20,IDC_SCI)
SendMessage(w1, SCI_SETMARGINMASKN, 1, SC_MASK_FOLDERS,IDC_SCI)


'SendMessage(w1, SCI_SETMARGINWIDTHN, 1,1,IDC_SCI):' hide margine 1 if visible


SendMessage(w1, SCI_MARKERDEFINE,1,SC_MARK_ROUNDRECT,IDC_SCI )
SendMessage(w1, SCI_MARKERADD, 1,1 ,IDC_SCI)
SendMessage(w1, SCI_MARKERADDSET, 1,SC_MASK_FOLDERS ,IDC_SCI)
'SendMessage(w1, SCI_MARKERDELETEALL,0,0,IDC_SCI)

sapero

September 30, 2009, 05:59:05 AM #39 Last Edit: September 30, 2009, 06:01:12 AM by sapero
Zlatko, try this:SendMessage(w1, SCI_SETMARGINTYPEN, 0, SC_MARGIN_NUMBER, IDC_SCI)
SendMessage(w1, SCI_SETMARGINWIDTHN, 0, 20, IDC_SCI)

SendMessage(w1, SCI_SETMARGINTYPEN, 1, SC_MARGIN_SYMBOL, IDC_SCI)
SendMessage(w1, SCI_SETMARGINWIDTHN, 1, 16, IDC_SCI)

' define markers - SCI_MARKERDEFINE(markerindex, markertype)
SendMessage(w1, SCI_MARKERDEFINE, 0, SC_MARK_CIRCLE, IDC_SCI) ' SC_MARK_CIRCLE is default
SendMessage(w1, SCI_MARKERDEFINE, 1, SC_MARK_ROUNDRECT, IDC_SCI)
SendMessage(w1, SCI_MARKERDEFINE, 2, SC_MARK_ARROW, IDC_SCI)

' marker colors - SCI_MARKERSETFORE(markerindex, color)
' SCI_MARKERSETBACK(markerindex, color)
SendMessage(w1, SCI_MARKERSETBACK, 0, rgb(0,0,255), IDC_SCI)

' add markers - SCI_MARKERADD(line, markerindex)
SendMessage(w1, SCI_MARKERADD, 0, 0, IDC_SCI)
SendMessage(w1, SCI_MARKERADD, 1, 1, IDC_SCI)
SendMessage(w1, SCI_MARKERADD, 2, 2, IDC_SCI)

' remove marker 2 from line 2 - SCI_MARKERDELETE(line, markerindex)
'SendMessage(w1, SCI_MARKERDELETE, 2, 2, IDC_SCI)

aurelCB

WOW....
Excellent Sapero.!!!!!!!!!!
I really dont know what we can do here without your help?
Thank you very much!

And here is my example(I finaly figured how work ::)):

; Margins ////////////////////////////////////////////////////////
'set number margin (for numnbers)
SendMessage(w1, SCI_SETMARGINTYPEN, 0, SC_MARGIN_NUMBER,IDC_SCI)
SendMessage(w1, SCI_SETMARGINWIDTHN, 0, 40,IDC_SCI)
'set symbol margin (for markers)
SendMessage(w1, SCI_SETMARGINTYPEN, 1, SC_MARGIN_SYMBOL,IDC_SCI)
SendMessage(w1, SCI_SETMARGINWIDTHN, 1, 20,IDC_SCI)

'define markers
SendMessage(w1, SCI_MARKERDEFINE,0,SC_MARK_CIRCLE,IDC_SCI )
SendMessage(w1, SCI_MARKERDEFINE,1,SC_MARK_ROUNDRECT,IDC_SCI )
SendMessage(w1, SCI_MARKERDEFINE,2,SC_MARK_ARROW,IDC_SCI)

'set marker 0 - circle - backcolor
SendMessage(w1, SCI_MARKERSETBACK, 0, RGB(0,150,0),IDC_SCI)
'set marker 1 - roundrect - backcolor
SendMessage(w1, SCI_MARKERSETBACK, 1, RGB(0,0,255),IDC_SCI)
'set marker 2 - arrow - backcolor
SendMessage(w1, SCI_MARKERSETBACK, 2, RGB(255,0,0),IDC_SCI)

'set marker to first position (zero position/empty editor/)show red arrow marker
SendMessage(w1, SCI_MARKERADD, 0,2 ,IDC_SCI)


Aurel

tbohon

Aurel:

Finally got some time to 'play around' with the Scintilla controls using your last working example above as a starting point.

When I try to compile in CBasic I get an error re: missing control for this line:

SENDMESSAGE(w, SCI_SETLEXER, SCLEX_IBASIC, 1, IDC_SCI)

What library/libraries are you using with this program?

Remember this is all new to me (CBasic anyway) so be gentle ... :)

Tnx.

Tom
"If you lead your life the right way, the karma will take care of itself ... the dreams will come to you."  -- Randy Pausch, PhD (1961-2008)

aurelCB

February 17, 2010, 10:15:23 AM #42 Last Edit: February 17, 2010, 10:20:21 AM by aurelCB
Hi Tom.

you probably miss this:
const IDC_SCI = 100
const IDC_SCI_CREATE = 2024+IDC_SCI


and then

def hlibsci, hsci:int
hlibsci = LoadLibrary( "SciLexer.dll" )
'create sci control
hsci=CreateWindowExA(0x20000,"Scintilla","",0x50010000,sciLw,sciTw,sciWidth,sciHeight,w1,IDC_SCI_CREATE,GetExeHandle(0),0)

tbohon

Gee, I get having those lines would help a bit, eh?

;)

Thanks.
"If you lead your life the right way, the karma will take care of itself ... the dreams will come to you."  -- Randy Pausch, PhD (1961-2008)

aurelCB

Tom
Heh i'm not sure exactly what you need.
Here is the scintilla constants which i use :
const SCE_IB_DEFAULT = 0
const SCE_IB_LINECOMMENT = 1
const SCE_IB_BLOCKCOMMENT = 2
const SCE_IB_NUMBER = 3
const SCE_IB_KEYWORD = 4
const SCE_IB_TYPE = 5
const SCE_IB_SETID = 6
const SCE_IB_PREPROCESSOR = 7
const SCE_IB_STRING = 8
const SCE_IB_OPERATOR = 9
const SCE_IB_IDENTIFIER = 10
const SCE_IB_LABEL = 11
const SCE_IB_ASM = 12
'---------------------------------------
const SCLEX_ABASIC = 40
'const SCLEX_VB=8
'---------------------------------------
const SCI_SETLEXER = 4001
const SCI_STYLESETFORE = 2051
const SCI_STYLESETBACK = 2052
const SCI_STYLECLEARALL = 2050
const SCI_SETKEYWORDS = 4005
const SCI_STYLESETFONT = 2056
const SCI_STYLESETSIZE = 2055
const SCI_SETMARGINWIDTHN = 2242
const SCI_SETMARGINTYPEN = 2240
const SCI_SETMARGINSENSITIVEN = 2246
const SCI_SETSELBACK = 2068
const SCI_GOTOLINE = 2024
const SCI_GETLINE = 2153
const SCI_GETLINECOUNT = 2154
const SCI_GETCURLINE= 2027
const SCI_SCROLLCARET=2169
const SCI_GOTOPOS=2025

const SCI_CLEAR=2180
const SCI_CLEARALL=2004
const SCI_BRACEBADLIGHT=2352
const SCI_BRACEHIGHLIGHT=2351
const SCI_BRACEMATCH=2353
const SCI_GETSELECTIONEND=2145
const SCI_GETTEXTLENGTH = 2183
const SCI_GETTEXT = 2182
const SCI_SETSELECTIONEND=2144
const SCI_SETCARETLINEVISIBLE=2096
const SCI_UNDO = 2176
const SCI_CUT = 2177
const SCI_COPY = 2178
const SCI_PASTE = 2179


'open main window here ---------------------------------------------------------------
--------------------------------------------------------------------------------------------------

And i create scintilla control under @idcreate:
CASE @IDCREATE

'-----------------------------------------------------------------------------------------
def hlibsci, hsci:int
hlibsci = LoadLibrary( "SciLexer.dll" )
'create sci control
hsci=CreateWindowExA(0x20000,"Scintilla","",0x50010000,sciLw,sciTw,sciWidth,sciHeight,w1,IDC_SCI_CREATE,GetExeHandle(0),0)

SENDMESSAGE(w1, SCI_SETLEXER, SCLEX_ABASIC, 1, IDC_SCI)
SENDMESSAGE(w1, SCI_STYLESETFORE, SCE_IB_DEFAULT,100, IDC_SCI)
SENDMESSAGE(w1, SCI_STYLESETBACK,32,rgb(255,255,250), IDC_SCI)
SENDMESSAGE(w1, SCI_STYLECLEARALL, 0, 1, IDC_SCI)

For i = 0 to 12
SENDMESSAGE (w1, SCI_STYLESETFONT, i, "Courier New", IDC_SCI)
SENDMESSAGE (w1, SCI_STYLESETSIZE, i, 9, IDC_SCI)
Next i

SENDMESSAGE(w1, SCI_SETKEYWORDS, 0, scired , IDC_SCI ):'red
SENDMESSAGE(w1, SCI_SETKEYWORDS, 1, sciblue , IDC_SCI ):'blue
SENDMESSAGE(w1, SCI_SETKEYWORDS, 2, scidblue ,IDC_SCI):'darkblue
SENDMESSAGE(w1, SCI_SETKEYWORDS, 3,"winhigh winwide clearspace text msgbox ", IDC_SCI ):'brown
SENDMESSAGE(w1, SCI_STYLESETFORE, SCE_IB_LINECOMMENT, 0x007F00, IDC_SCI )
SENDMESSAGE(w1, SCI_STYLESETFORE, SCE_IB_BLOCKCOMMENT, 0x008800, IDC_SCI )
SENDMESSAGE(w1, SCI_STYLESETFORE, SCE_IB_NUMBER, 0x555555, IDC_SCI)
SENDMESSAGE(w1, SCI_STYLESETFORE, SCE_IB_KEYWORD, 0x0000FF, IDC_SCI)
SENDMESSAGE(w1, SCI_STYLESETFORE, SCE_IB_TYPE, 0xFF0000, IDC_SCI)
SENDMESSAGE(w1, SCI_STYLESETFORE, SCE_IB_SETID,rgb(0,0,175), IDC_SCI ):'orange/to dark blue
SENDMESSAGE(w1, SCI_STYLESETFORE, SCE_IB_PREPROCESSOR, 0x000088, IDC_SCI)
SENDMESSAGE(w1, SCI_STYLESETFORE, SCE_IB_STRING, 0x880088, IDC_SCI )
SENDMESSAGE(w1, SCI_STYLESETFORE, SCE_IB_OPERATOR, 0x884400, IDC_SCI)
SENDMESSAGE(w1, SCI_STYLESETFORE, SCE_IB_IDENTIFIER, 0x000000, IDC_SCI )
SENDMESSAGE(w1, SCI_STYLESETFORE, SCE_IB_LABEL, 0xAAAAAA, IDC_SCI)
SENDMESSAGE(w1, SCI_STYLESETFORE, SCE_IB_ASM, 0x555555, IDC_SCI )
CENTERWINDOW w1


I hope that now you understand better