forked from OwnGoalStudio/TrollVNC
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClipboardManager.h
More file actions
59 lines (41 loc) · 1.99 KB
/
Copy pathClipboardManager.h
File metadata and controls
59 lines (41 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*
This file is part of TrollVNC
Copyright (c) 2025 82Flex <82flex@gmail.com> and contributors
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2
as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef ClipboardManager_h
#define ClipboardManager_h
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
/// Lightweight clipboard manager that only supports UTF-8 text.
/// Wraps UIPasteboard and listens for the Darwin notification: com.apple.pasteboard.notify.changed.
/// Exposes an onChange callback invoked on the main thread.
@interface ClipboardManager : NSObject
/// Global singleton instance
+ (instancetype)sharedManager;
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
/// Start listening for clipboard changes (idempotent)
- (void)start;
/// Stop listening for clipboard changes (safe to call multiple times)
- (void)stop;
/// Get current clipboard string (UTF-8). Returns nil if no plain text is available.
- (nullable NSString *)currentString;
/// Set clipboard string (UTF-8). Internally tries to avoid self-triggered callback loops.
- (void)setString:(NSString *)text;
/// Set clipboard string originating from a remote VNC client. This avoids echo by
/// skipping the immediate local callback and the subsequent system notification once.
- (void)setStringFromRemote:(NSString *)text;
/// Clipboard change callback (executed on the main thread; text is nil when no plain text).
@property (atomic, copy, nullable) void (^onChange)(NSString *_Nullable text);
@end
NS_ASSUME_NONNULL_END
#endif /* ClipboardManager_h */