Skip to content

Commit

Permalink
Backspace goes back in history
Browse files Browse the repository at this point in the history
Also:
  * Use webextension to navigate URLs instead of the DOM. This means
    that crashed pages can still be navigated away from.
  * An attempt to implement mouse dragndrop, but it doesn't work :(
  • Loading branch information
tombh committed May 25, 2018
1 parent f2d9d44 commit 4b84d52
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 7 deletions.
4 changes: 4 additions & 0 deletions interfacer/src/browsh/tty.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ func handleUserKeyPress(ev *tcell.EventKey) {
createNewEmptyTab()
case tcell.KeyCtrlW:
removeTab(CurrentTab.ID)
case tcell.KeyBackspace, tcell.KeyBackspace2:
if activeInputBox == nil {
sendMessageToWebExtension("/tab_command,/history_back")
}
}
if (ev.Rune() == 'm' && ev.Modifiers() == 4) {
toggleMonochromeMode()
Expand Down
16 changes: 15 additions & 1 deletion webext/src/background/tty_commands_mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export default (MixinBase) => class extends MixinBase {

_handleURLBarInput(input) {
const final_url = this._getURLfromUserInput(input);
this.sendToCurrentTab(`/url,${final_url}`);
this.gotoURL(final_url);
}

// TODO: move to CLI client
Expand Down Expand Up @@ -97,6 +97,20 @@ export default (MixinBase) => class extends MixinBase {
);
}

gotoURL(url) {
let updating = browser.tabs.update(parseInt(this.currentTab().id), {
url: url
});
updating.then(
tab => {
this.log(`Tab ${tab.id} loaded: ${url}`);
},
error => {
this.log(`Error loading: ${url} \nError: ${error}`);
}
);
}

switchToTab(id) {
let updating = browser.tabs.update(parseInt(id), {
active: true
Expand Down
21 changes: 15 additions & 6 deletions webext/src/dom/manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ export default class extends utils.mixins(CommonMixin) {
url = utils.rebuildArgsToSingleArg(parts);
document.location.href = url;
break;
case '/location_back':
case '/history_back':
history.go(-1);
break;
case '/window_stop':
Expand Down Expand Up @@ -247,14 +247,23 @@ export default class extends utils.mixins(CommonMixin) {
}
}

// TODO: Dragndrop doesn't seem to work :/
_handleMouse(input) {
switch (input.button) {
case 1: // mousedown
this._mouseAction('click', input.mouse_x, input.mouse_y);
this._mouseAction('mousedown', input.mouse_x, input.mouse_y);
case 1:
this._mouseAction('mousemove', input.mouse_x, input.mouse_y);
if (!this._mousedown) {
this._mouseAction('mousedown', input.mouse_x, input.mouse_y);
}
this._mousedown = true;
break;
case 0: //mouseup
this._mouseAction('mouseup', input.mouse_x, input.mouse_y);
case 0:
this._mouseAction('mousemove', input.mouse_x, input.mouse_y);
if (this._mousedown) {
this._mouseAction('click', input.mouse_x, input.mouse_y);
this._mouseAction('mouseup', input.mouse_x, input.mouse_y);
}
this._mousedown = false;
break;
}
}
Expand Down

0 comments on commit 4b84d52

Please sign in to comment.