A fork of https://github.com/ueokande/vim-vixen
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1012 B
45 lines
1012 B
import * as messages from '../../shared/messages'; |
|
import Key from '../../shared/settings/Key'; |
|
|
|
export default interface FollowMasterClient { |
|
startFollow(newTab: boolean, background: boolean): void; |
|
|
|
responseHintCount(count: number): void; |
|
|
|
sendKey(key: Key): void; |
|
} |
|
|
|
export class FollowMasterClientImpl implements FollowMasterClient { |
|
private window: Window; |
|
|
|
constructor(window: Window) { |
|
this.window = window; |
|
} |
|
|
|
startFollow(newTab: boolean, background: boolean): void { |
|
this.postMessage({ |
|
type: messages.FOLLOW_START, |
|
newTab, |
|
background, |
|
}); |
|
} |
|
|
|
responseHintCount(count: number): void { |
|
this.postMessage({ |
|
type: messages.FOLLOW_RESPONSE_COUNT_TARGETS, |
|
count, |
|
}); |
|
} |
|
|
|
sendKey(key: Key): void { |
|
this.postMessage({ |
|
type: messages.FOLLOW_KEY_PRESS, |
|
key: key.key, |
|
ctrlKey: key.ctrl || false, |
|
}); |
|
} |
|
|
|
private postMessage(msg: messages.Message): void { |
|
this.window.postMessage(JSON.stringify(msg), '*'); |
|
} |
|
}
|
|
|