If you use only letters of the Latin alphabet, then everything is very simple:
```lua
local s = geany.selection()
if (s ~= nil) and (s ~= "") then
  geany.selection(string.upper(s))
end
```
```lua
local s = geany.selection()
if (s ~= nil) and (s ~= "") then
  geany.selection(string.lower(s))
end
```
```lua
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
```
```lua
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](http://lua-users.org/wiki/LuaUnicode).
I use [luautf8](https://github.com/starwing/luautf8) in the scripts folder +
```lua
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 or view it on GitHub:
https://github.com/geany/geany/discussions/4086#discussioncomment-11426767
You are receiving this because you are subscribed to this thread.

Message ID: <geany/geany/repo-discussions/4086/comments/[email protected]>

Reply via email to