diff options
Diffstat (limited to '')
-rwxr-xr-x | telem.lua | 23 |
1 files changed, 21 insertions, 2 deletions
@@ -294,11 +294,30 @@ function create_post() -- This is used by both do_new and do_reply -- Launch editor to save post in temporary file local filename = os.tmpname() + ::edit:: os.execute(_EDITOR .. " " .. filename) -- Check that file exists and is not empty if not path.exists(filename) then return nil end if lfs.attributes(filename).size == 0 then return nil end - return filename + -- Get confirmation from user + print("PREVIEW:") + print(string.rep("-",79)) + cat_file(filename) + print(string.rep("-",79)) + local valid_chars = { y=true, n=true, e=true } + local c = nil + while not valid_chars[c] do + io.write("Post this? [y]es, [n]o, [e]dit ") + c = string.lower(getchar()) + print("") + end + if c == "e" then + goto edit + elseif c == "n" then + return nil + else + return filename + end end function do_new() @@ -391,7 +410,7 @@ function do_type_reply() -- Read reply body into temp file local filename = create_post() if not filename then - print("Empty file, reply cancelled.") + print("Reply cancelled.") return end -- Move temp file to correct location and set permissions |