t-suw****@users*****
t-suw****@users*****
2007年 9月 24日 (月) 11:09:04 JST
Index: AquaSKK/src/editor/SKKDirectInputState.cpp diff -u AquaSKK/src/editor/SKKDirectInputState.cpp:1.1.2.2 AquaSKK/src/editor/SKKDirectInputState.cpp:1.1.2.3 --- AquaSKK/src/editor/SKKDirectInputState.cpp:1.1.2.2 Sun Sep 16 09:18:52 2007 +++ AquaSKK/src/editor/SKKDirectInputState.cpp Mon Sep 24 11:09:04 2007 @@ -37,9 +37,8 @@ } SKKInputBuffer& buffer = context.InputBuffer(); - if(buffer.Input(param.code)) { - std::cerr << buffer.FixedString(); - } else { + SKKOutputPort& port = context.OutputPort(); + if(!buffer.Input(param.code)) { State state = 0; // 確å®ããªãã®ã¯ããªå ¥åæã®ã¿ do { @@ -71,14 +70,16 @@ if(state) { buffer.Clear(); + port.Terminate(); return new SKKEmptySubController(state); } + } - if(!buffer.FixedString().empty()) { - std::cerr << buffer.FixedString() << std::endl; - } + if(!buffer.FixedString().empty()) { + port.FixString(buffer.FixedString()); } - std::cerr << buffer.InputString() << std::endl; + + port.DisplayString(buffer.InputString()); return 0; } @@ -94,24 +95,28 @@ SKKSubController* SKKDirectInputState::HandleCancel(SKKContext& context, const SKKEventParam&) { SKKInputBuffer& buffer = context.InputBuffer(); + SKKOutputPort& port = context.OutputPort(); if(!buffer.IsEmpty()) { buffer.Clear(); } else { // port å¼ã³åºã } - std::cerr << buffer.InputString() << std::endl; + + port.DisplayString(buffer.InputString()); return 0; } SKKSubController* SKKDirectInputState::HandleBackSpace(SKKContext& context, const SKKEventParam&) { SKKInputBuffer& buffer = context.InputBuffer(); + SKKOutputPort& port = context.OutputPort(); if(!buffer.IsEmpty()) { buffer.BackSpace(); } - std::cerr << buffer.InputString() << std::endl; + + port.DisplayString(buffer.InputString()); return 0; } Index: AquaSKK/src/editor/SKKEditor.cpp diff -u AquaSKK/src/editor/SKKEditor.cpp:1.1.2.2 AquaSKK/src/editor/SKKEditor.cpp:1.1.2.3 --- AquaSKK/src/editor/SKKEditor.cpp:1.1.2.2 Sun Sep 16 09:18:52 2007 +++ AquaSKK/src/editor/SKKEditor.cpp Mon Sep 24 11:09:04 2007 @@ -22,20 +22,37 @@ #include "SKKDirectInputState.h" #include "SKKEntryInputState.h" -SKKEditor::SKKEditor() { - initialize(); +// ====================================================================== +// SKKRegistrationInfo ã¤ã³ã¿ãã§ã¼ã¹ +// ====================================================================== +SKKRegistrationInfo::SKKRegistrationInfo() { +} + +SKKRegistrationInfo::SKKRegistrationInfo(const std::string& prompt, SKKEngine::State returnPoint) + : prompt_(prompt), returnPoint_(returnPoint) { +} + +const std::string& SKKRegistrationInfo::Prompt() const { + return prompt_; } -SKKEditor::SKKEditor(const std::string& prompt) : context_(prompt) { +const SKKEngine::State SKKRegistrationInfo::ReturnPoint() const { + return returnPoint_; +} + +// ====================================================================== +// SKKEditor ã¤ã³ã¿ãã§ã¼ã¹ +// ====================================================================== +SKKEditor::SKKEditor() { initialize(); } -SKKEditor::SKKEditor(const SKKEditor& src) : context_(src.context_), state_(src.state_) { +SKKEditor::SKKEditor(const SKKRegistrationInfo& info) : context_(info.Prompt()), registrationInfo_(info) { + initialize(); } -// å¦ççµæ -const SKKEventResult& SKKEditor::Result() const { - return context_.Result(); +SKKEditor::SKKEditor(const SKKEditor& src) + : context_(src.context_), registrationInfo_(src.registrationInfo_), state_(src.state_) { } // ====================================================================== @@ -115,11 +132,16 @@ } } -std::string SKKEditor::EditString() const { - return ""; +const SKKRegistrationInfo& SKKEditor::RegistrationInfo() const { + return registrationInfo_; +} + +const std::string& SKKEditor::EditString() const { + return context_.Word(); } -void SKKEditor::Commit(const std::string& word) { +void SKKEditor::Commit(const std::string& str) { + context_.OutputPort().FixString(str); } // ====================================================================== Index: AquaSKK/src/editor/SKKEditor.h diff -u AquaSKK/src/editor/SKKEditor.h:1.1.2.2 AquaSKK/src/editor/SKKEditor.h:1.1.2.3 --- AquaSKK/src/editor/SKKEditor.h:1.1.2.2 Sun Sep 2 12:52:18 2007 +++ AquaSKK/src/editor/SKKEditor.h Mon Sep 24 11:09:04 2007 @@ -22,17 +22,31 @@ #define INC__SKKEditor__ #include "SKK.h" +#include "SKKEngine.h" #include "SKKContext.h" class SKKState; class SKKSubController; class SKKEventParam; -class SKKEventResult; + +// å帰çè¾æ¸ç»é²ç¨ãã¼ã¿ +class SKKRegistrationInfo { + std::string prompt_; + SKKEngine::State returnPoint_; + +public: + SKKRegistrationInfo(); + SKKRegistrationInfo(const std::string& prompt, SKKEngine::State returnPoint); + + const std::string& Prompt() const; + const SKKEngine::State ReturnPoint() const; +}; // ç·¨éã¤ã³ã¿ãã§ã¼ã¹ class SKKEditor { SKKContext context_; SKKState* state_; + SKKRegistrationInfo registrationInfo_; void initialize(); @@ -41,12 +55,9 @@ typedef SKKSubController* (SKKEditor::*Handler)(const SKKEventParam&); SKKEditor(); - SKKEditor(const std::string& prompt); + SKKEditor(const SKKRegistrationInfo& info); SKKEditor(const SKKEditor& src); - // å¦ççµæ - const SKKEventResult& Result() const; - // ãã¼å ¥åå¦ç SKKSubController* HandleInput(const SKKEventParam& param); SKKSubController* HandleEnter(const SKKEventParam& param); @@ -67,11 +78,14 @@ // å é¨ç¶æ å¤æ´ void ChangeState(SKK::EditState state); + // ç»é²æ å ±ãåå¾ + const SKKRegistrationInfo& RegistrationInfo() const; + // ç·¨éæååãåå¾ - std::string EditString() const; + const std::string& EditString() const; - // 確å®ããæååãåæ - void Commit(const std::string& word); + // ç¢ºå® + void Commit(const std::string& str); }; #endif // INC__SKKEditor__ Index: AquaSKK/src/editor/SKKEntryInputState.cpp diff -u AquaSKK/src/editor/SKKEntryInputState.cpp:1.1.2.1 AquaSKK/src/editor/SKKEntryInputState.cpp:1.1.2.2 --- AquaSKK/src/editor/SKKEntryInputState.cpp:1.1.2.1 Sun Sep 16 09:18:52 2007 +++ AquaSKK/src/editor/SKKEntryInputState.cpp Mon Sep 24 11:09:04 2007 @@ -33,6 +33,7 @@ SKKSubController* SKKEntryInputState::HandleInput(SKKContext& context, const SKKEventParam& param) { SKKInputBuffer& buffer = context.InputBuffer(); SKKEditBuffer& edit = context.EditBuffer(); + SKKOutputPort& port = context.OutputPort(); if(!edit.IsEmpty()) { State state = 0; @@ -43,7 +44,7 @@ std::string result; toggleKana(buffer.InputMode(), edit.EditString(), result); edit.Clear(); - std::cerr << result << std::endl; + port.FixString(result); state = State::Transition(&SKKEnvironment::KanaInput); break; } @@ -53,7 +54,7 @@ std::string result; toggleJisx0201Kana(buffer.InputMode(), edit.EditString(), result); edit.Clear(); - std::cerr << result << std::endl; + port.FixString(result); state = State::Transition(&SKKEnvironment::KanaInput); break; } @@ -61,6 +62,7 @@ // éããã if(param.IsUpperCases()) { std::cerr << "éãããéå§" << std::endl; + state = State::Transition(&SKKEnvironment::Okuri); break; } @@ -72,6 +74,7 @@ } while(0); if(state) { + port.Terminate(); return new SKKEmptySubController(state); } } @@ -99,7 +102,7 @@ } while(0); if(state) { - std::cerr << edit.EditString() << std::endl; + port.FixString(edit.EditString()); edit.Clear(); buffer.Clear(); return new SKKEmptySubController(state); @@ -110,7 +113,7 @@ } } - std::cerr << edit.EditString() << buffer.InputString() << std::endl; + display(context); return 0; } @@ -126,9 +129,10 @@ SKKSubController* SKKEntryInputState::HandleJmode(SKKContext& context, const SKKEventParam&) { SKKInputBuffer& buffer = context.InputBuffer(); SKKEditBuffer& edit = context.EditBuffer(); + SKKOutputPort& port = context.OutputPort(); // ç¾å¨ã®åè£ã§ç¢ºå® - std::cerr << edit.EditString() << std::endl; + port.FixString(edit.EditString()); edit.Clear(); buffer.Clear(); @@ -139,12 +143,13 @@ SKKSubController* SKKEntryInputState::HandleCancel(SKKContext& context, const SKKEventParam&) { SKKInputBuffer& buffer = context.InputBuffer(); SKKEditBuffer& edit = context.EditBuffer(); + SKKOutputPort& port = context.OutputPort(); edit.Clear(); buffer.Clear(); // 空ã«ãã - std::cerr << edit.EditString() << std::endl; + port.Terminate(); return new SKKEmptySubController(State::Transition(&SKKEnvironment::KanaInput)); } @@ -152,6 +157,7 @@ SKKSubController* SKKEntryInputState::HandleBackSpace(SKKContext& context, const SKKEventParam&) { SKKInputBuffer& buffer = context.InputBuffer(); SKKEditBuffer& edit = context.EditBuffer(); + SKKOutputPort& port = context.OutputPort(); if(!buffer.IsEmpty()) { buffer.BackSpace(); @@ -159,11 +165,13 @@ if(!edit.IsEmpty()) { edit.BackSpace(); } else { + port.Terminate(); + return new SKKEmptySubController(State::Transition(&SKKEnvironment::KanaInput)); } } - std::cerr << edit.EditString() << buffer.InputString() << std::endl; + display(context); return 0; } @@ -174,14 +182,14 @@ if(buffer.IsEmpty() && !edit.IsEmpty()) { edit.Delete(); - - std::cerr << edit.EditString() << std::endl; } + display(context); + return 0; } -SKKSubController* SKKEntryInputState::HandleTab(SKKContext& context, const SKKEventParam&) { +SKKSubController* SKKEntryInputState::HandleTab(SKKContext&, const SKKEventParam&) { // æ¤ç´¢ã§ããï¼ if(0) { // è£å®ã¢ã¼ã @@ -200,56 +208,44 @@ buffer.Clear(); edit.Insert("paste string"); - std::cerr << edit.EditString() << std::endl; + display(context); } return 0; } SKKSubController* SKKEntryInputState::HandleCursorLeft(SKKContext& context, const SKKEventParam&) { - SKKInputBuffer& buffer = context.InputBuffer(); - SKKEditBuffer& edit = context.EditBuffer(); - - buffer.Clear(); - edit.CursorLeft(); + context.InputBuffer().Clear(); + context.EditBuffer().CursorLeft(); - std::cerr << edit.EditString() << std::endl; + display(context); return 0; } SKKSubController* SKKEntryInputState::HandleCursorRight(SKKContext& context, const SKKEventParam&) { - SKKInputBuffer& buffer = context.InputBuffer(); - SKKEditBuffer& edit = context.EditBuffer(); + context.InputBuffer().Clear(); + context.EditBuffer().CursorRight(); - buffer.Clear(); - edit.CursorRight(); - - std::cerr << edit.EditString() << std::endl; + display(context); return 0; } SKKSubController* SKKEntryInputState::HandleCursorUp(SKKContext& context, const SKKEventParam&) { - SKKInputBuffer& buffer = context.InputBuffer(); - SKKEditBuffer& edit = context.EditBuffer(); - - buffer.Clear(); - edit.CursorUp(); + context.InputBuffer().Clear(); + context.EditBuffer().CursorUp(); - std::cerr << edit.EditString() << std::endl; + display(context); return 0; } SKKSubController* SKKEntryInputState::HandleCursorDown(SKKContext& context, const SKKEventParam&) { - SKKInputBuffer& buffer = context.InputBuffer(); - SKKEditBuffer& edit = context.EditBuffer(); - - buffer.Clear(); - edit.CursorDown(); + context.InputBuffer().Clear(); + context.EditBuffer().CursorDown(); - std::cerr << edit.EditString() << std::endl; + display(context); return 0; } @@ -257,6 +253,18 @@ // ====================================================================== // private method // ====================================================================== +void SKKEntryInputState::display(SKKContext& context) { + SKKOutputPort& port = context.OutputPort(); + SKKInputBuffer& input = context.InputBuffer(); + SKKEditBuffer edit(context.EditBuffer()); + + if(!input.IsEmpty()) { + edit.Insert(input.InputString()); + } + + port.DisplayString("â½" + edit.EditString(), 1 + edit.CursorPosition()); +} + void SKKEntryInputState::toggleKana(SKK::InputMode mode, const std::string& from, std::string& to) { to.clear(); Index: AquaSKK/src/editor/SKKEntryInputState.h diff -u AquaSKK/src/editor/SKKEntryInputState.h:1.1.2.1 AquaSKK/src/editor/SKKEntryInputState.h:1.1.2.2 --- AquaSKK/src/editor/SKKEntryInputState.h:1.1.2.1 Sun Sep 16 09:18:52 2007 +++ AquaSKK/src/editor/SKKEntryInputState.h Mon Sep 24 11:09:04 2007 @@ -26,7 +26,12 @@ #include "SKKState.h" // è¦åºãèªå ¥åç¶æ -struct SKKEntryInputState : public SKKState { +class SKKEntryInputState : public SKKState { + void display(SKKContext& context); + void toggleKana(SKK::InputMode mode, const std::string& from, std::string& to); + void toggleJisx0201Kana(SKK::InputMode mode, const std::string& from, std::string& to); + +public: static SKKEntryInputState& theInstance(); virtual SKKSubController* HandleInput(SKKContext& context, const SKKEventParam& param); @@ -41,10 +46,6 @@ virtual SKKSubController* HandleCursorRight(SKKContext& context, const SKKEventParam& param); virtual SKKSubController* HandleCursorUp(SKKContext& context, const SKKEventParam& param); virtual SKKSubController* HandleCursorDown(SKKContext& context, const SKKEventParam& param); - -private: - void toggleKana(SKK::InputMode mode, const std::string& from, std::string& to); - void toggleJisx0201Kana(SKK::InputMode mode, const std::string& from, std::string& to); }; #endif