sc-im config for spreadsheets

This commit is contained in:
Daniel Flanagan 2019-02-27 23:29:49 -06:00
parent 06c3be9318
commit 2830ab6f11
6 changed files with 114 additions and 0 deletions

90
apps/scim/lua/dice.lua Normal file
View file

@ -0,0 +1,90 @@
local os = require "os"
local math = require "math"
math.randomseed(os.clock())
function table.tostring(self, indent, done)
local result = ""
done = done or {}
indent = indent or 0
if type(self) == "table" then
for key, value in pairs(self) do
result = result .. string.rep(" ", indent)
if type(value) == "table" and not done[value] then
done[value] = true
result = result ..
string.format(
"[%s] => table\n",
tostring(key)
) ..
"{\n" ..
table.tostring(value, indent + 2, done) ..
"}\n"
else
result = result ..
string.format("[%s] => %s\n",
tostring(key),
tostring(value)
)
end
end
else
result = result .. self .. "\n"
end
return result
end
function log(s)
s = "[timestamp: " .. tostring(os.time()) .. "]\n" .. s
local out = s:gsub("\n", "\n ")
print(out)
local file = io.open("/tmp/sc-im-dice.log", "a+")
file:write("\n")
file:write(out)
io.close(file)
end
local dstr_matcher = "(%d*)d(%d+)"
function dstr(n, s, fl)
n = tonumber(n) or 1
local sum = 0
for di = 1, n do
sum = sum + math.random(1, tonumber(s))
end
return sum
end
function rolls(s)
local pieces = {}
for nd, ds in s:gmatch(dstr_matcher) do
local sum = dstr(tonumber(nd), tonumber(ds))
pieces[#pieces+1] = {
tostring(nd) .. "d" .. tostring(ds),
tostring(sum)
}
end
return pieces
end
function replacerolls(s, rolls)
local result = s
for k, n in ipairs(rolls) do
result = result:gsub(n[1], n[2], 1)
end
return result
end
function evalreturn(s)
local f = loadstring("return " .. s)
return f()
end
function parserollstr(s)
return evalreturn(replacerolls(s, rolls(s)))
end
function sc_rollres(c, r)
local sum = parserollstr(sc.lgetstr(c, r))
sc.lsetnum(c + 1, r, sum)
end

0
apps/scim/lua/h.lua Normal file
View file

13
apps/scim/rc Normal file
View file

@ -0,0 +1,13 @@
set autocalc
set numeric
set numeric_decimal=0
set overlap
set xlsx_readformulas
color "type=HEADINGS fg=WHITE bg=BLACK bold=0 dim=0 standout=0 reverse=0"
color "type=CELL_SELECTION_SC fg=WHITE bg=BLACK bold=1 dim=0 standout=1"
color "type=CELL_SELECTION fg=WHITE bg=BLACK bold=1 dim=0 standout=1"
color "type=STRG fg=WHITE bg=BLACK bold=0 dim=1"
color "type=NUMB fg=YELLOW bg=BLACK bold=0 dim=1"
nmap "J" "<C-j>"

5
scripts/bin/scn Executable file
View file

@ -0,0 +1,5 @@
#!/usr/bin/env bash
SUBDIR="${2:-}"
mkdir -p "$NOTES_PATH/$SUBDIR"
sc-im "$NOTES_PATH/$SUBDIR/$(date +%Y-%m-%d)_$1.sc"

4
setup
View file

@ -44,6 +44,10 @@ links=(
"$dfp/apps/qutebrowser/qutebrowser.conf" "$XDG_CONFIG_HOME/qutebrowser/qutebrowser.conf" "$dfp/apps/qutebrowser/qutebrowser.conf" "$XDG_CONFIG_HOME/qutebrowser/qutebrowser.conf"
"$dfp/apps/qutebrowser/keys.conf" "$XDG_CONFIG_HOME/qutebrowser/keys.conf" "$dfp/apps/qutebrowser/keys.conf" "$XDG_CONFIG_HOME/qutebrowser/keys.conf"
# sc-im config files and scripts
"$dfp/apps/scim/rc" "$HOME/.scimrc"
"$dfp/apps/scim/lua" "$HOME/.scim/lua"
# document viewer # document viewer
"$dfp/apps/zathura/" "$XDG_CONFIG_HOME/zathura" "$dfp/apps/zathura/" "$XDG_CONFIG_HOME/zathura"

View file

@ -84,6 +84,8 @@ alias resrc="source \$HOME/.bashrc"
alias redshift="redshift -r -l 39.0997:-94.5786 -t 6500K:2500K" alias redshift="redshift -r -l 39.0997:-94.5786 -t 6500K:2500K"
alias gpmdpe="electron --app=/usr/share/gpmdp/resources/app.asar" alias gpmdpe="electron --app=/usr/share/gpmdp/resources/app.asar"
alias t="task" alias t="task"
alias sc="sc-im"
alias scs="sc-im \"\$NOTES_PATH/_scratch.sc\""
# games aliases # games aliases
# this sometimes fixes steam dynamic library issues? # this sometimes fixes steam dynamic library issues?