-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aa16c2e
commit 1b3fafa
Showing
10 changed files
with
94 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
add_library(FcitxCommon common.cpp) | ||
add_library(FcitxCommon | ||
common.cpp | ||
inputmethod.cpp | ||
) | ||
target_include_directories(FcitxCommon PRIVATE | ||
"${PROJECT_SOURCE_DIR}/fcitx5/src/modules/notifications" | ||
) | ||
target_link_libraries(FcitxCommon Fcitx5::Core) | ||
target_link_libraries(FcitxCommon Fcitx5::Core nlohmann_json) | ||
|
||
add_library(SwiftUtil util.swift) | ||
set_target_properties(SwiftUtil PROPERTIES Swift_MODULE_NAME SwiftUtil) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#include <string> | ||
|
||
std::string getInputMethods(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#include "common-public.h" | ||
#include "common.h" | ||
#include <fcitx/inputmethodentry.h> | ||
#include <fcitx/inputmethodmanager.h> | ||
#include <nlohmann/json.hpp> | ||
|
||
static nlohmann::json jsonDescribeIm(const fcitx::InputMethodEntry *entry) { | ||
nlohmann::json j; | ||
j["name"] = entry->uniqueName(); | ||
j["displayName"] = entry->nativeName() != "" ? entry->nativeName() | ||
: entry->name() != "" ? entry->name() | ||
: entry->uniqueName(); | ||
j["languageCode"] = entry->languageCode(); | ||
return j; | ||
} | ||
|
||
std::string getInputMethods() { | ||
static std::string ret; | ||
nlohmann::json j; | ||
auto &imMgr = instance->inputMethodManager(); | ||
auto group = imMgr.currentGroup(); | ||
bool empty = true; | ||
for (const auto &im : group.inputMethodList()) { | ||
auto entry = imMgr.entry(im.name()); | ||
if (!entry) | ||
continue; | ||
empty = false; | ||
j.push_back(jsonDescribeIm(entry)); | ||
} | ||
if (empty) { // j is not treated array | ||
return "[]"; | ||
} | ||
ret = j.dump(); | ||
return ret.c_str(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module FcitxCommon { | ||
header "common-public.h" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import SwiftUI | ||
|
||
struct ConfigView: View { | ||
let inputMethod: InputMethod | ||
|
||
var body: some View { | ||
VStack { | ||
} | ||
.navigationTitle(inputMethod.displayName) | ||
.navigationBarTitleDisplayMode(.inline) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters