adapted and changed to the new words file

This commit is contained in:
UndeadMaelys 2022-06-06 07:13:30 +02:00
parent 6c54a672f7
commit 652a1e9cda
8 changed files with 67 additions and 12 deletions

View File

@ -236,6 +236,7 @@ function convertToHeonian(text)
-- output
if autocopy then CopyToClipboard(string.sub(transcribed_text,0,-1)) end
if transcribed_text == nil then transcribed_text = "" end
return transcribed_text
end
end

View File

@ -4,8 +4,9 @@ function addWord()
local file = io.open(data_get, "r")
local pos = 0
-- all this is old code, not useful now, but still in case i need it <:
-- get insertion point
pos = file:seek("end",-9)
pos = file:seek("end")
-- store after
local after = file:read("*all")
@ -32,14 +33,14 @@ function addWord()
local file = io.open(data_output, "w+")
file:write(before)
file:write("\ntable.insert(t,{\"")
file:write("\n")
for i=1, #modify do
if i > 1 then
file:write("\",\"")
file:write(" ")
end
file:write(modify[i])
end
file:write("\"})\n")
file:write("")
file:write(after)
file:close()
end

View File

@ -39,14 +39,17 @@ EFFECT = Enum {
}
function makeTextEffect(Effect, Text)
Text = Text or ""
return "\027["..tostring(Effect-1).."m"..Text.."\027[0;m"
end
function colorText(Color, Text)
Text = Text or ""
return "\027[38;5;"..tostring(Color-1).."m"..Text.."\027[0;m"
end
function colorTextBackground(Color, Text)
Text = Text or ""
return "\027[48;5;"..tostring(Color-1).."m"..Text.."\027[0;m"
end

View File

@ -130,14 +130,14 @@ function editWord(number)
--rewrite with new info
local file = io.open(data_output, "w+")
file:write(before)
file:write("table.insert(t,{\"")
file:write("\n")
for i=1, #modify do
if i > 1 then
file:write("\",\"")
file:write(" ")
end
file:write(modify[i])
end
file:write("\"})")
file:write("")
file:write(after)
file:close()
end

49
get_words.lua Normal file
View File

@ -0,0 +1,49 @@
function getWords(path)
local file = io.open(path,"r")
local text = file:read("*all")
file:close()
local t = {} -- this table will hold our words!!! words format is {word, translation, types, canon origin, meta origin, notes} last three are optional.
local p = 0 -- current position, nil if at end of file
while p do
p = p + 1
local new_word_data = ""
-- this isnt the whole word yet, but all the data around it separated with tabs, so lets get what we want.
-- careful if its uh end of file tho!
local np = string.find(text,"\n",p) -- np is the next word. this is so we can slice it
if np then
new_word_data = string.sub(text, p, np-1)
else
new_word_data = string.sub(text, p)
end
if new_word_data ~= "" then
local new_word = {} -- we'll hold it all here once spliced
local wp = 0 -- word data position!
while wp do -- nil if at end of string so.
wp = wp + 1 -- lets move past the tab we just found
local wnp = string.find(new_word_data, " ",wp)
local stuff = ""
-- we now splice the word every tab and add it to the uhhh
if wnp then
stuff = string.sub(new_word_data, wp, wnp-1) or stuff
else
stuff = string.sub(new_word_data,wp) or stuff
end
table.insert(new_word,stuff)
wp = wnp
end
-- now we add the word ot the word table
table.insert(t, new_word)
end
-- and move on the next
p = np
end
-- now we just. return the table.
return t
end

@ -1 +1 @@
Subproject commit 6a40a51d6ea7cf2bc2261ae783e8e7731b3fa007
Subproject commit 86163910b2236a27a8cfab8817a07f1450dfa770

View File

@ -16,12 +16,13 @@ require "search_list"
require "remove_word"
require "add_word"
require "edit_word"
require "get_words"
require "lessons"
data_get = "heonian-content/words.lua"
data_output = "heonian-content/words.lua"
data_get = "heonian-content/words"
data_output = "heonian-content/words"
words = dofile(data_get)
words = getWords(data_get)
for _, v in pairs(arg) do
if v == "-h"

View File

@ -9,7 +9,7 @@ function adjustTableSizes(tbl)
words_max_length[j+1] = length + 1
end
end
local length = string.len(convertToHeonian(this_word[1]))
local length = string.len(this_word[1])
if length + 1 > words_max_length[1] then
words_max_length[1] = length + 1
end