Skip to content

Commit

Permalink
push
Browse files Browse the repository at this point in the history
  • Loading branch information
bozso committed May 21, 2019
1 parent b6db3f1 commit fd1bc15
Show file tree
Hide file tree
Showing 9 changed files with 341 additions and 69 deletions.
56 changes: 0 additions & 56 deletions .textadept/init.lua
Original file line number Diff line number Diff line change
@@ -1,56 +0,0 @@
textadept.editing.auto_indent = true
buffer.tab_width = 4
buffer.use_tabs = false
buffer.edge_column = 79
buffer.edge_mode= buffer.EDGE_LINE


-- local _L = require('locale')

-- local m_edit = textadept.menu.menubar[_L['_Edit']]
-- local m_sel = m_edit[_L['_Select']]



function xml()
local left, right = "<", ">"
buffer:begin_undo_action()
for i = 0, buffer.selections - 1 do
local s, e = buffer.selection_n_start[i], buffer.selection_n_end[i]
if s == e then
buffer:set_target_range(buffer:word_start_position(s, true),
buffer:word_end_position(e, true))
else
buffer:set_target_range(s, e)
end
buffer:replace_target(left..buffer.target_text..right..left.."/"..buffer.target_text..right)
buffer.selection_n_start[i] = buffer.target_end
buffer.selection_n_end[i] = buffer.target_end
end
buffer:end_undo_action()
end


keys["ct"] = xml

keys["ca"] = buffer.home
keys["ce"] = buffer.line_end
keys["am"] = textadept.run.compile
keys["cm"] = textadept.editing.block_comment
keys["ck"] = buffer.del_line_left

textadept.run.compile_commands["latex"] = "latexrun %p"
textadept.run.build_commands["latex"] = "latexrun %p"

textadept.run.compile_commands["cpp"] = "ninja"
textadept.run.compile_commands["ansi_c"] = "ninja"
textadept.run.compile_commands["fortran"] = "ninja"

local cmd = "python /home/istvan/progs/utils/utils.py markdown --infile %p"

-- textadept.run.compile_commands["markdown"] = cmd
textadept.run.run_commands["markdown"] = cmd
-- textadept.run.build_commands["cpp"] = "ninja"


buffer:set_theme('light', {font = 'Monospace', fontsize = 14})
24 changes: 24 additions & 0 deletions configs/.xbindkeysrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"python /home/istvan/progs/utils/utils.py programs"
Control + space

"python /home/istvan/progs/utils/utils.py modules"
Mod4 + m

"xbindkeys --poll-rc"
Mod4 + r

"libreoffice"
Mod4 + l

"chromium-browser"
Mod4 + w

"gnome-calculator"
Mod4 + c

"x-terminal-emulator"
Mod4 + t

# Increase backlight
"xbacklight -inc 10"
XF86MonBrightnessUp
File renamed without changes.
260 changes: 260 additions & 0 deletions configs/textadept/PreProcessor.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,260 @@
--[[
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to <http://unlicense.org/>
]]

local PreProcessor = {}

local Error = error
local FileSystem_Read
local LoadString = loadstring
local Table_Concatenate = table.concat
local String_Byte = string.byte
local String_Find = string.find
local String_Format = string.format
local String_GMatch = string.gmatch
local String_Substring = string.sub
local Type = type
local Global = _G
local Pairs = pairs
local SetFunctionEnvironment = setfenv
local ToString = ToString

local CurrentEnvironment = Global

local function ToByteString(Str)
local NewStr = ""

for I = 1, #Str do
NewStr = NewStr .. "\\" .. String_Byte(String_Substring(Str, I, I))
end

return NewStr
end

local function include(Path)
local Data, Err = FileSystem_Read(Path)

if Data then
local Blocks = {}

do
local I = 1
local MaxI = #Data

while I <= MaxI do
local Char = String_Substring(Data, I, I)

if Char == "\"" or Char == "'" then
local BlockEnd = String_Find(Data, Char, I + 1, true)

while BlockEnd and String_Substring(Data, BlockEnd - 1, BlockEnd - 1) == "\\" do
local Count = 0
for J = BlockEnd - 1, I + 1, -1 do
if String_Substring(Data, J, J) == "\\" then
Count = Count + 1
else
break
end
end

if Count % 2 == 1 then
BlockEnd = String_Find(Data, Char, BlockEnd + 1, true)
else
BlockEnd = nil
break
end
end

