File: proper-case.lua

package info (click to toggle)
geany-plugins 2.0-6
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 19,940 kB
  • sloc: ansic: 94,986; sh: 4,482; makefile: 1,429
file content (25 lines) | stat: -rw-r--r-- 408 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
--[[
  Convert the document text or selection to "Proper Case"
  e.g. "john doe" becomes "John Doe"
--]]


function proper_case(s)
  local s=string.gsub(string.lower(s),"^(%w)", string.upper)
  return string.gsub(s,"([^%w]%w)", string.upper)
end



local s=geany.selection()

if (s)
then
  if ( s ~= "" )
  then
    geany.selection(proper_case(s))
  else
    geany.text(proper_case(geany.text()))
  end
end