Skip to content

Commit

Permalink
Allow copy and pasting of web source by pressing 'c'
Browse files Browse the repository at this point in the history
  • Loading branch information
pieter committed Sep 19, 2008
1 parent db39aee commit 38f16a2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion PBCommitList.m
Expand Up @@ -22,7 +22,7 @@ - (void) keyDown: (id) event
else
[webView scrollPageDown: self];
}
else if ([character rangeOfCharacterFromSet:[NSCharacterSet characterSetWithCharactersInString:@"jkv"]].location == 0)
else if ([character rangeOfCharacterFromSet:[NSCharacterSet characterSetWithCharactersInString:@"jkcv"]].location == 0)
[webController sendKey: character];
else
[super keyDown: event];
Expand Down
8 changes: 8 additions & 0 deletions PBWebGitController.m
Expand Up @@ -73,6 +73,14 @@ - (void) sendKey: (NSString*) key
[script callWebScriptMethod:@"handleKeyFromCocoa" withArguments: [NSArray arrayWithObject:key]];
}

- (void) copySource
{
NSString *source = [[[[view mainFrame] DOMDocument] documentElement] outerHTML];
NSPasteboard *a =[NSPasteboard generalPasteboard];
[a declareTypes:[NSArray arrayWithObject:NSStringPboardType] owner:self];
[a setString:source forType: NSStringPboardType];
}

+ (BOOL)isSelectorExcludedFromWebScript:(SEL)aSelector
{
return NO;
Expand Down
2 changes: 2 additions & 0 deletions html/keyboardNavigation.js
Expand Up @@ -24,6 +24,8 @@ var handleKeyFromCocoa = function(key) {
changeHunk(false);
else if (key == 'v')
showDiffs();
else if (key == 'c')
Controller.copySource();
}

var changeHunk = function(next) {
Expand Down

0 comments on commit 38f16a2

Please sign in to comment.