This repository was archived by the owner on Jul 30, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathOctopusBeast.h
144 lines (107 loc) · 2.87 KB
/
OctopusBeast.h
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
//
// OctopusBeast.h
// Octopus
//
// Created by K3A on 5/20/12.
// Copyright (c) 2012 K3A. All rights reserved.
//
#import <UIKit/UIKit.h>
#include "octopuscore/OctopusDaemon/octopus.h"
#include <vector>
#define MAX_SUGGS 12
#define PREF_FILE "/var/mobile/Library/Preferences/me.k3a.OctopusKeyboard.plist"
#define UIKeyboardTypeTwitter 9
#define IS_IOS7 ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0)
struct sLine
{
float x1;
float x2; // must be higher than x1
int y;
sLine(float _x1, float _x2, int _y)
{
x1 = _x1; x2 = _x2; y = _y;
}
bool CollidesWith(const sLine& ln)const
{
return y == ln.y && ( (ln.x1 > x1 && ln.x1 < x2) || (x1 > ln.x1 && x1 < ln.x2) );
}
};
typedef std::vector<sLine> LineVector;
void OLog(int level, const char* format, ...);
void OErr(const char* format, ...);
@interface OctopusBeast : UIView {
NSString* _inputMode;
BOOL _rightToLeft;
NSMutableString* _input;
NSString* _prevWord;
NSMutableSet* _keysDrawn;
NSMutableString* _suggs[MAX_SUGGS];
sSuggestions _suggs_struct;
bool _isCorrection[MAX_SUGGS];
unsigned _numSuggs;
BOOL _capitalizeWord;
BOOL _serverOK;
int _swipeLength;
bool _autocapitalization;
BOOL _enabled;
BOOL _downPlural;
BOOL _abovekeys;
BOOL _isPad;
int _minChars;
BOOL _longPressed;
LineVector _lines;
BOOL hasPendingChanges;
BOOL processingUpdate;
UIColor* _textColor;
UIColor* _outlineColor;
}
@property (nonatomic,retain) id keyplane;
@property (nonatomic,copy) id input;
@property (nonatomic,retain) UITextInputTraits* traits;
+(OctopusBeast*)inst;
-(void)applyPrefs;
-(void)printKeyplane;
-(int)swipeLength;
-(BOOL)pluralOnSwipeDown;
-(BOOL)canComplete;
-(BOOL)shouldCapitalize;
-(void)releaseCompletionEngine;
-(void)initCompletionEngine;
-(void)setInputMode:(NSString*)inpM;
-(void)updateSuggestions;
-(void)inputAdd:(NSString*)str;
-(void)inputSet:(NSString*)str;
-(void)inputBackspace;
-(void)inputClear;
-(void)inputClearWord;
-(void)setContext:(NSString*)ctx word:(NSString*)word offset:(int)offset;
-(int)suggestionIndexForKey:(NSString*)k;
-(NSString*)suggestionForKey:(NSString*)k isCorrection:(BOOL*)corr;
-(void)acceptWord:(NSString*)w;
-(NSString*)acceptWordFromSuggestionKey:(NSString *)k;
-(NSString*)inputMode;
-(NSString*)inputString;
// long press (variation keys)
-(void)longPress;
-(void)resetLongPress;
-(BOOL)isLongPressed;
// color management
-(UIColor*)colorForText;
-(UIColor*)colorForOutline;
@end
#include <sys/time.h>
inline unsigned GetTimestampMsec()
{
timeval time;
gettimeofday(&time, NULL);
unsigned elapsed_seconds = time.tv_sec;
unsigned elapsed_useconds = time.tv_usec;
return elapsed_seconds * 1000 + elapsed_useconds/1000;
}
inline BOOL isPad() {
#ifdef UI_USER_INTERFACE_IDIOM
return (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad);
#else
return NO;
#endif
}