aboutsummaryrefslogtreecommitdiff
path: root/data/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'data/plugins')
-rw-r--r--data/plugins/autoreload.lua26
-rw-r--r--data/plugins/contextmenu.lua16
-rw-r--r--data/plugins/detectindent.lua34
-rw-r--r--data/plugins/drawwhitespace.lua16
-rw-r--r--data/plugins/language_c.lua1
-rw-r--r--data/plugins/language_cpp.lua1
-rw-r--r--data/plugins/language_css.lua1
-rw-r--r--data/plugins/language_html.lua1
-rw-r--r--data/plugins/language_js.lua5
-rw-r--r--data/plugins/language_lua.lua1
-rw-r--r--data/plugins/language_md.lua17
-rw-r--r--data/plugins/language_python.lua21
-rw-r--r--data/plugins/language_xml.lua1
-rw-r--r--data/plugins/lineguide.lua21
-rw-r--r--data/plugins/projectsearch.lua3
-rw-r--r--data/plugins/scale.lua17
-rw-r--r--data/plugins/treeview.lua84
17 files changed, 129 insertions, 137 deletions
diff --git a/data/plugins/autoreload.lua b/data/plugins/autoreload.lua
index e772666f..9978092e 100644
--- a/data/plugins/autoreload.lua
+++ b/data/plugins/autoreload.lua
@@ -3,7 +3,6 @@ local core = require "core"
local config = require "core.config"
local Doc = require "core.doc"
-
local times = setmetatable({}, { __mode = "k" })
local function update_time(doc)
@@ -11,7 +10,6 @@ local function update_time(doc)
times[doc] = info.modified
end
-
local function reload_doc(doc)
local fp = io.open(doc.filename, "r")
local text = fp:read("*a")
@@ -27,23 +25,19 @@ local function reload_doc(doc)
core.log_quiet("Auto-reloaded doc \"%s\"", doc.filename)
end
+local on_modify = core.on_dirmonitor_modify
-core.add_thread(function()
- while true do
- -- check all doc modified times
- for _, doc in ipairs(core.docs) do
- local info = system.get_file_info(doc.filename or "")
- if info and times[doc] ~= info.modified then
- reload_doc(doc)
- end
- coroutine.yield()
+core.on_dirmonitor_modify = function(dir, filepath)
+ local abs_filename = dir.name .. PATHSEP .. filepath
+ for _, doc in ipairs(core.docs) do
+ local info = system.get_file_info(doc.filename or "")
+ if doc.abs_filename == abs_filename and info and times[doc] ~= info.modified then
+ reload_doc(doc)
+ break
end
-
- -- wait for next scan
- coroutine.yield(config.project_scan_rate)
end
-end)
-
+ on_modify(dir, filepath)
+end
-- patch `Doc.save|load` to store modified time
local load = Doc.load
diff --git a/data/plugins/contextmenu.lua b/data/plugins/contextmenu.lua
index dc95567f..4b34dfd5 100644
--- a/data/plugins/contextmenu.lua
+++ b/data/plugins/contextmenu.lua
@@ -62,15 +62,15 @@ menu:register("core.logview", {
if require("plugins.scale") then
menu:register("core.docview", {
- { text = "Font +", command = "scale:increase" },
- { text = "Font -", command = "scale:decrease" },
- { text = "Font Reset", command = "scale:reset" },
+ { text = "Cut", command = "doc:cut" },
+ { text = "Copy", command = "doc:copy" },
+ { text = "Paste", command = "doc:paste" },
+ { text = "Font +", command = "scale:increase" },
+ { text = "Font -", command = "scale:decrease" },
+ { text = "Font Reset", command = "scale:reset" },
ContextMenu.DIVIDER,
- { text = "Find", command = "find-replace:find" },
- { text = "Replace", command = "find-replace:replace" },
- ContextMenu.DIVIDER,
- { text = "Find Pattern", command = "find-replace:find-pattern" },
- { text = "Replace Pattern", command = "find-replace:replace-pattern" },
+ { text = "Find", command = "find-replace:find" },
+ { text = "Replace", command = "find-replace:replace" }
})
end
diff --git a/data/plugins/detectindent.lua b/data/plugins/detectindent.lua
index 20541c82..9ac29882 100644
--- a/data/plugins/detectindent.lua
+++ b/data/plugins/detectindent.lua
@@ -121,40 +121,17 @@ end
local clean = Doc.clean
function Doc:clean(...)
clean(self, ...)
- if not cache[self].confirmed then
+ local _, _, confirmed = self:get_indent_info()
+ if not confirmed then
update_cache(self)
end
end
-local function with_indent_override(doc, fn, ...)
- local c = cache[doc]
- if not c then
- return fn(...)
- end
- local type, size = config.tab_type, config.indent_size
- config.tab_type, config.indent_size = c.type, c.size or config.indent_size
- local r1, r2, r3 = fn(...)
- config.tab_type, config.indent_size = type, size
- return r1, r2, r3
-end
-
-
-local perform = command.perform
-function command.perform(...)
- return with_indent_override(core.active_view.doc, perform, ...)
-end
-
-
-local draw = DocView.draw
-function DocView:draw(...)
- return with_indent_override(self.doc, draw, self, ...)
-end
-
-
local function set_indent_type(doc, type)
+ local _, indent_size = doc:get_indent_info()
cache[doc] = {type = type,
- size = cache[doc].value or config.indent_size,
+ size = indent_size,
confirmed = true}
doc.indent_info = cache[doc]
end
@@ -180,7 +157,8 @@ end
local function set_indent_size(doc, size)
- cache[doc] = {type = cache[doc].type or config.tab_type,
+ local indent_type = doc:get_indent_info()
+ cache[doc] = {type = indent_type,
size = size,
confirmed = true}
doc.indent_info = cache[doc]
diff --git a/data/plugins/drawwhitespace.lua b/data/plugins/drawwhitespace.lua
index da9d1b12..0004c7ea 100644
--- a/data/plugins/drawwhitespace.lua
+++ b/data/plugins/drawwhitespace.lua
@@ -7,26 +7,30 @@ local common = require "core.common"
local draw_line_text = DocView.draw_line_text
function DocView:draw_line_text(idx, x, y)
- local font = (self:get_font() or style.syntax_fonts["comment"])
- local color = style.syntax.comment
- local ty, tx = y + self:get_line_text_y_offset()
+ local font = (self:get_font() or style.syntax_fonts["whitespace"] or style.syntax_fonts["comment"])
+ local color = style.syntax.whitespace or style.syntax.comment
+ local ty = y + self:get_line_text_y_offset()
+ local tx
local text, offset, s, e = self.doc.lines[idx], 1
+ local x1, _, x2, _ = self:get_content_bounds()
+ local _offset = self:get_x_offset_col(idx, x1)
+ offset = _offset
while true do
s, e = text:find(" +", offset)
if not s then break end
tx = self:get_col_x_offset(idx, s) + x
renderer.draw_text(font, string.rep("·", e - s + 1), tx, ty, color)
+ if tx > x + x2 then break end
offset = e + 1
end
- offset = 1
+ offset = _offset
while true do
s, e = text:find("\t", offset)
if not s then break end
tx = self:get_col_x_offset(idx, s) + x
renderer.draw_text(font, "»", tx, ty, color)
+ if tx > x + x2 then break end
offset = e + 1
end
draw_line_text(self, idx, x, y)
end
-
-
diff --git a/data/plugins/language_c.lua b/data/plugins/language_c.lua
index 44c3b895..b0a4dec5 100644
--- a/data/plugins/language_c.lua
+++ b/data/plugins/language_c.lua
@@ -2,6 +2,7 @@
local syntax = require "core.syntax"
syntax.add {
+ name = "C",
files = { "%.c$", "%.h$", "%.inl$" },
comment = "//",
patterns = {
diff --git a/data/plugins/language_cpp.lua b/data/plugins/language_cpp.lua
index 499a09db..8d6aef4b 100644
--- a/data/plugins/language_cpp.lua
+++ b/data/plugins/language_cpp.lua
@@ -4,6 +4,7 @@ pcall(require, "plugins.language_c")
local syntax = require "core.syntax"
syntax.add {
+ name = "C++",
files = {
"%.h$", "%.inl$", "%.cpp$", "%.cc$", "%.C$", "%.cxx$",
"%.c++$", "%.hh$", "%.H$", "%.hxx$", "%.hpp$", "%.h++$"
diff --git a/data/plugins/language_css.lua b/data/plugins/language_css.lua
index 222e2f94..395e375c 100644
--- a/data/plugins/language_css.lua
+++ b/data/plugins/language_css.lua
@@ -2,6 +2,7 @@
local syntax = require "core.syntax"
syntax.add {
+ name = "CSS",
files = { "%.css$" },
patterns = {
{ pattern = "\\.", type = "normal" },
diff --git a/data/plugins/language_html.lua b/data/plugins/language_html.lua
index cebb3f1a..1f4515bc 100644
--- a/data/plugins/language_html.lua
+++ b/data/plugins/language_html.lua
@@ -2,6 +2,7 @@
local syntax = require "core.syntax"
syntax.add {
+ name = "HTML",
files = { "%.html?$" },
patterns = {
{
diff --git a/data/plugins/language_js.lua b/data/plugins/language_js.lua
index 7556b00b..d9515d52 100644
--- a/data/plugins/language_js.lua
+++ b/data/plugins/language_js.lua
@@ -2,6 +2,7 @@
local syntax = require "core.syntax"
syntax.add {
+ name = "JavaScript",
files = { "%.js$", "%.json$", "%.cson$" },
comment = "//",
patterns = {
@@ -11,8 +12,8 @@ syntax.add {
{ pattern = { '"', '"', '\\' }, type = "string" },
{ pattern = { "'", "'", '\\' }, type = "string" },
{ pattern = { "`", "`", '\\' }, type = "string" },
- { pattern = "0x[%da-fA-F]+", type = "number" },
- { pattern = "-?%d+[%d%.eE]*", type = "number" },
+ { pattern = "0x[%da-fA-F_]+n?", type = "number" },
+ { pattern = "-?%d+[%d%.eE_n]*", type = "number" },
{ pattern = "-?%.?%d+", type = "number" },
{ pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" },
{ pattern = "[%a_][%w_]*%f[(]", type = "function" },
diff --git a/data/plugins/language_lua.lua b/data/plugins/language_lua.lua
index 165633b6..5c770d43 100644
--- a/data/plugins/language_lua.lua
+++ b/data/plugins/language_lua.lua
@@ -2,6 +2,7 @@
local syntax = require "core.syntax"
syntax.add {
+ name = "Lua",
files = "%.lua$",
headers = "^#!.*[ /]lua",
comment = "--",
diff --git a/data/plugins/language_md.lua b/data/plugins/language_md.lua
index 3c1c329a..e7c870ec 100644
--- a/data/plugins/language_md.lua
+++ b/data/plugins/language_md.lua
@@ -4,11 +4,11 @@ local syntax = require "core.syntax"
syntax.add {
+ name = "Markdown",
files = { "%.md$", "%.markdown$" },
patterns = {
{ pattern = "\\.", type = "normal" },
{ pattern = { "<!%-%-", "%-%->" }, type = "comment" },
- { pattern = { "```c", "```" }, type = "string", syntax = ".c" },
{ pattern = { "```c++", "```" }, type = "string", syntax = ".cpp" },
{ pattern = { "```python", "```" }, type = "string", syntax = ".py" },
{ pattern = { "```ruby", "```" }, type = "string", syntax = ".rb" },
@@ -25,6 +25,21 @@ syntax.add {
{ pattern = { "```cmake", "```" }, type = "string", syntax = ".cmake" },
{ pattern = { "```d", "```" }, type = "string", syntax = ".d" },
{ pattern = { "```glsl", "```" }, type = "string", syntax = ".glsl" },
+ { pattern = { "```c", "```" }, type = "string", syntax = ".c" },
+ { pattern = { "```julia", "```" }, type = "string", syntax = ".jl" },
+ { pattern = { "```rust", "```" }, type = "string", syntax = ".rs" },
+ { pattern = { "```dart", "```" }, type = "string", syntax = ".dart" },
+ { pattern = { "```v", "```" }, type = "string", syntax = ".v" },
+ { pattern = { "```toml", "```" }, type = "string", syntax = ".toml" },
+ { pattern = { "```yaml", "```" }, type = "string", syntax = ".yaml" },
+ { pattern = { "```php", "```" }, type = "string", syntax = ".php" },
+ { pattern = { "```nim", "```" }, type = "string", syntax = ".nim" },
+ { pattern = { "```typescript", "```" }, type = "string", syntax = ".ts" },
+ { pattern = { "```rescript", "```" }, type = "string", syntax = ".res" },
+ { pattern = { "```moon", "```" }, type = "string", syntax = ".moon" },
+ { pattern = { "```go", "```" }, type = "string", syntax = ".go" },
+ { pattern = { "```lobster", "```" }, type = "string", syntax = ".lobster" },
+ { pattern = { "```liquid", "```" }, type = "string", syntax = ".liquid" },
{ pattern = { "```", "```" }, type = "string" },
{ pattern = { "``", "``", "\\" }, type = "string" },
{ pattern = { "`", "`", "\\" }, type = "string" },
diff --git a/data/plugins/language_python.lua b/data/plugins/language_python.lua
index 252a0d14..8bc6fbd4 100644
--- a/data/plugins/language_python.lua
+++ b/data/plugins/language_python.lua
@@ -2,20 +2,21 @@
local syntax = require "core.syntax"
syntax.add {
+ name = "Python",
files = { "%.py$", "%.pyw$", "%.rpy$" },
headers = "^#!.*[ /]python",
comment = "#",
patterns = {
- { pattern = { "#", "\n" }, type = "comment" },
- { pattern = { '[ruU]?"', '"', '\\' }, type = "string" },
- { pattern = { "[ruU]?'", "'", '\\' }, type = "string" },
- { pattern = { '"""', '"""' }, type = "string" },
- { pattern = "0x[%da-fA-F]+", type = "number" },
- { pattern = "-?%d+[%d%.eE]*", type = "number" },
- { pattern = "-?%.?%d+", type = "number" },
- { pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" },
- { pattern = "[%a_][%w_]*%f[(]", type = "function" },
- { pattern = "[%a_][%w_]*", type = "symbol" },
+ { pattern = { "#", "\n" }, type = "comment" },
+ { pattern = { '[ruU]?"""', '"""'; '\\' }, type = "string" },
+ { pattern = { '[ruU]?"', '"', '\\' }, type = "string" },
+ { pattern = { "[ruU]?'", "'", '\\' }, type = "string" },
+ { pattern = "0x[%da-fA-F]+", type = "number" },
+ { pattern = "-?%d+[%d%.eE]*", type = "number" },
+ { pattern = "-?%.?%d+", type = "number" },
+ { pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" },
+ { pattern = "[%a_][%w_]*%f[(]", type = "function" },
+ { pattern = "[%a_][%w_]*", type = "symbol" },
},
symbols = {
["class"] = "keyword",
diff --git a/data/plugins/language_xml.lua b/data/plugins/language_xml.lua
index 95e310bb..c858d3cf 100644
--- a/data/plugins/language_xml.lua
+++ b/data/plugins/language_xml.lua
@@ -2,6 +2,7 @@
local syntax = require "core.syntax"
syntax.add {
+ name = "XML",
files = { "%.xml$" },
headers = "<%?xml",
patterns = {
diff --git a/data/plugins/lineguide.lua b/data/plugins/lineguide.lua
index 5a17c8ca..96745659 100644
--- a/data/plugins/lineguide.lua
+++ b/data/plugins/lineguide.lua
@@ -2,19 +2,20 @@
local config = require "core.config"
local style = require "core.style"
local DocView = require "core.docview"
+local CommandView = require "core.commandview"
local draw_overlay = DocView.draw_overlay
function DocView:draw_overlay(...)
- local ns = ("n"):rep(config.line_limit)
- local offset = self:get_font():get_width(ns)
- local x = self:get_line_screen_position(1) + offset
- local y = self.position.y
- local w = math.ceil(SCALE * 1)
- local h = self.size.y
-
- local color = style.guide or style.selection
- renderer.draw_rect(x, y, w, h, color)
-
+ if not self:is(CommandView) then
+ local offset = self:get_font():get_width("n") * config.line_limit
+ local x = self:get_line_screen_position(1) + offset
+ local y = self.position.y
+ local w = math.ceil(SCALE * 1)
+ local h = self.size.y
+
+ local color = style.guide or style.selection
+ renderer.draw_rect(x, y, w, h, color)
+ end
draw_overlay(self, ...)
end
diff --git a/data/plugins/projectsearch.lua b/data/plugins/projectsearch.lua
index dda3a2d0..d0d75d7f 100644
--- a/data/plugins/projectsearch.lua
+++ b/data/plugins/projectsearch.lua
@@ -92,7 +92,7 @@ end
function ResultsView:on_mouse_pressed(...)
local caught = ResultsView.super.on_mouse_pressed(self, ...)
if not caught then
- self:open_selected_result()
+ return self:open_selected_result()
end
end
@@ -108,6 +108,7 @@ function ResultsView:open_selected_result()
dv.doc:set_selection(res.line, res.col)
dv:scroll_to_line(res.line, false, true)
end)
+ return true
end
diff --git a/data/plugins/scale.lua b/data/plugins/scale.lua
index b8384609..616ee40b 100644
--- a/data/plugins/scale.lua
+++ b/data/plugins/scale.lua
@@ -54,6 +54,10 @@ local function set_scale(scale)
renderer.font.set_size(font, s * font:get_size())
end
+ for _, font in pairs(style.syntax_fonts) do
+ renderer.font.set_size(font, s * font:get_size())
+ end
+
-- restore scroll positions
for view, n in pairs(scrolls) do
view.scroll.y = n * (view:get_scrollable_size() - view.size.y)
@@ -67,17 +71,6 @@ local function get_scale()
return current_scale
end
-local on_mouse_wheel = RootView.on_mouse_wheel
-
-function RootView:on_mouse_wheel(d, ...)
- if keymap.modkeys["ctrl"] and config.plugins.scale.use_mousewheel then
- if d < 0 then command.perform "scale:decrease" end
- if d > 0 then command.perform "scale:increase" end
- else
- return on_mouse_wheel(self, d, ...)
- end
-end
-
local function res_scale()
set_scale(default_scale)
end
@@ -101,6 +94,8 @@ keymap.add {
["ctrl+0"] = "scale:reset",
["ctrl+-"] = "scale:decrease",
["ctrl+="] = "scale:increase",
+ ["ctrl+wheelup"] = "scale:increase",
+ ["ctrl+wheeldown"] = "scale:decrease"
}
return {
diff --git a/data/plugins/treeview.lua b/data/plugins/treeview.lua
index fa3ab53a..4f5db701 100644
--- a/data/plugins/treeview.lua
+++ b/data/plugins/treeview.lua
@@ -41,8 +41,15 @@ function TreeView:new()
self.init_size = true
self.target_size = default_treeview_size
self.cache = {}
- self.last = {}
self.tooltip = { x = 0, y = 0, begin = 0, alpha = 0 }
+
+ local on_dirmonitor_modify = core.on_dirmonitor_modify
+ function core.on_dirmonitor_modify(dir, filepath)
+ if self.cache[dir.name] then
+ self.cache[dir.name][filepath] = nil
+ end
+ on_dirmonitor_modify(dir, filepath)
+ end
end
@@ -54,7 +61,7 @@ function TreeView:set_target_size(axis, value)
end
-function TreeView:get_cached(item, dirname)
+function TreeView:get_cached(dir, item, dirname)
local dir_cache = self.cache[dirname]
if not dir_cache then
dir_cache = {}
@@ -80,6 +87,7 @@ function TreeView:get_cached(item, dirname)
end
t.name = basename
t.type = item.type
+ t.dir = dir -- points to top level "dir" item
dir_cache[cache_name] = t
end
return t
@@ -104,18 +112,13 @@ end
function TreeView:check_cache()
- -- invalidate cache's skip values if project_files has changed
for i = 1, #core.project_directories do
local dir = core.project_directories[i]
- local last_files = self.last[dir.name]
- if not last_files then
- self.last[dir.name] = dir.files
- else
- if dir.files ~= last_files then
- self:invalidate_cache(dir.name)
- self.last[dir.name] = dir.files
- end
+ -- invalidate cache's skip values if directory is declared dirty
+ if dir.is_dirty and self.cache[dir.name] then
+ self:invalidate_cache(dir.name)
end
+ dir.is_dirty = false
end
end
@@ -131,14 +134,14 @@ function TreeView:each_item()
for k = 1, #core.project_directories do
local dir = core.project_directories[k]
- local dir_cached = self:get_cached(dir.item, dir.name)
+ local dir_cached = self:get_cached(dir, dir.item, dir.name)
coroutine.yield(dir_cached, ox, y, w, h)
count_lines = count_lines + 1
y = y + h
local i = 1
while i <= #dir.files and dir_cached.expanded do
local item = dir.files[i]
- local cached = self:get_cached(item, dir.name)
+ local cached = self:get_cached(dir, item, dir.name)
coroutine.yield(cached, ox, y, w, h)
count_lines = count_lines + 1
@@ -206,7 +209,6 @@ local function create_directory_in(item)
core.error("cannot create directory %q: %s", dirname, err)
end
item.expanded = true
- core.reschedule_project_scan()
end)
end
@@ -223,26 +225,17 @@ function TreeView:on_mouse_pressed(button, x, y, clicks)
if keymap.modkeys["ctrl"] and button == "left" then
create_directory_in(hovered_item)
else
- if core.project_files_limit and not hovered_item.expanded then
- local filename, abs_filename = hovered_item.filename, hovered_item.abs_filename
- local index = 0
- -- The loop below is used to find the first match starting from the end
- -- in case there are multiple matches.
- while index and index + #filename < #abs_filename do
- index = string.find(abs_filename, filename, index + 1, true)
- end
- -- we assume here index is not nil because the abs_filename must contain the
- -- relative filename
- local dirname = string.sub(abs_filename, 1, index - 2)
- if core.is_project_folder(dirname) then
- core.scan_project_folder(dirname, filename)
- self:invalidate_cache(dirname)
- end
- end
hovered_item.expanded = not hovered_item.expanded
+ if hovered_item.dir.files_limit then
+ core.update_project_subdir(hovered_item.dir, hovered_item.filename, hovered_item.expanded)
+ core.project_subdir_set_show(hovered_item.dir, hovered_item.filename, hovered_item.expanded)
+ end
end
else
core.try(function()
+ if core.last_active_view and core.active_view == self then
+ core.set_active_view(core.last_active_view)
+ end
local doc_filename = core.normalize_to_project_dir(hovered_item.abs_filename)
core.root_view:open_doc(core.open_doc(doc_filename))
end)
@@ -295,6 +288,12 @@ function TreeView:draw_tooltip()
end
+function TreeView:color_for_item(abs_filename)
+ -- other plugins can override this to customize the color of each icon
+ return nil
+end
+
+
function TreeView:draw()
self:draw_background(style.background2)
@@ -318,6 +317,9 @@ function TreeView:draw()
color = style.accent
end
+ -- allow for color overrides
+ local icon_color = self:color_for_item(item.abs_filename) or color
+
-- icons
x = x + item.depth * style.padding.x + style.padding.x
if item.type == "dir" then
@@ -325,11 +327,11 @@ function TreeView:draw()
local icon2 = item.expanded and "D" or "d"
common.draw_text(style.icon_font, color, icon1, nil, x, y, 0, h)
x = x + style.padding.x
- common.draw_text(style.icon_font, color, icon2, nil, x, y, 0, h)
+ common.draw_text(style.icon_font, icon_color, icon2, nil, x, y, 0, h)
x = x + icon_width
else
x = x + style.padding.x
- common.draw_text(style.icon_font, color, "f", nil, x, y, 0, h)
+ common.draw_text(style.icon_font, icon_color, "f", nil, x, y, 0, h)
x = x + icon_width
end
@@ -404,7 +406,7 @@ function RootView:draw(...)
end
local function is_project_folder(path)
- return common.basename(core.project_dir) == path
+ return core.project_dir == path
end
menu:register(function() return view.hovered_item end, {
@@ -415,7 +417,7 @@ menu:register(function() return view.hovered_item end, {
menu:register(
function()
return view.hovered_item
- and not is_project_folder(view.hovered_item.filename)
+ and not is_project_folder(view.hovered_item.abs_filename)
end,
{
{ text = "Rename", command = "treeview:rename" },
@@ -461,14 +463,12 @@ command.add(function() return view.hovered_item ~= nil end, {
else
core.error("Error while renaming \"%s\" to \"%s\": %s", old_abs_filename, abs_filename, err)
end
- core.reschedule_project_scan()
end, common.path_suggest)
end,
["treeview:new-file"] = function()
- local dir_name = view.hovered_item.filename
- if not is_project_folder(dir_name) then
- core.command_view:set_text(dir_name .. "/")
+ if not is_project_folder(view.hovered_item.abs_filename) then
+ core.command_view:set_text(view.hovered_item.filename .. "/")
end
core.command_view:enter("Filename", function(filename)
local doc_filename = core.project_dir .. PATHSEP .. filename
@@ -476,20 +476,17 @@ command.add(function() return view.hovered_item ~= nil end, {
file:write("")
file:close()
core.root_view:open_doc(core.open_doc(doc_filename))
- core.reschedule_project_scan()
core.log("Created %s", doc_filename)
end, common.path_suggest)
end,
["treeview:new-folder"] = function()
- local dir_name = view.hovered_item.filename
- if not is_project_folder(dir_name) then
- core.command_view:set_text(dir_name .. "/")
+ if not is_project_folder(view.hovered_item.abs_filename) then
+ core.command_view:set_text(view.hovered_item.filename .. "/")
end
core.command_view:enter("Folder Name", function(filename)
local dir_path = core.project_dir .. PATHSEP .. filename
common.mkdirp(dir_path)
- core.reschedule_project_scan()
core.log("Created %s", dir_path)
end, common.path_suggest)
end,
@@ -526,7 +523,6 @@ command.add(function() return view.hovered_item ~= nil end, {
return
end
end
- core.reschedule_project_scan()
core.log("Deleted \"%s\"", filename)
end
end