Suche Beispiel: Simpler Code-Editor mit Autocomplete
Suche Beispiel: Simpler Code-Editor mit Autocomplete
Hi!
Ich brauche einen Tritt in die richtige Richtung:
Suche einen simplen (Pseudo-)Code-Editor, der nach ein paar Zeichen vordefinierte Schlüsselwörter erkennt und per DropDown Vorschläge bringt - ähnlich wie die PB IDE..
Hat hier jemand einen Codeschnipsel für mich, da ich irgendwie nichts passendes finde?
(muss nur auf einer Windows-Maschine laufen, daher ist API auch i.O.)
Danke!!
Ich brauche einen Tritt in die richtige Richtung:
Suche einen simplen (Pseudo-)Code-Editor, der nach ein paar Zeichen vordefinierte Schlüsselwörter erkennt und per DropDown Vorschläge bringt - ähnlich wie die PB IDE..
Hat hier jemand einen Codeschnipsel für mich, da ich irgendwie nichts passendes finde?
(muss nur auf einer Windows-Maschine laufen, daher ist API auch i.O.)
Danke!!
Never change a running system - Never run a changed system!
(PB 6.03 LTS [x86])
(PB 6.03 LTS [x86])
Re: Suche Beispiel: Simpler Code-Editor mit Autocomplete
Hallo techniker,
ich würde dir unbedingt Scintilla empfehlen. (Etwa besseres wirst du nicht finden )
Google doch mal nach GoScintilla für PureBasic.
Dort gibt es auch eine Demo wie diese:
->Ich hoffe helfen zu können.
ich würde dir unbedingt Scintilla empfehlen. (Etwa besseres wirst du nicht finden )
Google doch mal nach GoScintilla für PureBasic.
Dort gibt es auch eine Demo wie diese:
Code: Alles auswählen
IncludePath "../../"
XIncludeFile "GoScintilla.pbi"
;Initialise the Scintilla library for Windows.
CompilerIf #PB_Compiler_OS = #PB_OS_Windows
InitScintilla()
CompilerEndIf
If OpenWindow(0, 100, 200, 600, 600, "GoScintilla demo!", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_ScreenCentered)
RemoveKeyboardShortcut(0, #PB_Shortcut_Tab) ;Required for the tab key to function correctly when the Scintilla control has the focus.
;Create our Scintilla control. Note that we do not specify a callback; this is optional for GoScintilla.
GOSCI_Create(1, 10, 10, 580, 580, 0, #GOSCI_AUTOSIZELINENUMBERSMARGIN)
;Set the padding added to the width of the line-number margin.
GOSCI_SetAttribute(1, #GOSCI_LINENUMBERAUTOSIZEPADDING, 10)
;Set folding symbols margin width.
GOSCI_SetMarginWidth(1, #GOSCI_MARGINFOLDINGSYMBOLS, 24)
;Set the back color of the line containing the caret.
GOSCI_SetColor(1, #GOSCI_CARETLINEBACKCOLOR, $B4FFFF)
;Set font.
GOSCI_SetFont(1, "Courier New", 10)
;Set tabs. Here we use a 'hard' tab in which a tab character is physically inserted. Set the 3rd (optional) parameter to 1 to use soft-tabs.
GOSCI_SetTabs(1, 2)
;Set styles for our syntax highlighting.
;=======================================
;First define some constants to identify our various styles.
;You can name these as we wish.
Enumeration
#STYLES_COMMANDS = 1
#STYLES_COMMENTS
#STYLES_LITERALSTRINGS
#STYLES_NUMBERS
#STYLES_CONSTANTS
#STYLES_FUNCTIONS
EndEnumeration
;Set individual styles for commands.
GOSCI_SetStyleFont(1, #STYLES_COMMANDS, "", -1, #PB_Font_Bold)
GOSCI_SetStyleColors(1, #STYLES_COMMANDS, $800000) ;We have omitted the optional back color.
;Set individual styles for comments.
GOSCI_SetStyleFont(1, #STYLES_COMMENTS, "", -1, #PB_Font_Italic)
GOSCI_SetStyleColors(1, #STYLES_COMMENTS, $006400) ;We have omitted the optional back color.
;Set individual styles for literal strings.
GOSCI_SetStyleColors(1, #STYLES_LITERALSTRINGS, #Gray) ;We have omitted the optional back color.
;Set individual styles for numbers.
GOSCI_SetStyleColors(1, #STYLES_NUMBERS, #Red) ;We have omitted the optional back color.
;Set individual styles for constants.
GOSCI_SetStyleColors(1, #STYLES_CONSTANTS, $2193DE) ;We have omitted the optional back color.
;Set individual styles for functions.
GOSCI_SetStyleColors(1, #STYLES_FUNCTIONS, #Blue) ;We have omitted the optional back color.
;Set delimiters and keywords for our syntax highlighting.
;========================================================
;Note the use of #GOSCI_ADDTOCODECOMPLETION (new for GoScintilla 2.0).
;First some commands.
GOSCI_AddKeywords(1, "Debug End If ElseIf Else EndIf For To Next Step Protected ProcedureReturn", #STYLES_COMMANDS, #GOSCI_ADDTOCODECOMPLETION)
;Now set up a ; symbol to denote a comment. Note the use of #GOSCI_DELIMITTOENDOFLINE.
;Note also that this symbol will act as an additional separator.
GOSCI_AddDelimiter(1, ";", "", #GOSCI_DELIMITTOENDOFLINE, #STYLES_COMMENTS)
;Now set up quotes to denote literal strings.
GOSCI_AddDelimiter(1, Chr(34), Chr(34), #GOSCI_DELIMITBETWEEN, #STYLES_LITERALSTRINGS)
;Now set up a # symbol to denote a constant. Note the use of #GOSCI_LEFTDELIMITWITHOUTWHITESPACE.
GOSCI_AddDelimiter(1, "#", "", #GOSCI_LEFTDELIMITWITHOUTWHITESPACE, #STYLES_CONSTANTS)
;Now set up a ( symbol to denote a function. Note the use of #GOSCI_RIGHTDELIMITWITHWHITESPACE.
GOSCI_AddDelimiter(1, "(", "", #GOSCI_RIGHTDELIMITWITHWHITESPACE, #STYLES_FUNCTIONS)
;We arrange for a ) symbol to match the coloring of the ( symbol.
GOSCI_AddDelimiter(1, ")", "", 0, #STYLES_FUNCTIONS)
;Add some folding keywords. Again note the use of #GOSCI_ADDTOCODECOMPLETION.
GOSCI_AddKeywords(1, "Procedure Macro", #STYLES_COMMANDS, #GOSCI_OPENFOLDKEYWORD|#GOSCI_ADDTOCODECOMPLETION)
;Note the final parameter (optional) which we set to #True in order to have the keywords sorted into alphabetic order.
;We do this for code-completion and the fact that we have not added the keywords ourselves in alphabetic order etc.
GOSCI_AddKeywords(1, "EndProcedure EndMacro", #STYLES_COMMANDS, #GOSCI_CLOSEFOLDKEYWORD|#GOSCI_ADDTOCODECOMPLETION, #True)
;Additional lexer options.
;=========================
GOSCI_SetLexerOption(1, #GOSCI_LEXEROPTION_SEPARATORSYMBOLS, @"=+-*/%()[],.") ;You would use GOSCI_AddKeywords() to set a style for some of these if required.
GOSCI_SetLexerOption(1, #GOSCI_LEXEROPTION_NUMBERSSTYLEINDEX, #STYLES_NUMBERS)
;Set call-completion.
;====================
;This lexer state is not set by default.
GOSCI_SetLexerState(1, #GOSCI_LEXERSTATE_ENABLESYNTAXSTYLING|#GOSCI_LEXERSTATE_ENABLECODEFOLDING|#GOSCI_LEXERSTATE_ENABLECODECOMPLETION)
;Set some initial text.
;======================
text$ = "; GoScintilla 2.0." + #CRLF$
text$ + "; With thanks to Peyman Mehrabi." + #CRLF$ + #CRLF$
text$ + "; Try out the new code-completion! Go ahead, type some PB code!" + #CRLF$
text$ + "; (NB - only a few commands are supported in this simple demo!)" + #CRLF$ + #CRLF$
text$ + "#MyConstant$ = " + Chr(34) + "Version = 1.0" + Chr(34) + #CRLF$ + #CRLF$
text$ + "Procedure.i AddIntegers(a, b)" + #CRLF$
text$ + #TAB$ + "Protected result" + #CRLF$
text$ + #TAB$ + "result = a + b ; Calculate the sum of the 2 integers." + #CRLF$
text$ + #TAB$ + "ProcedureReturn result" + #CRLF$
text$ + "EndProcedure" + #CRLF$ + #CRLF$
text$ + "Debug " + Chr(34) + "The sum of 10 and 20 is " + Chr(34) + " + Str(AddIntegers(10, 20))" + #CRLF$ + #CRLF$
text$ + "End" + #CRLF$
GOSCI_SetText(1, text$)
Repeat
eventID = WaitWindowEvent()
Select eventID
Case #PB_Event_Gadget
Select EventGadget()
EndSelect
EndSelect
Until eventID = #PB_Event_CloseWindow
;Free the Scintilla gadget.
;This needs explicitly calling in order to free resources used by GoScintilla.
GOSCI_Free(1)
EndIf
Betriebssysteme: div. Windows, Linux, Unix - Systeme
no Keyboard, press any key
no mouse, you need a cat
no Keyboard, press any key
no mouse, you need a cat
Re: Suche Beispiel: Simpler Code-Editor mit Autocomplete
Danke!
Das ist genau das, was ich gesucht habe..
Das ist genau das, was ich gesucht habe..
Never change a running system - Never run a changed system!
(PB 6.03 LTS [x86])
(PB 6.03 LTS [x86])
Re: Suche Beispiel: Simpler Code-Editor mit Autocomplete
Seit PB 4.10 gibt es ScintillaGadget auch nativ.
Ansonsten gibt es auch scintilla_helper von ts-soft: http://www.purebasic.fr/german/viewtopi ... 11&t=19580
Ansonsten gibt es auch scintilla_helper von ts-soft: http://www.purebasic.fr/german/viewtopi ... 11&t=19580
Re: Suche Beispiel: Simpler Code-Editor mit Autocomplete
Kann man das ScintillaGadget auch auf eine Zeile und einer bestimmten Anzahl an Zeichen begrenzen?
Von der Funktionalität (Highlighting und Autocomplete per Dropdown) würde es zu 100% passen - aber in meinem Fall ist es wie mit Kanonen auf Spatzen schießen..
Meine Anforderungen konkret:
Der User gibt einen Syntax-String ein wie z.B. "Sehr geehrte{ARG1} {ARG2} {ARG3}, dies ist {ARG4}ein Test."
Dabei sollen die geschweiften Klammern incl. deren Inhalt farbig hervorgehoben und die Namen der Parameter per DropDown vorgeschlagen werden. Vor und nach den Klammern kann alles stehen. Zusätzlich sollte ein Backslash vor der einleitenden Klammer das Highlighting und DropDown-Menü unterdrücken.
Im obigen Beispiel wären somit folgende Kombinationen möglich:
"Sehr geehrter Hr. Müller, dies ist ein Test."
"Sehr geehrte Fr. Meier, dies ist kein Test."
usw..
PS: Nutze aktuell PB5.61 (x86)
Von der Funktionalität (Highlighting und Autocomplete per Dropdown) würde es zu 100% passen - aber in meinem Fall ist es wie mit Kanonen auf Spatzen schießen..
Meine Anforderungen konkret:
Der User gibt einen Syntax-String ein wie z.B. "Sehr geehrte{ARG1} {ARG2} {ARG3}, dies ist {ARG4}ein Test."
Dabei sollen die geschweiften Klammern incl. deren Inhalt farbig hervorgehoben und die Namen der Parameter per DropDown vorgeschlagen werden. Vor und nach den Klammern kann alles stehen. Zusätzlich sollte ein Backslash vor der einleitenden Klammer das Highlighting und DropDown-Menü unterdrücken.
Im obigen Beispiel wären somit folgende Kombinationen möglich:
"Sehr geehrter Hr. Müller, dies ist ein Test."
"Sehr geehrte Fr. Meier, dies ist kein Test."
usw..
PS: Nutze aktuell PB5.61 (x86)
Never change a running system - Never run a changed system!
(PB 6.03 LTS [x86])
(PB 6.03 LTS [x86])
- ts-soft
- Beiträge: 22292
- Registriert: 08.09.2004 00:57
- Computerausstattung: Mainboard: MSI 970A-G43
CPU: AMD FX-6300 Six-Core Processor
GraKa: GeForce GTX 750 Ti, 2 GB
Memory: 16 GB DDR3-1600 - Dual Channel - Wohnort: Berlin
Re: Suche Beispiel: Simpler Code-Editor mit Autocomplete
<offtopic>
Anreden in Briefen, E-Mails u. ä. bitte nicht abkürzen, das ist einfach Unhöflich.
</offtopic>
Anreden in Briefen, E-Mails u. ä. bitte nicht abkürzen, das ist einfach Unhöflich.
PS: Frl. ist die Abkürzung für Ferkel und nicht für Fräuleinhttps://www.gutefrage.net/frage/sollte-man-bei-der-anrede-nicht-frau-mit-fr-abkuerzen hat geschrieben:Herr und Frau werden in der Anrede niemals (!) abgekürzt
</offtopic>
PureBasic 5.73 LTS | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Nutella hat nur sehr wenig Vitamine. Deswegen muss man davon relativ viel essen.
Nutella hat nur sehr wenig Vitamine. Deswegen muss man davon relativ viel essen.
Re: Suche Beispiel: Simpler Code-Editor mit Autocomplete
Das war doch nur ein Beispiel..
Den korrekten Hintergrund zu erklären sprengt hier den Rahmen.
Vom Sinn her macht das aber keinen Unterschied..
Den korrekten Hintergrund zu erklären sprengt hier den Rahmen.
Vom Sinn her macht das aber keinen Unterschied..
Never change a running system - Never run a changed system!
(PB 6.03 LTS [x86])
(PB 6.03 LTS [x86])
Re: Suche Beispiel: Simpler Code-Editor mit Autocomplete
Guten Tag techniker,
Hier einmal ein Ansatz:
...jetzt geht's nur noch um das wirklich knifflige: "Die Falt- oder Vorschau-Logik"
Hier einmal ein Ansatz:
Code: Alles auswählen
IncludePath "../../"
XIncludeFile "GoScintilla.pbi"
CompilerIf #PB_Compiler_OS = #PB_OS_Windows
InitScintilla()
CompilerEndIf
If OpenWindow(0, 0, 0, 500, 90, "ScintillaGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
GOSCI_Create(0, 10, 10, 480, 20, 0, #Null)
ScintillaSendMessage(0, #SCI_STYLESETFORE, 0, RGB(255, 0, 0))
ScintillaSendMessage(0, #SCI_SETHSCROLLBAR, 0) ;kein horizontaller Balken!
ScintillaSendMessage(0, #SCI_SETVSCROLLBAR, 0) ;kein vertikaler Balken!
GOSCI_SetMarginWidth(0, #GOSCI_MARGINFOLDINGSYMBOLS, 0) ;0 = keine linke Randspalte
;Set the back color of the line containing the caret.
GOSCI_SetColor(0, #GOSCI_CARETLINEBACKCOLOR, $B4FFFF)
;Set font.
GOSCI_SetFont(0, "Courier New", 10)
;Set styles for our syntax highlighting.
;=======================================
;First define some constants to identify our various styles.
;You can name these as we wish.
Enumeration
#KLAMMERSTYLE1
#KLAMMERSTYLE2
EndEnumeration
;Set individual styles for functions.
GOSCI_SetStyleColors(0, #KLAMMERSTYLE1, #Red)
GOSCI_SetStyleColors(0, #KLAMMERSTYLE2, #Blue)
GOSCI_AddDelimiter(0, "{", "}", #GOSCI_DELIMITBETWEEN, #KLAMMERSTYLE1)
GOSCI_SetLexerState(0, #GOSCI_LEXERSTATE_ENABLESYNTAXSTYLING|#GOSCI_LEXERSTATE_ENABLECODEFOLDING|#GOSCI_LEXERSTATE_ENABLECODECOMPLETION)
text$ = "Sehr geehrte{ARG1} {ARG2} {ARG3}, dies ist {ARG4}ein Test."
GOSCI_SetText(0, text$)
Repeat
If ScintillaSendMessage(0, #SCI_GETLINECOUNT) > 1 ;verhindert die Enter-Taste
ScintillaSendMessage(0, #SCI_DELETEBACK)
EndIf
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Quit = 1
EndSelect
Until Quit = 1
GOSCI_Free(0)
EndIf
Betriebssysteme: div. Windows, Linux, Unix - Systeme
no Keyboard, press any key
no mouse, you need a cat
no Keyboard, press any key
no mouse, you need a cat
Re: Suche Beispiel: Simpler Code-Editor mit Autocomplete
@techniker
Du kannst JaPBe herunterladen. JaPBe war damals ein sehr guter alternativer Editor für PB. Ist OpenSource und da kannst du viele Sachen heraus kopieren und wiederverwenden.
Einfach mal nach "JaPBe" suchen. Falls der Downloadlink ungültig sein sollte, dann schau auf meiner Website unter "Backups" nach.
Du kannst JaPBe herunterladen. JaPBe war damals ein sehr guter alternativer Editor für PB. Ist OpenSource und da kannst du viele Sachen heraus kopieren und wiederverwenden.
Einfach mal nach "JaPBe" suchen. Falls der Downloadlink ungültig sein sollte, dann schau auf meiner Website unter "Backups" nach.
Re: Suche Beispiel: Simpler Code-Editor mit Autocomplete
Code: Alles auswählen
XIncludeFile "GoScintilla.pbi"
;Initialise the Scintilla library for Windows.
CompilerIf #PB_Compiler_OS = #PB_OS_Windows
InitScintilla()
CompilerEndIf
If OpenWindow(0, 100, 200, 600, 300, "GoScintilla demo!", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_ScreenCentered)
; RemoveKeyboardShortcut(0, #PB_Shortcut_Tab) ;Required for the tab key to function correctly when the Scintilla control has the focus.
GOSCI_Create(1, 10, 10, 580, 280, 0);, #GOSCI_AUTOSIZELINENUMBERSMARGIN)
GOSCI_SetFont(1, "Courier New", 10)
GOSCI_SetTabs(1, 2)
Enumeration
#STYLES_COMMANDS = 1
EndEnumeration
GOSCI_SetStyleFont(1, #STYLES_COMMANDS, "", -1, #PB_Font_Bold)
GOSCI_SetStyleColors(1, #STYLES_COMMANDS, #Yellow, #Black);$800000) ;We have omitted the optional back color.
GOSCI_AddDelimiter(1, "{", "", #GOSCI_LEFTDELIMITWITHWHITESPACE, #STYLES_COMMANDS)
GOSCI_AddDelimiter(1, "}", "", #GOSCI_RIGHTDELIMITWITHWHITESPACE, #STYLES_COMMANDS)
GOSCI_AddKeywords(1, "ARG1 ARG2 ARG3 ARG4", #STYLES_COMMANDS, #GOSCI_ADDTOCODECOMPLETION)
GOSCI_SetLexerState(1, #GOSCI_LEXERSTATE_ENABLESYNTAXSTYLING|#GOSCI_LEXERSTATE_ENABLECODECOMPLETION);#GOSCI_LEXERSTATE_ENABLECODEFOLDING|
GOSCI_SetText(1, "")
Repeat
If ScintillaSendMessage(1, #SCI_GETLINECOUNT) > 1 ;verhindert die Enter-Taste
ScintillaSendMessage(1, #SCI_DELETEBACK)
EndIf
eventID = WaitWindowEvent()
Select eventID
Case #PB_Event_Gadget
Select EventGadget()
EndSelect
EndSelect
Until eventID = #PB_Event_CloseWindow
GOSCI_Free(1)
EndIf
Das war die Lösung: (Danke!)
Code: Alles auswählen
If ScintillaSendMessage(1, #SCI_GETLINECOUNT) > 1 ;verhindert die Enter-Taste
ScintillaSendMessage(1, #SCI_DELETEBACK)
EndIf
Never change a running system - Never run a changed system!
(PB 6.03 LTS [x86])
(PB 6.03 LTS [x86])