Skip to content

Commit

Permalink
Mouse wheel scrolling
Browse files Browse the repository at this point in the history
Also throttle the frame rate to 40ms/ Previously it was redrawing on
every sent STDIN event.
  • Loading branch information
tombh committed Feb 9, 2018
1 parent f624ea0 commit 819a29c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
3 changes: 0 additions & 3 deletions interfacer/main.go
Expand Up @@ -145,7 +145,6 @@ func readStdin() {
}
shutdown("normal")
}
log(fmt.Sprintf("EventKey: k: %d, c: %c, mod: %s", ev.Key, ev.Ch, ev.Mod))
eventMap := map[string]interface{}{
"key": int(ev.Key),
"char": string(ev.Ch),
Expand All @@ -160,7 +159,6 @@ func readStdin() {
termbox.Flush()
sendTtySize()
case termbox.EventMouse:
log(fmt.Sprintf("Mouse: k: %d, x: %d, y: %d, mod: %s", ev.Key, ev.MouseX, ev.MouseY, ev.Mod))
eventMap := map[string]interface{}{
"key": int(ev.Key),
"mouse_x": int(ev.MouseX),
Expand Down Expand Up @@ -262,7 +260,6 @@ func webSocketWriter(ws *websocket.Conn) {
}
shutdown(err.Error())
}
log(fmt.Sprintf("TTY sent: %s", message))
}
}

Expand Down
5 changes: 4 additions & 1 deletion webext/src/background/tty_commands_mixin.js
@@ -1,3 +1,4 @@
import _ from 'lodash';
import utils from 'utils';

// Handle commands coming in from the terminal, like; STDIN keystrokes, TTY resize, etc
Expand Down Expand Up @@ -25,7 +26,9 @@ export default (MixinBase) => class extends MixinBase {
}
// Trigger a faster feedback response
// TODO: cancel the current FPS iteration when using this
this.sendToCurrentTab('/request_frame');
_.throttle(() => {
this.sendToCurrentTab('/request_frame')
}, 50);
break;
case '/status':
this.updateStatus('', parts.slice(1).join(','));
Expand Down
6 changes: 6 additions & 0 deletions webext/src/dom/frame_builder.js
Expand Up @@ -137,6 +137,12 @@ export default class FrameBuilder extends BaseBuilder{
case 65516: // down arrow
window.scrollBy(0, 20);
break;
case 65508: // scroll up
window.scrollBy(0, -20);
break;
case 65507: // scroll down
window.scrollBy(0, 20);
break;
case 65512: // mousedown
this._mouseAction('click', input.mouse_x, input.mouse_y);
this._mouseAction('mousedown', input.mouse_x, input.mouse_y);
Expand Down

0 comments on commit 819a29c

Please sign in to comment.