Hallo
Versuch seit Tagen eine Lösung zum Scintilla-Gadget zu finden.
Wie kann man die X-Position einer Zeile zum Cursor ermitteln ?
Z.B. Cursor befindet sich am 5 Zeichen, dann soll 5 angezeigt werden.
Über Lösungen wäre ich Euch sehr Dankbar.
Grüße
Lite
Scintilla
Re: Scintilla
http://www.purebasic.fr/english/viewtop ... 38#p332038
Und die aktuelle Zeile lässt sich mit #SCI_GETCURRENTPOS ermitteln.
Und die aktuelle Zeile lässt sich mit #SCI_GETCURRENTPOS ermitteln.
Re: Scintilla
@RSbasic
Vielen Dank, genau dannach hab ich gesucht.
Lite
Vielen Dank, genau dannach hab ich gesucht.
Lite
Re: Scintilla
Hallo
Suche eine möglichkeit wie man "Else" in die Verbindungslinien mit einbindet.
Es soll sich ein Knoten zwischen If und Endif bilden.
- If
- Else
- Endif
Für eine Lösung bin ich dankbar.
Beispiel nur mit If und Endif
Suche eine möglichkeit wie man "Else" in die Verbindungslinien mit einbindet.
Es soll sich ein Knoten zwischen If und Endif bilden.
- If
- Else
- Endif
Für eine Lösung bin ich dankbar.
Beispiel nur mit If und Endif
Code: Alles auswählen
#DS_EDITOR_KEYWORDS = " if else elseif endif exit free while wend goto label "
#DS_EDITOR_OPENFOLD = " while if "
#DS_EDITOR_CLOSEFOLD = " wend endif "
#DS_EDITOR_ENDCONSTANT = "+=-*/%$ !<>|\/.,()"
Enumeration 0
#LexerState_Space
#LexerState_Comment
#LexerState_NonKeyword
#LexerState_Keyword
#LexerState_FoldKeyword
#LexerState_Constant
#LexerState_String
EndEnumeration
Procedure.l Scintilla(sciptr.l, p1.l, p2.l=0, p3.l=0)
ProcedureReturn ScintillaSendMessage(sciptr,p1,p2,p3)
EndProcedure
Procedure Highlight(sciptr.l, startpos.l, endpos.l)
Debug(sciptr)
If startpos = -1
endstyled.l = Scintilla(sciptr, #SCI_GETENDSTYLED)
linenumber.l = Scintilla(sciptr, #SCI_LINEFROMPOSITION, endstyled)
Else
linenumber = Scintilla(sciptr, #SCI_LINEFROMPOSITION, startpos)
EndIf
If linenumber = 0
level = #SC_FOLDLEVELBASE
Else
linenumber - 1
level = Scintilla(sciptr, #SCI_GETFOLDLEVEL, linenumber) & ~ #SC_FOLDLEVELHEADERFLAG
EndIf
thislevel.l = level
nextlevel.l = level
currentpos.l = Scintilla(sciptr, #SCI_POSITIONFROMLINE, linenumber)
Scintilla(sciptr, #SCI_STARTSTYLING, currentpos, $1f | #INDICS_MASK)
state = #LexerState_Space
startkeyword = currentpos
keyword.s = ""
qpos.l = -1 ;quote pos
While currentpos <= endpos
oldstate = state
lastchar.l = char.l
char.l = Scintilla(sciptr, #SCI_GETCHARAT, currentpos)
If char = ';'
state = #LexerState_Comment
ElseIf char = '"' And state<>#LexerState_String And state<>#LexerState_Comment
state = #LexerState_String
qpos = currentpos
ElseIf state = #LexerState_String
If (qpos<>currentpos-1 And lastchar = '"') Or char = 10 Or char = 13
state=#LexerState_Space
qpos=-1
EndIf
ElseIf char = 10 Or char = 13
state = #LexerState_Space
ElseIf state <> #LexerState_Comment
If state=#LexerState_Constant
If FindString(#DS_EDITOR_ENDCONSTANT,Chr(char),1) Or char=10 Or char=13 Or char=9
state=#LexerState_Space
EndIf
Else
If char='#'
state = #LexerState_Constant
ElseIf char = 9 Or char = ' ' Or char = '.'
state = #LexerState_Space
Else
state = #LexerState_NonKeyword
keyword + Chr(char)
EndIf
EndIf
EndIf
If oldstate <> state Or currentpos = endpos
If oldstate = #LexerState_NonKeyword
lkeyword.s = LCase(keyword)
If FindString(#DS_EDITOR_OPENFOLD," "+LCase(keyword)+" ",1)
thislevel | #SC_FOLDLEVELHEADERFLAG
nextlevel + 1
ElseIf FindString(#DS_EDITOR_CLOSEFOLD," "+LCase(keyword)+" ",1)
nextlevel - 1
If nextlevel < #SC_FOLDLEVELBASE
nextlevel = #SC_FOLDLEVELBASE
EndIf
EndIf
If FindString(#DS_EDITOR_KEYWORDS," "+LCase(keyword)+" ",1)
oldstate = #LexerState_Keyword
EndIf
keyword = ""
EndIf
Scintilla(sciptr, #SCI_SETSTYLING, currentpos - startkeyword, oldstate)
startkeyword = currentpos
EndIf
If char = 10 Or currentpos = endpos
Scintilla(sciptr, #SCI_SETFOLDLEVEL, linenumber, thislevel)
thislevel = nextlevel
linenumber + 1
EndIf
currentpos + 1
Wend
EndProcedure
ProcedureDLL ScCallBack(EditorGadget.l, *scinotify.SCNotification)
If *scinotify\nmhdr\code = #SCN_STYLENEEDED
Highlight(1, -1, *scinotify\position)
ElseIf *scinotify\nmhdr\code = #SCN_MARGINCLICK
modifiers = *scinotify\modifiers
position = *scinotify\position
margin = *scinotify\margin
linenumber = Scintilla(1, #SCI_LINEFROMPOSITION, position)
Select margin
Case 2
Scintilla(1, #SCI_TOGGLEFOLD, linenumber)
EndSelect
EndIf
EndProcedure
OpenWindow(0,0,0,600,600,"")
RemoveKeyboardShortcut(0, #PB_Shortcut_Tab)
RemoveKeyboardShortcut(0, #PB_Shortcut_Tab | #PB_Shortcut_Shift)
InitScintilla("Scintilla.dll")
CreateGadgetList(WindowID(0))
ScintillaGadget(1,0,0,600,500,@ScCallBack())
ButtonGadget(2,0,510,100,50,"GetText")
; Margins
Scintilla(1, #SCI_STYLESETSIZE, #STYLE_DEFAULT, 10)
Scintilla(1, #SCI_SETMARGINTYPEN, 0, #SC_MARGIN_NUMBER)
Scintilla(1, #SCI_SETMARGINMASKN, 2, #SC_MASK_FOLDERS)
Scintilla(1, #SCI_SETMARGINWIDTHN, 0, 34)
Scintilla(1, #SCI_SETMARGINWIDTHN, 1, 1)
Scintilla(1, #SCI_SETMARGINWIDTHN, 2, 15)
Scintilla(1, #SCI_SETMARGINSENSITIVEN, 2, #True)
; Choose folding icons
Scintilla(1, #SCI_MARKERDEFINE, #SC_MARKNUM_FOLDEROPEN, #SC_MARK_CIRCLEMINUS)
Scintilla(1, #SCI_MARKERDEFINE, #SC_MARKNUM_FOLDER, #SC_MARK_CIRCLEPLUS)
Scintilla(1, #SCI_MARKERDEFINE, #SC_MARKNUM_FOLDERSUB, #SC_MARK_VLINE)
Scintilla(1, #SCI_MARKERDEFINE, #SC_MARKNUM_FOLDERTAIL, #SC_MARK_LCORNERCURVE)
Scintilla(1, #SCI_MARKERDEFINE, #SC_MARKNUM_FOLDEREND, #SC_MARK_CIRCLEPLUSCONNECTED)
Scintilla(1, #SCI_MARKERDEFINE, #SC_MARKNUM_FOLDEROPENMID, #SC_MARK_CIRCLEMINUSCONNECTED)
Scintilla(1, #SCI_MARKERDEFINE, #SC_MARKNUM_FOLDERMIDTAIL, #SC_MARK_TCORNERCURVE)
; Choose folding icon colours
Scintilla(1, #SCI_MARKERSETFORE, #SC_MARKNUM_FOLDER, $FFFFFF)
Scintilla(1, #SCI_MARKERSETBACK, #SC_MARKNUM_FOLDER, 0)
Scintilla(1, #SCI_MARKERSETFORE, #SC_MARKNUM_FOLDEROPEN, $FFFFFF)
Scintilla(1, #SCI_MARKERSETBACK, #SC_MARKNUM_FOLDEROPEN, 0)
Scintilla(1, #SCI_MARKERSETBACK, #SC_MARKNUM_FOLDEROPENMID, 0)
Scintilla(1, #SCI_MARKERSETBACK, #SC_MARKNUM_FOLDERSUB, 0)
Scintilla(1, #SCI_MARKERSETBACK, #SC_MARKNUM_FOLDERTAIL, 0)
Scintilla(1, #SCI_MARKERSETBACK, #SC_MARKNUM_FOLDERMIDTAIL, 0)
;lex setup
ScintillaSendMessage(1,#SCI_SETLEXER, #SCLEX_CONTAINER, 0);
ScintillaSendMessage(1,#SCI_STYLESETFORE, #STYLE_DEFAULT, RGB(0,0,0));
ScintillaSendMessage(1,#SCI_STYLESETBACK, #STYLE_DEFAULT, RGB(255,255,255));
ScintillaSendMessage(1,#SCI_STYLECLEARALL);
; Set caret line colour
ScintillaSendMessage(1, #SCI_SETCARETLINEBACK, RGB(231, 245, 255))
ScintillaSendMessage(1, #SCI_SETCARETLINEVISIBLE, #True)
; Set styles for custom lexer
ScintillaSendMessage(1, #SCI_STYLESETFORE, #LexerState_Comment, $8800)
ScintillaSendMessage(1, #SCI_STYLESETITALIC, #LexerState_Comment, 1)
ScintillaSendMessage(1, #SCI_STYLESETFORE, #LexerState_NonKeyword, 0)
ScintillaSendMessage(1, #SCI_STYLESETFORE, #LexerState_Keyword, 0)
ScintillaSendMessage(1, #SCI_STYLESETBOLD, #LexerState_NonKeyword, 0)
ScintillaSendMessage(1, #SCI_STYLESETBOLD, #LexerState_Keyword, 1)
ScintillaSendMessage(1, #SCI_STYLESETFORE, #LexerState_FoldKeyword, $ff)
ScintillaSendMessage(1, #SCI_STYLESETFORE, #LexerState_Constant, RGB(180,0,0))
ScintillaSendMessage(1, #SCI_STYLESETFORE, #LexerState_String, RGB(0,100,170))
SetGadgetText(1,";test comment"+#CRLF$+"If abc=1"+#CRLF$+" Goto hi_there"+#CRLF$+"EndIf")
Repeat
event=WaitWindowEvent()
If event=#PB_Event_Gadget
If EventGadget()=2
MessageRequester("Get",GetGadgetText(1))
EndIf
EndIf
Until event=#PB_Event_CloseWindow
End
Re: Scintilla
Einfach einschalten:
p.s.: Meine Scintilla-Lösung findet man hier:
http://www.purebasic.fr/german/viewtopi ... 81#p340218
Code: Alles auswählen
ScintillaSendMessage(gadget,#SCI_SETINDENTATIONGUIDES,#SC_IV_LOOKFORWARD)
http://www.purebasic.fr/german/viewtopi ... 81#p340218
CodeArchiv Rebirth: Deutsches Forum Github Hilfe ist immer gern gesehen!