|
|
@@ -742,15 +742,17 @@ bind_key("C-x C-b", function()
|
|
|
table.insert(lines, "Buffer List:")
|
|
|
table.insert(lines, "------------")
|
|
|
table.insert(lines, "")
|
|
|
+ table.insert(lines, string.format("%-3s %-20s %-10s %s", "Mod", "Name", "Size", "File"))
|
|
|
+ table.insert(lines, string.format("%-3s %-20s %-10s %s", "---", "----", "----", "----"))
|
|
|
|
|
|
for i, info in ipairs(buffer_info) do
|
|
|
- local modified = info.modified and "[+]" or " "
|
|
|
+ local modified = info.modified and " * " or " "
|
|
|
local filepath = ""
|
|
|
if info.filepath then
|
|
|
filepath = tostring(info.filepath)
|
|
|
end
|
|
|
|
|
|
- local line = string.format("%s %-20s %5d lines %s",
|
|
|
+ local line = string.format("%s %-20s %-10d %s",
|
|
|
modified,
|
|
|
info.name,
|
|
|
info.size,
|
|
|
@@ -759,38 +761,23 @@ bind_key("C-x C-b", function()
|
|
|
table.insert(lines, line)
|
|
|
end
|
|
|
|
|
|
- -- Create a new buffer for the list
|
|
|
local list_text = table.concat(lines, "\n")
|
|
|
-
|
|
|
- -- For now, just show in message (full buffer list implementation would create a special buffer)
|
|
|
- -- This is a simple version that shows the list in a new buffer
|
|
|
- local current_buf_name = editor.buffer:name()
|
|
|
-
|
|
|
- -- Try to find or create the *Buffer List* buffer
|
|
|
- local list_buf = editor:get_buffer_by_name("*Buffer List*")
|
|
|
- if not list_buf then
|
|
|
- -- Create a new buffer for buffer list
|
|
|
- editor:new_buffer("*Buffer List*")
|
|
|
- local buf = editor.buffer
|
|
|
-
|
|
|
- -- Clear buffer and insert list
|
|
|
- buf:clear_styles()
|
|
|
- -- Insert the formatted text
|
|
|
- local cursor = editor.cursor
|
|
|
- buf:insert(cursor, list_text)
|
|
|
-
|
|
|
- message(string.format("Buffer list (%d buffers)", #buffer_info))
|
|
|
+ local list_buf_name = "*Buffer List*"
|
|
|
+
|
|
|
+ -- Switch to or create buffer
|
|
|
+ local list_buf = editor:get_buffer_by_name(list_buf_name)
|
|
|
+ if list_buf then
|
|
|
+ editor:switch_buffer_in_window(list_buf_name)
|
|
|
else
|
|
|
- -- Switch to existing buffer list
|
|
|
- editor:switch_buffer_in_window("*Buffer List*")
|
|
|
-
|
|
|
- -- Update the content
|
|
|
- local buf = editor.buffer
|
|
|
- -- Clear and reinsert (simple approach)
|
|
|
- -- In a full implementation, we'd replace the content properly
|
|
|
-
|
|
|
- message("Showing buffer list")
|
|
|
+ editor:new_buffer(list_buf_name)
|
|
|
end
|
|
|
+
|
|
|
+ local buf = editor.buffer
|
|
|
+ buf:clear()
|
|
|
+ buf:insert(lumacs.Position(0,0), list_text)
|
|
|
+ editor:goto_beginning()
|
|
|
+
|
|
|
+ message(string.format("Buffer list (%d buffers)", #buffer_info))
|
|
|
end)
|
|
|
|
|
|
-- Test control keys (ncurses versions)
|