- Offizieller Beitrag
Bisher habe ich auf SciTE über Lua-Skripte oder das SciTE-Director-Interface zugegriffen. Das Interface erlaubt aber nur einen geringen Teil der Funktionen zu nutzen. Deshalb schreibe ich gerade ein Scintilla Interface. Im Wesentlichen ist das auch unproblematisch und hauptsächlich Schreibarbeit. Aber bei Funktionen, die Text auslesen sollen, also einen Buffer bereitstellen, an den die Funktion dann übergibt, hänge ich im Moment und weiß nicht warum.
Exemplarisch habe ich mal gewählt: SCI_GETCURLINE
Damit werden Inhalt und Länge der aktuellen Zeile abgefragt. Die Länge stimmt auch, aber der Textbuffer wird nicht befüllt und die Position in der Zeile wird nicht zurückgegeben.
Hat jemand eine Idee?
AutoIt: SCI_GETCURLINE
#cs
SCI_GETCURLINE(int length, char *text NUL-terminated) → int
This retrieves the text of the line containing the caret and returns the position within the line of the caret.
Pass in char* text pointing at a buffer large enough to hold the text you wish to retrieve and a terminating 0 character.
Set length to the length of the buffer which must be at least 1 to hold the terminating 0 character.
If the text argument is 0 then the length that should be allocated to store the entire current line is returned.
#ce
#include <SendMessage.au3>
Global Const $SCI_GETCURLINE = 2027
; Handle des Editors ermitteln
Global $hWndSciTE = WinGetHandle('[Class:SciTEWindow]')
Global $hWndSciTEEditor = ControlGetHandle($hWndSciTE, '', '[Class:Scintilla;Instance:1]')
; Länge der aktuellen Zeile (Zeile in der der Cursor steht)
Global $iLen = _SendMessage($hWndSciTEEditor, $SCI_GETCURLINE) ; inkl. Zeilenumbruch
ConsoleWrite("@@ Debug line" & @TAB & @ScriptLineNumber & " var: $iLen --> " & $iLen & @LF)
; Buffer bereitstellen für Null-terminierten String
Global $tBuffer = DllStructCreate('char[' & $iLen +1 & ']')
; Text der aktuellen Zeile abfragen
Global $iPosInLine = _SendMessage($hWndSciTEEditor, $SCI_GETCURLINE, $iLen+1, DllStructGetPtr($tBuffer))
ConsoleWrite("@@ Debug line" & @TAB & @ScriptLineNumber & " var: $iPosInLine --> " & $iPosInLine & @LF & "!@ " & @TAB & "#Error: " & @error & @TAB & "#Extended: " & @extended & @LF)
; Ausgabe in Konsole
ConsoleWrite('Current-Line:' & @CRLF & DllStructGetData($tBuffer, 1) & @CRLF)
Alles anzeigen