Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .clangd
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
CompileFlags:
Add:
- "-isysroot"
- "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk"
- "-I${workspaceFolder}/Sources/OpenKey/engine"
- "-I${workspaceFolder}/Sources/OpenKey/macOS/ModernKey"
- "-x"
- "objective-c++"
- "-std=c++11"
- "-fobjc-arc"
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
################################################################################
################################################################################
# This .gitignore file was automatically created by Microsoft(R) Visual Studio.
################################################################################

Expand All @@ -8,3 +8,6 @@
/Sources/OpenKey/win32/OpenKey/OpenKey/x64/Debug
/Sources/OpenKey/win32/OpenKey/OpenKey/x64/Release
/Sources/OpenKey/win32/OpenKey/OpenKeyUpdate/x64/Release
build/
.DS_Store
scratch/
39 changes: 34 additions & 5 deletions Sources/OpenKey/engine/Engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,36 @@ void startNewSession() {
_longWordHelper.clear();
}

Byte getCurrentWordIndex() {
return _index;
}

bool isCurrentWordActive() {
return _index > 0 && _spaceCount == 0;
}

bool loadCurrentTypingWord(const std::vector<Uint32>& wordData) {
if (wordData.empty() || wordData.size() >= MAX_BUFF) return false;
startNewSession();
_index = (Byte)wordData.size();
for (size_t idx = 0; idx < wordData.size(); idx++) {
TypingWord[idx] = wordData[idx];
KeyStates[idx] = (wordData[idx] & CHAR_MASK) | (wordData[idx] & CAPS_MASK);
}
_stateIndex = _index;
_spellingEndIndex = _index;
findAndCalculateVowel();
return true;
}

void getCurrentTypingWord(std::vector<Uint32>& outData) {
outData.clear();
outData.reserve(_index);
for (Byte i = 0; i < _index; i++) {
outData.push_back(TypingWord[i]);
}
}

void checkCorrectVowel(vector<vector<Uint16>>& charset, int& i, int& k, const Uint16& markKey) {
//ignore "qu" case
if (_index >= 2 && CHR(_index-1) == KEY_U && CHR(_index-2) == KEY_Q) {
Expand Down Expand Up @@ -669,9 +699,9 @@ void handleModernMark() {
CHR(VSI+2) == KEY_M || CHR(VSI+2) == KEY_N ||
CHR(VSI+2) == KEY_O || CHR(VSI+2) == KEY_U ||
CHR(VSI+2) == KEY_I || CHR(VSI+2) == KEY_C ||
(VSI+3 < _index && CHR(VSI+2) == KEY_C && CHR(VSI+2) == KEY_H) ||
(VSI+3 < _index && CHR(VSI+2) == KEY_N && CHR(VSI+2) == KEY_H) ||
(VSI+3 < _index && CHR(VSI+2) == KEY_N && CHR(VSI+2) == KEY_G)) {
(VSI+3 < _index && CHR(VSI+2) == KEY_C && CHR(VSI+3) == KEY_H) ||
(VSI+3 < _index && CHR(VSI+2) == KEY_N && CHR(VSI+3) == KEY_H) ||
(VSI+3 < _index && CHR(VSI+2) == KEY_N && CHR(VSI+3) == KEY_G)) {

VWSM = VSI + 1;
hBPC = _index - VWSM;
Expand Down Expand Up @@ -799,9 +829,8 @@ void insertMark(const Uint32& markMask, const bool& canModifyFlag) {
}
hData[kk--] = GET(TypingWord[ii]);
}

hBPC = _index - VSI;
}
hBPC = _index - VSI;
hNCC = hBPC;
}

Expand Down
8 changes: 8 additions & 0 deletions Sources/OpenKey/engine/Engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,14 @@ void vKeyHandleEvent(const vKeyEvent& event,
*/
void startNewSession();

/**
* Get current word index and load external word into engine
*/
Byte getCurrentWordIndex();
bool isCurrentWordActive();
bool loadCurrentTypingWord(const std::vector<Uint32>& wordData);
void getCurrentTypingWord(std::vector<Uint32>& outData);

/**
* do some task in english mode (use for macro)
*/
Expand Down
6 changes: 6 additions & 0 deletions Sources/OpenKey/macOS/ModernKey/MacroViewController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
//

#import "MacroViewController.h"
#if __has_include("Engine.h")
#include "Engine.h"
#elif __has_include("../../engine/Engine.h")
#include "../../engine/Engine.h"
#endif

#define MACRO_ADD_TEXT @"Thêm"
#define MACRO_EDIT_TEXT @"Sửa"
Expand All @@ -22,6 +26,8 @@ @implementation MacroViewController{
vector<string> macroContent;
}

@synthesize macroContent = _macroContent;

- (void)viewDidLoad {
[super viewDidLoad];
self.tableView.dataSource = self;
Expand Down
Loading