Skip to content

Commit

Permalink
Merge remote-tracking branch 'yury/tune-selection' into raw
Browse files Browse the repository at this point in the history
  • Loading branch information
Carlos Cabanero committed Oct 5, 2017
2 parents 858bb33 + 7bfd7a9 commit 1f21062
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
5 changes: 4 additions & 1 deletion Blink/TermView.m
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,10 @@ - (void)activeControl:(UITapGestureRecognizer *)gestureRecognizer
setMenuVisible:NO
animated:YES];
} else {
[[UIMenuController sharedMenuController] setTargetRect:self.frame

CGRect targetRect = CGRectMake(0, self.bounds.size.height - 20, self.bounds.size.width, 10);

[[UIMenuController sharedMenuController] setTargetRect: targetRect
inView:self];

UIMenuItem *pasteItem = [[UIMenuItem alloc] initWithTitle:@"Paste"
Expand Down
19 changes: 11 additions & 8 deletions Resources/termcontrol.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,15 @@ var reset = function() {
t.reset();
}

hterm.copySelectionToClipboard = function(document) {
window.webkit.messageHandlers.interOp.postMessage({"op": "copy", "data":{"content": document.getSelection().toString()}});
// The following code tends to remove current selection...
// If it is ok to keep selection just remove it.
var input = document.createElement('input');
document.body.appendElement(input)
input.focus();
document.body.removeChild(input);
hterm.Terminal.prototype.copyStringToClipboard = function(str) {
if (this.prefs_.get('enable-clipboard-notice'))
setTimeout(this.showOverlay.bind(this, hterm.notifyCopyMessage, 500), 200);

hterm.copySelectionToClipboard(this.document_, str);
};

hterm.copySelectionToClipboard = function(document, content) {
var selection = document.getSelection();
selection.removeAllRanges();
window.webkit.messageHandlers.interOp.postMessage({"op": "copy", "data":{"content": content}});
}

0 comments on commit 1f21062

Please sign in to comment.