Skip to content

Commit

Permalink
Bind /sync to Alt+S
Browse files Browse the repository at this point in the history
  • Loading branch information
LBPHacker committed Jun 22, 2021
1 parent f1ad8d7 commit 9d2cb9a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion tptmp/client/client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function client_i:read_bytes_(count)
coroutine.yield()
end
local data, first, last = self.rx_:next()
if last - first + 1 >= count then
if last >= first + count - 1 then
-- * Less memory-intensive path.
self.rx_:pop(count)
return data:byte(first, first + count - 1)
Expand Down
3 changes: 3 additions & 0 deletions tptmp/client/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ local function run()
show_window_func = show_window,
hide_window_func = hide_window,
window_hidden_func = window_hidden,
sync_func = function()
cmd:parse("/sync")
end,
})

local grab_drop_text_input
Expand Down
4 changes: 4 additions & 0 deletions tptmp/client/side_button.lua
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ function side_button_i:handle_keypress(key, scan, rep, shift, ctrl, alt)
if shift and scan == sdl.SDL_SCANCODE_ESCAPE then
self.show_window_func_()
return true
elseif alt and scan == sdl.SDL_SCANCODE_S then
self.sync_func_()
return true
end
end

Expand Down Expand Up @@ -143,6 +146,7 @@ local function new(params)
show_window_func_ = params.show_window_func,
hide_window_func_ = params.hide_window_func,
window_hidden_func_ = params.window_hidden_func,
sync_func_ = params.sync_func,
}, side_button_m)
end

Expand Down
2 changes: 1 addition & 1 deletion tptmp/server/client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ end
function client_i:read_bytes_(count)
self:read_wait_(count)
local data, first, last = self.rx_:next()
if last - first + 1 >= count then
if last >= first + count - 1 then
-- * Less memory-intensive path.
self.rx_:pop(count)
return data:byte(first, first + count - 1)
Expand Down

0 comments on commit 9d2cb9a

Please sign in to comment.