[aquaskk-changes 356] CVS update: AquaSKK/src/controller

Back to archive index

t-suw****@users***** t-suw****@users*****
2007年 9月 2日 (日) 12:36:25 JST


Index: AquaSKK/src/controller/SKKController.cpp
diff -u /dev/null AquaSKK/src/controller/SKKController.cpp:1.1.2.1
--- /dev/null	Sun Sep  2 12:36:25 2007
+++ AquaSKK/src/controller/SKKController.cpp	Sun Sep  2 12:36:25 2007
@@ -0,0 +1,136 @@
+/* -*- 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
+*/
+
+#include "SKKController.h"
+#include "SKKSubController.h"
+
+typedef SKKController::Event Event;
+typedef SKKController::State State;
+typedef SKKController::Handler Handler;
+typedef SKKController::Output Output;
+
+static SKKEventParam dummy;
+
+SKKController::SKKController() {
+    // プライマリエディタを生成
+    stack_.push_back(SKKEditor());
+}
+
+// 処理結果
+const Output& SKKController::Result() const {
+    return editor().Result();
+}
+
+// キー入力処理
+State SKKController::HandleInput(const SKKEventParam& param) {
+    return invoke(&SKKEditor::HandleInput, param);
+}
+
+State SKKController::HandleJmode() {
+    return invoke(&SKKEditor::HandleJmode, dummy);
+}
+
+State SKKController::HandleEnter() {
+    return invoke(&SKKEditor::HandleEnter, dummy);
+}
+
+State SKKController::HandleCancel() {
+    return invoke(&SKKEditor::HandleCancel, dummy);
+}
+
+State SKKController::HandleBackSpace() {
+    return invoke(&SKKEditor::HandleBackSpace, dummy);
+}
+
+State SKKController::HandleDelete() {
+    return invoke(&SKKEditor::HandleDelete, dummy);
+}
+
+State SKKController::HandleTab() {
+    return invoke(&SKKEditor::HandleTab, dummy);
+}
+
+State SKKController::HandlePaste() {
+    return invoke(&SKKEditor::HandlePaste, dummy);
+}
+
+State SKKController::HandleCursorLeft() {
+    return invoke(&SKKEditor::HandleCursorLeft, dummy);
+}
+
+State SKKController::HandleCursorRight() {
+    return invoke(&SKKEditor::HandleCursorRight, dummy);
+}
+
+State SKKController::HandleCursorUp() {
+    return invoke(&SKKEditor::HandleCursorUp, dummy);
+}
+
+State SKKController::HandleCursorDown() {
+    return invoke(&SKKEditor::HandleCursorDown, dummy);
+}
+
+// 入力モード変更
+void SKKController::SelectInputMode(SKK::InputMode mode) {
+    editor().SelectInputMode(mode);
+}
+
+// 内部状態変更
+void SKKController::ChangeState(SKK::EditState state) {
+    editor().ChangeState(state);
+}
+
+// 登録開始
+void SKKController::BeginRegistration(const std::string& prompt) {
+    stack_.push_back(SKKEditor(prompt));
+}
+
+// 登録終了
+void SKKController::EndRegistration(bool commit) {
+    if(stack_.size() == 1) return;
+
+    std::string result = editor().EditString();
+
+    stack_.pop_back();
+
+    if(commit) {
+	editor().Commit(result);
+    }
+}
+
+// ======================================================================
+// private method
+// ======================================================================
+SKKEditor& SKKController::editor() {
+    return stack_.back();
+}
+
+const SKKEditor& SKKController::editor() const {
+    return stack_.back();
+}
+
+State SKKController::invoke(SKKEditor::Handler handler, const SKKEventParam& param) {
+    // SKKEditor.HandleXXX を起動する
+    std::auto_ptr<SKKSubController> sub((editor().*handler)(param));
+
+    // 副作用を適用する
+    return sub->Apply(*this);
+}
Index: AquaSKK/src/controller/SKKController.h
diff -u /dev/null AquaSKK/src/controller/SKKController.h:1.1.2.1
--- /dev/null	Sun Sep  2 12:36:25 2007
+++ AquaSKK/src/controller/SKKController.h	Sun Sep  2 12:36:25 2007
@@ -0,0 +1,77 @@
+/* -*- C++ -*-
+   $Id: SKKController.h,v 1.1.2.1 2007/09/02 03:36:25 t-suwa Exp $
+
+   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__SKKController__
+#define INC__SKKController__
+
+#include <string>
+#include <vector>
+#include "SKK.h"
+#include "SKKEventParam.h"
+#include "SKKEnvironment.h"
+#include "SKKEditor.h"
+
+struct SKKController {
+    typedef SKKEnvironment::State State;
+    typedef SKKEnvironment::Event Event;
+    typedef SKKEnvironment::Handler Handler;
+    typedef SKKEnvironment::Output Output;
+
+    SKKController();
+
+    // 処理結果
+    const Output& Result() const;
+
+    // キー入力処理
+    State HandleInput(const SKKEventParam& param);
+    State HandleJmode();
+    State HandleEnter();
+    State HandleCancel();
+    State HandleBackSpace();
+    State HandleDelete();
+    State HandleTab();
+    State HandlePaste();
+    State HandleCursorLeft();
+    State HandleCursorRight();
+    State HandleCursorUp();
+    State HandleCursorDown();
+
+    // 入力モード変更
+    void SelectInputMode(SKK::InputMode);
+
+    // 内部状態変更
+    void ChangeState(SKK::EditState);
+
+    // 再帰的辞書登録
+    void BeginRegistration(const std::string& prompt);
+    void EndRegistration(bool commit);
+
+private:
+    std::vector<SKKEditor> stack_;
+
+    SKKEditor& editor();
+    const SKKEditor& editor() const;
+
+    State invoke(SKKEditor::Handler handler, const SKKEventParam& param);
+};
+
+#endif
Index: AquaSKK/src/controller/SKKEmptySubController.cpp
diff -u /dev/null AquaSKK/src/controller/SKKEmptySubController.cpp:1.1.2.1
--- /dev/null	Sun Sep  2 12:36:25 2007
+++ AquaSKK/src/controller/SKKEmptySubController.cpp	Sun Sep  2 12:36:25 2007
@@ -0,0 +1,29 @@
+/* -*- 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
+*/
+
+#include "SKKEmptySubController.h"
+
+SKKEmptySubController::SKKEmptySubController(State target) : state_(target) {
+}
+
+SKKEmptySubController::State SKKEmptySubController::Apply(SKKController&) {
+    return state_;
+}
Index: AquaSKK/src/controller/SKKEmptySubController.h
diff -u /dev/null AquaSKK/src/controller/SKKEmptySubController.h:1.1.2.1
--- /dev/null	Sun Sep  2 12:36:25 2007
+++ AquaSKK/src/controller/SKKEmptySubController.h	Sun Sep  2 12:36:25 2007
@@ -0,0 +1,39 @@
+/* -*- 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__SKKEmptySubController__
+#define INC__SKKEmptySubController__
+
+#include "SKKSubController.h"
+
+// 空のマニピュレーター
+class SKKEmptySubController : public SKKSubController {
+    State state_;
+
+    SKKEmptySubController();
+
+public:
+    SKKEmptySubController(State target);
+
+    virtual State Apply(SKKController& controller);
+};
+
+#endif
Index: AquaSKK/src/controller/SKKSubController.h
diff -u /dev/null AquaSKK/src/controller/SKKSubController.h:1.1.2.1
--- /dev/null	Sun Sep  2 12:36:25 2007
+++ AquaSKK/src/controller/SKKSubController.h	Sun Sep  2 12:36:25 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__SKKSubController__
+#define INC__SKKSubController__
+
+#include "SKKController.h"
+
+// SKKController 用マニピュレーター
+struct SKKSubController {
+    typedef SKKController::State State;
+    typedef SKKController::Event Event;
+    typedef SKKController::Handler Handler;
+    typedef SKKController::Output Output;
+
+    virtual State Apply(SKKController& controller) = 0;
+};
+
+#endif


aquaskk-changes メーリングリストの案内
Back to archive index