mirror of
https://github.com/keymanapp/keyman.git
synced 2026-08-28 19:27:44 +00:00
chore(developer): remove some comments
This commit is contained in:
parent
09f7eefeca
commit
34bd86b706
7 changed files with 5 additions and 263 deletions
|
|
@ -11,7 +11,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "kmx_base.h"
|
||||
#include "../debug.hpp" // _S2 #include <debug.hpp>
|
||||
#include <debug.hpp>
|
||||
|
||||
namespace km {
|
||||
namespace kbp {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#include <string>
|
||||
|
||||
#include "../option.hpp" // _S2 #include "option.hpp"
|
||||
#include "option.hpp"
|
||||
#include "kmx_base.h"
|
||||
|
||||
namespace km {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
#include <vector>
|
||||
|
||||
#include <keyman/keyboardprocessor.h>
|
||||
#include "../option.hpp"
|
||||
#include "option.hpp"
|
||||
|
||||
#include "kmx_base.h"
|
||||
#include "kmx_debugger.h"
|
||||
|
|
|
|||
|
|
@ -489,8 +489,6 @@ int KMX_ProcessEvent::PostString(PKMX_WCHAR str, LPKEYBOARD lpkb, PKMX_WCHAR end
|
|||
case CODE_CALL:
|
||||
p++;
|
||||
m_kbp_state->imx_callback(*p-1);
|
||||
// _S2 m_kbp_state->imx_callback(*p-1); // _S2 DebugLog("CallDLL not supported [store=%d].\n", *p-1);
|
||||
|
||||
FoundUse = TRUE;
|
||||
break;
|
||||
case CODE_USE: // use another group
|
||||
|
|
|
|||
|
|
@ -378,206 +378,3 @@ km_kbp_keyboard_imx * kmx_processor::get_imx_list() const {
|
|||
imx_list[fn_idx] = KM_KBP_KEYBOARD_IMX_END;
|
||||
return imx_list;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//*********** _S2 old ******************
|
||||
/*
|
||||
|
||||
#include <keyman/keyboardprocessor.h>
|
||||
#include "state.hpp"
|
||||
#include "kmx/kmx_processor.hpp"
|
||||
|
||||
using namespace km::kbp;
|
||||
using namespace kmx;
|
||||
|
||||
km_kbp_status kmx_processor::validate() const {
|
||||
return _valid ? KM_KBP_STATUS_OK : KM_KBP_STATUS_INVALID_KEYBOARD;
|
||||
}
|
||||
|
||||
kmx_processor::kmx_processor(kbp::path p) {
|
||||
p.replace_extension(".kmx");
|
||||
_valid = bool(_kmx.Load(p.c_str()));
|
||||
|
||||
if (!_valid)
|
||||
return;
|
||||
|
||||
keyboard_attributes::options_store defaults;
|
||||
_kmx.GetOptions()->Init(defaults);
|
||||
|
||||
for (auto const & opt: defaults)
|
||||
{
|
||||
if (!opt.empty() && opt.scope == KM_KBP_OPT_KEYBOARD )
|
||||
persisted_store()[opt.key] = opt.value;
|
||||
}
|
||||
// Fill out attributes
|
||||
auto v = _kmx.GetKeyboard()->Keyboard->version;
|
||||
auto vs = std::to_string(v >> 16) + "." + std::to_string(v & 0xffff);
|
||||
|
||||
_attributes = keyboard_attributes(static_cast<std::u16string>(p.stem()),
|
||||
std::u16string(vs.begin(), vs.end()), p.parent(), defaults);
|
||||
}
|
||||
|
||||
char16_t const *
|
||||
kmx_processor::lookup_option(
|
||||
km_kbp_option_scope scope,
|
||||
std::u16string const &key
|
||||
) const {
|
||||
char16_t const *pValue = nullptr;
|
||||
switch (scope) {
|
||||
case KM_KBP_OPT_KEYBOARD:
|
||||
pValue = _kmx.GetOptions()->LookUp(key);
|
||||
break;
|
||||
case KM_KBP_OPT_ENVIRONMENT:
|
||||
pValue = _kmx.GetEnvironment()->LookUp(key);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return pValue ? pValue : nullptr;
|
||||
}
|
||||
|
||||
option
|
||||
kmx_processor::update_option(
|
||||
km_kbp_option_scope scope,
|
||||
std::u16string const &key,
|
||||
std::u16string const &value
|
||||
) {
|
||||
switch (scope) {
|
||||
case KM_KBP_OPT_KEYBOARD:
|
||||
_kmx.GetOptions()->Set(key, value);
|
||||
persisted_store()[key] = value;
|
||||
break;
|
||||
case KM_KBP_OPT_ENVIRONMENT:
|
||||
_kmx.GetEnvironment()->Set(key, value);
|
||||
break;
|
||||
default:
|
||||
return option();
|
||||
break;
|
||||
}
|
||||
|
||||
return option(scope, key, value);
|
||||
}
|
||||
|
||||
km_kbp_status
|
||||
kmx_processor::process_event(
|
||||
km_kbp_state *state,
|
||||
km_kbp_virtual_key vk,
|
||||
uint16_t modifier_state,
|
||||
uint8_t is_key_down
|
||||
) {
|
||||
// Construct a context buffer from the items
|
||||
|
||||
std::u16string ctxt;
|
||||
auto cp = state->context();
|
||||
for (auto c = cp.begin(); c != cp.end(); c++) {
|
||||
switch (c->type) {
|
||||
case KM_KBP_CT_CHAR:
|
||||
if (Uni_IsSMP(c->character)) {
|
||||
ctxt += Uni_UTF32ToSurrogate1(c->character);
|
||||
ctxt += Uni_UTF32ToSurrogate2(c->character);
|
||||
} else {
|
||||
ctxt += (km_kbp_cp)c->character;
|
||||
}
|
||||
break;
|
||||
case KM_KBP_CT_MARKER:
|
||||
assert(c->marker > 0);
|
||||
ctxt += UC_SENTINEL;
|
||||
ctxt += CODE_DEADKEY;
|
||||
ctxt += c->marker;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
_kmx.GetContext()->Set(ctxt.c_str());
|
||||
_kmx.GetActions()->ResetQueue();
|
||||
state->actions().clear();
|
||||
|
||||
if (!_kmx.ProcessEvent(state, vk, modifier_state, is_key_down)) {
|
||||
// We need to output the default keystroke
|
||||
state->actions().push_emit_keystroke();
|
||||
}
|
||||
|
||||
for (auto i = 0; i < _kmx.GetActions()->Length(); i++) {
|
||||
auto a = _kmx.GetActions()->Get(i);
|
||||
switch (a.ItemType) {
|
||||
case QIT_CAPSLOCK:
|
||||
state->actions().push_capslock(a.dwData);
|
||||
break;
|
||||
case QIT_VKEYDOWN:
|
||||
case QIT_VKEYUP:
|
||||
case QIT_VSHIFTDOWN:
|
||||
case QIT_VSHIFTUP:
|
||||
// TODO: eliminate??
|
||||
break;
|
||||
case QIT_CHAR:
|
||||
state->context().push_character(a.dwData);
|
||||
state->actions().push_character(a.dwData);
|
||||
break;
|
||||
case QIT_DEADKEY:
|
||||
state->context().push_marker(a.dwData);
|
||||
state->actions().push_marker(a.dwData);
|
||||
break;
|
||||
case QIT_BELL:
|
||||
state->actions().push_alert();
|
||||
break;
|
||||
case QIT_BACK:
|
||||
switch (a.dwData) {
|
||||
case BK_DEFAULT:
|
||||
// This only happens if we know we have context to delete. Last item must be a character
|
||||
assert(!state->context().empty());
|
||||
assert(state->context().back().type != KM_KBP_IT_MARKER);
|
||||
if(!state->context().empty()) {
|
||||
auto item = state->context().back();
|
||||
state->context().pop_back();
|
||||
state->actions().push_backspace(KM_KBP_BT_CHAR, item.character);
|
||||
} else {
|
||||
// Note: only runs on non-debug build, fail safe
|
||||
state->actions().push_backspace(KM_KBP_BT_UNKNOWN);
|
||||
}
|
||||
break;
|
||||
case BK_DEADKEY:
|
||||
// This only happens if we know we have context to delete. Last item must be a deadkey
|
||||
assert(!state->context().empty());
|
||||
assert(state->context().back().type == KM_KBP_IT_MARKER);
|
||||
if(!state->context().empty()) {
|
||||
auto item = state->context().back();
|
||||
state->context().pop_back();
|
||||
state->actions().push_backspace(KM_KBP_BT_MARKER, item.marker);
|
||||
} else {
|
||||
// Note: only runs on non-debug build, fail safe
|
||||
state->actions().push_backspace(KM_KBP_BT_UNKNOWN);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
assert(false);
|
||||
}
|
||||
break;
|
||||
case QIT_INVALIDATECONTEXT:
|
||||
state->actions().push_invalidate_context();
|
||||
break;
|
||||
default:
|
||||
// std::cout << "Unexpected item type " << a.ItemType << ", " << a.dwData << std::endl;
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
|
||||
state->actions().commit();
|
||||
|
||||
return KM_KBP_STATUS_OK;
|
||||
}
|
||||
|
||||
constexpr km_kbp_attr const engine_attrs = {
|
||||
256,
|
||||
KM_KBP_LIB_CURRENT,
|
||||
KM_KBP_LIB_AGE,
|
||||
KM_KBP_LIB_REVISION,
|
||||
KM_KBP_TECH_KMX,
|
||||
"SIL International"
|
||||
};
|
||||
|
||||
km_kbp_attr const & kmx_processor::attributes() const {
|
||||
return engine_attrs;
|
||||
}
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -76,56 +76,3 @@ namespace kbp
|
|||
|
||||
} // namespace kbp
|
||||
} // namespace km
|
||||
|
||||
|
||||
//***** _S2 old **********************************
|
||||
/*
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <keyman/keyboardprocessor.h>
|
||||
#include "kmx/kmx_processevent.h"
|
||||
#include "keyboard.hpp"
|
||||
#include "processor.hpp"
|
||||
|
||||
namespace km {
|
||||
namespace kbp
|
||||
{
|
||||
class kmx_processor : public abstract_processor
|
||||
{
|
||||
private:
|
||||
bool _valid;
|
||||
kmx::KMX_ProcessEvent _kmx;
|
||||
public:
|
||||
kmx_processor(path);
|
||||
|
||||
km_kbp_status
|
||||
process_event(
|
||||
km_kbp_state *state,
|
||||
km_kbp_virtual_key vk,
|
||||
uint16_t modifier_state,
|
||||
uint8_t is_key_down
|
||||
) override;
|
||||
|
||||
km_kbp_attr const & attributes() const override;
|
||||
km_kbp_status validate() const override;
|
||||
|
||||
char16_t const *
|
||||
lookup_option(
|
||||
km_kbp_option_scope,
|
||||
std::u16string const & key
|
||||
) const override;
|
||||
|
||||
option
|
||||
update_option(
|
||||
km_kbp_option_scope scope,
|
||||
std::u16string const & key,
|
||||
std::u16string const & value
|
||||
) override;
|
||||
};
|
||||
|
||||
} // namespace kbp
|
||||
} // namespace km
|
||||
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -11,10 +11,10 @@ namespace kmx {
|
|||
#define Uni_IsSMP(ch) ((ch) >= 0x10000)
|
||||
|
||||
#define Uni_SurrogateToUTF32(ch, cl) (((ch) - 0xD800) * 0x400 + ((cl) - 0xDC00) + 0x10000)
|
||||
/* _ S2
|
||||
|
||||
#define Uni_UTF32ToSurrogate1(ch) (char16_t)(((ch) - 0x10000) / 0x400 + 0xD800)
|
||||
#define Uni_UTF32ToSurrogate2(ch) (char16_t)(((ch) - 0x10000) % 0x400 + 0xDC00)
|
||||
*/
|
||||
|
||||
PKMX_WCHAR incxstr(PKMX_WCHAR p);
|
||||
PKMX_WCHAR decxstr(PKMX_WCHAR p, PKMX_WCHAR pStart);
|
||||
int xstrlen(PKMX_WCHAR p);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue