t-suw****@users*****
t-suw****@users*****
2007年 10月 20日 (土) 12:17:17 JST
Index: AquaSKK/src/statemachine/GenericStateMachine.h
diff -u AquaSKK/src/statemachine/GenericStateMachine.h:1.1.2.4 AquaSKK/src/statemachine/GenericStateMachine.h:1.1.2.5
--- AquaSKK/src/statemachine/GenericStateMachine.h:1.1.2.4 Fri Oct 5 23:58:29 2007
+++ AquaSKK/src/statemachine/GenericStateMachine.h Sat Oct 20 12:17:17 2007
@@ -246,7 +246,7 @@
iter->second.push(event);
}
- void Transfer(const Handler key) {
+ void Commit(const Handler key) {
QueueIterator iter = find(key, arrival_);
if(iter != arrival_.end()) {
@@ -334,7 +334,7 @@
history_.Save(handler, prior_, active_);
}
- queue_.Transfer(handler);
+ queue_.Commit(handler);
prior_ = handler;
@@ -504,15 +504,18 @@
}
if(next.IsTransition() || next.IsDeepHistory() || next.IsForward() || next.IsDeepForward()) {
+ State target = next;
+
if(next.IsDeepHistory() || next.IsDeepForward()) {
- next = history_.Deep(next);
- assert(next != 0 && "*** Deep history not found ***");
+ target = history_.Deep(next);
+ assert(target != 0 && "*** Deep history not found ***");
}
- transition(source, next);
- initialize(next);
+ transition(source, target);
+ initialize(target);
if(next.IsForward() || next.IsDeepForward()) {
+ next = target;
continue;
}
Index: AquaSKK/src/statemachine/SKKCompletePolicy.h
diff -u /dev/null AquaSKK/src/statemachine/SKKCompletePolicy.h:1.1.2.1
--- /dev/null Sat Oct 20 12:17:17 2007
+++ AquaSKK/src/statemachine/SKKCompletePolicy.h Sat Oct 20 12:17:17 2007
@@ -0,0 +1,37 @@
+/* -*- C++ -*-
+ MacOS X implementation of the SKK input method.
+
+ Copyright (C) 2007 Tomotaka SUWA <t.suw****@mac*****>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#ifndef INC__SKKCompletePolicy__
+#define INC__SKKCompletePolicy__
+
+#include "SKKBackEnd.h"
+
+class SKKNormalComplete {
+ std::string entry_;
+
+public:
+ SKKNormalComplete(const std::string& entry) : entry_(entry) {}
+
+ void operator()(std::vector<std::string>& buffer) const {
+ SKKBackEnd::Complete(entry_, buffer);
+ }
+};
+
+#endif
Index: AquaSKK/src/statemachine/SKKState.cpp
diff -u AquaSKK/src/statemachine/SKKState.cpp:1.1.2.1 AquaSKK/src/statemachine/SKKState.cpp:1.1.2.2
--- AquaSKK/src/statemachine/SKKState.cpp:1.1.2.1 Fri Oct 5 23:58:29 2007
+++ AquaSKK/src/statemachine/SKKState.cpp Sat Oct 20 12:17:17 2007
@@ -24,6 +24,7 @@
#include "SKKStateKanaEntryHandler.h"
#include "SKKStateOkuriEntryHandler.h"
#include "SKKStateAsciiEntryHandler.h"
+#include "SKKStateEntryCompletionHandler.h"
#include "jconv.h"
typedef SKKState::Event Event;
@@ -327,19 +328,30 @@
State SKKState::EntryCompletion(const Event& event) {
const SKKEventParam& param = event.Param();
+ // ENTRY 以å¤ã®ã·ã¹ãã ã¤ãã³ãã¯ä¸ä½ç¶æ
ã«ã«ã¼ãã£ã³ã°
+ if(event.IsSystem() && event != ENTRY_EVENT) {
+ return &SKKState::Compose;
+ }
+
switch(event) {
case ENTRY_EVENT:
- //controller_->ChangeState(SKK::Completion);
- return 0;
- }
+ case SKK_HIRAKANA:
+ case SKK_KATAKANA:
+ case SKK_JISX0201KANA:
+ case SKK_ASCII:
+ case SKK_JISX0208LATIN:
+ return EntryCompletionHandler<ENTRY_EVENT>();
- // ã·ã¹ãã ã¤ãã³ãã¨å¤æã¯ç¡è¦ãã
- if(event.IsSystem() ||
- event == SKK_TAB ||
- (event == SKK_CHAR && (param.IsNextCandidate() ||
- param.IsNextCompletion() ||
- param.IsPrevCompletion()))) {
- return &SKKState::Compose;
+ case SKK_TAB:
+ return EntryCompletionHandler<SKK_TAB>();
+
+ case SKK_CHAR:
+ if(param.IsNextCompletion() || param.IsPrevCompletion()) {
+ return EntryCompletionHandler<SKK_CHAR>(param);
+ }
+ if(param.IsNextCandidate()) {
+ return &SKKState::Compose;
+ }
}
// è£å®ãã¼ä»¥å¤ãªãå±¥æ´ã«è»¢éãã
@@ -458,23 +470,23 @@
void SKKState::composeDisplay() {
SKKOutputPort& port = context().OutputPort();
SKKInputBuffer& input = context().InputBuffer();
- SKKEditBuffer edit(context().EditBuffer());
+ SKKEditBuffer tmp(context().EditBuffer());
if(!input.IsEmpty()) {
- edit.Insert(input.InputString());
+ tmp.Insert(input.InputString());
}
- port.DisplayString("â½" + edit.EditString(), 1 + edit.CursorPosition());
+ port.DisplayString("â½" + tmp.EditString(), 1 + tmp.CursorPosition());
}
void SKKState::okuriDisplay() {
SKKOutputPort& port = context().OutputPort();
SKKOkuriBuffer& okuri = context().OkuriBuffer();
- SKKEditBuffer edit(context().EditBuffer());
+ SKKEditBuffer tmp(context().EditBuffer());
- edit.Insert("*" + okuri.KanaString());
+ tmp.Insert("*" + okuri.KanaString());
- port.DisplayString("â½" + edit.EditString(), 1 + edit.CursorPosition());
+ port.DisplayString("â½" + tmp.EditString(), 1 + tmp.CursorPosition());
}
void SKKState::toggleKana() {
Index: AquaSKK/src/statemachine/SKKState.h
diff -u AquaSKK/src/statemachine/SKKState.h:1.1.2.1 AquaSKK/src/statemachine/SKKState.h:1.1.2.2
--- AquaSKK/src/statemachine/SKKState.h:1.1.2.1 Fri Oct 5 23:58:29 2007
+++ AquaSKK/src/statemachine/SKKState.h Sat Oct 20 12:17:17 2007
@@ -40,12 +40,19 @@
// ã¤ãã³ããã³ãã©
template <int Signal> State DirectHandler();
template <int Signal> State DirectHandler(const SKKEventParam& param);
+
template <int Signal> State ComposeHandler();
+
template <int Signal> State KanaEntryHandler(const SKKEventParam& event);
+
template <int Signal> State OkuriEntryHandler();
template <int Signal> State OkuriEntryHandler(const SKKEventParam& event);
+
template <int Signal> State AsciiEntryHandler(const SKKEventParam& event);
+ template <int Signal> State EntryCompletionHandler();
+ template <int Signal> State EntryCompletionHandler(const SKKEventParam& event);
+
// 表示
void composeDisplay();
void okuriDisplay();
Index: AquaSKK/src/statemachine/SKKStateComposeHandler.h
diff -u AquaSKK/src/statemachine/SKKStateComposeHandler.h:1.1.2.1 AquaSKK/src/statemachine/SKKStateComposeHandler.h:1.1.2.2
--- AquaSKK/src/statemachine/SKKStateComposeHandler.h:1.1.2.1 Fri Oct 5 23:58:29 2007
+++ AquaSKK/src/statemachine/SKKStateComposeHandler.h Sat Oct 20 12:17:17 2007
@@ -22,6 +22,7 @@
#define INC__SKKStateComposeHandler__
#include "SKKState.h"
+#include "SKKCompletePolicy.h"
typedef SKKState::State State;
@@ -106,13 +107,14 @@
template <>
State SKKState::ComposeHandler<SKK_TAB>() {
- // æ¤ç´¢ã§ããï¼
- if(0) {
- // è£å®ã¢ã¼ã
+ SKKEditBuffer& edit = context().EditBuffer();
+ SKKCompletionBuffer& comp = context().CompletionBuffer();
+
+ if(comp.Complete(SKKNormalComplete(edit.EditString()))) {
return State::Transition(&SKKState::EntryCompletion);
- } else {
- return 0;
}
+
+ return 0;
}
template <>
Index: AquaSKK/src/statemachine/SKKStateEntryCompletionHandler.h
diff -u /dev/null AquaSKK/src/statemachine/SKKStateEntryCompletionHandler.h:1.1.2.1
--- /dev/null Sat Oct 20 12:17:17 2007
+++ AquaSKK/src/statemachine/SKKStateEntryCompletionHandler.h Sat Oct 20 12:17:17 2007
@@ -0,0 +1,66 @@
+/* -*- C++ -*-
+ MacOS X implementation of the SKK input method.
+
+ Copyright (C) 2007 Tomotaka SUWA <t.suw****@mac*****>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#ifndef INC__SKKEntryCompletionHandler__
+#define INC__SKKEntryCompletionHandler__
+
+#include "SKKState.h"
+#include <iostream>
+
+typedef SKKState::State State;
+
+// ======================================================================
+// è£å®
+// ======================================================================
+
+template <>
+State SKKState::EntryCompletionHandler<ENTRY_EVENT>() {
+ SKKEditBuffer& edit = context().EditBuffer();
+ SKKCompletionBuffer& comp = context().CompletionBuffer();
+
+ edit.Clear();
+ edit.Insert(comp.CurrentString());
+
+ composeDisplay();
+
+ return 0;
+}
+
+template <>
+State SKKState::EntryCompletionHandler<SKK_TAB>() {
+ context().CompletionBuffer().Next();
+
+ return State::Transition(&SKKState::EntryCompletion);
+}
+
+template <>
+State SKKState::EntryCompletionHandler<SKK_CHAR>(const SKKEventParam& param) {
+ if(param.IsNextCompletion()) {
+ return EntryCompletionHandler<SKK_TAB>();
+ }
+
+ if(param.IsPrevCompletion()) {
+ context().CompletionBuffer().Prev();
+ }
+
+ return State::Transition(&SKKState::EntryCompletion);
+}
+
+#endif