But it is not clear how to make a jump to the line.
No word highlighting.
Code: Select all
; ----------------------------------------------------------------------------
; File : FindAllReferences[Linux].pb
; ----------------------------------------------------------------------------
EnableExplicit
;- Structure
Structure sFoundReference
LineNo.i
Reference.s
Selregexp.s
EndStructure
Structure xywhm
x.i
y.i
w.i
h.i
m.i
EndStructure
;- Enumeration
Enumeration ; Windows
#frmMain
EndEnumeration
Enumeration ; Gadgets
#cmbRex
#btnRex
; #btnClose
#frmMain_References
EndEnumeration
Enumeration ; Menu-/Toolbaritems
#frmMain_Shortcut_Escape_Event
#Shortcut_Ctrl_Shift_C
#Shortcut_Enter
EndEnumeration
;- Constants
CompilerIf #PB_Compiler_Debugger
#SelectedWordMarker$ = "|"
CompilerElse
#SelectedWordMarker$ = Chr(1) ; not used in source codes
CompilerEndIf
; " Line = Trim(Line)"
; " |Line| = Trim(|Line|)"
; --> ReplaceString(text$, SelectedWord, #SelectedWordMarker$ + SelectedWord + #SelectedWordMarker$)
;/-----------------------------------------------------------------------------
;| RGB() as HEX() --> BB GG RR .. i.e. RGB (1, 2, 3) --> 03 02 01
;| RGB() as HEX() --> AA BB GG RR .. i.e. RGBA(1, 2, 3, 4) --> 04 03 02 01
;\
#coloredChars_Delimeter = "{***\"
;- Global
Global ini$ = LSet(ProgramFilename(), Len(ProgramFilename()) - 3) + "ini"
Global centered
Global xywh.xywhm
Global xywh2.xywhm
Global xywh\w = 600
Global xywh\h = 300
Global hHeader
Global frmMain_References
Global CursorLine
Global flgRead
Global PbIdeHandle, ScintillaHandle
Global SelectedWord.s, ScintillaText.s
Global CountSelectedWords ; new, because we want to know all references (not only the lines)
Global NewList FoundReference.sFoundReference()
Global Dim Lines.s(0)
Global BackColor = $3f3f3f
Global ForeColor = $cccccc
Global BackColorHeader = $222222
Global ForeColorHeader = $72ADC0
Global BorderColor = $888888
; Global HightLightBrush = CreateSolidBrush_(GetSysColor_(#COLOR_HIGHLIGHT))
; Global HightLightBrush = CreateSolidBrush_($423926)
; Global BackColorBrush = CreateSolidBrush_(BackColor)
; Global BackColorBrushHeader = CreateSolidBrush_(BackColorHeader)
; ; ; Global PbIdeHandle = Val(GetEnvironmentVariable("PB_TOOL_MainWindow"))
; ; ; If PbIdeHandle = 0 : End : EndIf
; ; ;
; ; ; Global ScintillaHandle = Val(GetEnvironmentVariable("PB_TOOL_Scintilla"))
; ; ; If ScintillaHandle = 0 : End : EndIf
; ---== Procedures ==--------------------------------------------------------------------------------------------------
; AZJIO
Procedure.s LTrimChar(String$, TrimChar$ = #CRLF$ + #TAB$ + #FF$ + #VT$ + " ")
Protected *memChar, *c.Character, *jc.Character
If Not Asc(String$)
ProcedureReturn ""
EndIf
*c.Character = @String$
*memChar = @TrimChar$
While *c\c
*jc.Character = *memChar
While *jc\c
If *c\c = *jc\c
*c\c = 0
Break
EndIf
*jc + SizeOf(Character)
Wend
If *c\c
String$ = PeekS(*c)
Break
EndIf
*c + SizeOf(Character)
Wend
ProcedureReturn String$
EndProcedure
Procedure.s RTrimChar(String$, TrimChar$ = #CRLF$ + #TAB$ + #FF$ + #VT$ + " ")
Protected Len2, Blen, i
Protected *memChar, *c.Character, *jc.Character
Len2 = Len(String$)
Blen = StringByteLength(String$)
If Not Asc(String$)
ProcedureReturn ""
EndIf
*c.Character = @String$ + Blen - SizeOf(Character)
*memChar = @TrimChar$
For i = Len2 To 1 Step - 1
*jc.Character = *memChar
While *jc\c
If *c\c = *jc\c
*c\c = 0
Break
EndIf
*jc + SizeOf(Character)
Wend
If *c\c
Break
EndIf
*c - SizeOf(Character)
Next
ProcedureReturn String$
EndProcedure
Procedure Initialization()
Protected PathFile$
If CountProgramParameters() > 0
SelectedWord = ProgramParameter(0)
CursorLine = Int(Val(StringField(ProgramParameter(1), 1, "x")))
PathFile$ = ProgramParameter(2)
#File = 0
If ReadFile(#File, PathFile$)
ScintillaText = ReadString(#File, #PB_UTF8 | #PB_File_IgnoreEOL)
CloseFile(#File)
EndIf
; MessageRequester(SelectedWord, Str(CountProgramParameters()))
; MessageRequester(SelectedWord, ScintillaText)
EndIf
; For test only
CompilerIf #PB_Compiler_Debugger
If SelectedWord = ""
; SelectedWord = "Line" ; try one of these
; SelectedWord = "#Line" ; -"- #Line could be in a comment also
SelectedWord = "ScintillaText" ; -"-
EndIf
If ScintillaText = ""
#File = 0
If ReadFile(#File, #PB_Compiler_File)
ScintillaText = ReadString(#File, #PB_UTF8 | #PB_File_IgnoreEOL)
CloseFile(#File)
EndIf
If ScintillaText = ""
MessageRequester("", "Не могу получить текст Scintilla.")
EndIf
EndIf
CompilerEndIf
; End: For test only
ProcedureReturn 0 ; default (ZERO is returned by default, even if there is no ProcedureReturn)
EndProcedure
; ---------------------------------------------------------------------------------------------------------------------
; ChrisR
Procedure CopyClipboard()
Protected text$
PushListPosition(FoundReference())
ForEach FoundReference()
If text$ : text$ + #CRLF$ : EndIf
If Right(FoundReference()\Reference, 2) = #CRLF$
text$ + Left(FoundReference()\Reference, Len(FoundReference()\Reference) - 2)
Else
text$ + FoundReference()\Reference
EndIf
Next
PopListPosition(FoundReference())
If text$
text$ = ReplaceString(text$, #SelectedWordMarker$, "")
SetClipboardText(text$)
Protected Title$ = GetWindowTitle(#frmMain)
SetWindowTitle(#frmMain, Title$ + " (Reference copied To the clipboard)")
Delay(500)
SetWindowTitle(#frmMain, Title$)
EndIf
EndProcedure
; AZJIO
Procedure GoRegExp()
; LINK : https://www.purebasic.fr/english/viewtopic.php?p=595832#p595832
Protected rex, LSize, Pos = 0, i, tmp$
Protected Dim Tokens.s(0)
Protected timer
timer = ElapsedMilliseconds()
ClearGadgetItems(#frmMain_References)
ClearList(FoundReference())
tmp$ = GetGadgetText(#cmbRex)
If Not Asc(tmp$)
ProcedureReturn
EndIf
rex = CreateRegularExpression(#PB_Any, tmp$)
; CountTokens = ExtractRegularExpression(rex, ScintillaText, Tokens()) ; tokenize the line
; Debug ArraySize(Lines())
If rex
If ExamineRegularExpression(rex, ScintillaText)
While NextRegularExpressionMatch(rex)
If Not FindString(RegularExpressionMatchString(rex), #LF$)
AddElement(FoundReference())
FoundReference()\Selregexp = RegularExpressionMatchString(rex)
FoundReference()\LineNo = RegularExpressionMatchPosition(rex)
; Debug FoundReference()\LineNo
EndIf
Wend
EndIf
Else
MessageRequester("Regular expression error", RegularExpressionError())
ProcedureReturn
EndIf
LSize = ListSize(FoundReference())
If LSize > 0
; If LSize > 5000 And MessageRequester("Continue?", "Found" + Str(LSize) + " rows, Continue?", #PB_MessageRequester_YesNo) = #PB_MessageRequester_No
; ProcedureReturn
; EndIf
Pos = 0
i = 0
ForEach FoundReference()
While Pos < FoundReference()\LineNo
Pos = FindString(ScintillaText, #LF$, Pos + 1)
If Pos
i + 1
Else
Break
EndIf
; Debug Str(FoundReference()\LineNo) + " " + Str(Pos)
Wend
If i < 1 Or i > ArraySize(Lines())
Continue
EndIf
FoundReference()\LineNo = i
FoundReference()\Reference = Lines(i - 1)
FoundReference()\Reference = LTrimChar(FoundReference()\Reference, " " + #TAB$)
FoundReference()\Reference = RTrimChar(FoundReference()\Reference, #CRLF$)
; >> first attempt to mark the selected word in the string
FoundReference()\Reference = ReplaceString(FoundReference()\Reference, FoundReference()\Selregexp, #SelectedWordMarker$ + FoundReference()\Selregexp + #SelectedWordMarker$, #PB_String_NoCase)
AddGadgetItem(#frmMain_References, -1, Str(FoundReference()\LineNo) + #LF$ + FoundReference()\Reference)
Next
SelectedWord = "regexp"
SetWindowTitle(#frmMain, Str(ElapsedMilliseconds() - timer) + " ms, '" + SelectedWord + "', Found " + " in " + Str(ListSize(FoundReference())) + " Lines")
EndIf
EndProcedure
Procedure LookForWordUnderCursor()
; LINK : http://www.purebasic.fr/english/viewtopic.php?f=12&t=37823
Protected RegexLines, PbRegexTokens
Protected CountLines, LineCounter, CountTokens, TokenCounter
Protected Line.s, selWord.s, stx.s
Protected Dim Tokens.s(0)
RegexLines = CreateRegularExpression(#PB_Any , ".*\r?\n")
; RegexLines = CreateRegularExpression(#PB_Any , ".*(?=\r?\n)")
PbRegexTokens = CreateRegularExpression(#PB_Any, #DOUBLEQUOTE$ + "[^" + #DOUBLEQUOTE$ + "]*" + #DOUBLEQUOTE$ + "|[\*]?[a-zA-Z_]+[\w]*[\x24]?|#[a-zA-Z_]+[\w]*[\x24]?|[\[\]\(\)\{\}]|[-+]?[0-9]*\.?[0-9]+|;.*|\.|\+|-|[&@!\\\/\*,\|]|::|:|\|<>|>>|<<|=>{1}|>={1}|<={1}|=<{1}|={1}|<{1}|>{1}|\x24+[0-9a-fA-F]+|\%[0-1]*|%|'")
CountLines = CountString(ScintillaText, #CRLF$)
CountLines = ExtractRegularExpression(RegexLines, ScintillaText, Lines())
selWord = LCase(SelectedWord) ; keep the original writing
CountSelectedWords = 0 ; init for new search
; MessageRequester("Lines", Str(ArraySize(Lines())))
For LineCounter = 0 To CountLines - 1
Line = Lines(LineCounter)
;Debug "tokenize Line '" + Line + "'"
CountTokens = ExtractRegularExpression(PbRegexTokens, Line, Tokens()) ; tokenize the line
For TokenCounter = 0 To CountTokens - 1
;Debug " check Token '" + Tokens(TokenCounter) + "'"
If selWord = LCase(Tokens(TokenCounter))
AddElement(FoundReference())
FoundReference()\LineNo = LineCounter + 1
Line = Trim(Line)
Line = Mid(Line, 1, Len(Line) - 2) ; remove the #CRLF$
CountSelectedWords + CountString(LCase(Line), selWord) ; <-- count SelectedWord in the codeline
FoundReference()\Reference = Line
Break ; only one line (evenn if there are more than one SelectedWord )
EndIf
Next TokenCounter
Next LineCounter
; MessageRequester("FoundReference", Str(ListSize(FoundReference())))
; because of #Constant or *Pointer
If ListSize(FoundReference()) = 0
For LineCounter = 0 To CountLines - 1
Line = Lines(LineCounter)
CountTokens = ExtractRegularExpression(PbRegexTokens, Line, Tokens())
For TokenCounter = 0 To CountTokens - 1
stx = LCase(Tokens(TokenCounter))
If stx = "#" + selWord Or stx = "*" + selWord
AddElement(FoundReference())
FoundReference()\LineNo = LineCounter + 1
Line = Trim(Line)
Line = Mid(Line, 1, Len(Line) - 2)
CountSelectedWords + CountString(LCase(Line), stx) ; <-- count SelectedWord in the codeline
FoundReference()\Reference = Line
Break
EndIf
Next
Next
CompilerIf Not #PB_Compiler_Debugger
If ListSize(FoundReference()) = 0 : End : EndIf
CompilerEndIf
EndIf
EndProcedure
; ---------------------------------------------------------------------------------------------------------------------
; XIncludeFile "ColorListIconGadget.pbi" ; I prefer .pbi (instead of .pb)
; ---------------------------------------------------------------------------------------------------------------------
;... Create brushes for painting item background
Structure MYBRUSHES
brushDefault.l
brushSelected.l
EndStructure
; Global brush.MYBRUSHES
Global Dim Colors(1)
; brush\brushSelected = CreateSolidBrush_(GetSysColor_(#COLOR_HIGHLIGHT))
; brush\brushSelected = CreateSolidBrush_(GetSysColor_(#COLOR_INFOBK))
; brush\brushDefault = GetStockObject_(#WHITE_BRUSH)
; brush\brushSelected = ForeColor
; brush\brushDefault = BackColor
; ---== Color for Default Text and Selected Word ==--------------------------------------------------------------------
; Colors(0) = #Red ; the SelectedWord
Colors(0) = $8080FF ; the SelectedWord
; Colors(1) = GetSysColor_(#COLOR_HIGHLIGHTTEXT) ; the default text
; Colors(1) = GetSysColor_(#COLOR_WINDOWTEXT); the default text
Colors(1) = ForeColor ; the default text
; ---== MainWindow Procedures ==---------------------------------------------------------------------------------------
Procedure Resize_Event()
Protected wlv
xywh\w = WindowWidth(#frmMain)
xywh\h = WindowHeight(#frmMain)
ResizeGadget(#cmbRex, #PB_Ignore, #PB_Ignore, xywh\w - 39, 30)
ResizeGadget(#btnRex, xywh\w - 33, #PB_Ignore, #PB_Ignore, #PB_Ignore)
ResizeGadget(#frmMain_References, #PB_Ignore, #PB_Ignore, xywh\w - 6, xywh\h - 38)
EndProcedure
; Procedure SendMessage2(x, y, w, h)
; EndProcedure
Procedure JumpToLine(SelectedLine)
Protected Count
; SendMessage2(ScintillaHandle, #SCI_GOTOLINE, SelectedLine - 1, 0)
; Count = SendMessage2(ScintillaHandle, #SCI_LINESONSCREEN, 0, 0) / 2
; SendMessage2(ScintillaHandle, #SCI_SETFIRSTVISIBLELINE, SelectedLine - Count - 1, 0)
EndProcedure
Procedure Event_ListView()
Protected SelectedLine
SelectedLine = Val(GetGadgetItemText(#frmMain_References, GetGadgetState(#frmMain_References), 0))
If SelectedLine > 0
JumpToLine(SelectedLine)
EndIf
EndProcedure
; ---------------------------------------------------------------------------------------------------------------------
Procedure main()
Protected WWE ;, idx, pos, le
Protected timer
timer = ElapsedMilliseconds()
Initialization() ;
LookForWordUnderCursor()
; MessageRequester(SelectedWord, ini$)
;--> ini
If OpenPreferences(ini$) ; открываем ini
If PreferenceGroup("set")
xywh\x = ReadPreferenceInteger("x", xywh\x)
xywh\y = ReadPreferenceInteger("y", xywh\y)
xywh\w = ReadPreferenceInteger("w", xywh\w)
xywh\h = ReadPreferenceInteger("h", xywh\h)
EndIf
ClosePreferences()
EndIf
If xywh\x = 0 And xywh\y = 0
centered = #PB_Window_ScreenCentered
EndIf
CopyStructure(@xywh, @xywh2, xywhm)
;- GUI
If OpenWindow(#frmMain, xywh\x, xywh\y, xywh\w, xywh\h,
Str(ElapsedMilliseconds() - timer) + " ms, '" + SelectedWord + "', Found " + CountSelectedWords + " in " + Str(ListSize(FoundReference())) + " Lines",
#PB_Window_SystemMenu | #PB_Window_MaximizeGadget | #PB_Window_MinimizeGadget | #PB_Window_SizeGadget | centered)
SetWindowColor(#frmMain, BackColor)
StickyWindow(#frmMain, #True)
ComboBoxGadget(#cmbRex, 3, 3, 30, 30, #PB_ComboBox_Editable)
ResizeGadget(#cmbRex, #PB_Ignore, #PB_Ignore, WindowWidth(#frmMain) - 39, 30)
;ComboBoxGadget(#cmbRex, 3, 3, WindowWidth(#frmMain) - 60, 24, #PB_ComboBox_Editable)
AddGadgetItem(#cmbRex, -1, "(?# Debug, All )\bDebug\b")
AddGadgetItem(#cmbRex, -1, "(?# Debug, real )(?m)^\h*\KDebug\b")
AddGadgetItem(#cmbRex, -1, "(?# WinAPI )(?mi)[a-z][\da-z]*_(?=\h*\()")
AddGadgetItem(#cmbRex, -1, "(?# Link )https?://[\w.:]+/?(?:[\w/?&=.~;\+!*_#%-]+)")
AddGadgetItem(#cmbRex, -1, "(?# Procedure )(?mi)^\h*(?:Procedure[CDL$]{0,5}?(?:\h*\.[abcdfilqsuw])?\h+\K)[A-Za-z_]\w*\h*(?=\()")
AddGadgetItem(#cmbRex, -1, "(?# Macro )(?mi)^\h*Macro\h+\K[A-Za-z_]\w*\h*(?=\()")
AddGadgetItem(#cmbRex, -1, "(?# Var$ )(?<![#@\w])\w+\$")
AddGadgetItem(#cmbRex, -1, "(?# @*Point, whole )[@*]{1,2}\w+\b\$?(?![\\.(])")
AddGadgetItem(#cmbRex, -1, "(?# @*Point, var)[@*]{1,2}\w+(?!\()")
AddGadgetItem(#cmbRex, -1, "(?# @Point, Procedure)@\w+\(\)")
AddGadgetItem(#cmbRex, -1, "(?# Hex num )(?i)\$[\da-f]+")
AddGadgetItem(#cmbRex, -1, "(?# Comments )(?m)^\h*\K;.*?(?=\r?$)")
#q$ = Chr(34)
AddGadgetItem(#cmbRex, -1, "(?# Comments, All )(?m)^(?:[^" + #q$ + ";]*" + #q$ + "[^" + #q$ + "]*?" + #q$ + ")*[^" + #q$ + ";]*(;.*?)(?=\r?$)")
AddGadgetItem(#cmbRex, -1, "(?# Structures, Declare )(?i)(?<![=\w" + #q$ + "\\./-])[a-z]\w*\.[a-z]\w+(?![\w" + #q$ + "\\./-])")
AddGadgetItem(#cmbRex, -1, "(?# Structures, item )(?<![\w.:" + #q$ + "\\])\*?\w+(?:(?:\(\))?\\[\d_a-zA-Z]+)+(?![\w" + #q$ + "\\])")
AddGadgetItem(#cmbRex, -1, "(?# Structures, Content )(?m)^\h*Structure\h*\K\w+")
; AddGadgetItem(#cmbRex, -1, ~"(?# Comments )(?m)^(?:[^\";]*\"[^\"]*?\")*[^\";]*(;.*?)(?=\r?$)")
; AddGadgetItem(#cmbRex, -1, ~"(?# Structures, Declare )(?i)(?<![=\\w\"\\./-])[a-z]\\w*\\.[a-z]\\w+(?![\\w\"\\\\./-])")
; AddGadgetItem(#cmbRex, -1, ~"(?# Structures, item )(?<![\\w.:\"\\\\])\\*?\\w+(?:(?:\\(\\))?\\\\[\\d_a-zA-Z]+)+(?![\\w\"\\\\])")
AddGadgetItem(#cmbRex, -1, "(?# Types )\b\w+\.[sfdqbliwcapu]\b")
AddGadgetItem(#cmbRex, -1, "(?# Constants, Declare )(?m)^\h*\K#\w+\$?(?=\h*(?:=|\r?$))")
AddGadgetItem(#cmbRex, -1, "(?# Constants, All )#\w+\b\$?")
AddGadgetItem(#cmbRex, -1, "(?# CONSTANTS, DECLARE )(?m)^\h*\K#[A-Z\d_]+(?=\h*(?:=|\r?$))")
AddGadgetItem(#cmbRex, -1, "(?# CONSTANTS, ALL )#[A-Z\d_]+\b")
AddGadgetItem(#cmbRex, -1, "(?# CONSTANTS, X_X )#[A-Z\d]+_[A-Z\d]+\b")
AddGadgetItem(#cmbRex, -1, "(?# Constants, #PB_ )#PB_\w+\b\$?")
AddGadgetItem(#cmbRex, -1, "(?# Constants, Str )#\w+\$")
AddGadgetItem(#cmbRex, -1, "(?# If )(?mi)^\h*\KIf(?=\h)")
AddGadgetItem(#cmbRex, -1, "(?# Loop )(?mi)^\h*\K(For(Each)?|Repeat|While)(?=\h)")
AddGadgetItem(#cmbRex, -1, "(?# Select )(?mi)^\h*\KSelect(?=\h)")
AddGadgetItem(#cmbRex, -1, "(?# Include )(?mi)^\h*\KX?Include[a-z]{4,6}\b(?=\h)")
; ButtonGadget(#btnRex, WindowWidth(#frmMain) - 28, 3, 24, 24, ">")
; ButtonImageGadget(#btnRex, WindowWidth(#frmMain) - 28, 3, 24, 24, GetClassLongPtr_(WindowID(#frmMain), #GCL_HICONSM))
#img = 0
; Protected tmp = GadgetHeight(#cmbRex)
Protected tmp = 30
If CreateImage(#img, tmp, tmp, 32, RGB(255, 255, 255))
StartDrawing(ImageOutput(#img))
Box(0, 0, tmp, tmp, BorderColor)
Box(1, 1, tmp - 2, tmp - 2, BackColorHeader)
DrawText((tmp - TextWidth(">")) / 2, (tmp - TextHeight(">")) / 2, ">", ForeColor, BackColorHeader)
StopDrawing()
EndIf
ImageGadget(#btnRex, WindowWidth(#frmMain) - 33, 3, tmp, tmp, ImageID(0))
; ButtonImageGadget(#btnRex, WindowWidth(#frmMain) - 28, 3, 24, 24, ImageID(0))
; CatchImage(0, GetClassLongPtr_(WindowID(#frmMain), #GCL_HICONSM))
; ButtonImageGadget(#btnRex, WindowWidth(#frmMain) - 28, 3, 24, 24, ImageID(0))
; ButtonGadget(#btnClose, WindowWidth(#frmMain) - 27, 3, 24, 24, "x") ; to make a black theme
; MessageRequester("CursorLine", Str(CursorLine))
If CursorLine < 1 Or CursorLine > ArraySize(Lines())
CursorLine = 1
EndIf
ListIconGadget(#frmMain_References, 3, 35, WindowWidth(#frmMain) - 6, WindowHeight(#frmMain) - 38, Str(CursorLine), 55, #PB_ListIcon_FullRowSelect | #PB_ListIcon_GridLines | #PB_ListIcon_AlwaysShowSelection)
; SetWindowLongPtr_(GadgetID(#frmMain_References),#GWL_STYLE,GetWindowLongPtr_(GadgetID(#frmMain_References),#GWL_STYLE) | #LVS_NOCOLUMNHEADER)
AddGadgetColumn(#frmMain_References, 1, LTrimChar(RTrimChar(Lines(CursorLine - 1), #CRLF$), " " + #TAB$), 400)
SetGadgetColor(#frmMain_References, #PB_Gadget_BackColor, BackColor)
SetGadgetColor(#frmMain_References, #PB_Gadget_FrontColor, ForeColor)
ForEach FoundReference()
FoundReference()\Reference = LTrimChar(FoundReference()\Reference, " " + #TAB$)
; >> first attempt to mark the selected word in the string
FoundReference()\Reference = ReplaceString(FoundReference()\Reference, SelectedWord, #SelectedWordMarker$ + SelectedWord + #SelectedWordMarker$, #PB_String_NoCase)
AddGadgetItem(#frmMain_References, -1, Str(FoundReference()\LineNo) + #LF$ + FoundReference()\Reference)
Next
AddKeyboardShortcut(#frmMain, #PB_Shortcut_Escape, #frmMain_Shortcut_Escape_Event)
BindEvent(#PB_Event_SizeWindow, @Resize_Event(), #frmMain)
; BindGadgetEvent(#frmMain_References, @Event_ListView())
SetActiveGadget(#frmMain_References)
AddKeyboardShortcut(#frmMain, #PB_Shortcut_Control | #PB_Shortcut_Shift | #PB_Shortcut_C, #Shortcut_Ctrl_Shift_C)
AddKeyboardShortcut(#frmMain, #PB_Shortcut_Return, #Shortcut_Enter)
;- Loop
Repeat
Select WaitWindowEvent()
Case #PB_Event_MoveWindow
xywh\x = WindowX(#frmMain)
xywh\y = WindowY(#frmMain)
Case #PB_Event_CloseWindow
; Если размеры окна изменились, то сохраняем.
If Not CompareMemory(@xywh, @xywh2, SizeOf(xywhm))
If OpenPreferences(ini$) Or CreatePreferences(ini$)
PreferenceGroup("set")
WritePreferenceInteger("x", xywh\x)
WritePreferenceInteger("y", xywh\y)
WritePreferenceInteger("w", xywh\w)
WritePreferenceInteger("h", xywh\h)
ClosePreferences()
EndIf
EndIf
Break
Case #PB_Event_Menu
Select EventMenu()
Case #Shortcut_Enter
If GetActiveGadget() = #cmbRex
flgRead = 0
GoRegExp()
EndIf
If GetActiveGadget() = #frmMain_References
Event_ListView()
EndIf
Case #Shortcut_Ctrl_Shift_C
CopyClipboard()
Case #frmMain_Shortcut_Escape_Event
Break
EndSelect
Case #PB_Event_Gadget
Select EventGadget()
Case #cmbRex
If EventType() = #PB_EventType_Change
flgRead = 0
GoRegExp()
EndIf
Case #btnRex
GoRegExp()
EndSelect
EndSelect
ForEver
EndIf
ProcedureReturn 0 ; not necessary, but looks good/better
EndProcedure
End main()
;- Bottom of File