Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add a __tostring method to every object #1534

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions data/core/commandview.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ function SingleLineDoc:insert(line, col, text)
SingleLineDoc.super.insert(self, line, col, text:gsub("\n", ""))
end

function SingleLineDoc:__tostring() return "SingleLineDoc" end

---@class core.commandview : core.docview
---@field super core.docview
local CommandView = DocView:extend()
Expand Down Expand Up @@ -375,5 +377,6 @@ function CommandView:draw()
end
end

function CommandView:__tostring() return "CommandView" end

return CommandView
2 changes: 2 additions & 0 deletions data/core/contextmenu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -235,4 +235,6 @@ function ContextMenu:draw_context_menu()
end
end

function ContextMenu:__tostring() return "ContextMenu" end

return ContextMenu
1 change: 1 addition & 0 deletions data/core/doc/highlighter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -126,5 +126,6 @@ function Highlighter:each_token(idx)
return tokenizer.each_token(self:get_line(idx).tokens)
end

function Highlighter:__tostring() return "Highlighter" end

return Highlighter
1 change: 1 addition & 0 deletions data/core/doc/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -669,5 +669,6 @@ function Doc:on_close()
core.log_quiet("Closed doc \"%s\"", self:get_name())
end

function Doc:__tostring() return "Doc" end

return Doc
1 change: 1 addition & 0 deletions data/core/docview.lua
Original file line number Diff line number Diff line change
Expand Up @@ -590,5 +590,6 @@ function DocView:draw()
self:draw_scrollbar()
end

function DocView:__tostring() return "DocView" end

return DocView
2 changes: 2 additions & 0 deletions data/core/emptyview.lua
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,6 @@ function EmptyView:draw()
draw_text(x, y, style.dim)
end

function EmptyView:__tostring() return "EmptyView" end

return EmptyView
2 changes: 1 addition & 1 deletion data/core/logview.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ local function get_item_height(item)
return h
end


local LogView = View:extend()

LogView.context = "session"
Expand Down Expand Up @@ -212,5 +211,6 @@ function LogView:draw()
LogView.super.draw_scrollbar(self)
end

function LogView:__tostring() return "LogView" end

return LogView
2 changes: 2 additions & 0 deletions data/core/nagview.lua
Original file line number Diff line number Diff line change
Expand Up @@ -300,4 +300,6 @@ function NagView:show(title, message, options, on_select)
self:next()
end

function NagView:__tostring() return "NagView" end

return NagView
2 changes: 2 additions & 0 deletions data/core/node.lua
Original file line number Diff line number Diff line change
Expand Up @@ -791,4 +791,6 @@ function Node:get_drag_overlay_tab_position(x, y, dragged_node, dragged_index)
return tab_index, tab_x, tab_y + margin_y, tab_w, tab_h - margin_y
end

function Node:__tostring() return "Node" end

return Node
1 change: 1 addition & 0 deletions data/core/rootview.lua
Original file line number Diff line number Diff line change
Expand Up @@ -565,5 +565,6 @@ function RootView:draw()
end
end

function RootView:__tostring() return "RootView" end

return RootView
1 change: 1 addition & 0 deletions data/core/scrollbar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -338,5 +338,6 @@ function Scrollbar:draw()
self:draw_thumb()
end

function Scrollbar:__tostring() return "Scrollbar" end

return Scrollbar
4 changes: 4 additions & 0 deletions data/core/statusview.lua
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ function StatusViewItem:set_predicate(predicate)
self.predicate = command.generate_predicate(predicate)
end

function StatusViewItem:__tostring() return "StatusViewItem" end

---@type core.statusview.item
StatusView.Item = StatusViewItem

Expand Down Expand Up @@ -1190,4 +1192,6 @@ function StatusView:draw()
end
end

function StatusView:__tostring() return "StatusView" end

return StatusView
2 changes: 2 additions & 0 deletions data/core/titleview.lua
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,6 @@ function TitleView:draw()
self:draw_window_controls()
end

function TitleView:__tostring() return "TitleView" end

return TitleView
1 change: 1 addition & 0 deletions data/core/view.lua
Original file line number Diff line number Diff line change
Expand Up @@ -328,5 +328,6 @@ end
function View:draw()
end

function View:__tostring() return "View" end

return View
1 change: 1 addition & 0 deletions data/plugins/projectsearch.lua
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ function ResultsView:draw()
self:draw_scrollbar()
end

function ResultsView:__tostring() return "ResultsView" end

---@param path string
---@param text string
Expand Down
2 changes: 2 additions & 0 deletions data/plugins/toolbarview.lua
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ function ToolbarView:on_mouse_moved(px, py, ...)
end
end

function ToolbarView:__tostring() return "ToolbarView" end

-- The toolbarview pane is not plugged here but it is added in the
-- treeview plugin.

Expand Down
1 change: 1 addition & 0 deletions data/plugins/treeview.lua
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,7 @@ function TreeView:open_doc(filename)
core.root_view:open_doc(core.open_doc(filename))
end

function TreeView:__tostring() return "TreeView" end

-- init
local view = TreeView()
Expand Down