Skip to content

help for plugin using a translation table #126

@evanescente-ondine

Description

@evanescente-ondine

Description

Hi,
I am asking here because you've been so helpful before, and even if I knew Lua it wouldn't help much as you told me, because of the APIs.
So in short, I wrote a generator of sort in an unrelated language, that substitute places in a pattern to produce a sequence:

"NRNV_5"	"1[1](R)2[3](V) [1](R)22[3](V) [1](R)23[3](R) 1[1](R)2[3](V) [1](R)22[3](V) [1](R)23[3](V) [1](R)2[3](V) 1[1](R)223[3](V) 1[1](R)223[3](V) [1](R)23"

... But I'm fû©îed in the rare cases numbers are present in the data, as I noticed. So I reckon, the simplest would be to convert these places into look-alike unicode symbols, and input them directly when I need to edit the patterns. I would help a lot to convert all the numbers in the current line into those symbols too. I asked IA to piss some code, but it's so obscure to me I can't troubleshoot shîþ. Fortunately it's short:

local mode_enabled = false
function onRune(rune)
  if mode_enabled and math_digits[rune] then
    local newRune = math_digits[rune]
    buffer:RemoveRune()
    buffer:InsertRune(newRune)
    return true
  end
  return false
end
function toggleMode()
  mode_enabled = not mode_enabled
  statusline:Redraw()
end
function replaceCurrentLineDigits()
    local line, col = buffer:getCursorLine(), buffer:getCursorCol()
    local text = buffer:getLine(line):gsub("1", "𝟣"):gsub("2", "𝟤"):gsub("3", "𝟥"):gsub("4", "𝟦"):gsub("5", "𝟧"):gsub("6", "𝟨")
    buffer:startUndoGroup()
    buffer:removeLine(line)
    buffer:insertLine(line, text)
    buffer:endUndoGroup()    
    buffer:gotoLineCol(line, math.min(col, #text))
end

I hope it's not too much to ask 😢😢
In exchange I'll use nightly version and do bug report

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions