fixed: smart copy/paste

This commit is contained in:
daboe01 committed 2025-07-05 08:49:08 +02:00
1 parent 9e15700f93
commit b0186bf4f2
5 files changed
+33 -17

No files matched your search

+16 -10
View File
@@ -449,19 +449,26 @@ var kDelegateRespondsTo_textShouldBeginEditing
{
[super copy:sender];
if (![self isRichText])
return;
var selectedRange = [self selectedRange],
pasteboard = [CPPasteboard generalPasteboard],
stringForPasting = [[self textStorage] attributedSubstringFromRange:CPMakeRangeCopy(selectedRange)],
richData = [_CPRTFProducer produceRTF:stringForPasting documentAttributes:@{}];
if ([self isRichText])
{
[pasteboard declareTypes:[CPStringPboardType, CPRTFPboardType, _CPSmartPboardType, _CPASPboardType] owner:nil];
[pasteboard setString:[stringForPasting._string stringByReplacingOccurrencesOfString:_CPAttachmentCharacterAsString withString:''] forType:CPStringPboardType];
[pasteboard setString:richData forType:CPRTFPboardType];
[pasteboard setString:_previousSelectionGranularity + '' forType:_CPSmartPboardType];
[pasteboard setString:[[CPKeyedArchiver archivedDataWithRootObject:stringForPasting] rawString] forType:_CPASPboardType];
}
else
{
[pasteboard declareTypes:[CPStringPboardType, _CPSmartPboardType] owner:nil];
[pasteboard setString:stringForPasting._string forType:CPStringPboardType];
[pasteboard setString:_previousSelectionGranularity + '' forType:_CPSmartPboardType];
}
}
- (void)_pasteString:(id)stringForPasting
@@ -510,9 +517,6 @@ var kDelegateRespondsTo_textShouldBeginEditing
- (void)paste:(id)sender
{
if (![sender isKindOfClass:_CPNativeInputManager] && [[CPApp currentEvent] type] != CPAppKitDefined)
return
[self _pasteString:[self _stringForPasting]];
}
@@ -2697,9 +2701,11 @@ var _CPCopyPlaceholder = '-';
var currentFirstResponder = [[CPApp keyWindow] firstResponder];
var isPlain = ![currentFirstResponder isRichText];
// Correctly check for shift key to force plain text paste.
if (!isPlain && !e.shiftKey && (richtext = nativeClipboard.getData('text/rtf'))) {
setTimeout(function() {
// Check for shift key to force plain text paste.
if (!isPlain && !e.shiftKey && (richtext = nativeClipboard.getData('text/rtf')))
{
setTimeout(function()
{
[currentFirstResponder paste:self];
}, 0);
return;
@@ -2722,9 +2728,9 @@ var _CPCopyPlaceholder = '-';
e.clipboardData.setData('text/plain', stringForPasting);
var rtfForPasting = [pasteboard stringForType:CPRTFPboardType];
if (rtfForPasting) {
if (rtfForPasting)
e.clipboardData.setData('text/rtf', rtfForPasting);
}
};
// CUT handler
+1 -1
View File
@@ -233,7 +233,7 @@ ObjectiveJFlattener.prototype.serializeFunctions = function() {
var functionString = executable._function.toString().replace(", require, exports, module, system, print, window", ""); // HACK
var relative = this.rootPath.relative(path).toString();
this.functionsBuffer.push("ObjectiveJ.StaticResource._cacheFunction(new CFURL("+JSON.stringify(relative)+", baseURL),\n"+functionString+");");
this.functionsBuffer.push("ObjectiveJ.FileExecutable._cacheFunction(new CFURL("+JSON.stringify(relative)+", baseURL),\n"+functionString+");");
}
var bundle = this.context.global.CFBundle.bundleContainingURL(path);
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
+16 -6
View File
@@ -4,14 +4,11 @@
var fs = require("fs"),
acorn = require("objj-parser"),
walk = require("objj-parser/util/walk"),
walk = require("acorn-walk"),
stream = ObjectiveJ.term;
debugger;
function main(args)
{
debugger;
args.shift();
if (args.length < 1)
@@ -40,6 +37,8 @@ function raise(pos, message)
throw syntaxError;
}
function ignore(_node, _st, _c) {}
var errors = [],
xcc = walk.make(
{
@@ -115,7 +114,18 @@ var errors = [],
else
raise(node.loc.start, "Action methods must have exactly one parameter");
}
}
},
TypeDefStatement: ignore,
ClassStatement: ignore,
MessageSendExpression: ignore,
GlobalStatement: ignore,
ProtocolDeclarationStatement: ignore,
ArrayLiteral: ignore,
Reference: ignore,
DictionaryLiteral: ignore,
Dereference: ignore,
ImportStatement: ignore,
SelectorLiteralExpression: ignore
}
);
@@ -154,7 +164,7 @@ function parser(args)
outputHeaderURL = new CFURL([outputDirectory stringByAppendingPathComponent:baseFilenameWithNoExtension + ".h"]),
outputImplementationURL = new CFURL([outputDirectory stringByAppendingPathComponent:baseFilenameWithNoExtension + ".m"]),
source = fs.readFileSync(sourcePath, { encoding: "utf8" }),
tokens = acorn.parse(source, { locations:true, sourceFile:sourcePath }),
tokens = acorn.parse(source, { locations:true, sourceFile:sourcePath, ecmaVersion: 2022 }),
classesInformation = [],
ObjectiveCSource = "",
ObjectiveCHeader = "",