Skip to content

Commit

Permalink
(rime_proto.capnp): define capnproto schema for rime api
Browse files Browse the repository at this point in the history
  • Loading branch information
lotem committed Sep 5, 2020
1 parent d5b8814 commit 4a10263
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 2 deletions.
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ if(Boost_FOUND)
link_directories(${Boost_LIBRARY_DIRS})
endif()

find_package(CapnProto REQUIRED)

if(ENABLE_LOGGING)

find_package(Gflags)
Expand Down Expand Up @@ -149,7 +151,7 @@ if(MSVC)
endif()

if(UNIX)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
endif()

if(NOT DEFINED LIB_INSTALL_DIR)
Expand Down
8 changes: 7 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)

capnp_generate_cpp(CAPNP_SRCS CAPNP_HDRS rime_proto.capnp)
message(STATUS "compiled capnproto schema: ${CAPNP_SRCS} ${CAPNP_HDRS}")

aux_source_directory(. rime_api_src)
aux_source_directory(rime rime_base_src)
aux_source_directory(rime/algo rime_algo_src)
Expand All @@ -14,7 +17,8 @@ endif()
set(rime_core_module_src
${rime_api_src}
${rime_base_src}
${rime_config_src})
${rime_config_src}
${CAPNP_SRCS})
set(rime_dict_module_src
${rime_algo_src}
${rime_dict_src})
Expand All @@ -38,6 +42,7 @@ endif()

set(rime_core_deps
${Boost_LIBRARIES}
CapnProto::capnp
${Glog_LIBRARY}
${YamlCpp_LIBRARY}
${CMAKE_THREAD_LIBS_INIT}
Expand Down Expand Up @@ -69,6 +74,7 @@ endif()
if(BUILD_SHARED_LIBS)
add_library(rime ${rime_src})
target_link_libraries(rime ${rime_deps})
target_include_directories(rime PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
set_target_properties(rime PROPERTIES
DEFINE_SYMBOL "RIME_EXPORTS"
VERSION ${rime_version}
Expand Down
51 changes: 51 additions & 0 deletions src/rime_proto.capnp
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
@0xde912f558dde6b99;

struct RimeCommit {
# Text to commit to input field.
text @0 :Text;
}

struct RimeCandidate {
text @0 :Text;
comment @1 :Text;
}

struct RimeContext {
# Input context.

struct Composition {
# (de-)Compostion of current input.
length @0 :Int32;
cursorPos @1 :Int32;
selStart @2 :Int32;
selEnd @3 :Int32;
preedit @4 :Text;
commitTextPreview @5 :Text;
}

struct Menu {
# Menu of text candidates.
pageSize @0 :Int32;
pageNo @1 :Int32;
isLastPage @2 :Bool;
highlightedCandidateIndex @3 :Int32;
candidates @4 :List(RimeCandidate);
selectKeys @5 :Text;
selectLabels @6 :List(Text);
}

composition @0 :Composition;
menu @1 :Menu;
}

struct RimeStatus {
schemaId @0 :Text;
schemaName @1 :Text;
isDisabled @2 :Bool;
isComposing @3 :Bool;
isAsciiMode @4 :Bool;
isFullShape @5 :Bool;
isSimplified @6 :Bool;
isTraditional @7 :Bool;
isAsciiPunct @8 :Bool;
}

0 comments on commit 4a10263

Please sign in to comment.