t-suw****@users*****
t-suw****@users*****
2007年 9月 12日 (水) 22:45:16 JST
Index: AquaSKK/src/context/SKKInputBuffer.cpp diff -u /dev/null AquaSKK/src/context/SKKInputBuffer.cpp:1.1.2.1 --- /dev/null Wed Sep 12 22:45:16 2007 +++ AquaSKK/src/context/SKKInputBuffer.cpp Wed Sep 12 22:45:15 2007 @@ -0,0 +1,83 @@ +/* -*- 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 "SKKInputBuffer.h" +#include "SKKRomanKanaConverter.h" +#include "jconv.h" +#include "utf8util.h" + +SKKInputBuffer::SKKInputBuffer() { + SelectInputMode(SKK::Hirakana); +} + +bool SKKInputBuffer::Input(char ch) { + bool converted = true; + + fixed_.clear(); + + switch(input_mode_) { + case SKK::Hirakana: + case SKK::Katakana: + case SKK::Jisx0201Kana: + buf_ += ch; + converted = SKKRomanKanaConverter::theInstance().Execute(input_mode_, buf_, fixed_, next_); + buf_ = next_; + break; + + case SKK::Ascii: + fixed_ += ch; + break; + + case SKK::Jisx0208Latin: + buf_ += ch; + jconv::ascii_to_jisx0208_latin(buf_, fixed_); + buf_.clear(); + break; + } + + return converted; +} + +void SKKInputBuffer::BackSpace() { + utf8::pop(buf_); +} + +void SKKInputBuffer::Clear() { + buf_.clear(); + fixed_.clear(); +} + +bool SKKInputBuffer::IsEmpty() const { + return buf_.empty(); +} + +void SKKInputBuffer::SelectInputMode(SKK::InputMode mode) { + input_mode_ = mode; + + Clear(); +} + +const std::string& SKKInputBuffer::InputString() const { + return buf_; +} + +const std::string& SKKInputBuffer::FixedString() const { + return fixed_; +} Index: AquaSKK/src/context/SKKInputBuffer.h diff -u /dev/null AquaSKK/src/context/SKKInputBuffer.h:1.1.2.1 --- /dev/null Wed Sep 12 22:45:16 2007 +++ AquaSKK/src/context/SKKInputBuffer.h Wed Sep 12 22:45:15 2007 @@ -0,0 +1,50 @@ +/* -*- 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__SKKInputBuffer__ +#define INC__SKKInputBuffer__ + +#include <string> +#include "SKK.h" + +// å ¥åãããã¡ +class SKKInputBuffer { + SKK::InputMode input_mode_; + std::string buf_; + std::string fixed_; + std::string next_; + +public: + SKKInputBuffer(); + + // ç·¨é + bool Input(char ch); + void BackSpace(); + void Clear(); + + bool IsEmpty() const; + + void SelectInputMode(SKK::InputMode mode); + + const std::string& InputString() const; + const std::string& FixedString() const; +}; + +#endif