AZJIO Posted February 20, 2023 Share Posted February 20, 2023 (edited) FindAllReferencesSciTE screenshot Tool for SciTE to show all lines of code containing the selected keyword. Working with the program: 1. Select a function, variable, keyword or something else, or simply put the cursor on the word without selecting anything and press the hot key. 2. In the window that appears, there will be a table of all found lines with this word and the line number. Clicking on a line scrolls the SciTE code to the position of that line and you can edit at that point. Clicking in the header returns to its original position. 3. You can choose one of the ready-made regular expressions, for example "find all cycles", etc. and navigate through these elements. You can enter your regular expression and press Enter. 4. The window retains its dimensions, so drag to the right and increase in height. Download: yandex, upload.ee Edited March 22, 2023 by AZJIO argumentum 1 My other projects or all Link to comment Share on other sites More sharing options...
AZJIO Posted February 22, 2023 Author Share Posted February 22, 2023 Update Regular expressions are now in the ini file My other projects or all Link to comment Share on other sites More sharing options...
AZJIO Posted March 22, 2023 Author Share Posted March 22, 2023 Update Command line "TitlePart ClassWindow CurrentWord TestFlag" supported for 3rd party Scintilla editors. Now you can use the same executable for PureBasic, SciTE, Notepad++. In the description of the program, I added configuration files for SciTE and Notepad++ Added context menu with 5 items (Copy, Autohide, Next color, ini, Exit) Improved regular expressions, this increased the speed by almost 2 times. Calling the program again terminates the previous instance of the program. Bugfix: now precise positioning, expands collapsed code snippets. argumentum 1 My other projects or all Link to comment Share on other sites More sharing options...
AZJIO Posted March 25, 2023 Author Share Posted March 25, 2023 I tried to make functions for capturing text from Scintilla expandcollapse popup#include <WinAPI.au3> Global Const $SCI_GETLENGTH = 2006 Global Const $SCI_GETCHARACTERPOINTER = 2520 Global Const $SCI_GETRANGEPOINTER = 2643 Global Const $SCI_GETCODEPAGE = 2137 Global Const $SCI_GETCURRENTPOS = 2008 Global Const $SCI_GETANCHOR = 2009 Global Const $SC_CP_UTF8 = 65001 Global Const $PROCESS_ALL_ACCESS = 2035711 ; Global Const $SMTO_ABORTIFHUNG = 2 ; В оригинале на PureBasic для получения SCI_GETRANGEPOINTER используется WinAPI функция SendMessageTimeout(), ; хотя непонятно зачем, если получение указателя не является затратной по времени функцией Func GetScintillaText() Local $ReturnValue Local $tagSTRING Local $tBuffer Local $length Local $iPID, $hProcess, $iOffset ; вынести получение дескриптора за пределы функции $ScintillaHandle = ControlGetHandle('[CLASS:SciTEWindow]', "", "[CLASSNN:Scintilla1]") ; [CLASS:Notepad++] If $ScintillaHandle Then $length = _SendMessage($ScintillaHandle, $SCI_GETLENGTH, 0, 0) If $length Then $length += 2 $tagSTRING = "char strdata[" & $length & "]" ; $tagSTRING = "wchar strdata[" & $length & "]" ; $tagSTRING = "struct;wchar strdata[" & $length & "];endstruct" $tBuffer = DllStructCreate($tagSTRING) If Not $tBuffer Then ; получаем позицию данных в процессе Scintilla, чтобы прочитать данные по указателю в памяти $iOffset = _SendMessage($ScintillaHandle, $SCI_GETCHARACTERPOINTER, 0, 0) $CodePage = _SendMessage($ScintillaHandle, $SCI_GETCODEPAGE, 0, 0) If $iOffset Then _WinAPI_GetWindowThreadProcessId ($ScintillaHandle, $iPID) $hProcess = _WinAPI_OpenProcess($PROCESS_ALL_ACCESS, 0, $iPID) If $hProcess Then _WinAPI_ReadProcessMemory($hProcess, $iOffset, DllStructGetPtr($tBuffer), $length, 0) _WinAPI_CloseHandle($hProcess) $ReturnValue = DllStructGetData($tBuffer, "strdata") If $CodePage = $SC_CP_UTF8 Then ; Чтобы не тратить память на бинарную строку преобразование с помощью _WinAPI_MultiByteToWideChar $ReturnValue = _WinAPI_MultiByteToWideChar($ReturnValue, 65001, 0, True) ; $ReturnValue = StringToBinary($ReturnValue) ; $ReturnValue = BinaryToString($ReturnValue, 4) EndIf EndIf EndIf EndIf EndIf EndIf Return $ReturnValue EndFunc ; Func GetScintillaRangeText($cursor, $length) Func GetScintillaRangeText() Local $ReturnValue Local $tagSTRING Local $tBuffer Local $iPID, $hProcess, $iOffset Local $cursor, $anchor ; вынести получение дескриптора за пределы функции $ScintillaHandle = ControlGetHandle('[CLASS:SciTEWindow]', "", "[CLASSNN:Scintilla1]") ; [CLASS:Notepad++] If $ScintillaHandle Then ; вынести за скобки, чтобы функция могла захватывать диапазон не обязательно выделенный ; в кодировке UTF-8 есть однобайтовые и двубайтовые символы, поэтому позиция в байтах заданная ручками не всегда объективна, ; так как может встать на середину двухбайтового символа и результат неверный. А захват выделенного не имеет этой проблемы. ; Мы задаём в символах, а функция работает в байтах. ; Чтобы задать в символах можно попробовать получить в широких символах, а после преобразования ($CodePage) обрезать по числу символов. $cursor = _SendMessage($ScintillaHandle, $SCI_GETCURRENTPOS, 0, 0) $anchor = _SendMessage($ScintillaHandle, $SCI_GETANCHOR, 0, 0) If $anchor = $cursor Then Return "" EndIf If $anchor < $cursor Then $length = $cursor - $anchor $cursor = $anchor Else $length = $anchor - $cursor EndIf If $length Then $tagSTRING = "char strdata[" & $length & "]" ; $tagSTRING = "wchar strdata[" & $length & "]" ; $tagSTRING = "struct;wchar strdata[" & $length & "];endstruct" $tBuffer = DllStructCreate($tagSTRING) If Not $tBuffer Then ; получаем позицию данных со сдвигом к курсору в процессе Scintilla, чтобы прочитать данные по указателю в памяти $iOffset = _SendMessage($ScintillaHandle, $SCI_GETRANGEPOINTER, $cursor, 0) $CodePage = _SendMessage($ScintillaHandle, $SCI_GETCODEPAGE, 0, 0) If $iOffset Then _WinAPI_GetWindowThreadProcessId ($ScintillaHandle, $iPID) $hProcess = _WinAPI_OpenProcess($PROCESS_ALL_ACCESS, 0, $iPID) If $hProcess Then _WinAPI_ReadProcessMemory($hProcess, $iOffset, DllStructGetPtr($tBuffer), $length, 0) _WinAPI_CloseHandle($hProcess) $ReturnValue = DllStructGetData($tBuffer, "strdata") If $CodePage = $SC_CP_UTF8 Then ; Чтобы не тратить память на бинарную строку преобразование с помощью _WinAPI_MultiByteToWideChar $ReturnValue = _WinAPI_MultiByteToWideChar($ReturnValue, 65001, 0, True) ; $ReturnValue = StringToBinary($ReturnValue) ; $ReturnValue = BinaryToString($ReturnValue, 4) EndIf EndIf EndIf EndIf EndIf EndIf Return $ReturnValue EndFunc MsgBox(0, 'Весь текст', "|" & GetScintillaText() & "|") ; MsgBox(0, 'Сообщение', "|" & GetScintillaRangeText(7, 4) & "|") ; MsgBox(0, 'Сообщение', "|" & GetScintillaRangeText(8, 4) & "|") MsgBox(0, 'Выделенное', "|" & GetScintillaRangeText() & "|") My other projects or all Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now