Skip to content

Commit

Permalink
red: Codepoint
Browse files Browse the repository at this point in the history
  • Loading branch information
hugeping committed Sep 13, 2023
1 parent 81deebe commit 70a29bb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions data/apps/red.lua
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,7 @@ gsub /lua-regexp/b/ - chnage a to b global
fmt [width] - fmt text by width
Run prog - run prog in rein
Getline - get current line in buffer
Codepoint - get codepoint of the sym
]])
w.buf.cur = 1
w:toline(1, false)
Expand Down
10 changes: 10 additions & 0 deletions data/lib/red/proc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,16 @@ proc['<'] = function(w, prog)
pipe(w:output(), prog)
end

function proc.Codepoint(w)
local data = w:winmenu()
if not data then return end
local sym = data.buf.text[data:cur()]
local cp = utf.codepoint(sym)
local cur = w:cur()
w.buf:input(" "..string.format("%x", cp))
w:cur(cur)
end

function proc.Getline(w)
if not w.frame.frame then -- main menu
return
Expand Down

0 comments on commit 70a29bb

Please sign in to comment.