diff options
author | Solderpunk <solderpunk@sdf.org> | 2018-12-08 12:58:42 +0000 |
---|---|---|
committer | Solderpunk <solderpunk@sdf.org> | 2018-12-08 12:58:42 +0000 |
commit | 3fcb7e5c6faa208bffac7f14733a99f3ad5a12a4 (patch) | |
tree | ee42899d252f58fcd91345b6cb332d2cb6e704b9 /telem.lua | |
parent | Validate inputs. (diff) |
Reduce code duplication and needless function argument.
Diffstat (limited to 'telem.lua')
-rwxr-xr-x | telem.lua | 19 |
1 files changed, 8 insertions, 11 deletions
@@ -209,24 +209,21 @@ end function do_type_first() current_thread_index = 1 - do_type_show_post(current_thread_index) - print(string.format("Viewing post %d of %d in thread", current_thread_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 end - do_type_show_post(current_thread_index) - print(string.format("Viewing post %d of %d in thread", current_thread_index, #current_thread_posts)) + do_type_show_post() end function do_type_prev() if current_thread_index ~= 1 then current_thread_index = current_thread_index - 1 end - do_type_show_post(current_thread_index) - print(string.format("Viewing post %d of %d in thread", current_thread_index, #current_thread_posts)) + do_type_show_post() end function do_type_reply() @@ -241,7 +238,7 @@ function do_type_reply() end current_thread_posts = get_posts(thread) current_thread_index = #current_thread_posts - do_type_show_post(current_thread_index) + do_type_show_post() end type_dispatch = {} @@ -262,8 +259,7 @@ function do_type() current_thread_subject = thread.subject current_thread_posts = get_posts(thread) current_thread_index = #current_thread_posts - do_type_show_post(current_thread_index) - print(string.format("Viewing post %d of %d in thread", current_thread_index, #current_thread_posts)) + do_type_show_post() repeat show_type_prompt() c = getchar() @@ -280,14 +276,15 @@ function show_type_prompt() io.write("[f]irst, [n]ext, [p]rev, [r]eply, [d]one > ") end -function do_type_show_post(index) - local post = current_thread_posts[index] +function do_type_show_post() + local post = current_thread_posts[current_thread_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)) end function do_quit() |