Fixed up link selection

This commit is contained in:
sloumdrone 2019-01-03 07:30:04 -08:00
parent 7179c65bff
commit feaf05c11d
1 changed files with 15 additions and 3 deletions

View File

@ -118,7 +118,7 @@ function mainloop()
print('| text files. |')
print('| |')
while true do
print('\27[7m (G)o to url, (B)ack, (#) Visit link, (Q)uit \27[0m')
print('\27[7m (G)o to url, (B)ack, (V)isit link, (Q)uit \27[0m')
local key = string.lower(getch())
io.write('\n')
if key == 'q' then
@ -137,9 +137,17 @@ function mainloop()
handle_response(filedata, url.gophertype)
print(separator)
end
elseif type(tonumber(key)) == 'number' then
local linkurl = links[tonumber(key)]
elseif key == 'v' then
local linkid
repeat
io.write('Enter link id: ')
io.flush()
linkid = tonumber(io.read())
until linkid
local linkurl = links[linkid]
print(separator)
print(linkurl or 'No such link')
print(separator)
end
end
end
@ -158,6 +166,9 @@ function handle_response(res_table, gtype)
end
end
-- Modified version of socket.url.parse
-- Sets up defaults and adds parsing of gophertype
function parse_url(u)
if not string.find(u, '://', 1, true) then
u = 'gopher://'..u
@ -180,5 +191,6 @@ function parse_url(u)
return parsed
end
-- run the program
mainloop()