if BlockEnd then
Blocks[#Blocks + 1] = {1, I, BlockEnd}
I = BlockEnd
else
Blocks[#Blocks + 1] = {1, I, #Data}
I = #Data
end
elseif Char == "-" and String_Substring(Data, I + 1, I + 1) == "-" then
if String_Substring(Data, I + 2, I + 2) == "[" then
local Next = I + 3

local Equals = ""
local Found = false
while not Found do
local Char2 = String_Substring(Data, Next, Next)

if not Char2 then
Blocks[#Blocks + 1] = {1, I, #Data}
I = #Data
elseif Char2 == "=" then
Equals = Equals .. "="
elseif Char2 == "[" then
break
else
Blocks[#Blocks + 1] = {1, I, #Data}
I = #Data
end

Next = Next + 1
end

local _, BlockEnd = String_Find(Data, "]" .. Equals .. "]", Next, true)

if not BlockEnd then
Blocks[#Blocks + 1] = {1, I, #Data}
I = #Data
else
Blocks[#Blocks + 1] = {1, I, BlockEnd}
I = BlockEnd
end
else
local BlockEnd = String_Find(Data, "\n", I + 2, true)

if BlockEnd then
Blocks[#Blocks + 1] = {1, I, BlockEnd}
I = BlockEnd
else
Blocks[#Blocks + 1] = {1, I, #Data}
I = #Data
end
end
end

I = I + 1
end
end

local LocalDefined = false
local Chunk = {"local Output = \"\" "}

local LineStart = 1
local LineEnd = String_Find(Data, "\n", nil, true)

if not LineEnd then
LineEnd = #Data + 1
end

while LineEnd do
local Line = String_Substring(Data, LineStart, LineEnd - 1)

local CodeBegin, CodeEnd = String_Find(Line, "%@")

if CodeBegin then
local TempCodeBegin = LineStart + CodeBegin

for I = 1, #Blocks do
if TempCodeBegin >= Blocks[I][2] and TempCodeBegin <= Blocks[I][3] then
CodeBegin = nil
break
end
end
end

if CodeBegin then
Chunk[#Chunk + 1] = String_Substring(Line, CodeEnd + 1) .. "\n"
else
local LastCodeEnd = 0
local CodeBegin, CodeEnd = String_Find(Line, "%$(%b())()")

while CodeBegin do
local TempCodeBegin = LineStart + CodeBegin

for I = 1, #Blocks do
if TempCodeBegin >= Blocks[I][2] and TempCodeBegin <= Blocks[I][3] then
CodeBegin = nil
break
end
end

if CodeBegin then
local NewCodeBegin = String_Find(String_Substring(Line, CodeBegin + 1, CodeEnd), "$", nil, true)

if NewCodeBegin then
CodeBegin = CodeBegin + NewCodeBegin
end

local BeforeString = String_Substring(Line, LastCodeEnd + 1, CodeBegin - 1)
local AfterString = String_Substring(Line, CodeBegin + 1, CodeEnd)

if BeforeString ~= "" then
Chunk[#Chunk + 1] = String_Format("Output = Output .. \"%s\"", ToByteString(BeforeString))
end

Chunk[#Chunk + 1] = String_Format(" Output = Output .. %s ", AfterString)

LastCodeEnd = CodeEnd
end

CodeBegin, CodeEnd = String_Find(Line, "(.-)%$(%b())()", CodeEnd + 1)
end

if LastCodeEnd < #Line then
Chunk[#Chunk + 1] = String_Format("Output = Output .. \"%s\"", ToByteString(String_Substring(Line, LastCodeEnd + 1)))
end

Chunk[#Chunk + 1] = " Output = Output .. \"\\n\"\n"
end

if LineEnd == #Data + 1 then
break
end

LineStart = LineEnd + 1
LineEnd = String_Find(Data, "\n", LineEnd + 1, true)

if not LineEnd then
LineEnd = #Data + 1
end
end

Chunk[#Chunk + 1] = "return Output\n"

local ConcatenatedChunk = Table_Concatenate(Chunk)
local Func, Err = LoadString(ConcatenatedChunk, Path)

if Func then
SetFunctionEnvironment(Func, CurrentEnvironment)
return Func()
else
Error("Could not load include (" .. Path .. "). Error: " .. Err)
end
else
Error("Could not include (" .. Path .. ") Error: " .. ToString(Err))
end
end

function PreProcessor.ReplaceFileSystemReadFunction(ReadFunction)
FileSystem_Read = ReadFunction
end

function PreProcessor.PrepareEnvironment(Tab)
Tab.include = include
end

function PreProcessor.GenerateCode(Path, Environment)
CurrentEnvironment = Environment or Global
return include(Path)
end

return PreProcessor
File renamed without changes.
Loading

0 comments on commit fd1bc15

Please sign in to comment.