折腾了一晚上, 查了一晚上的资料,
终于解决了一个困扰我很久的难题.
需要以下lua:
--------------------------------------------------------------------------------
-- This library contains various functions which can be used in numerous places.
-- New objects should inherit from this object.
--------------------------------------------------------------------------------
Common = Class:new()
--------------------------------------------------------------------------------
-- IsLexer(lexer)
--
-- Provides a clean method for checking the current lexer.
--
-- Parameters:
-- lexer - The lexer to check.
--
-- Returns:
-- The value true if the lexer is currently active.
-- The value false if the lexer is inactive.
--------------------------------------------------------------------------------
function Common:IsLexer(lexer)
return editor.Lexer == lexer
end -- IsLexer()
--------------------------------------------------------------------------------
-- CancelAutoComplete()
--
-- Cancels AutoComplete if it's showing.
--
-- Returns:
-- The value true is returned if AutoComplete was hidden.
-- The value false is returned if AutoComplete was not hidden.
--------------------------------------------------------------------------------
function Common:CancelAutoComplete()
if editor:AutoCActive() then
editor:AutoCCancel()
return true
end
return false
end -- CancelAutoComplete()
--------------------------------------------------------------------------------
-- MatchWordAtStart(word, line)
--
-- Checks if word is the first word on line skipping whitespace.
--
-- Parameters:
-- word - The word to search for.
-- line - The line to search on.
--
-- Returns:
-- The value true if word is the first word on the line.
-- The value false if word is not the first word on the line.
-- In either case, the word start position, start end position and word itself
-- are returned.
--------------------------------------------------------------------------------
function Common:MatchWordAtStart(word, line)
local word_pos = editor.LineIndentPosition[line] + 1
local word_start = editor:WordStartPosition(word_pos)
local word_end = editor:WordEndPosition(word_pos)
local word_found = editor:textrange(word_start, word_end)
return string.lower(word_found) == string.lower(word), word_start, word_end, word_found
end -- MatchWordAtStart()
--------------------------------------------------------------------------------
-- GetWord()
--
-- Gets the selected word or the word under the caret.
--
-- Returns:
-- If a word can be found, it is returned, otherwise an empty string.
--------------------------------------------------------------------------------
function Common:GetWord()
-- This pattern checks to see if a string is empty or all whitespace.
local pattern = "^%s*$"
-- First, get the selected text.
local word = editor:GetSelText()
if word:match(pattern) then
-- No text was selected, try getting the word where the caret is.
word = editor:textrange(editor:WordStartPosition(editor.CurrentPos, true),
editor:WordEndPosition(editor.CurrentPos, true))
if word:match(pattern) then
-- No text found anywhere, set as an empty string.
word = ""
end
end
return word:gsub("^%s*", "")
end -- GetWord()
--------------------------------------------------------------------------------
-- ReplaceCharacters(p, r)
--
-- Replace characters in the document and attempt to save the view.
--
-- Parameters:
-- p - The pattern to replace.
-- r - The replacement text.
--------------------------------------------------------------------------------
function Common:ReplaceCharacters(p, r)
y = editor:PointYFromPosition(editor.CurrentPos)
x = editor:PointXFromPosition(editor.CurrentPos)
line = editor:LineFromPosition(editor.CurrentPos)
s = editor:GetText()
editor:SetText(s:gsub(p, r))
pos = editor:PositionFromLine(line)
editor:SetSel(pos, pos)
yn = editor:PointYFromPosition(editor.CurrentPos)
while y ~= yn do
if yn < y then
editor:LineScroll(0, -1)
elseif yn > y then
editor:LineScroll(0, 1)
end
yn = editor:PointYFromPosition(editor.CurrentPos)
end
xn = editor:PointXFromPosition(editor.CurrentPos)
i = 0
while x ~= xn and i < 50 do
if xn < x then
editor:CharRight()
elseif xn > x then
editor:CharLeft()
end
xn = editor:PointXFromPosition(editor.CurrentPos)
i = i + 1
end
end -- ReplaceCharacters()
--------------------------------------------------------------------------------
-- ReplaceDocByPattern(sPat, fnPatMatch)
--
-- Replaces all occurences of a specific pattern by calling a user-defined
-- callback function.
--
-- Parameters:
-- sPat - The regular expresion pattern to match.
-- fnPatMatch - A callback function which will be called for each match. The
-- captures from the pattern will be passed as arguments to the function.
-- Return the replacement string.
--------------------------------------------------------------------------------
function Common:ReplaceDocByPattern(sPat, fnPatMatch)
local pos = editor.CurrentPos -- Current position before modification
local caret_line = editor:LineFromPosition(pos) -- Line number to return to.
local first_line = editor.FirstVisibleLine -- The first visible line in the buffer
local line_offset = 0 -- Number of lines inserted above the caret's original position
local column = pos - editor:PositionFromLine(caret_line) -- Convert back to beginning of line
local old_line_count = editor.LineCount
sPat = "()" .. sPat -- Internal capture to record the position of each match.
-- Local function which builds a string from the pattern matches.
local function pat_match(p, ...)
if pos > p then line_offset = line_offset + 1 end
return fnPatMatch(...)
end
local sDoc = editor:GetText()
-- We style the entire document so that match callbacks can use
-- styling information to determine replacement data.
editor:Colourise(0, -1)
editor:SetText(sDoc:gsub(sPat, pat_match))
local new_line_count = editor.LineCount
if old_line_count > new_line_count then
line_offset = line_offset * -1
elseif old_line_count == new_line_count then
line_offset = 0
end
pos = editor:PositionFromLine(caret_line + line_offset)
editor:GotoPos(pos + column)
editor:LineScroll(0, first_line - editor.FirstVisibleLine + line_offset)
end -- ReplaceDocByPattern()
--------------------------------------------------------------------------------
-- NewLineInUse()
--
-- Returns the current newline character(s) in use by the document.
--
-- Returns:
-- Either the value of "\n", "\r" or "\r\n" depending on the EOLMode.
--------------------------------------------------------------------------------
function Common:NewLineInUse()
if editor.EOLMode == 2 then
return "\n"
elseif editor.EOLMode == 1 then
return "\r"
else
return"\r\n"
end
end -- NewLineInUse()
--------------------------------------------------------------------------------
-- FileExists(file)
--
-- Checks to see if a file exists by attempting to open it.
--
-- Parameters:
-- file - The full path of the file to test.
--
-- Returns:
-- The value true if the file was successfully opened.
-- The value false if the file was not successfully opened.
--------------------------------------------------------------------------------
function Common:FileExists(file)
local fp = io.open(file)
if fp then
fp:close()
end
return io.type(fp) == "closed file"
end -- FileExists()
AutoCloseBraces=EventClass:new(Common)
--------------------------------------------------------------------------------
-- OnChar(charAdded)
--
-- AutoComplete Braces and Qoutes.
--https://www.autoitscript.com/forum/topic/67008-solved-autoclosebraceslua-for-scite/
-- Parameters:
-- charAdded - The character typed.
--------------------------------------------------------------------------------
function AutoCloseBraces:OnChar(charAdded)
-- trace(charAdded)
local toClose = { ['('] = ')', ['{'] = '}', ['['] = ']', ['"'] = '"', ["'"] = "'" }
if toClose[charAdded] ~= nil then
local pos = editor.CurrentPos
editor:ReplaceSel(toClose[charAdded])
editor:SetSel(pos, pos)
end
return false -- Let next handler to process event
-- return true -- Don't let next handler to process event
end
--------------------------------------------------------------------------------
-- This library provides class factories and event manager for SciTE events.
-- To create a new class without events, assign the result of Class:new() to a
-- global variable. For a class with events, use EventClass:new(). Example:
-- A basic object:
-- Basic = Class:new()
-- An object with events:
-- Event = EventClass:new()
--
-- To receive callbacks for SciTE events, just create a method named after the
-- event. Example:
-- function Test:OnChar(c) print(c) end
--
-- In addition to all the standard SciTE events, a special OnStartup() event
-- can be specified. It will be invoked when BeginEvents() is called.
--
-- The class factories also support inheritance. Pass each base object as
-- members to a new() method. The metatable and base member's for each object
-- will be inherited by the new object.
-- NOTE: If more than one object has a member (or metatable member) with the
-- same name, then the right-most object (in the parameter list) takes
-- precedence. For example, if Test3 inherits from Test1 and Test2 and both of
-- those have a member "Function", then the following will happen:
-- Test3 = Class:new(Test1, Test2) -- Test3:Function() will call Test2:Function().
-- Test3 = Class:new(Test2, Test1) -- Test3:Function() will call Test1:Function().
--
-- To use this file, call dofile("path to file") at the top of the Lua startup
-- script. Any other modules using the EventClass object should have their
-- dofile() statements after this one. Lastly, after all dofile() statements
-- and objects have been created, call EventClass:BeginEvents(). Example:
-- dofile(props["SciteDefaultHome"] .. "\\EventClass.lua") -- Must always be loaded first.
-- dofile(props["SciteDefaultHome"] .. "\\Sample.lua")
-- EventClass:BeginEvents()
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
-- NewRawClass()
--
-- Creates a new object ready to go.
-- NOTE: This function should not be called from user scripts.
--
-- Returns:
-- An initialized object.
--------------------------------------------------------------------------------
function NewRawClass()
return { }
end -- NewRawClass()
-- Create a base class from which all newly constructed class will derive.
BaseClass = NewRawClass()
--------------------------------------------------------------------------------
-- DebugPrint(s)
--
-- Set self.Debug = true to allow debug messages to print.
--
-- Parameters:
-- s = The string to print.
--------------------------------------------------------------------------------
function BaseClass:DebugPrint(s)
if self.Debug then print("����: " .. s) end
end -- DebugPrint()
-- Create a class factory for constructing objects.
Class = NewRawClass()
--------------------------------------------------------------------------------
-- Class:new(...)
--
-- Class factory. This function creates a new object. Optionally allows an
-- object to inherit from other objects.
-- NOTE: This function should be used to construct all class objects that
-- require events.
--
-- Parameters:
-- ... - Base classes to inherit from. The new object will have each bases'
-- metatable and members.
--
-- Returns:
-- A new object.
--------------------------------------------------------------------------------
function Class:new(...)
-- First create the object.
local obj = NewRawClass()
-- Copy all base members.
for k,v in pairs(BaseClass) do
obj[k] = v
end
-- We start with BaseClass' metatable or an empty one.
local mt = getmetatable(BaseClass) or { }
-- Loop through all the objects we need to inherti from.
for i = 1, select("#", ...) do
-- Get the base object and verify it's valid.
local base = select(i, ...)
if type(base) == "table" then
-- Copy base's members to obj.
for k,v in pairs(base) do
obj[k] = v
end
-- Get base's metatable and verify it's valid.
local bmt = getmetatable(base)
if type(bmt) == "table" then
-- Copy base's metatable to obj's metatable.
for k,v in pairs(bmt) do
mt[k] = v
end
end
end
end
-- Set the metatable.
setmetatable(obj, mt)
return obj
end -- new()
-- Create a class factory for constructing objects with SciTE events.
EventClass = Class:new()
--------------------------------------------------------------------------------
-- EventClass:new(...)
--
-- Class factory. This function creates a new object and adds it to the event
-- queue. Optionally allows an object to inherit from other objects.
-- NOTE: This function should be used to construct all class objects that
-- require events.
--
-- Parameters:
-- ... - Base classes to inherit from. The new object will have each bases'
-- metatable and members.
--
-- Returns:
-- A new object.
--------------------------------------------------------------------------------
function EventClass:new(...)
local obj = Class:new(...)
-- Add the object to EventClass' object table (for invoking callbacks).
-- If this is the first object created, the table will be created.
local t = EventClass.objects or { }
table.insert(t, obj)
EventClass.objects = t
return obj
end -- new()
--------------------------------------------------------------------------------
-- BeginEvents()
--
-- This enables the events. It also calls OnStartup() for any already created
-- functions. Any function created after this *will not* have OnStartup()
-- called. This should be called after all the dofile() statements.
--------------------------------------------------------------------------------
function EventClass:BeginEvents()
-- This lists all the SciTE events.
local events = {
"OnOpen",
"OnClose",
"OnSwitchFile",
"OnSave",
"OnBeforeSave",
"OnChar",
"OnKey",
"OnSavePointReached",
"OnSavePointLeft",
"OnDwellStart",
"OnDoubleClick",
"OnMarginClick",
"OnUserListSelection",
"OnUpdateUI",
"OnClear"
}
-- Create a function for each event handler. We add these directly to
-- the global table using their string names.
for index, event in ipairs(events) do
_G[event] = function (...) return EventClass:HandleEvent(event, ...) end
end
-- Call OnStartup() for each object (that has it).
if self.objects then
for index, obj in pairs(self.objects) do
if obj.OnStartup then obj:OnStartup() end
end
end
end -- BeginEvents()
--------------------------------------------------------------------------------
-- HandleEvent(event, ...)
--
-- This function handles all the events. It looks up the functions by string
-- name and forwards all the parameters.
--
-- Parameters:
-- event - The name of the event/function.
-- ... - The remaining arguments passed to us, which are forwarded to the
-- callback.
--
-- Returns:
-- The value true is returned if any one callback function returns true.
-- Otherwise the return value will be false.
--------------------------------------------------------------------------------
function EventClass:HandleEvent(event, ...)
-- We return true back to SciTE if a callback returns true,
-- however we don't actually abort as recommended.
local block = false
if self.objects then
for index, obj in pairs(self.objects) do
-- Look up function names in the metatable by string name.
local fn = obj[event]
if fn and fn ~= self[event] then
-- Functions are expecting self so we must simulate this.
block = fn(obj, ...) or block
end
end
end
return block
end -- HandleEvent()
--[[---------------------------------------------- ----
SciTE 智能闭合
版本:1.3.1
作者:Dmitry Maslov、Julgo、TymurGubayev
-------------------------------------------------
在以下情况下工作:
连接到自动加载
首选项设置为braces.autoclose = 1
首选项设置为braces.open=左括号
首选项设置为braces.close=右括号
由于扩展的 OnKey 功能,仅在俄语程序集中使用
braces.multiline参数指定一个词法分析器名称列表(用逗号分隔),花括号插入三行,光标在中间。默认braces.multiline=cpp
-------------------------------------------------
功能:
自动闭合括号
自动闭合括号中的选定文本
cpp 中 { 和 } 的特殊处理:自动缩进
-------------------------------------------------
工作逻辑:
该脚本仅在braces.autoclose = 1 时才有效
如果我们从braces.open 中输入一个字符,那么它会被自动插入
将其与braces.close 配对,因此光标位于方括号之间
如果我们从braces.close 和下一个字符输入右括号
相同的右括号,然后输入被吞下,额外的关闭
括号未打印
如果我们选择了文本并从braces.open 中输入一个字符,
然后文本用引号括起来braces.open-braces.close
如果它已经被引号包围,那么它们被删除,
在这种情况下,会考虑换行符,即如果选择
文本以换行符结尾,然后在中断之前插入括号
线条
如果我们在编辑cpp文件的时候输入{字符,那么自动
两次插入换行符,在 } 之后 - 光标原来是
在中间,即在第一个换行符之后,所有缩进都被保留
如果我们在编辑 cpp 文件时插入 } 字符,那么缩进
自动减一
如果我们刚刚自动插入了一个括号,那么之后
当我们按下 BACK_SPACE 时,插入的括号被移除,即
像 DEL 一样触发,而不像 BACK_SPACE
如果我们用braces.open == braces.close 插入一个括号,
那么只有当字符串中有偶数个这样的括号时才会插入一对
注意:脚本使用 COMMON.lua 中的 string.pattern 函数
--]]---------------------------------------------- ----
-- 返回当前的换行符
local function GetEOL()
local eol = "\r\n"
if editor.EOLMode == SC_EOL_CR then
eol = "\r"
elseif editor.EOLMode == SC_EOL_LF then
eol = "\n"
end
return eol
end
local function FindCount( text, textToFind )
local count = 0;
for _ in string.gmatch( text, textToFind:pattern() ) do
count = count + 1
end
return count
end
-- 位置是行的开头(给定缩进)
local function IsLineStartPos( pos )
return ( editor.LineIndentPosition[editor:LineFromPosition(pos)] == pos )
end
-- Получить номер текущей строки
local function GetCurrLineNumber()
return editor:LineFromPosition( editor.CurrentPos )
end
-- Получить отступ в строке
local function GetLineIndentation( num_line )
if ( num_line < 0 ) then num_line = 0 end
if ( num_line >= editor.LineCount ) then num_line = editor.LineCount - 1 end
return ( editor.LineIndentation[num_line] / editor.Indent )
end
-- последний в строке ?
local function IsInLineEnd( num_line, text )
local endpos = editor.LineEndPosition[num_line]
if ( endpos >= string.len( text ) )
and
string.find( editor:textrange( editor:PositionBefore( endpos - string.len( text ) + 1 ), endpos ), text:pattern() )
then
return true
end
return false
end
-- последний символ в строке - конец строки?
local function IsEOLlast( text )
-- в луа конец строки всегда один символ
--[[ if string.find( text, GetEOL(), string.len( text ) - 1 ) then
return true
end
return false]]
return (text:sub(-1) == GetEOL())
end
-- следующий за позицией текст == text ?
local function nextIs(pos, text)
if ( string.find( editor:textrange( pos, editor:PositionAfter( pos + string.len( text ) - 1 ) ), text:pattern() ) ) then
return true
end
return false
end
-- следующий символ позиции конец строки?
local function nextIsEOL(pos)
if ( pos == editor.Length )
or
( nextIs( pos, GetEOL() ) )
then
return true
end
return false
end
-----------------------------------------------------------------
-- проверяет скобки, заданные bracebegin и braceend в строке s на
-- сбалансированность: "(x)y(z)" -> true, "x)y(z" -> false
local function BracesBalanced (s, bracebegin, braceend)
if (#bracebegin + #braceend) > 2 then
--@warn: данная функция не будет работать со "скобками" больше одного символа.
--@todo: для "длинных" скобок нужно переписать эту функцию на lpeg. Но кому оно надо?..
return true
end
local b,e = s:find("%b"..bracebegin..braceend)
local b2 = s:find(bracebegin, 1, true)
local e2 = s:find(braceend, 1, true)
return (b == b2) and (e == e2)
end -- BracesBalanced
local function BlockBraces( bracebegin, braceend )
local text = editor:GetSelText()
local selbegin = editor.SelectionStart
local selend = editor.SelectionEnd
local b, e = string.find( text, "^%s*"..bracebegin:pattern() )
local b2, e2 = string.find( text, braceend:pattern().."%s*$" )
local add = ( IsEOLlast( text ) and GetEOL() ) or ""
editor:BeginUndoAction()
if (b and b2) and BracesBalanced( text:sub( e+1, b2-1 ) , bracebegin, braceend ) then
text = string.sub( text, e+1, b2-1 )
editor:ReplaceSel( text..add )
editor:SetSel( selbegin, selbegin + #( text..add ) )
else
editor:insert( selend - #add, braceend )
editor:insert( selbegin, bracebegin )
editor:SetSel( selbegin, selend + #( bracebegin..braceend ) )
end
editor:EndUndoAction()
return true
end
local function GetIndexFindCharInProps( value, findchar )
if findchar then
local resIndex = string.find( props[value], findchar:pattern() , 1 )
if ( resIndex ~= nil )
and
( string.sub( props[value], resIndex,resIndex ) == findchar )
then
return resIndex
end
end
return nil
end
local function GetCharInProps( value, index )
return string.sub( props[value], index, index )
end
-- возвращает открывающуюся скобку и закрывающуюся скобку
-- по входящему символу, т.е. например,
-- если на входе ')' то на выходе '(' ')'
-- если на входе '(' то на выходе '(' ')'
local function GetBraces( char )
local braceOpen = ''
local braceClose = ''
local symE = ''
local brIdx = GetIndexFindCharInProps( 'braces.open', char )
if ( brIdx ~= nil ) then
symE = GetCharInProps( 'braces.close', brIdx )
if ( symE ~= nil ) then
braceOpen = char
braceClose = symE
end
else
brIdx = GetIndexFindCharInProps( 'braces.close', char )
if ( brIdx ~= nil ) then
symE = GetCharInProps( 'braces.open', brIdx )
if ( symE ~= nil ) then
braceOpen = symE
braceClose = char
end
end
end
return braceOpen, braceClose
end
local g_isPastedBraceClose = false
-- “智能括号/引号”
-- 当不需要进一步的字符处理时返回 true
local function SmartBraces( char )
local multiline = props['braces.multiline']
if multiline == '' then multiline = 'cpp' end
local use_multiline = string.find(','..multiline..',', ','..props['Language']..',')
if ( props['braces.autoclose'] == '1' ) then
local isSelection = editor.SelectionStart ~= editor.SelectionEnd
-- находим парный символ
local braceOpen, braceClose = GetBraces(char)
if ( braceOpen ~= '' and braceClose ~= '' ) then
-- проверяем выделен ли у нас какой либо текст
if ( isSelection == true ) then
-- делаем обработку по автозакрытию текста скобками
return BlockBraces( braceOpen, braceClose )
else
-- если следующий символ закрывающаяся скобка
-- и мы ее вводим, то ввод проглатываем
local nextsymbol = string.format( "%c", editor.CharAt[editor.CurrentPos] )
if ( GetIndexFindCharInProps( 'braces.close', nextsymbol ) ~= nil )
and
( nextsymbol == char )
then
editor:CharRight()
return true
end
-- если мы ставим открывающуюся скобку и
-- следующий символ конец строки или это парная закрывающаяся скобка
-- то сразу вставляем закрывающуюся скобку
if ( char == braceOpen )
and
( nextIsEOL( editor.CurrentPos ) or nextIs( editor.CurrentPos, braceClose ) )
then
-- по волшебному обрабатываем скобку { в cpp
if ( char == '{' ) and
( use_multiline )
then
editor:BeginUndoAction()
local ln = GetCurrLineNumber()
if ( ln > 0 and GetLineIndentation( ln ) > GetLineIndentation( ln - 1 ) )
and
( IsLineStartPos( editor.CurrentPos ) )
and
( not IsInLineEnd( ln-1, '{' ) )
then
editor:BackTab()
end
editor:AddText( '{' )
editor:NewLine()
if ( GetLineIndentation( ln ) == GetLineIndentation( ln + 1 ) ) then
editor:Tab()
end
local pos = editor.CurrentPos
editor:NewLine()
if ( GetLineIndentation( ln + 2 ) == GetLineIndentation( ln + 1 ) ) then
editor:BackTab()
end
editor:AddText( '}' )
editor:GotoPos( pos )
editor:EndUndoAction()
return true
end
-- если вставляем скобку с одинаковыми правой и левой, то смотрим есть ли уже открытая в строке
if ( braceOpen == braceClose )
and
( math.fmod( FindCount( editor:GetCurLine(), braceOpen ), 2 ) == 1 )
then
return false
end
-- вставляем закрывающуюся скобку
editor:BeginUndoAction()
editor:InsertText( editor.CurrentPos, braceClose )
editor:EndUndoAction()
g_isPastedBraceClose = true
end
-- если мы ставим закрывающуюся скобку
if ( char == braceClose ) then
-- "по волшебному" обрабатываем скобку } в cpp
if ( char == '}' ) and
( use_multiline )
then
editor:BeginUndoAction()
if (IsLineStartPos( editor.CurrentPos ) )
then
editor:BackTab()
end
editor:AddText( '}' )
editor:EndUndoAction()
return true
end
end
end
end
end
return false
end
-- Перехватываем функцию редактора OnKey
AddEventHandler("OnKey", function(key, shift, ctrl, alt, char)
if ( editor.Focus ) then
if ( key == 8 and g_isPastedBraceClose == true ) then -- VK_BACK (08)
g_isPastedBraceClose = false
editor:BeginUndoAction()
editor:CharRight()
editor:DeleteBack()
editor:EndUndoAction()
return true
end
g_isPastedBraceClose = false
if ( char ~= '' ) then
return SmartBraces( char )
end
end
end)
--[[--------------------------------------------------
ShowCalltip.lua
显示当前单词的提示
作者:mozers™,TymurGubayev
版本 1.2.4
-------------------------------------------------- - ----
在光标所在的单词上显示工具提示
通过菜单命令“显示提示”(Ctrl + Shift + Space)
(当然,除非在 api 文件中指定了相应的调用类型)。
如果可以使用内部 SciTE 工具进行提示输出,
然后脚本选项被忽略。
-------------------------------------------------- - ----
要连接,将以下行添加到您的 SciTEStartup.lua:
dofile (props ["SciteDefaultHome"] .. .. "\\ tools \\ ShowCalltip.lua")
注意:该脚本使用 COMMON.lua 中的函数(string.pattern,GetCurrentWord)
--]]--------------------------------------------------
--[[
AddEventHandler("OnOpen", function()
string.lower = StringLower
string.upper = StringUpper
string.len = StringLen
EditorInitMarkStyles()
SetMarginTypeN()
props["pane.accessible"] = '1'
end, 'RunOnce')
function string.pattern( s )
return (s:gsub(lua_patt_chars,'%%%0')) -- -- 实际上是通过 % 符号屏蔽了服务符号
end
function GetCurrentWord()
local current_pos = editor.CurrentPos
return editor:textrange(editor:WordStartPosition(current_pos, true),
editor:WordEndPosition(current_pos, true))
end
--]]
local function ShowCalltip()
local word = GetCurrentWord()
if #word < 1 then return end
for api_filename in string.gmatch(props["APIPath"], "[^;]+") do
if api_filename ~= '' then
local api_file = io.open(api_filename)
if api_file then
for line in api_file:lines() do
local _start, _end, calltip = line:find('^('..word:pattern()..'[^%w%.%_%:].+)')
if _start == 1 then
editor:CallTipCancel()
local cp = editor:codepage()
if cp ~= 65001 then calltip=calltip:from_utf8(cp) end
editor:CallTipShow(editor.CurrentPos, calltip:gsub('\\n','\n'))
editor:CallTipSetHlt(0, #word)
break
end
end
api_file:close()
end
end
end
end https://www.youtube.com/watch?v=7diHtKE5guU
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。
这个,能用在任何IDE中吗?比如,在文本编辑器中用,或者vscode用,或者idea中用,能吗?