If you use only letters of the Latin alphabet, then everything is very simple:

local s = geany.selection()
if (s ~= nil) and (s ~= "") then
  geany.selection(string.upper(s))
end
local s = geany.selection()
if (s ~= nil) and (s ~= "") then
  geany.selection(string.lower(s))
end
local s = geany.selection()
if (s ~= nil) and (s ~= "") then
  local s1= string.upper(string.sub(s, 1, 1))
  local s1 =  string.lower(string.sub(s, 2, -1))
  geany.selection(s1 .. s2)
end
local s = geany.selection()
if (s ~= nil) and (s ~= "") then
  s = string.gsub(string.lower(s), "^(%w)", string.upper)
  s = string.gsub(s, "([^%w]%w)", string.upper)
  geany.selection(s)
end

If you need support for other languages, then everything becomes interesting. UTF-8 support is required, for example.
I use luautf8 in the scripts folder +

local a
if (geany.dirsep == '/') then
  a = '?.so'; -- Unix
else
  a = '?.dll'; -- MS Windows
end

local sf = geany.dirname(geany.script)
local p = sf .. geany.dirsep .. a
if not string.find(package.cpath, p) then
  package.cpath = package.cpath .. ';' .. p
end

local utf8 = require "lua-utf8"

local s = geany.selection()
if ...

and so on...


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <geany/geany/repo-discussions/4086/comments/11426767@github.com>