Fixed up link selection
This commit is contained in:
parent
7179c65bff
commit
feaf05c11d
18
main.lua
18
main.lua
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue