根据官网脚本修改一个嵌入 Scite 脚本编辑控件的窗口,使用了“马甲”版主修改显示中文 BUG 的代码,
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <string.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <GuiButton.au3>
;Set options
Opt("GUIOnEventMode", 1)
;改变工作目录到应用程序的目录
FileChangeDir(@ScriptDir);更改当前工作目录
#Region 定义常量
Global $ScintillaDir = @ScriptDir & "\Scintilla"
Global $user32 = DllOpen("user32.dll")
Global $kernel32 = DllOpen("kernel32.dll")
Global $hlStart, $hlEnd, $sCallTip
Global $line_Tally = 1
Global Enum $MARGIN_SCRIPT_NUMBER = 0, $MARGIN_SCRIPT_ICON, $MARGIN_SCRIPT_FOLD
Global Const $SC_MARGIN_NUMBER = 1
Global Const $SC_MARGIN_SYMBOL = 0
Global Const $SC_MARK_ARROW = 2
Global Const $SC_MARK_ARROWDOWN = 6
Global Const $SC_MARK_LCORNER = 10
Global Const $SC_MARK_TCORNER = 11
Global Const $SC_MARK_VLINE = 9
Global Const $SC_MARKNUM_FOLDER = 30
Global Const $SC_MARKNUM_FOLDEREND = 25
Global Const $SC_MARKNUM_FOLDERMIDTAIL = 27
Global Const $SC_MARKNUM_FOLDEROPEN = 31
Global Const $SC_MARKNUM_FOLDEROPENMID = 26
Global Const $SC_MARKNUM_FOLDERSUB = 29
Global Const $SC_MARKNUM_FOLDERTAIL = 28
Global Const $SC_MASK_FOLDERS = 0xFE000000
Global Const $SCE_AU3_COMMENT = 1
Global Const $SCE_AU3_COMMENTBLOCK = 2
Global Const $SCE_AU3_COMOBJ = 14
Global Const $SCE_AU3_DEFAULT = 0
Global Const $SCE_AU3_EXPAND = 13
Global Const $SCE_AU3_FUNCTION = 4
Global Const $SCE_AU3_KEYWORD = 5
Global Const $SCE_AU3_MACRO = 6
Global Const $SCE_AU3_NUMBER = 3
Global Const $SCE_AU3_OPERATOR = 8
Global Const $SCE_AU3_PREPROCESSOR = 11
Global Const $SCE_AU3_SENT = 10
Global Const $SCE_AU3_SPECIAL = 12
Global Const $SCE_AU3_STRING = 7
Global Const $SCE_AU3_UDF = 15
Global Const $SCE_AU3_VARIABLE = 9
Global Const $SCI_ADDTEXT = 2001
Global Const $SCI_AUTOCSETIGNORECASE = 2115
Global Const $SCI_AUTOCSETSEPARATOR = 2106
Global Const $SCI_CALLTIPCANCEL = 2201
Global Const $SCI_CALLTIPACTIVE = 2202
Global Const $SCI_CALLTIPSETHLT = 2204
Global Const $SCI_GETCURLINE = 2027
Global Const $SCI_GETCURRENTPOS = 2008
Global Const $SCI_GETLINE = 2153
Global Const $SCI_GETLINEENDPOSITION = 2136
Global Const $SCI_GETSTYLEBITSNEEDED = 4011
Global Const $SCI_GOTOLINE = 2024
Global Const $SCI_GOTOPOS = 2025
Global Const $SCI_LINEFROMPOSITION = 2166
Global Const $SCI_MARKERDEFINE = 2040
Global Const $SCI_MARKERSETBACK = 2042
Global Const $SCI_MARKERSETFORE = 2041
Global Const $SCI_SETFOLDFLAGS = 2233
Global Const $SCI_SETINDENTATIONGUIDES = 2132
Global Const $SCI_SETKEYWORDS = 4005
Global Const $SCI_SETLEXER = 4001
Global Const $SCI_SETMARGINMASKN = 2244
Global Const $SCI_SETMARGINSENSITIVEN = 2246
Global Const $SCI_SETMARGINTYPEN = 2240
Global Const $SCI_SETMARGINWIDTHN = 2242
Global Const $SCI_SETPROPERTY = 4004
Global Const $SCI_SETSTYLEBITS = 2090
Global Const $SCI_SETTABWIDTH = 2036
Global Const $SCI_STYLECLEARALL = 2050
Global Const $SCI_STYLESETBACK = 2052
Global Const $SCI_STYLESETBOLD = 2053
Global Const $SCI_STYLESETFONT = 2056
Global Const $SCI_STYLESETFORE = 2051
Global Const $SCI_STYLESETITALIC = 2054
Global Const $SCI_STYLESETSIZE = 2055
Global Const $SCI_STYLESETUNDERLINE = 2059
Global Const $SCI_TEXTWIDTH = 2276
Global Const $SCI_TOGGLEFOLD = 2231
Global Const $SCLEX_AU3 = 60
Global Const $SCN_CHARADDED = 2001
Global Const $SCN_MARGINCLICK = 2010
Global Const $SCN_SAVEPOINTLEFT = 2003
Global Const $SCN_SAVEPOINTREACHED = 2002
Global Const $STYLE_BRACEBAD = 35
Global Const $STYLE_DEFAULT = 32
Global Const $STYLE_LINENUMBER = 33
#EndRegion 定义常量
;定义全局变量
Global $Main_Win, $TV, $SciControl, $Input, $GUI_EVENT_Button, $Text
;创建 GUI
$Main_Win = GUICreate("Au3DB", 700, 220, (@DesktopWidth - 615) / 2, 3, $WS_POPUP)
$Target_File_Button = GUICtrlCreateButton("写 入", 125, 192, 80, 25, $BS_BITMAP)
GUICtrlSetOnEvent(-1, "Target_File_Button")
$Main_Win_Exit = GUICtrlCreateButton("退 出", 550, 192, 60, 25, $BS_BITMAP)
GUICtrlSetOnEvent(-1, "Win_Exit")
$SciControl = Sci_CreateEditor($Main_Win, 0, 0, 700, 184);创建 SCITE 控件
;显示 GUI
GUISetState()
;主循环
While 1
Sleep(100)
WEnd
; 添加编辑代码 ===================
Func Target_File_Button() ;"写入"
$AText = "#requireadmin|"
$AText &= "#Region AutoIt3Wrapper 预编译参数(常用参数)|"
$AText &= "#AutoIt3Wrapper_icon = |"
$AText &= "#AutoIt3Wrapper_outfile = |"
$AText &= "#AutoIt3Wrapper_Res_Description = |"
$AText &= "#AutoIt3Wrapper_Res_Comment = |"
$AText &= "#EndRegion AutoIt3Wrapper 预编译参数设置完成|"
$AText &= " |"
$AText &= "#include <GUIConstantsEx.au3>|"
$AText &= "#include <WindowsConstants.au3>|"
$AText &= "#Include <GuiListView.au3>|"
$AText &= "#include <GuiImageList.au3>|"
$AText &= " |"
$AText &= 'Opt("MouseCoordMode", 0)|'
$AText &= " |"
$AText &= 'Global $hListView, $Path_Fitx, $Path_Fit, $Nem_Path'
$BText = StringSplit($AText, "|")
For $i = 1 To $BText[0]
$Text = $BText[$i]
GUI_Event_About()
Next
EndFunc ;==>Target_File_Button
Func Win_Exit();主、子窗退出函数
Exit
EndFunc ;==>Win_Exit
;======================
Func GUI_Event_About();向 SCITE 写入数据
Sci_AddLines($SciControl, $Text & @CR, $line_Tally);向 SCITE 写入 数据 信息
$line_Tally += 1
EndFunc ;==>GUI_Event_About
Func Sci_CreateEditor($Hwnd, $X, $Y, $W, $H) ; 返回窗口句柄, 可用于 Win.. 函数
$Sci = CreateEditor($Hwnd, $X, $Y, $W, $H)
If @error Then
Return 0
EndIf
InitEditor($Sci)
If @error Then
Return 0
Else
Return $Sci
EndIf
EndFunc ;==>Sci_CreateEditor
Func CreateEditor($Hwnd, $X, $Y, $W, $H);创建 SCITE 控件
Local $GWL_HINSTANCE = -6
Local $hLib = LoadLibrary($ScintillaDir & "\SciLexer.dll")
If @error Then
Return 0
EndIf
Local $Sci
$Sci = CreateWindowEx($WS_EX_CLIENTEDGE, "Scintilla", "SciLexer", _
BitOR($WS_CHILD, $WS_VISIBLE, $WS_HSCROLL, $WS_VSCROLL, $WS_TABSTOP), $X, $Y, $W, $H, $Hwnd, 0, 0, 0)
If @error Then
Return 0
Else
If Not IsHWnd($Sci) Then $Sci = HWnd($Sci)
Return $Sci
EndIf
EndFunc ;==>CreateEditor
Func InitEditor($Sci);设置 SCITE 文本颜色格式
SendMessage($Sci, $SCI_SETLEXER, $SCLEX_AU3, 0)
Local $bits = SendMessage($Sci, $SCI_GETSTYLEBITSNEEDED, 0, 0)
SendMessage($Sci, $SCI_SETSTYLEBITS, $bits, 0)
SendMessage($Sci, $SCI_SETTABWIDTH, 4, 0)
SendMessage($Sci, $SCI_SETINDENTATIONGUIDES, True, 0)
SendMessageString($Sci, $SCI_SETKEYWORDS, 0, FileRead($ScintillaDir & "\Keywords.txt"))
SendMessageString($Sci, $SCI_SETKEYWORDS, 1, FileRead($ScintillaDir & "\Functions.txt"))
SendMessageString($Sci, $SCI_SETKEYWORDS, 2, FileRead($ScintillaDir & "\Macros.txt"))
SendMessageString($Sci, $SCI_SETKEYWORDS, 3, FileRead($ScintillaDir & "\SendKeys.txt"))
SendMessageString($Sci, $SCI_SETKEYWORDS, 4, FileRead($ScintillaDir & "\PreProcessor.txt"))
SendMessageString($Sci, $SCI_SETKEYWORDS, 5, FileRead($ScintillaDir & "\Special.txt"))
SendMessageString($Sci, $SCI_SETKEYWORDS, 7, FileRead($ScintillaDir & "\UDFs.txt"))
SendMessage($Sci, $SCI_SETMARGINTYPEN, $MARGIN_SCRIPT_NUMBER, $SC_MARGIN_NUMBER)
SendMessage($Sci, $SCI_SETMARGINWIDTHN, $MARGIN_SCRIPT_NUMBER, SendMessageString($Sci, $SCI_TEXTWIDTH, $STYLE_LINENUMBER, "_99999"))
SendMessage($Sci, $SCI_SETMARGINWIDTHN, $MARGIN_SCRIPT_ICON, 16)
SendMessage($Sci, $SCI_AUTOCSETSEPARATOR, Asc(@CR), 0)
SendMessage($Sci, $SCI_AUTOCSETIGNORECASE, True, 0)
SetStyle($Sci, $STYLE_DEFAULT, 0x000000, 0xFFFFFF, 10, "Courier New")
SendMessage($Sci, $SCI_STYLECLEARALL, 0, 0)
SetStyle($Sci, $STYLE_BRACEBAD, 0x009966, 0xFFFFFF, 0, "", 0, 1)
SetStyle($Sci, $SCE_AU3_DEFAULT, 0x000000, 0xFFFFFF)
SetStyle($Sci, $SCE_AU3_COMMENT, 0x339900, 0xFFFFFF)
SetStyle($Sci, $SCE_AU3_COMMENTBLOCK, 0x009966, 0xFFFFFF)
SetStyle($Sci, $SCE_AU3_NUMBER, 0xA900AC, 0xFFFFFF, 0, "", 1)
SetStyle($Sci, $SCE_AU3_FUNCTION, 0xAA0000, 0xFFFFFF, 0, "", 1, 1)
SetStyle($Sci, $SCE_AU3_KEYWORD, 0xFF0000, 0xFFFFFF, 0, "", 1)
SetStyle($Sci, $SCE_AU3_MACRO, 0xFF33FF, 0xFFFFFF, 0, "", 1)
SetStyle($Sci, $SCE_AU3_STRING, 0xCC9999, 0xFFFFFF, 0, "", 1)
SetStyle($Sci, $SCE_AU3_OPERATOR, 0x0000FF, 0xFFFFFF, 0, "", 1)
SetStyle($Sci, $SCE_AU3_VARIABLE, 0x000090, 0xFFFFFF, 0, "", 1)
SetStyle($Sci, $SCE_AU3_SENT, 0x0080FF, 0xFFFFFF, 0, "", 1)
SetStyle($Sci, $SCE_AU3_PREPROCESSOR, 0xFF00F0, 0xFFFFFF, 0, "", 0, 0)
SetStyle($Sci, $SCE_AU3_SPECIAL, 0xF00FA0, 0xFFFFFF, 0, "", 0, 1)
SetStyle($Sci, $SCE_AU3_EXPAND, 0x0000FF, 0xFFFFFF, 0, "", 1)
SetStyle($Sci, $SCE_AU3_COMOBJ, 0xFF0000, 0xFFFFFF, 0, "", 1, 1)
SetStyle($Sci, $SCE_AU3_UDF, 0xFF8000, 0xFFFFFF, 0, "", 1, 1)
SetProperty($Sci, "fold", "1")
SetProperty($Sci, "fold.compact", "1")
SetProperty($Sci, "fold.comment", "1")
SetProperty($Sci, "fold.preprocessor", "1")
SendMessage($Sci, $SCI_SETMARGINWIDTHN, $MARGIN_SCRIPT_FOLD, 0); fold margin width=0
SendMessage($Sci, $SCI_SETMARGINTYPEN, $MARGIN_SCRIPT_FOLD, $SC_MARGIN_SYMBOL)
SendMessage($Sci, $SCI_SETMARGINMASKN, $MARGIN_SCRIPT_FOLD, $SC_MASK_FOLDERS)
SendMessage($Sci, $SCI_SETMARGINWIDTHN, $MARGIN_SCRIPT_FOLD, 20)
SendMessage($Sci, $SCI_MARKERDEFINE, $SC_MARKNUM_FOLDER, $SC_MARK_ARROW)
SendMessage($Sci, $SCI_MARKERDEFINE, $SC_MARKNUM_FOLDEROPEN, $SC_MARK_ARROWDOWN)
SendMessage($Sci, $SCI_MARKERDEFINE, $SC_MARKNUM_FOLDEREND, $SC_MARK_ARROW)
SendMessage($Sci, $SCI_MARKERDEFINE, $SC_MARKNUM_FOLDERMIDTAIL, $SC_MARK_TCORNER)
SendMessage($Sci, $SCI_MARKERDEFINE, $SC_MARKNUM_FOLDEROPENMID, $SC_MARK_ARROWDOWN)
SendMessage($Sci, $SCI_MARKERDEFINE, $SC_MARKNUM_FOLDERSUB, $SC_MARK_VLINE)
SendMessage($Sci, $SCI_MARKERDEFINE, $SC_MARKNUM_FOLDERTAIL, $SC_MARK_LCORNER)
SendMessage($Sci, $SCI_SETFOLDFLAGS, 16, 0)
SendMessage($Sci, $SCI_MARKERSETFORE, $SC_MARKNUM_FOLDER, 0xFFFFFF)
SendMessage($Sci, $SCI_MARKERSETBACK, $SC_MARKNUM_FOLDERSUB, 0x808080);黑色
SendMessage($Sci, $SCI_MARKERSETBACK, $SC_MARKNUM_FOLDEREND, 0x808080);黑色
SendMessage($Sci, $SCI_MARKERSETFORE, $SC_MARKNUM_FOLDEREND, 0x808080);白色
SendMessage($Sci, $SCI_MARKERSETBACK, $SC_MARKNUM_FOLDERTAIL, 0x808080);黑色
SendMessage($Sci, $SCI_MARKERSETBACK, $SC_MARKNUM_FOLDERMIDTAIL, 0x808080);黑色
SendMessage($Sci, $SCI_MARKERSETBACK, $SC_MARKNUM_FOLDER, 0x808080);黑色
SendMessage($Sci, $SCI_MARKERSETFORE, $SC_MARKNUM_FOLDEROPEN, 0x808080);白色
SendMessage($Sci, $SCI_MARKERSETBACK, $SC_MARKNUM_FOLDEROPEN, 0x808080);黑色
SendMessage($Sci, $SCI_MARKERSETFORE, $SC_MARKNUM_FOLDEROPENMID, 0x808080);白色
SendMessage($Sci, $SCI_MARKERSETBACK, $SC_MARKNUM_FOLDEROPENMID, 0x808080);黑色
SendMessage($Sci, $SCI_SETMARGINSENSITIVEN, $MARGIN_SCRIPT_FOLD, 1)
SendMessage($Sci, $SCI_MARKERSETBACK, 0, 0x0000FF)
GUIRegisterMsg(0x004E, "WM_NOTIFY");注册已知 Windows 消息 ID (WM_MSG) 的用户自定义函数
If @error Then
Return 0
Else
Return 1
EndIf
EndFunc ;==>InitEditor
Func LoadLibrary($lpFileName);加载 SCITE 库文件
Local $ret
$ret = DllCall($kernel32, "int", "LoadLibrary", "str", $lpFileName)
If @error Then Return 0
Local $hLib = $ret[0]
Return $ret[0]
EndFunc ;==>LoadLibrary
Func Sci_AddLines($Sci, $Text, $Line);向 SCITE 写入文本 ;参数 $Sci=编辑框句柄;$Line=0
$Oldpos = Sci_GetCurrentLine($Sci);获取当前行
If @error Then
Return 0
EndIf
Sci_SetCurrentLine($Sci, $Line);设置当前行
If @error Then
Return 0
EndIf
$LineLenght = StringSplit(StringRegExpReplace($Text, '[^\x00-\xff]', '00'), "")
If @error Then
Return 0
EndIf
DllCall($user32, "long", "SendMessageA", "long", $Sci, "int", $SCI_ADDTEXT, "int", $LineLenght[0], "str", $Text)
If @error Then
Return 0
EndIf
Sci_SetCurrentLine($Sci, $Oldpos);设置当前行
If @error Then
Return 0
Else
Return 1
EndIf
EndFunc ;==>Sci_AddLines
Func CreateWindowEx($dwExStyle, $lpClassName, $lpWindowName = "", $dwStyle = -1, $X = 0, $Y = 0, $nWidth = 0, $nHeight = 0, $hwndParent = 0, $hMenu = 0, $hInstance = 0, $lParm = 0)
Local $ret
If $hInstance = 0 Then
$ret = DllCall($user32, "long", "GetWindowLong", "hwnd", $hwndParent, "int", -6)
$hInstance = $ret[0]
EndIf
$ret = DllCall($user32, "hwnd", "CreateWindowEx", "long", $dwExStyle, _
"str", $lpClassName, "str", $lpWindowName, _
"long", $dwStyle, "int", $X, "int", $Y, "int", $nWidth, "int", $nHeight, _
"hwnd", $hwndParent, "hwnd", $hMenu, "long", $hInstance, "ptr", $lParm)
If @error Then Return 0
Return $ret[0]
EndFunc ;==>CreateWindowEx
Func SendMessage($Hwnd, $msg, $wp, $lp)
Local $ret
$ret = DllCall($user32, "long", "SendMessageA", "long", $Hwnd, "int", $msg, "int", $wp, "int", $lp)
If @error Then
SetError(1)
Return 0
Else
SetError(0)
Return $ret[0]
EndIf
EndFunc ;==>SendMessage
Func SendMessageString($Hwnd, $msg, $wp, $str)
Local $ret
$ret = DllCall($user32, "int", "SendMessageA", "hwnd", $Hwnd, "int", $msg, "int", $wp, "str", $str)
Return $ret[0]
EndFunc ;==>SendMessageString
Func SetStyle($Sci, $style, $fore, $back, $size = 0, $font = "", $bold = 0, $italic = 0, $underline = 0)
SendMessage($Sci, $SCI_STYLESETFORE, $style, $fore)
SendMessage($Sci, $SCI_STYLESETBACK, $style, $back)
If $size >= 1 Then
SendMessage($Sci, $SCI_STYLESETSIZE, $style, $size)
EndIf
If $font <> '' Then
SendMessageString($Sci, $SCI_STYLESETFONT, $style, $font)
EndIf
SendMessage($Sci, $SCI_STYLESETBOLD, $style, $bold)
SendMessage($Sci, $SCI_STYLESETITALIC, $style, $italic)
SendMessage($Sci, $SCI_STYLESETUNDERLINE, $style, $underline)
EndFunc ;==>SetStyle
Func SetProperty($Hwnd, $property, $value, $int1 = False, $int2 = False)
Local $ret
If $int1 And $int2 Then
$ret = DllCall($user32, "int", "SendMessageA", "hwnd", $Hwnd, "int", $SCI_SETPROPERTY, "int", $property, "int", $value)
ElseIf Not $int1 And Not $int2 Then
$ret = DllCall($user32, "int", "SendMessageA", "hwnd", $Hwnd, "int", $SCI_SETPROPERTY, "str", $property, "str", $value)
ElseIf $int1 And Not $int2 Then
$ret = DllCall($user32, "int", "SendMessageA", "hwnd", $Hwnd, "int", $SCI_SETPROPERTY, "int", $property, "str", $value)
ElseIf Not $int1 And $int2 Then
$ret = DllCall($user32, "int", "SendMessageA", "hwnd", $Hwnd, "int", $SCI_SETPROPERTY, "str", $property, "int", $value)
EndIf
Return $ret[0]
EndFunc ;==>SetProperty
Func WM_NOTIFY($hWndGUI, $MsgID, $wParam, $lParam)
#forceref $hWndGUI, $MsgID, $wParam
Local $tagNMHDR, $event
Local $tagNMHDR = DllStructCreate("int;int;int;int;int;int;int;ptr;int;int;int;int;int;int;int;int;int;int;int", $lParam)
If @error Then Return
Local $hwndFrom = DllStructGetData($tagNMHDR, 1)
Local $idFrom = DllStructGetData($tagNMHDR, 2)
Local $event = DllStructGetData($tagNMHDR, 3)
Local $position = DllStructGetData($tagNMHDR, 4)
Local $ch = DllStructGetData($tagNMHDR, 5)
Local $modifiers = DllStructGetData($tagNMHDR, 6)
Local $modificationType = DllStructGetData($tagNMHDR, 7)
Local $char = DllStructGetData($tagNMHDR, 8)
Local $length = DllStructGetData($tagNMHDR, 9)
Local $linesAdded = DllStructGetData($tagNMHDR, 10)
Local $message = DllStructGetData($tagNMHDR, 11)
Local $uptr_t = DllStructGetData($tagNMHDR, 12)
Local $sptr_t = DllStructGetData($tagNMHDR, 13)
Local $Line = DllStructGetData($tagNMHDR, 14)
Local $foldLevelNow = DllStructGetData($tagNMHDR, 15)
Local $foldLevelPrev = DllStructGetData($tagNMHDR, 16)
Local $margin = DllStructGetData($tagNMHDR, 17)
Local $listType = DllStructGetData($tagNMHDR, 18)
Local $X = DllStructGetData($tagNMHDR, 19)
Local $Y = DllStructGetData($tagNMHDR, 20)
Local $Sci = $hwndFrom
If Not IsHWnd($Sci) Then $Sci = HWnd($Sci)
Local $line_number = SendMessage($Sci, $SCI_LINEFROMPOSITION, $position, 0)
;Select
;Case $hwndFrom = $Sci
;If IsHWnd($Sci) Then
Switch $event
Case $SCN_CHARADDED
If Chr($ch) = "(" Then
Local $ret, $sText, $iPos = SendMessage($Sci, $SCI_GETCURRENTPOS, 0, 0), $sFuncName
$iLen = SendMessage($Sci, $SCI_GETCURLINE, 0, 0)
$sBuf = DllStructCreate("byte[" & $iLen & "]")
$ret = DllCall($user32, "long", "SendMessageA", "long", $Sci, "int", $SCI_GETCURLINE, "int", $iLen, "ptr", DllStructGetPtr($sBuf))
$current = $ret[0]
$startword = $current
While $startword > 0 And StringIsAlpha(Chr(DllStructGetData($sBuf, 1, $startword - 1)))
$startword -= 1
$sFuncName &= Chr(DllStructGetData($sBuf, 1, $startword))
WEnd
$sFuncName = _StringReverse($sFuncName);反转指定字符串的内容
$sBuf = 0
ElseIf Chr($ch) = "," Then
If SendMessage($Sci, $SCI_CALLTIPACTIVE, 0, 0) Then
$hlStart = $hlEnd
$iTemp = StringInStr(StringTrimLeft($sCallTip, $hlStart + 1), ",") + $hlStart
If StringInStr(StringTrimLeft($sCallTip, $hlStart + 1), ")") + $hlStart < $iTemp Or $iTemp - $hlStart = 0 Then
$hlEnd = StringInStr(StringTrimLeft($sCallTip, $hlStart + 1), ")") + $hlStart
Else
$hlEnd = $iTemp
EndIf
SendMessage($Sci, $SCI_CALLTIPSETHLT, $hlStart, $hlEnd)
EndIf
ElseIf Chr($ch) = ")" Then
If SendMessage($Sci, $SCI_CALLTIPACTIVE, 0, 0) Then SendMessage($Sci, $SCI_CALLTIPCANCEL, 0, 0)
ElseIf Chr($ch) = @CR Then ; if: enter is pressed / new line created
$CurrentLine = Sci_GetCurrentLine($Sci);获取当前行
$PreviousLine = Sci_GetLine($Sci, $CurrentLine - 1)
$TabsAdd = ""
$Tabs = StringSplit($PreviousLine, @TAB)
For $i = 1 To $Tabs[0]
$TabsAdd &= @TAB
Next
Sci_AddLines($Sci, $TabsAdd, $CurrentLine)
$Pos = Sci_GetLineEndPos($Sci, $CurrentLine - 1)
Sci_SetCurrentPos($Sci, $Pos);设置当前位置
Else
EndIf
Case $SCN_MARGINCLICK
SendMessage($Sci, $SCI_TOGGLEFOLD, $line_number, 0)
Case $SCN_SAVEPOINTREACHED
Case $SCN_SAVEPOINTLEFT
EndSwitch
Local $tagNMHDR = 0
Local $event = 0
$lParam = 0
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY
Func Sci_GetCurrentLine($Sci);获取当前行
$Pos = SendMessage($Sci, $SCI_GETCURRENTPOS, 0, 0)
$Line = SendMessage($Sci, $SCI_LINEFROMPOSITION, $Pos, 0)
Return $Line + 1
EndFunc ;==>Sci_GetCurrentLine
Func Sci_SetCurrentLine($Sci, $Line);设置当前行
SendMessage($Sci, $SCI_GOTOLINE, $Line - 1, 0)
If @error Then
Return 0
Else
Return 1
EndIf
EndFunc ;==>Sci_SetCurrentLine
Func Sci_GetLine($Sci, $Line)
Local $ret, $sText
$iLen = SendMessage($Sci, $SCI_GETLINE, $Line, 0)
If @error Then
Return 0
EndIf
$sBuf = DllStructCreate("byte[" & $iLen & "]")
;If @error Then
; Return 0
;EndIf
$ret = DllCall($user32, "long", "SendMessageA", "long", $Sci, "int", $SCI_GETLINE, "int", $Line, "ptr", DllStructGetPtr($sBuf))
If @error Then
Return 0
EndIf
$sText = BinaryToString(DllStructGetData($sBuf, 1))
$sBuf = 0
If @error Then
Return 0
Else
Return $sText
EndIf
EndFunc ;==>Sci_GetLine
Func Sci_GetLineEndPos($Sci, $Line)
Return SendMessage($Sci, $SCI_GETLINEENDPOSITION, $Line, 0)
EndFunc ;==>Sci_GetLineEndPos
Func Sci_SetCurrentPos($Sci, $char);设置当前位置
SendMessage($Sci, $SCI_GOTOPOS, $char, 0)
If @error Then
Return 0
Else
Return 1
EndIf
EndFunc ;==>Sci_SetCurrentPos