- local function SelectBlock(info, sel, pos)
- if not sel then
- if pos > info.CurPos then
- editor.Select(info.EditorId, 1, info.CurLine, info.CurPos, pos - info.CurPos, 1)
- else
- editor.Select(info.EditorId, 1, info.CurLine, pos, info.CurPos - pos, 1)
- end
- else
- --msgbox("", sel.EndLine .. " " .. sel.EndPos .. "\n" .. info.CurLine .. " " .. info.CurPos .. "\n" .. pos)
- if info.CurLine < sel.EndLine or (info.CurLine == sel.EndLine and info.CurPos < sel.EndPos) then
- if info.CurLine == sel.EndLine and (pos - 1) == sel.EndPos then
- editor.Select(info.EditorId, 0)
- else
- editor.Select(info.EditorId, 1, info.CurLine, pos, sel.EndPos - pos + 1, sel.EndLine - info.CurLine + 1)
- end
- else
- editor.Select(info.EditorId, 1, sel.StartLine, sel.StartPos, pos - sel.StartPos, info.CurLine - sel.StartLine + 1)
- end
- end
- end
- Macro {
- area="Editor"; key="Home"; flags=""; action = function()
- local info = editor.GetInfo()
- if info then
- local str = editor.GetString(-1, info.CurLine)
- local s = str.StringText
- local len = s:len()
- local set = false
- for i = 1, len do
- local c = s:sub(i, i)
- if c ~= " " and c ~= "\t" then
- local pos = i
- if pos == info.CurPos then
- pos = 1
- end
- editor.Select(info.EditorId, 0)
- editor.SetPosition(info.EditorId, info.CurLine, pos)
- set = true
- break
- end
- end
- if not set then
- editor.SetPosition(info.EditorId, info.CurLine, 1)
- end
- end
- end;
- }
- Macro {
- area="Editor"; key="ShiftHome"; flags=""; action = function()
- local info = editor.GetInfo()
- local sel = editor.GetSelection()
- if info then
- local str = editor.GetString(-1, info.CurLine)
- local s = str.StringText
- local len = s:len()
- local set = false
- for i = 1, len do
- local c = s:sub(i, i)
- if c ~= " " and c ~= "\t" then
- local pos = i
- if pos == info.CurPos then
- pos = 1
- end
- editor.SetPosition(info.EditorId, info.CurLine, pos)
- SelectBlock(info, sel, pos)
- set = true
- break
- end
- end
- if not set then
- editor.SetPosition(info.EditorId, info.CurLine, 1)
- end
- end
- end;
- }
- Macro {
- area="Editor"; key="End"; flags=""; action = function()
- local info = editor.GetInfo()
- if info then
- local str = editor.GetString(-1, info.CurLine)
- local s = str.StringText
- local len = s:len()
- local set = false
- for i = len, 1, -1 do
- local c = s:sub(i, i)
- if c ~= " " and c ~= "\t" then
- local pos = i + 1
- if pos == info.CurPos then
- pos = string.len(s) + 1
- end
- editor.Select(info.EditorId, 0)
- editor.SetPosition(info.EditorId, info.CurLine, pos)
- set = true
- break
- end
- end
- if not set then
- editor.SetPosition(info.EditorId, info.CurLine, len + 1)
- end
- end
- end;
- }
- Macro {
- area="Editor"; key="ShiftEnd"; flags=""; action = function()
- local info = editor.GetInfo()
- local sel = editor.GetSelection()
- if info then
- local str = editor.GetString(-1, info.CurLine)
- local s = str.StringText
- local len = s:len()
- local set = false
- for i = len, 1, -1 do
- local c = s:sub(i, i)
- if c ~= " " and c ~= "\t" then
- local pos = i + 1
- if pos == info.CurPos then
- pos = string.len(s) + 1
- end
- editor.SetPosition(info.EditorId, info.CurLine, pos)
- SelectBlock(info, sel, pos)
- set = true
- break
- end
- end
- if not set then
- editor.SetPosition(info.EditorId, info.CurLine, len + 1)
- end
- end
- end;
- }
GeSHi © Codebox Plus Extension
upd
да уж, по сравнению с остальными - размер кода просто огромный