~ubuntu-branches/debian/squeeze/geany-plugins/squeeze

« back to all changes in this revision

Viewing changes to geanylua/examples/edit/proper-case.lua

  • Committer: Bazaar Package Importer
  • Author(s): Chow Loong Jin
  • Date: 2009-07-10 22:56:41 UTC
  • Revision ID: james.westby@ubuntu.com-20090710225641-xc1126t7pq0jmpos
Tags: upstream-0.17.1
ImportĀ upstreamĀ versionĀ 0.17.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
--[[
 
2
  Convert the document text or selection to "Proper Case"
 
3
  e.g. "john doe" becomes "John Doe"
 
4
--]]
 
5
 
 
6
 
 
7
function proper_case(s)
 
8
  local s=string.gsub(string.lower(s),"^(%w)", string.upper)
 
9
  return string.gsub(s,"([^%w]%w)", string.upper)
 
10
end
 
11
 
 
12
 
 
13
 
 
14
local s=geany.selection()
 
15
 
 
16
if (s)
 
17
then
 
18
  if ( s ~= "" )
 
19
  then
 
20
    geany.selection(proper_case(s))
 
21
  else
 
22
    geany.text(proper_case(geany.text()))
 
23
  end
 
24
end
 
25