File: select-block.lua

package info (click to toggle)
geany-plugins 1.24%2Bdfsg-5
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 17,532 kB
  • ctags: 10,926
  • sloc: ansic: 89,639; sh: 11,434; python: 1,365; makefile: 1,302
file content (32 lines) | stat: -rw-r--r-- 457 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
--[[
  Select the innermost "block" of text from the current caret position.
  Block boundaries are a pair of: () [] {} <>
--]]


local pos=geany.caret()
local start=pos
local match

while (pos>=0)
do
  match=geany.match(pos)
  if (match>=start) then break end
  pos=pos-1
end

if (match >= 0 ) 
then
  if (match>pos)
  then
    geany.select(pos,match+1)
  else
    geany.select(pos+1,match)
  end
else
  geany.message("Can't find matching brace!")
end