aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xtelem.lua44
1 files changed, 21 insertions, 23 deletions
diff --git a/telem.lua b/telem.lua
index c99d3a9..a6b149a 100755
--- a/telem.lua
+++ b/telem.lua
@@ -130,6 +130,7 @@ function do_go()
print("No such board! Hit `l` to list boards.")
else
current_board = board
+ current_board_threads = get_threads(current_board)
end
end
@@ -159,12 +160,11 @@ function do_messages()
if current_board == "" then
print("Not at any board")
else
- threads = get_threads(current_board)
- for i, thread in ipairs(threads) do
+ current_board_threads = get_threads(current_board)
+ for i, thread in ipairs(current_board_threads) do
print(tostring(i), os.date("%x %H:%M", thread.timestamp), thread.author, thread.subject, "("..tostring(thread.post_count).." posts)")
end
end
- current_thread_index = threads
end
function do_new()
@@ -205,25 +205,25 @@ end
-- Type stuff below
function do_type_first()
- current_thread_index = 1
+ current_post_index = 1
do_type_show_post()
end
function do_type_last()
- current_thread_index = #current_thread_posts
+ current_post_index = #current_thread_posts
do_type_show_post()
end
function do_type_next()
- if current_thread_index ~= #current_thread_posts then
- current_thread_index = current_thread_index + 1
+ if current_post_index ~= #current_thread_posts then
+ current_post_index = current_post_index + 1
end
do_type_show_post()
end
function do_type_prev()
- if current_thread_index ~= 1 then
- current_thread_index = current_thread_index - 1
+ if current_post_index ~= 1 then
+ current_post_index = current_post_index - 1
end
do_type_show_post()
end
@@ -238,8 +238,8 @@ function do_type_reply()
if not ret then
print(str)
end
- current_thread_posts = get_posts(thread)
- current_thread_index = #current_thread_posts
+ current_thread_posts = get_posts(current_thread)
+ current_post_index = #current_thread_posts
do_type_show_post()
end
@@ -254,14 +254,13 @@ type_dispatch["d"] = function() return end
function do_type()
io.write("Display which thread? ")
local thread_id = tonumber(io.read())
- if not thread_id or thread_id < 0 or thread_id > #current_thread_index then
+ if not thread_id or thread_id < 0 or thread_id > #current_board_threads then
print("Invalid thread index!")
return
end
- thread = current_thread_index[tonumber(thread_id)]
- current_thread_subject = thread.subject
- current_thread_posts = get_posts(thread)
- current_thread_index = #current_thread_posts
+ current_thread = current_board_threads[thread_id]
+ current_thread_posts = get_posts(current_thread)
+ current_post_index = #current_thread_posts
do_type_show_post()
repeat
show_type_prompt()
@@ -280,14 +279,14 @@ function show_type_prompt()
end
function do_type_show_post()
- local post = current_thread_posts[current_thread_index]
- print("SUBJECT: " .. current_thread_subject)
+ local post = current_thread_posts[current_post_index]
+ print("SUBJECT: " .. current_thread.subject)
print("AUTHOR: " .. post.author)
print("POSTED: " .. os.date("%H:%M %B %d, %Y", post.timestamp))
print("--------------------------------")
cat_file(post.filename)
print("--------------------------------")
- print(string.format("Viewing post %d of %d in thread", current_thread_index, #current_thread_posts))
+ print(string.format("Viewing post %d of %d in thread", current_post_index, #current_thread_posts))
end
function do_quit()
@@ -301,14 +300,13 @@ function do_reply()
end
io.write("Reply to which thread? ")
local thread_id = tonumber(io.read())
- if not thread_id or thread_id < 0 or thread_id > #current_thread_index then
+ if not thread_id or thread_id < 0 or thread_id > #current_board_threads then
print("Invalid thread index!")
return
end
- thread = current_thread_index[tonumber(thread_id)]
- current_thread_subject = thread.subject
+ current_thread = current_board_threads[thread_id]
current_thread_posts = get_posts(thread)
- current_thread_index = #current_thread_posts
+ current_post_index = #current_thread_posts
do_type_reply()
end