Skip to content

Instantly share code, notes, and snippets.

@pkulchenko
pkulchenko / shebang.lua
Created June 24, 2015 02:31
Shebang plugin for ZeroBrane Studio
-- Copyright 2015 Paul Kulchenko, ZeroBrane LLC; All rights reserved
return {
name = "File type based on Shebang",
description = "Sets file type based on executable in shebang.",
author = "Paul Kulchenko",
version = 0.1,
dependencies = 1.0,
onEditorLoad = function(self, editor)
@pkulchenko
pkulchenko / memory-report.diff
Created August 6, 2015 16:26
ZeroBrane Studio patch to report memory usage in the status bar
diff --git a/src/editor/commands.lua b/src/editor/commands.lua
index f02d161..daf37da 100644
--- a/src/editor/commands.lua
+++ b/src/editor/commands.lua
@@ -1033,5 +1033,7 @@ frame:Connect(wx.wxEVT_IDLE,
if #ide.onidle > 0 then table.remove(ide.onidle)() end
if #ide.onidle > 0 then event:RequestMore(true) end -- request more if anything left
+ ide:SetStatus(math.floor(collectgarbage("count")).."Kb")
+
@pkulchenko
pkulchenko / wxlua-aui-dynamic-branch.diff
Created August 21, 2015 06:54
wxlua diff with AUI dynamic branch changes
Index: wxLua/bindings/wxwidgets/wx_datatypes.lua
===================================================================
--- wxLua/bindings/wxwidgets/wx_datatypes.lua (revision 245)
+++ wxLua/bindings/wxwidgets/wx_datatypes.lua (working copy)
@@ -438,13 +438,13 @@
ValueType = "enum",
},
wxAuiNotebookPage = {
- Condition = "wxLUA_USE_wxAUI && wxCHECK_VERSION(2,8,0) && wxUSE_AUI",
+ Condition = "(wxLUA_USE_wxAUI && wxCHECK_VERSION(2,8,0) && wxUSE_AUI) && (!wxCHECK_VERSION(3,1,0))",
@pkulchenko
pkulchenko / plaindump.lua
Created September 9, 2015 04:02
Simple Lua serializer
local function plaindump(val, opts, done)
local keyignore = opts and opts.keyignore or {}
local final = done == nil
opts, done = opts or {}, done or {}
local t = type(val)
if t == "table" then
done[#done+1] = '{'
done[#done+1] = ''
for key, value in pairs (val) do
if not keyignore[key] then
@pkulchenko
pkulchenko / win32_starter.c
Created November 19, 2015 05:32
Simplified starter for ZeroBrane Studio
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <windows.h>
int main (int argc, char *argv[])
{
char buffer[MAX_PATH],*file;
if (!GetFullPathName(argv[0],MAX_PATH,buffer,&file)) {
@pkulchenko
pkulchenko / util.diff
Created April 10, 2016 05:32
Relative path fix
diff --git a/src/util.lua b/src/util.lua
index ad4cbe3..573482f 100644
--- a/src/util.lua
+++ b/src/util.lua
@@ -267,25 +267,22 @@ function FileSysGetRecursive(path, recursive, spec, opts)
end
local normalflags = wx.wxPATH_NORM_ABSOLUTE + wx.wxPATH_NORM_DOTS + wx.wxPATH_NORM_TILDE
-function GetFullPathIfExists(p, f)
+function MergeFullPath(p, f)
@pkulchenko
pkulchenko / icon-assert-linux.diff
Last active April 20, 2016 00:47
Icon assert fix on Linux
diff --git a/src/editor/package.lua b/src/editor/package.lua
index a1149e0..aba9db2 100644
--- a/src/editor/package.lua
+++ b/src/editor/package.lua
@@ -175,7 +175,8 @@ function ide:MakeMenu(t)
menu:Append(id, label, submenu, help or "")
else
local item = wx.wxMenuItem(menu, id, label, help or "", kind or wx.wxITEM_NORMAL)
- if menuicon and type(iconmap[id]) == "table" then
+ if menuicon and type(iconmap[id]) == "table"
@pkulchenko
pkulchenko / luapp.lua
Last active April 21, 2016 17:18
PP interpreter
dofile 'interpreters/luabase.lua'
local intr = MakeLuaInterpreter()
intr.name = "Lua PP"
intr.frun = function(self,wfilename,rundebug)
local exe = self:fexepath("")
local filepath = wfilename:GetFullPath()
do
-- if running on Windows and can't open the file, this may mean that
-- the file path includes unicode characters that need special handling
@pkulchenko
pkulchenko / linemap.lua
Created May 2, 2016 04:26
Example of linemap function
local init = [=[
(loadstring or load)([[
if pcall(require, "mobdebug") then
local mdb = require "mobdebug"
mdb.linemap = function(line, src) return codemap[src][line] end
end
]])()
]=]
@pkulchenko
pkulchenko / user.lua
Created May 3, 2016 01:10
Debugger initialization to limit the depth of tables in the stack window
debugger.init = [[
local mdb = require('mobdebug')
local dump = mdb.dump
mdb.dump = function(v, opts)
opts = opts or {sortkeys = true, comment = true}
opts.maxlevel = 6
return dump(v, opts)
end
]]