Skip to content

Instantly share code, notes, and snippets.

@mnogu
Created September 4, 2011 09:12
Show Gist options
  • Select an option

  • Save mnogu/1192565 to your computer and use it in GitHub Desktop.

Select an option

Save mnogu/1192565 to your computer and use it in GitHub Desktop.
diff --git a/qt4/pref/customwidgets.cpp b/qt4/pref/customwidgets.cpp
index 3807e50..6bb2aac 100644
--- a/qt4/pref/customwidgets.cpp
+++ b/qt4/pref/customwidgets.cpp
@@ -39,8 +39,10 @@
#include <QtCore/QPointer>
#include <QtGui/QFileDialog>
+#include <QtGui/QHeaderView>
#include <QtGui/QLabel>
#include <QtGui/QPushButton>
+#include <QtGui/QTableWidget>
#include <QtGui/QTreeWidget>
#include <QtGui/QTreeWidgetItem>
#include <QtGui/QVBoxLayout>
@@ -1190,6 +1192,182 @@ void KeyGrabDialog::setKeyStr()
}
+//----------------------------------------------------------------------------------------
+CustomTable::CustomTable( struct uim_custom *c, QWidget *parent )
+ : QFrame( parent ),
+ UimCustomItemIface( c )
+{
+ m_table = new QTableWidget;
+ m_table->setSelectionMode( QAbstractItemView::SingleSelection );
+ m_table->horizontalHeader()->setVisible( false );
+ m_table->verticalHeader()->setVisible( false );
+ connect( m_table, SIGNAL(cellChanged(int, int)),
+ this, SLOT(slotCellChanged(int, int)) );
+
+ m_addButton = new QPushButton;
+ m_addButton->setText( _("Add") );
+ connect( m_addButton, SIGNAL(clicked()),
+ this, SLOT(slotAddClicked()) );
+
+ m_removeButton = new QPushButton;
+ m_removeButton->setText( _("Remove") );
+ connect( m_removeButton, SIGNAL(clicked()),
+ this, SLOT(slotRemoveClicked()) );
+
+ QVBoxLayout *buttonLayout = new QVBoxLayout;
+ buttonLayout->addWidget( m_addButton );
+ buttonLayout->addWidget( m_removeButton );
+ buttonLayout->addStretch();
+
+ QHBoxLayout *layout = new QHBoxLayout;
+ layout->addWidget( m_table );
+ layout->addLayout( buttonLayout );
+
+ setLayout( layout );
+
+ update();
+}
+
+void CustomTable::update()
+{
+ if( !m_custom || m_custom->type != UCustom_Table )
+ return;
+
+ char ***custom_table = m_custom->value->as_table;
+ if ( custom_table ) {
+ // the number may differ from row to row
+ int max_column = -1;
+ int row;
+ for ( row = 0; custom_table[row]; row++ ) {
+ for ( int column = 0; custom_table[row][column]; column++ ) {
+ if ( max_column < column )
+ max_column = column;
+ }
+ }
+ m_table->setRowCount( row );
+ m_table->setColumnCount( max_column + 1 );
+
+ // don't call slotCellChanged()
+ m_table->setEnabled( false );
+ for ( int row = 0; custom_table[row]; row++ ) {
+ bool expanded = false;
+ for ( int column = 0; column < max_column + 1; column++ ) {
+ if ( !custom_table[row][column] )
+ expanded = true;
+ QTableWidgetItem *item = new QTableWidgetItem( expanded ?
+ "" : _FU8( custom_table[row][column] ) );
+ if ( expanded )
+ item->setFlags( Qt::NoItemFlags );
+ m_table->setItem( row, column, item );
+ }
+ }
+ m_table->setEnabled( true );
+ }
+
+ /* sync with Label */
+ parentWidget()->setEnabled( m_custom->is_active );
+}
+
+void CustomTable::setDefault()
+{
+ char ***custom_table = m_custom->value->as_table;
+ for ( int row = 0; custom_table[row]; row++ ) {
+ for ( int column = 0; custom_table[row][column]; column++ ) {
+ free( custom_table[row][column] );
+ }
+ free( custom_table[row] );
+ }
+ char ***default_table = m_custom->default_value->as_table;
+ int row;
+ for ( row = 0; default_table[row]; row++ )
+ ;
+ custom_table = (char ***)malloc( sizeof(char **) * ( row + 1 ) );
+ custom_table[row] = 0;
+
+ m_custom->value->as_table = custom_table;
+
+ for ( int row = 0; default_table[row]; row++ ) {
+ int column;
+ for ( column = 0; default_table[row][column]; column++ )
+ ;
+ custom_table[row] = (char **)malloc( sizeof(char *) * ( column + 1 ) );
+ custom_table[row][column] = 0;
+ for ( int column = 0; default_table[row][column]; column++ )
+ custom_table[row][column] = strdup( default_table[row][column] );
+ }
+
+ setCustom( m_custom );
+ update();
+}
+
+void CustomTable::setTableCustom()
+{
+ char ***custom_table = m_custom->value->as_table;
+ for ( int row = 0; custom_table[row]; row++ ) {
+ for ( int column = 0; custom_table[row][column]; column++ ) {
+ free( custom_table[row][column] );
+ }
+ free( custom_table[row] );
+ }
+ int rowCount = m_table->rowCount();
+ custom_table = (char ***)malloc( sizeof(char **) * ( rowCount + 1 ) );
+ custom_table[rowCount] = 0;
+
+ m_custom->value->as_table = custom_table;
+
+ int columnCount = m_table->columnCount();
+
+ for ( int row = 0; row < rowCount; row++ ) {
+ int columnCountForRow = columnCount;
+ for ( int column = 0; column < columnCount; column++ ) {
+ if ( !( m_table->item( row, column )->flags() ) ) {
+ columnCountForRow = column;
+ break;
+ }
+ }
+ custom_table[row]
+ = (char **)malloc( sizeof(char *) * ( columnCountForRow + 1 ) );
+ custom_table[row][columnCountForRow] = 0;
+ for ( int column = 0; column < columnCountForRow; column++ )
+ custom_table[row][column] = strdup(
+ m_table->item( row, column )->text().toUtf8().data() );
+ }
+
+ setCustom( m_custom );
+}
+
+void CustomTable::slotCellChanged(int row, int column)
+{
+ if ( !m_table->isEnabled() )
+ return;
+ m_custom->value->as_table[row][column]
+ = strdup( m_table->item( row, column )->text().toUtf8().data() );
+ setCustom( m_custom );
+}
+
+void CustomTable::slotAddClicked()
+{
+ QList<QTableWidgetItem *> items = m_table->selectedItems();
+ int row = ( items.count() > 0 ) ? items[0]->row() + 1 : m_table->rowCount();
+ m_table->insertRow( row );
+ // don't call slotCellChanged()
+ m_table->setEnabled( false );
+ for ( int i = 0; i < m_table->columnCount(); i++ )
+ m_table->setItem( row, i, new QTableWidgetItem( "" ) );
+ m_table->setEnabled( true );
+ m_table->scrollToItem( m_table->item( row, 0 ) );
+ setTableCustom();
+}
+
+void CustomTable::slotRemoveClicked()
+{
+ QList<QTableWidgetItem *> items = m_table->selectedItems();
+ if ( items.count() != 1 )
+ return;
+ m_table->removeRow( items[0]->row() );
+ setTableCustom();
+}
+
static QString unicodeKeyToSymStr ( QChar c )
{
QString str;
diff --git a/qt4/pref/customwidgets.h b/qt4/pref/customwidgets.h
index def9009..3c87f1b 100644
--- a/qt4/pref/customwidgets.h
+++ b/qt4/pref/customwidgets.h
@@ -47,9 +47,10 @@
#include "keyeditformbase.h"
#include "olisteditformbase.h"
-class QPushButton;
class QListViewItem;
class QFileDialog;
+class QPushButton;
+class QTableWidget;
class UimCustomItemIface
{
@@ -296,4 +297,29 @@ protected:
QString m_keystr;
};
+//----------------------------------------------------------------------------------------
+class CustomTable : public QFrame, public UimCustomItemIface
+{
+ Q_OBJECT
+
+public:
+ CustomTable( struct uim_custom *c, QWidget *parent );
+
+ virtual void update();
+ virtual void setDefault();
+private:
+ void setTableCustom();
+ QTableWidget *m_table;
+ QPushButton *m_addButton;
+ QPushButton *m_removeButton;
+protected:
+ void currentCustomValueChanged(){ emit customValueChanged(); }
+signals:
+ void customValueChanged();
+private slots:
+ void slotCellChanged(int row, int column);
+ void slotAddClicked();
+ void slotRemoveClicked();
+};
+
#endif /* Not def: UIM_QT4_PREF_CUSTOMWIDGETS_H */
diff --git a/qt4/pref/qt4.cpp b/qt4/pref/qt4.cpp
index f2e7618..8d15812 100644
--- a/qt4/pref/qt4.cpp
+++ b/qt4/pref/qt4.cpp
@@ -540,6 +540,9 @@ UimCustomItemIface *GroupPageWidget::addCustom( QGroupBox *vbox, const char *cus
case UCustom_Key:
w = addCustomTypeKey( vbox, custom );
break;
+ case UCustom_Table:
+ w = addCustomTypeTable( vbox, custom );
+ break;
default:
w = 0;
qWarning( "Invalid custom type: %d\n", custom->type );
@@ -693,6 +696,28 @@ UimCustomItemIface *GroupPageWidget::addCustomTypeKey( QGroupBox *vbox, struct u
return keyEditBox;
}
+UimCustomItemIface *GroupPageWidget::addCustomTypeTable( QGroupBox *vbox, struct uim_custom *custom )
+{
+ QFrame *hbox = new QFrame;
+ QLabel *label = new QLabel( _FU8(custom->label), hbox );
+ CustomTable *tableBox = new CustomTable( custom, hbox );
+ label->setBuddy( tableBox );
+ connect( tableBox, SIGNAL(customValueChanged()),
+ this, SLOT(slotCustomValueChanged()) );
+
+ QVBoxLayout *layout = new QVBoxLayout;
+ layout->setMargin( 0 );
+ layout->setSpacing( 6 );
+ layout->addWidget( label );
+ layout->addWidget( tableBox );
+
+ hbox->setLayout( layout );
+ vbox->layout()->addWidget( hbox );
+
+ return tableBox;
+}
+
+
void GroupPageWidget::setDefault()
{
foreach ( UimCustomItemIface *iface, m_customIfaceList )
diff --git a/qt4/pref/qt4.h b/qt4/pref/qt4.h
index 58ae67f..27c93a2 100644
--- a/qt4/pref/qt4.h
+++ b/qt4/pref/qt4.h
@@ -126,6 +126,7 @@ protected:
UimCustomItemIface *addCustomTypeChoice( QGroupBox *vbox, struct uim_custom *custom );
UimCustomItemIface *addCustomTypeOrderedList( QGroupBox *vbox, struct uim_custom *custom );
UimCustomItemIface *addCustomTypeKey( QGroupBox *vbox, struct uim_custom *custom );
+ UimCustomItemIface *addCustomTypeTable( QGroupBox *vbox, struct uim_custom *custom );
protected slots:
void slotCustomValueChanged(){ emit customValueChanged(); }
diff --git a/scm/custom.scm b/scm/custom.scm
index f9bb938..94b3d4d 100644
--- a/scm/custom.scm
+++ b/scm/custom.scm
@@ -65,7 +65,8 @@
(pathname . custom-pathname?)
(choice . custom-valid-choice?)
(ordered-list . custom-ordered-list?)
- (key . custom-key?)))
+ (key . custom-key?)
+ (table . custom-table?)))
(define anything?
(lambda (x)
@@ -119,6 +120,16 @@
(custom-exist? key 'key))))
key-repls))))
+(define custom-table?
+ (lambda (table-repls)
+ (and (list? table-repls)
+ (every (lambda (row)
+ (and (list? row)
+ (every (lambda (cell)
+ (string? cell))
+ row)))
+ table-repls))))
+
(define custom-pathname-type
(lambda (custom-sym)
(car (custom-type-attrs custom-sym))))
@@ -677,6 +688,18 @@
lst)))
(string-append "'(" (string-join canonicalized " ") ")"))))
+; (custom-list-as-table '(("a" "b" "c") ("d" "e")))
+; -> "'((\"a\" \"b\" \"c\") (\"d\" \"e\"))"
+(define custom-list-as-table
+ (lambda (tbl)
+ (string-append "'("
+ (string-join
+ (map (lambda (lst)
+ (string-append "("
+ (string-join
+ (map (lambda (elem)
+ (string-escape elem)) lst) " ") ")")) tbl) " ") ")")))
+
;; API
(define custom-value-as-literal
(lambda (sym)
@@ -694,6 +717,8 @@
((or (eq? type 'ordered-list)
(eq? type 'key))
(custom-list-as-literal val))
+ ((eq? type 'table)
+ (custom-list-as-table val))
((or (eq? val #f)
(eq? type 'boolean))
(if (eq? val #f)
diff --git a/scm/japanese-custom.scm b/scm/japanese-custom.scm
index 645b1a7..14a17be 100644
--- a/scm/japanese-custom.scm
+++ b/scm/japanese-custom.scm
@@ -28,6 +28,619 @@
;;; SUCH DAMAGE.
;;;;
+(define ja-rk-rule-basic
+ '(
+ ((("-"). ())("ー" "ー" "ー"))
+ (((","). ())("、" "、" "、"))
+ ((("."). ())("。" "。" "。"))
+ ((("!"). ())("!" "!" "!"))
+ ((("\""). ())("”" "”" "\""))
+ ((("#"). ())("#" "#" "#"))
+ ((("$"). ())("$" "$" "$"))
+ ((("%"). ())("%" "%" "%"))
+ ((("&"). ())("&" "&" "&"))
+ ((("'"). ())("’" "’" "'"))
+ ((("("). ())("(" "(" "("))
+ (((")"). ())(")" ")" ")"))
+ ((("~"). ())("〜" "〜" "~"))
+ ((("="). ())("=" "=" "="))
+ ((("^"). ())("^" "^" "^"))
+ ((("\\"). ())("\" "\" "\\"))
+ ((("|"). ())("|" "|" "|"))
+ ((("`"). ())("‘" "‘" "`"))
+ ((("@"). ())("@" "@" "@"))
+ ((("{"). ())("{" "{" "{"))
+ ((("["). ())("「" "「" "「"))
+ ((("+"). ())("+" "+" "+"))
+ (((";"). ())(";" ";" ";"))
+ ((("*"). ())("*" "*" "*"))
+ (((":"). ())(":" ":" ":"))
+ ((("}"). ())("}" "}" "}"))
+ ((("]"). ())("」" "」" "」"))
+ ((("<"). ())("<" "<" "<"))
+ (((">"). ())(">" ">" ">"))
+ ((("?"). ())("?" "?" "?"))
+ ((("/"). ())("/" "/" "/"))
+ ((("_"). ())("_" "_" "_"))
+ ;; Since ordinary Japanese users press the "yen sign" key on
+ ;; Japanese keyboard in romaji-halfwidth-kana-mode "to input
+ ;; character code 134" rather than "to input yen sign symbol", I
+ ;; changed the fullwidth yen sign with backslash.
+ ;; -- YamaKen 2007-09-17
+ ;; ((("yen"). ())("¥" "¥" "¥")) ;; XXX
+ ((("yen"). ())("¥" "¥" "\\"))
+
+ ((("1"). ())("1" "1" "1"))
+ ((("2"). ())("2" "2" "2"))
+ ((("3"). ())("3" "3" "3"))
+ ((("4"). ())("4" "4" "4"))
+ ((("5"). ())("5" "5" "5"))
+ ((("6"). ())("6" "6" "6"))
+ ((("7"). ())("7" "7" "7"))
+ ((("8"). ())("8" "8" "8"))
+ ((("9"). ())("9" "9" "9"))
+ ((("0"). ())("0" "0" "0"))
+
+ ((("a"). ())("あ" "ア" "ア"))
+ ((("i"). ())("い" "イ" "イ"))
+ ((("u"). ())("う" "ウ" "ウ"))
+ ((("e"). ())("え" "エ" "エ"))
+ ((("o"). ())("お" "オ" "オ"))
+
+ ((("x" "a"). ())("ぁ" "ァ" "ァ"))
+ ((("x" "i"). ())("ぃ" "ィ" "ィ"))
+ ((("x" "y" "i"). ())("ぃ" "ィ" "ィ"))
+ ((("x" "u"). ())("ぅ" "ゥ" "ゥ"))
+ ((("x" "e"). ())("ぇ" "ェ" "ェ"))
+ ((("x" "y" "e"). ())("ぇ" "ェ" "ェ"))
+ ((("x" "o"). ())("ぉ" "ォ" "ォ"))
+
+ ((("l" "a"). ())("ぁ" "ァ" "ァ"))
+ ((("l" "i"). ())("ぃ" "ィ" "ィ"))
+ ((("l" "u"). ())("ぅ" "ゥ" "ゥ"))
+ ((("l" "e"). ())("ぇ" "ェ" "ェ"))
+ ((("l" "o"). ())("ぉ" "ォ" "ォ"))
+
+ ((("k" "k"). ("k"))("っ" "ッ" "ッ"))
+
+ ((("k" "a"). ())("か" "カ" "カ"))
+ ((("k" "i"). ())("き" "キ" "キ"))
+ ((("k" "u"). ())("く" "ク" "ク"))
+ ((("k" "e"). ())("け" "ケ" "ケ"))
+ ((("k" "o"). ())("こ" "コ" "コ"))
+ ((("k" "y" "a"). ())(("き" "キ" "キ") ("ゃ" "ャ" "ャ")))
+ ((("k" "y" "i"). ())(("き" "キ" "キ") ("ぃ" "ィ" "ィ")))
+ ((("k" "y" "u"). ())(("き" "キ" "キ") ("ゅ" "ュ" "ュ")))
+ ((("k" "y" "e"). ())(("き" "キ" "キ") ("ぇ" "ェ" "ェ")))
+ ((("k" "y" "o"). ())(("き" "キ" "キ") ("ょ" "ョ" "ョ")))
+
+ ((("g" "g"). ("g"))("っ" "ッ" "ッ"))
+
+
+ ((("g" "a"). ())("が" "ガ" "ガ"))
+ ((("g" "i"). ())("ぎ" "ギ" "ギ"))
+ ((("g" "u"). ())("ぐ" "グ" "グ"))
+ ((("g" "e"). ())("げ" "ゲ" "ゲ"))
+ ((("g" "o"). ())("ご" "ゴ" "ゴ"))
+
+ ((("g" "y" "a"). ())(("ぎ" "ギ" "ギ") ("ゃ" "ャ" "ャ")))
+ ((("g" "y" "i"). ())(("ぎ" "ギ" "ギ") ("ぃ" "ィ" "ィ")))
+ ((("g" "y" "u"). ())(("ぎ" "ギ" "ギ") ("ゅ" "ュ" "ュ")))
+ ((("g" "y" "e"). ())(("ぎ" "ギ" "ギ") ("ぇ" "ェ" "ェ")))
+ ((("g" "y" "o"). ())(("ぎ" "ギ" "ギ") ("ょ" "ョ" "ョ")))
+
+ ((("q" "a"). ())(("く" "ク" "ク") ("ぁ" "ァ" "ァ")))
+ ((("q" "i"). ())(("く" "ク" "ク") ("ぃ" "ィ" "ィ")))
+ ((("q" "u"). ())("く" "ク" "ク"))
+ ((("q" "e"). ())(("く" "ク" "ク") ("ぇ" "ェ" "ェ")))
+ ((("q" "o"). ())(("く" "ク" "ク") ("ぉ" "ォ" "ォ")))
+
+ ((("s" "s"). ("s"))("っ" "ッ" "ッ"))
+
+ ((("s" "a"). ())("さ" "サ" "サ"))
+ ((("s" "i"). ())("し" "シ" "シ"))
+ ((("s" "u"). ())("す" "ス" "ス"))
+ ((("s" "e"). ())("せ" "セ" "セ"))
+ ((("s" "o"). ())("そ" "ソ" "ソ"))
+
+ ((("s" "y" "a"). ())(("し" "シ" "シ") ("ゃ" "ャ" "ャ")))
+ ((("s" "y" "i"). ())(("し" "シ" "シ") ("ぃ" "ィ" "ィ")))
+ ((("s" "y" "u"). ())(("し" "シ" "シ") ("ゅ" "ュ" "ュ")))
+ ((("s" "y" "e"). ())(("し" "シ" "シ") ("ぇ" "ェ" "ェ")))
+ ((("s" "y" "o"). ())(("し" "シ" "シ") ("ょ" "ョ" "ョ")))
+
+ ((("z" "z"). ("z"))("っ" "ッ" "ッ"))
+
+ ((("z" "a"). ())("ざ" "ザ" "ザ"))
+ ((("z" "i"). ())("じ" "ジ" "ジ"))
+ ((("z" "u"). ())("ず" "ズ" "ズ"))
+ ((("z" "e"). ())("ぜ" "ゼ" "ゼ"))
+ ((("z" "o"). ())("ぞ" "ゾ" "ゾ"))
+ ((("z" "y" "a"). ())(("じ" "ジ" "ジ") ("ゃ" "ャ" "ャ")))
+ ((("z" "y" "i"). ())(("じ" "ジ" "ジ") ("ぃ" "ィ" "ィ")))
+ ((("z" "y" "u"). ())(("じ" "ジ" "ジ") ("ゅ" "ュ" "ュ")))
+ ((("z" "y" "e"). ())(("じ" "ジ" "ジ") ("ぇ" "ェ" "ェ")))
+ ((("z" "y" "o"). ())(("じ" "ジ" "ジ") ("ょ" "ョ" "ョ")))
+
+ ((("j" "j"). ("j"))("っ" "ッ" "ッ"))
+
+ ((("j" "a"). ())(("じ" "ジ" "ジ") ("ゃ" "ャ" "ャ")))
+ ((("j" "i"). ())("じ" "ジ" "ジ"))
+ ((("j" "u"). ())(("じ" "ジ" "ジ") ("ゅ" "ュ" "ュ")))
+ ((("j" "e"). ())(("じ" "ジ" "ジ") ("ぇ" "ェ" "ェ")))
+ ((("j" "o"). ())(("じ" "ジ" "ジ") ("ょ" "ョ" "ョ")))
+
+ ((("j" "y" "a"). ())(("じ" "ジ" "ジ") ("ゃ" "ャ" "ャ")))
+ ((("j" "y" "i"). ())(("じ" "ジ" "ジ") ("ぃ" "ィ" "ィ")))
+ ((("j" "y" "u"). ())(("じ" "ジ" "ジ") ("ゅ" "ュ" "ュ")))
+ ((("j" "y" "e"). ())(("じ" "ジ" "ジ") ("ぇ" "ェ" "ェ")))
+ ((("j" "y" "o"). ())(("じ" "ジ" "ジ") ("ょ" "ョ" "ョ")))
+
+ ((("t" "t"). ("t"))("っ" "ッ" "ッ"))
+ ((("t" "c"). ("c"))("っ" "ッ" "ッ"))
+
+ ((("t" "a"). ())("た" "タ" "タ"))
+ ((("t" "i"). ())("ち" "チ" "チ"))
+ ((("t" "u"). ())("つ" "ツ" "ツ"))
+ ((("t" "e"). ())("て" "テ" "テ"))
+ ((("t" "o"). ())("と" "ト" "ト"))
+
+ ((("t" "y" "a"). ())(("ち" "チ" "チ") ("ゃ" "ャ" "ャ")))
+ ((("t" "y" "i"). ())(("ち" "チ" "チ") ("ぃ" "ィ" "ィ")))
+ ((("t" "y" "u"). ())(("ち" "チ" "チ") ("ゅ" "ュ" "ュ")))
+ ((("t" "y" "e"). ())(("ち" "チ" "チ") ("ぇ" "ェ" "ェ")))
+ ((("t" "y" "o"). ())(("ち" "チ" "チ") ("ょ" "ョ" "ョ")))
+
+ ((("t" "s" "a"). ())(("つ" "ツ" "ツ") ("ぁ" "ァ" "ァ")))
+ ((("t" "s" "i"). ())(("つ" "ツ" "ツ") ("ぃ" "ィ" "ィ")))
+ ((("t" "s" "u"). ())("つ" "ツ" "ツ"))
+ ((("t" "s" "e"). ())(("つ" "ツ" "ツ") ("ぇ" "ェ" "ェ")))
+ ((("t" "s" "o"). ())(("つ" "ツ" "ツ") ("ぉ" "ォ" "ォ")))
+
+ ((("c" "y" "a"). ())(("ち" "チ" "チ") ("ゃ" "ャ" "ャ")))
+ ((("c" "y" "i"). ())(("ち" "チ" "チ") ("ぃ" "ィ" "ィ")))
+ ((("c" "y" "u"). ())(("ち" "チ" "チ") ("ゅ" "ュ" "ュ")))
+ ((("c" "y" "e"). ())(("ち" "チ" "チ") ("ぇ" "ェ" "ェ")))
+ ((("c" "y" "o"). ())(("ち" "チ" "チ") ("ょ" "ョ" "ョ")))
+
+ ((("x" "t" "u"). ())("っ" "ッ" "ッ"))
+ ((("x" "t" "s" "u"). ())("っ" "ッ" "ッ"))
+ ((("c" "c"). ("c"))("っ" "ッ" "ッ"))
+
+ ((("d" "d"). ("d"))("っ" "ッ" "ッ"))
+
+ ((("d" "a"). ())("だ" "ダ" "ダ"))
+ ((("d" "i"). ())("ぢ" "ヂ" "ヂ"))
+ ((("d" "u"). ())("づ" "ヅ" "ヅ"))
+ ((("d" "e"). ())("で" "デ" "デ"))
+ ((("d" "o"). ())("ど" "ド" "ド"))
+
+ ((("d" "y" "a"). ())(("ぢ" "ヂ" "ヂ") ("ゃ" "ャ" "ャ")))
+ ((("d" "y" "i"). ())(("ぢ" "ヂ" "ヂ") ("ぃ" "ィ" "ィ")))
+ ((("d" "y" "u"). ())(("ぢ" "ヂ" "ヂ") ("ゅ" "ュ" "ュ")))
+ ((("d" "y" "e"). ())(("ぢ" "ヂ" "ヂ") ("ぇ" "ェ" "ェ")))
+ ((("d" "y" "o"). ())(("ぢ" "ヂ" "ヂ") ("ょ" "ョ" "ョ")))
+
+ ((("n" "n"). ())("ん" "ン" "ン"))
+ ((("n" "'"). ())("ん" "ン" "ン"))
+ ((("n"). ())("ん" "ン" "ン"))
+
+ ((("n" "a"). ())("な" "ナ" "ナ"))
+ ((("n" "i"). ())("に" "ニ" "ニ"))
+ ((("n" "u"). ())("ぬ" "ヌ" "ヌ"))
+ ((("n" "e"). ())("ね" "ネ" "ネ"))
+ ((("n" "o"). ())("の" "ノ" "ノ"))
+
+ ((("n" "y" "a"). ())(("に" "ニ" "ニ") ("ゃ" "ャ" "ャ")))
+ ((("n" "y" "i"). ())(("に" "ニ" "ニ") ("ぃ" "ィ" "ィ")))
+ ((("n" "y" "u"). ())(("に" "ニ" "ニ") ("ゅ" "ュ" "ュ")))
+ ((("n" "y" "e"). ())(("に" "ニ" "ニ") ("ぇ" "ェ" "ェ")))
+ ((("n" "y" "o"). ())(("に" "ニ" "ニ") ("ょ" "ョ" "ョ")))
+
+ ((("h" "h"). ("h"))("っ" "ッ" "ッ"))
+
+ ((("h" "a"). ())("は" "ハ" "ハ"))
+ ((("h" "i"). ())("ひ" "ヒ" "ヒ"))
+ ((("h" "u"). ())("ふ" "フ" "フ"))
+ ((("h" "e"). ())("へ" "ヘ" "ヘ"))
+ ((("h" "o"). ())("ほ" "ホ" "ホ"))
+
+ ((("h" "y" "a"). ())(("ひ" "ヒ" "ヒ") ("ゃ" "ャ" "ャ")))
+ ((("h" "y" "i"). ())(("ひ" "ヒ" "ヒ") ("ぃ" "ィ" "ィ")))
+ ((("h" "y" "u"). ())(("ひ" "ヒ" "ヒ") ("ゅ" "ュ" "ュ")))
+ ((("h" "y" "e"). ())(("ひ" "ヒ" "ヒ") ("ぇ" "ェ" "ェ")))
+ ((("h" "y" "o"). ())(("ひ" "ヒ" "ヒ") ("ょ" "ョ" "ョ")))
+
+ ((("f" "f"). ("f"))("っ" "ッ" "ッ"))
+
+ ((("f" "a"). ())(("ふ" "フ" "フ") ("ぁ" "ァ" "ァ")))
+ ((("f" "i"). ())(("ふ" "フ" "フ") ("ぃ" "ィ" "ィ")))
+ ((("f" "u"). ())("ふ" "フ" "フ"))
+ ((("f" "e"). ())(("ふ" "フ" "フ") ("ぇ" "ェ" "ェ")))
+ ((("f" "o"). ())(("ふ" "フ" "フ") ("ぉ" "ォ" "ォ")))
+
+ ((("f" "y" "a"). ())(("ふ" "フ" "フ") ("ゃ" "ャ" "ャ")))
+ ((("f" "y" "i"). ())(("ふ" "フ" "フ") ("ぃ" "ィ" "ィ")))
+ ((("f" "y" "u"). ())(("ふ" "フ" "フ") ("ゅ" "ュ" "ュ")))
+ ((("f" "y" "e"). ())(("ふ" "フ" "フ") ("ぇ" "ェ" "ェ")))
+ ((("f" "y" "o"). ())(("ふ" "フ" "フ") ("ょ" "ョ" "ョ")))
+
+ ((("b" "b"). ("b"))("っ" "ッ" "ッ"))
+
+ ((("b" "a"). ())("ば" "バ" "バ"))
+ ((("b" "i"). ())("び" "ビ" "ビ"))
+ ((("b" "u"). ())("ぶ" "ブ" "ブ"))
+ ((("b" "e"). ())("べ" "ベ" "ベ"))
+ ((("b" "o"). ())("ぼ" "ボ" "ボ"))
+
+ ((("b" "y" "a"). ())(("び" "ビ" "ビ") ("ゃ" "ャ" "ャ")))
+ ((("b" "y" "i"). ())(("び" "ビ" "ビ") ("ぃ" "ィ" "ィ")))
+ ((("b" "y" "u"). ())(("び" "ビ" "ビ") ("ゅ" "ュ" "ュ")))
+ ((("b" "y" "e"). ())(("び" "ビ" "ビ") ("ぇ" "ェ" "ェ")))
+ ((("b" "y" "o"). ())(("び" "ビ" "ビ") ("ょ" "ョ" "ョ")))
+
+ ((("p" "p"). ("p"))("っ" "ッ" "ッ"))
+
+ ((("p" "a"). ())("ぱ" "パ" "パ"))
+ ((("p" "i"). ())("ぴ" "ピ" "ピ"))
+ ((("p" "u"). ())("ぷ" "プ" "プ"))
+ ((("p" "e"). ())("ぺ" "ペ" "ペ"))
+ ((("p" "o"). ())("ぽ" "ポ" "ポ"))
+
+ ((("p" "y" "a"). ())(("ぴ" "ピ" "ピ") ("ゃ" "ャ" "ャ")))
+ ((("p" "y" "i"). ())(("ぴ" "ピ" "ピ") ("ぃ" "ィ" "ィ")))
+ ((("p" "y" "u"). ())(("ぴ" "ピ" "ピ") ("ゅ" "ュ" "ュ")))
+ ((("p" "y" "e"). ())(("ぴ" "ピ" "ピ") ("ぇ" "ェ" "ェ")))
+ ((("p" "y" "o"). ())(("ぴ" "ピ" "ピ") ("ょ" "ョ" "ョ")))
+
+ ((("m" "m"). ("m"))("っ" "ッ" "ッ"))
+
+ ((("m" "b"). ("b"))("ん" "ン" "ン"))
+ ((("m" "p"). ("p"))("ん" "ン" "ン"))
+
+ ((("m" "a"). ())("ま" "マ" "マ"))
+ ((("m" "i"). ())("み" "ミ" "ミ"))
+ ((("m" "u"). ())("む" "ム" "ム"))
+ ((("m" "e"). ())("め" "メ" "メ"))
+ ((("m" "o"). ())("も" "モ" "モ"))
+
+ ((("m" "y" "a"). ())(("み" "ミ" "ミ") ("ゃ" "ャ" "ャ")))
+ ((("m" "y" "i"). ())(("み" "ミ" "ミ") ("ぃ" "ィ" "ィ")))
+ ((("m" "y" "u"). ())(("み" "ミ" "ミ") ("ゅ" "ュ" "ュ")))
+ ((("m" "y" "e"). ())(("み" "ミ" "ミ") ("ぇ" "ェ" "ェ")))
+ ((("m" "y" "o"). ())(("み" "ミ" "ミ") ("ょ" "ョ" "ョ")))
+
+ ((("y" "y"). ("y"))("っ" "ッ" "ッ"))
+
+ ((("y" "a"). ())("や" "ヤ" "ヤ"))
+ ((("y" "u"). ())("ゆ" "ユ" "ユ"))
+ ((("y" "e"). ())(("い" "イ" "イ") ("ぇ" "ェ" "ェ")))
+ ((("y" "o"). ())("よ" "ヨ" "ヨ"))
+
+ ((("x" "c" "a"). ())("ヵ" "ヵ" "カ"))
+ ((("x" "k" "a"). ())("ヵ" "ヵ" "カ"))
+ ((("x" "k" "e"). ())("ヶ" "ヶ" "ケ"))
+
+ ((("x" "y" "a"). ())("ゃ" "ャ" "ャ"))
+ ((("x" "y" "u"). ())("ゅ" "ュ" "ュ"))
+ ((("x" "y" "o"). ())("ょ" "ョ" "ョ"))
+
+ ((("r" "r"). ("r"))("っ" "ッ" "ッ"))
+
+ ((("r" "a"). ())("ら" "ラ" "ラ"))
+ ((("r" "i"). ())("り" "リ" "リ"))
+ ((("r" "u"). ())("る" "ル" "ル"))
+ ((("r" "e"). ())("れ" "レ" "レ"))
+ ((("r" "o"). ())("ろ" "ロ" "ロ"))
+
+ ((("l" "t" "u"). ())("っ" "ッ" "ッ"))
+ ((("l" "t" "s" "u"). ())("っ" "ッ" "ッ"))
+
+ ((("l" "y" "a"). ())("ゃ" "ャ" "ャ"))
+ ((("l" "y" "i"). ())("ぃ" "ィ" "ィ"))
+ ((("l" "y" "u"). ())("ゅ" "ュ" "ュ"))
+ ((("l" "y" "e"). ())("ぇ" "ェ" "ェ"))
+ ((("l" "y" "o"). ())("ょ" "ョ" "ョ"))
+
+ ((("r" "y" "a"). ())(("り" "リ" "リ") ("ゃ" "ャ" "ャ")))
+ ((("r" "y" "i"). ())(("り" "リ" "リ") ("ぃ" "ィ" "ィ")))
+ ((("r" "y" "u"). ())(("り" "リ" "リ") ("ゅ" "ュ" "ュ")))
+ ((("r" "y" "e"). ())(("り" "リ" "リ") ("ぇ" "ェ" "ェ")))
+ ((("r" "y" "o"). ())(("り" "リ" "リ") ("ょ" "ョ" "ョ")))
+
+ ((("w" "w"). ("w"))("っ" "ッ" "ッ"))
+
+ ((("w" "a"). ())("わ" "ワ" "ワ"))
+ ((("w" "i"). ())(("う" "ウ" "ウ") ("ぃ" "ィ" "ィ")))
+ ((("w" "u"). ())("う" "ウ" "ウ"))
+ ((("w" "e"). ())(("う" "ウ" "ウ") ("ぇ" "ェ" "ェ")))
+ ((("w" "o"). ())("を" "ヲ" "ヲ"))
+ ((("w" "h" "a"). ())(("う" "ウ" "ウ") ("ぁ" "ァ" "ァ")))
+ ((("w" "h" "i"). ())(("う" "ウ" "ウ") ("ぃ" "ィ" "ィ")))
+ ((("w" "h" "u"). ())("う" "ウ" "ウ"))
+ ((("w" "h" "e"). ())(("う" "ウ" "ウ") ("ぇ" "ェ" "ェ")))
+ ((("w" "h" "o"). ())(("う" "ウ" "ウ") ("ぉ" "ォ" "ォ")))
+
+ ((("v" "v"). ("v"))("っ" "ッ" "ッ"))
+
+ ((("v" "a"). ())(("う゛" "ヴ" "ヴ") ("ぁ" "ァ" "ァ")))
+ ((("v" "i"). ())(("う゛" "ヴ" "ヴ") ("ぃ" "ィ" "ィ")))
+ ((("v" "u"). ())("う゛" "ヴ" "ヴ"))
+ ((("v" "e"). ())(("う゛" "ヴ" "ヴ") ("ぇ" "ェ" "ェ")))
+ ((("v" "o"). ())(("う゛" "ヴ" "ヴ") ("ぉ" "ォ" "ォ")))
+
+ ((("v" "y" "a"). ())(("う゛" "ヴ" "ヴ") ("ゃ" "ャ" "ャ")))
+ ((("v" "y" "u"). ())(("う゛" "ヴ" "ヴ") ("ゅ" "ュ" "ュ")))
+ ((("v" "y" "o"). ())(("う゛" "ヴ" "ヴ") ("ょ" "ョ" "ョ")))
+
+ ((("z" "k"). ())("↑" "↑" ""))
+ ((("z" "j"). ())("↓" "↓" ""))
+ ((("z" "h"). ())("←" "←" ""))
+ ((("z" "l"). ())("→" "→" ""))
+ ((("z" "-"). ())("〜" "〜" ""))
+ ((("z" "["). ())("『" "『" ""))
+ ((("z" "]"). ())("』" "』" ""))
+ ((("z" ","). ())("‥" "‥" ""))
+ ((("z" "."). ())("…" "…" ""))
+ ((("z" "/"). ())("・" "・" "・"))
+ ))
+
+(define ja-rk-rule-additional
+ '(
+ ((("d" "s" "u"). ())("づ" "ヅ" "ヅ"))
+
+ ((("d" "h" "a"). ())(("で" "デ" "デ") ("ゃ" "ャ" "ャ")))
+ ((("d" "h" "i"). ())(("で" "デ" "デ") ("ぃ" "ィ" "ィ")))
+ ((("d" "h" "u"). ())(("で" "デ" "デ") ("ゅ" "ュ" "ュ")))
+ ((("d" "h" "e"). ())(("で" "デ" "デ") ("ぇ" "ェ" "ェ")))
+ ((("d" "h" "o"). ())(("で" "デ" "デ") ("ょ" "ョ" "ョ")))
+
+ ((("d" "w" "a"). ())(("ど" "ド" "ド") ("ぁ" "ァ" "ァ")))
+ ((("d" "w" "i"). ())(("ど" "ド" "ド") ("ぃ" "ィ" "ィ")))
+ ((("d" "w" "u"). ())(("ど" "ド" "ド") ("ぅ" "ゥ" "ゥ")))
+ ((("d" "w" "e"). ())(("ど" "ド" "ド") ("ぇ" "ェ" "ェ")))
+ ((("d" "w" "o"). ())(("ど" "ド" "ド") ("ぉ" "ォ" "ォ")))
+
+ ((("k" "w" "a"). ())(("く" "ク" "ク") ("ぁ" "ァ" "ァ")))
+ ((("k" "w" "i"). ())(("く" "ク" "ク") ("ぃ" "ィ" "ィ")))
+ ((("k" "w" "u"). ())(("く" "ク" "ク") ("ぅ" "ゥ" "ゥ")))
+ ((("k" "w" "e"). ())(("く" "ク" "ク") ("ぇ" "ェ" "ェ")))
+ ((("k" "w" "o"). ())(("く" "ク" "ク") ("ぉ" "ォ" "ォ")))
+
+ ((("s" "h" "a"). ())(("し" "シ" "シ") ("ゃ" "ャ" "ャ")))
+ ((("s" "h" "i"). ())("し" "シ" "シ"))
+ ((("s" "h" "u"). ())(("し" "シ" "シ") ("ゅ" "ュ" "ュ")))
+ ((("s" "h" "e"). ())(("し" "シ" "シ") ("ぇ" "ェ" "ェ")))
+ ((("s" "h" "o"). ())(("し" "シ" "シ") ("ょ" "ョ" "ョ")))
+
+ ((("s" "w" "a"). ())(("す" "ス" "ス") ("ぁ" "ァ" "ァ")))
+ ((("s" "w" "i"). ())(("す" "ス" "ス") ("ぃ" "ィ" "ィ")))
+ ((("s" "w" "u"). ())(("す" "ス" "ス") ("ぅ" "ゥ" "ゥ")))
+ ((("s" "w" "e"). ())(("す" "ス" "ス") ("ぇ" "ェ" "ェ")))
+ ((("s" "w" "o"). ())(("す" "ス" "ス") ("ぉ" "ォ" "ォ")))
+
+ ((("t" "w" "a"). ())(("と" "ト" "ト") ("ぁ" "ァ" "ァ")))
+ ((("t" "w" "i"). ())(("と" "ト" "ト") ("ぃ" "ィ" "ィ")))
+ ((("t" "w" "u"). ())(("と" "ト" "ト") ("ぅ" "ゥ" "ゥ")))
+ ((("t" "w" "e"). ())(("と" "ト" "ト") ("ぇ" "ェ" "ェ")))
+ ((("t" "w" "o"). ())(("と" "ト" "ト") ("ぉ" "ォ" "ォ")))
+
+ ((("t" "h" "a"). ())(("て" "テ" "テ") ("ゃ" "ャ" "ャ")))
+ ((("t" "h" "i"). ())(("て" "テ" "テ") ("ぃ" "ィ" "ィ")))
+ ((("t" "h" "u"). ())(("て" "テ" "テ") ("ゅ" "ュ" "ュ")))
+ ((("t" "h" "e"). ())(("て" "テ" "テ") ("ぇ" "ェ" "ェ")))
+ ((("t" "h" "o"). ())(("て" "テ" "テ") ("ょ" "ョ" "ョ")))
+
+ ((("h" "w" "a"). ())(("ふ" "フ" "フ") ("ぁ" "ァ" "ァ")))
+ ((("h" "w" "i"). ())(("ふ" "フ" "フ") ("ぃ" "ィ" "ィ")))
+ ((("h" "w" "e"). ())(("ふ" "フ" "フ") ("ぇ" "ェ" "ェ")))
+ ((("h" "w" "o"). ())(("ふ" "フ" "フ") ("ぉ" "ォ" "ォ")))
+
+ ((("f" "w" "a"). ())(("ふ" "フ" "フ") ("ぁ" "ァ" "ァ")))
+ ((("f" "w" "i"). ())(("ふ" "フ" "フ") ("ぃ" "ィ" "ィ")))
+ ((("f" "w" "u"). ())(("ふ" "フ" "フ") ("ぅ" "ゥ" "ゥ")))
+ ((("f" "w" "e"). ())(("ふ" "フ" "フ") ("ぇ" "ェ" "ェ")))
+ ((("f" "w" "o"). ())(("ふ" "フ" "フ") ("ぉ" "ォ" "ォ")))
+
+ ((("x" "w" "a"). ())("ゎ" "ヮ" "ワ"))
+ ((("x" "w" "i"). ())("ゐ" "ヰ" "ィ"))
+ ((("x" "w" "e"). ())("ゑ" "ヱ" "ェ"))
+
+ ((("w" "y" "i"). ())("ゐ" "ヰ" "ィ"))
+ ((("w" "y" "e"). ())("ゑ" "ヱ" "ェ"))
+
+ ((("c" "h" "a"). ())(("ち" "チ" "チ") ("ゃ" "ャ" "ャ")))
+ ((("c" "h" "i"). ())("ち" "チ" "チ"))
+ ((("c" "h" "u"). ())(("ち" "チ" "チ") ("ゅ" "ュ" "ュ")))
+ ((("c" "h" "e"). ())(("ち" "チ" "チ") ("ぇ" "ェ" "ェ")))
+ ((("c" "h" "o"). ())(("ち" "チ" "チ") ("ょ" "ョ" "ョ")))
+
+ ((("q" "w" "a"). ())(("く" "ク" "ク") ("ぁ" "ァ" "ァ")))
+ ((("q" "w" "i"). ())(("く" "ク" "ク") ("ぃ" "ィ" "ィ")))
+ ((("q" "w" "u"). ())(("く" "ク" "ク") ("ぅ" "ゥ" "ゥ")))
+ ((("q" "w" "e"). ())(("く" "ク" "ク") ("ぇ" "ェ" "ェ")))
+ ((("q" "w" "o"). ())(("く" "ク" "ク") ("ぉ" "ォ" "ォ")))
+
+ ((("q" "y" "a"). ())(("く" "ク" "ク") ("ゃ" "ャ" "ャ")))
+ ((("q" "y" "i"). ())(("く" "ク" "ク") ("ぃ" "ィ" "ィ")))
+ ((("q" "y" "u"). ())(("く" "ク" "ク") ("ゅ" "ュ" "ュ")))
+ ((("q" "y" "e"). ())(("く" "ク" "ク") ("ぇ" "ェ" "ェ")))
+ ((("q" "y" "o"). ())(("く" "ク" "ク") ("ょ" "ョ" "ョ")))
+
+ ((("g" "w" "a"). ())(("ぐ" "グ" "グ") ("ぁ" "ァ" "ァ")))
+ ((("g" "w" "i"). ())(("ぐ" "グ" "グ") ("ぃ" "ィ" "ィ")))
+ ((("g" "w" "u"). ())(("ぐ" "グ" "グ") ("ぅ" "ゥ" "ゥ")))
+ ((("g" "w" "e"). ())(("ぐ" "グ" "グ") ("ぇ" "ェ" "ェ")))
+ ((("g" "w" "o"). ())(("ぐ" "グ" "グ") ("ぉ" "ォ" "ォ")))
+
+ ((("z" "w" "a"). ())(("ず" "ズ" "ズ") ("ぁ" "ァ" "ァ")))
+ ((("z" "w" "i"). ())(("ず" "ズ" "ズ") ("ぃ" "ィ" "ィ")))
+ ((("z" "w" "u"). ())(("ず" "ズ" "ズ") ("ぅ" "ゥ" "ゥ")))
+ ((("z" "w" "e"). ())(("ず" "ズ" "ズ") ("ぇ" "ェ" "ェ")))
+ ((("z" "w" "o"). ())(("ず" "ズ" "ズ") ("ぉ" "ォ" "ォ")))
+
+ ;((("n" "w" "a"). ())(("ぬ" "ヌ" "ヌ") ("ぁ" "ァ" "ァ")))
+ ;((("n" "w" "i"). ())(("ぬ" "ヌ" "ヌ") ("ぃ" "ィ" "ィ")))
+ ;((("n" "w" "u"). ())(("ぬ" "ヌ" "ヌ") ("ぅ" "ゥ" "ゥ")))
+ ;((("n" "w" "e"). ())(("ぬ" "ヌ" "ヌ") ("ぇ" "ェ" "ェ")))
+ ;((("n" "w" "o"). ())(("ぬ" "ヌ" "ヌ") ("ぉ" "ォ" "ォ")))
+
+ ((("b" "w" "a"). ())(("ぶ" "ブ" "ブ") ("ぁ" "ァ" "ァ")))
+ ((("b" "w" "i"). ())(("ぶ" "ブ" "ブ") ("ぃ" "ィ" "ィ")))
+ ((("b" "w" "u"). ())(("ぶ" "ブ" "ブ") ("ぅ" "ゥ" "ゥ")))
+ ((("b" "w" "e"). ())(("ぶ" "ブ" "ブ") ("ぇ" "ェ" "ェ")))
+ ((("b" "w" "o"). ())(("ぶ" "ブ" "ブ") ("ぉ" "ォ" "ォ")))
+
+ ((("p" "w" "a"). ())(("ぷ" "プ" "プ") ("ぁ" "ァ" "ァ")))
+ ((("p" "w" "i"). ())(("ぷ" "プ" "プ") ("ぃ" "ィ" "ィ")))
+ ((("p" "w" "u"). ())(("ぷ" "プ" "プ") ("ぅ" "ゥ" "ゥ")))
+ ((("p" "w" "e"). ())(("ぷ" "プ" "プ") ("ぇ" "ェ" "ェ")))
+ ((("p" "w" "o"). ())(("ぷ" "プ" "プ") ("ぉ" "ォ" "ォ")))
+
+ ((("m" "w" "a"). ())(("む" "ム" "ム") ("ぁ" "ァ" "ァ")))
+ ((("m" "w" "i"). ())(("む" "ム" "ム") ("ぃ" "ィ" "ィ")))
+ ((("m" "w" "u"). ())(("む" "ム" "ム") ("ぅ" "ゥ" "ゥ")))
+ ((("m" "w" "e"). ())(("む" "ム" "ム") ("ぇ" "ェ" "ェ")))
+ ((("m" "w" "o"). ())(("む" "ム" "ム") ("ぉ" "ォ" "ォ")))
+
+ ((("y" "w" "a"). ())(("ゆ" "ユ" "ユ") ("ぁ" "ァ" "ァ")))
+ ((("y" "w" "i"). ())(("ゆ" "ユ" "ユ") ("ぃ" "ィ" "ィ")))
+ ((("y" "w" "u"). ())(("ゆ" "ユ" "ユ") ("ぅ" "ゥ" "ゥ")))
+ ((("y" "w" "e"). ())(("ゆ" "ユ" "ユ") ("ぇ" "ェ" "ェ")))
+ ((("y" "w" "o"). ())(("ゆ" "ユ" "ユ") ("ぉ" "ォ" "ォ")))
+
+ ((("r" "w" "a"). ())(("る" "ル" "ル") ("ぁ" "ァ" "ァ")))
+ ((("r" "w" "i"). ())(("る" "ル" "ル") ("ぃ" "ィ" "ィ")))
+ ((("r" "w" "u"). ())(("る" "ル" "ル") ("ぅ" "ゥ" "ゥ")))
+ ((("r" "w" "e"). ())(("る" "ル" "ル") ("ぇ" "ェ" "ェ")))
+ ((("r" "w" "o"). ())(("る" "ル" "ル") ("ぉ" "ォ" "ォ")))
+
+ ((("d" "'" "i"). ())(("で" "デ" "デ") ("ぃ" "ィ" "ィ")))
+ ((("d" "'" "y" "u"). ())(("で" "デ" "デ") ("ゅ" "ュ" "ュ")))
+
+ ((("d" "'" "u"). ())(("ど" "ド" "ド") ("ぅ" "ゥ" "ゥ")))
+
+ ((("t" "'" "i"). ())(("て" "テ" "テ") ("ぃ" "ィ" "ィ")))
+ ((("t" "'" "y" "u"). ())(("て" "テ" "テ") ("ゅ" "ュ" "ュ")))
+
+ ((("t" "'" "u"). ())(("と" "ト" "ト") ("ぅ" "ゥ" "ゥ")))
+
+ ))
+
+(define ja-type-direct -1)
+(define ja-type-hiragana 0)
+(define ja-type-katakana 1)
+(define ja-type-halfkana 2)
+(define ja-type-halfwidth-alnum 3)
+(define ja-type-fullwidth-alnum 4)
+
+(define ja-rk-rule (append ja-rk-rule-basic ja-rk-rule-additional))
+
+;; getting required type of kana string from above kana-str-list
+;; (ja-make-kana-str
+;; (("じ" "ジ" "ジ") ("ん" "ン" "ン") ("か" "カ" "カ"))
+;; ja-type-katakana)
+;; -> "カンジ"
+(define ja-make-kana-str
+ (lambda (sl type)
+ (let ((get-str-by-type
+ (lambda (l)
+ (cond
+ ((= type ja-type-hiragana)
+ (caar l))
+ ((= type ja-type-katakana)
+ (car (cdar l)))
+ ((= type ja-type-halfkana)
+ (cadr (cdar l)))))))
+ (if (not (null? sl))
+ (string-append (ja-make-kana-str (cdr sl) type)
+ (get-str-by-type sl))
+ ""))))
+
+(define ja-rk-rule-rule->table (lambda (rule)
+ (map
+ (lambda (item)
+ ; ((("k" "a")) ("か" "カ" "カ")) -> ("ka" "" "か")
+ ; ((("k" "k") "k") ("っ" "ッ" "ッ")) -> ("kk" "k" "っ")
+ ; ((("k" "y" "a")) (("き" "キ" "キ") ("ゃ" "ャ" "ャ"))) -> ("kya" "" "きゃ")
+ (list
+ ; ((("k" "a")) ("か" "カ" "カ")) -> "ka"
+ (fold-right string-append ""
+ (caar item))
+ (let ((next-input (cdar item)))
+ (or
+ (and
+ ; ((("k" "a")) ("か" "カ" "カ")) -> ""
+ (null? next-input) "")
+ ; ((("k" "k") "k") ("っ" "ッ" "ッ")) -> "k"
+ (car next-input)))
+ (let*
+ ((output (cadr item))
+ (single-output (car output))
+ (eucjp->utf8 (lambda (str)
+ (and-let* ((ic (iconv-open "UTF-8" "EUC-JP"))
+ (converted-str (iconv-code-conv ic str)))
+ (and ic
+ (iconv-release ic))
+ converted-str))))
+ (or
+ (and
+ ; ((("k" "a")) ("か" "カ" "カ")) -> "か"
+ (string? single-output)
+ (eucjp->utf8 single-output))
+ ; ((("k" "y" "a")) (("き" "キ" "キ") ("ゃ" "ャ" "ャ"))) -> "きゃ"
+ (eucjp->utf8
+ (fold-right string-append ""
+ (string-to-list
+ (ja-make-kana-str output ja-type-hiragana)))))))) rule)))
+
+(define ja-rk-rule-table->rule (lambda (table)
+ (map
+ (lambda (item)
+ ; ("ka" "" "か") -> ((("k" "a")) ("か" "カ" "カ"))
+ ; ("kk" "k" "っ") -> ((("k" "k") "k") ("っ" "ッ" "ッ"))
+ ; ("kya" "" "きゃ") -> ((("k" "y" "a")) (("き" "キ" "キ") ("ゃ" "ャ" "ャ")))
+ (list
+ (cons
+ (let ((input (car item)))
+ (or
+ (and
+ (string=? input "yen")
+ ; ("yen" "" "¥") -> ("yen")
+ '("yen"))
+ ; ("ka" "" "か") -> ("k" "a")
+ (reverse
+ (string-to-list input))))
+ (let ((next-input (cadr item)))
+ (or
+ (and
+ ; ("ka" "" "か") -> none
+ (string=? next-input "") '())
+ ; ("kk" "k" "っ") -> "k"
+ (cons next-input '()))))
+ (let ((output (caddr item))
+ (utf8->eucjp (lambda (str)
+ (and-let* ((ic (iconv-open "EUC-JP" "UTF-8"))
+ (converted-str (iconv-code-conv ic str)))
+ (and ic
+ (iconv-release ic))
+ converted-str))))
+ (or
+ (let ((eucjp-output (utf8->eucjp output)))
+ (and
+ (=
+ (length
+ (string-to-list eucjp-output)) 1)
+ ; ("ka" "" "か") -> ("か" "カ" "カ")
+ (ja-find-kana-list-from-rule ja-rk-rule eucjp-output)))
+ ; ("kya" "" "きゃ") -> (("き" "キ" "キ") ("ゃ" "ャ" "ャ"))
+ (map
+ (lambda (char)
+ (ja-find-kana-list-from-rule ja-rk-rule char))
+ (reverse
+ (string-to-list
+ (utf8->eucjp output)))))))) table)))
+
(define-custom-group 'ja-rk-rule
(N_ "Japanese Romaji-Kana")
(N_ "long description will be here."))
@@ -42,7 +655,21 @@
(N_ "Keep consonant Romaji not convertible to Kana")
(N_ "long description will be here."))
+(define-custom 'ja-rk-rule-table-basic
+ (ja-rk-rule-rule->table ja-rk-rule-basic)
+ '(ja-rk-rule)
+ '(table)
+ (N_ "Japanese Romaji-Kana rule")
+ (N_ "long description will be here."))
+
(custom-add-hook 'ja-rk-rule-keep-consonant?
'custom-set-hooks
(lambda ()
(ja-rk-rule-update)))
+
+(custom-add-hook 'ja-rk-rule-table-basic
+ 'custom-set-hooks
+ (lambda ()
+ (set! ja-rk-rule-basic
+ (ja-rk-rule-table->rule ja-rk-rule-table-basic))
+ (ja-rk-rule-update)))
diff --git a/scm/japanese.scm b/scm/japanese.scm
index 3ff95d0..f287fae 100644
--- a/scm/japanese.scm
+++ b/scm/japanese.scm
@@ -33,507 +33,6 @@
(require-extension (srfi 1 2))
(require-custom "japanese-custom.scm")
-(define ja-rk-rule-basic
- '(
- ((("-"). ())("ー" "ー" "ー"))
- (((","). ())("、" "、" "、"))
- ((("."). ())("。" "。" "。"))
- ((("!"). ())("!" "!" "!"))
- ((("\""). ())("”" "”" "\""))
- ((("#"). ())("#" "#" "#"))
- ((("$"). ())("$" "$" "$"))
- ((("%"). ())("%" "%" "%"))
- ((("&"). ())("&" "&" "&"))
- ((("'"). ())("’" "’" "'"))
- ((("("). ())("(" "(" "("))
- (((")"). ())(")" ")" ")"))
- ((("~"). ())("〜" "〜" "~"))
- ((("="). ())("=" "=" "="))
- ((("^"). ())("^" "^" "^"))
- ((("\\"). ())("\" "\" "\\"))
- ((("|"). ())("|" "|" "|"))
- ((("`"). ())("‘" "‘" "`"))
- ((("@"). ())("@" "@" "@"))
- ((("{"). ())("{" "{" "{"))
- ((("["). ())("「" "「" "「"))
- ((("+"). ())("+" "+" "+"))
- (((";"). ())(";" ";" ";"))
- ((("*"). ())("*" "*" "*"))
- (((":"). ())(":" ":" ":"))
- ((("}"). ())("}" "}" "}"))
- ((("]"). ())("」" "」" "」"))
- ((("<"). ())("<" "<" "<"))
- (((">"). ())(">" ">" ">"))
- ((("?"). ())("?" "?" "?"))
- ((("/"). ())("/" "/" "/"))
- ((("_"). ())("_" "_" "_"))
- ;; Since ordinary Japanese users press the "yen sign" key on
- ;; Japanese keyboard in romaji-halfwidth-kana-mode "to input
- ;; character code 134" rather than "to input yen sign symbol", I
- ;; changed the fullwidth yen sign with backslash.
- ;; -- YamaKen 2007-09-17
- ;; ((("yen"). ())("¥" "¥" "¥")) ;; XXX
- ((("yen"). ())("¥" "¥" "\\"))
-
- ((("1"). ())("1" "1" "1"))
- ((("2"). ())("2" "2" "2"))
- ((("3"). ())("3" "3" "3"))
- ((("4"). ())("4" "4" "4"))
- ((("5"). ())("5" "5" "5"))
- ((("6"). ())("6" "6" "6"))
- ((("7"). ())("7" "7" "7"))
- ((("8"). ())("8" "8" "8"))
- ((("9"). ())("9" "9" "9"))
- ((("0"). ())("0" "0" "0"))
-
- ((("a"). ())("あ" "ア" "ア"))
- ((("i"). ())("い" "イ" "イ"))
- ((("u"). ())("う" "ウ" "ウ"))
- ((("e"). ())("え" "エ" "エ"))
- ((("o"). ())("お" "オ" "オ"))
-
- ((("x" "a"). ())("ぁ" "ァ" "ァ"))
- ((("x" "i"). ())("ぃ" "ィ" "ィ"))
- ((("x" "y" "i"). ())("ぃ" "ィ" "ィ"))
- ((("x" "u"). ())("ぅ" "ゥ" "ゥ"))
- ((("x" "e"). ())("ぇ" "ェ" "ェ"))
- ((("x" "y" "e"). ())("ぇ" "ェ" "ェ"))
- ((("x" "o"). ())("ぉ" "ォ" "ォ"))
-
- ((("l" "a"). ())("ぁ" "ァ" "ァ"))
- ((("l" "i"). ())("ぃ" "ィ" "ィ"))
- ((("l" "u"). ())("ぅ" "ゥ" "ゥ"))
- ((("l" "e"). ())("ぇ" "ェ" "ェ"))
- ((("l" "o"). ())("ぉ" "ォ" "ォ"))
-
- ((("k" "k"). ("k"))("っ" "ッ" "ッ"))
-
- ((("k" "a"). ())("か" "カ" "カ"))
- ((("k" "i"). ())("き" "キ" "キ"))
- ((("k" "u"). ())("く" "ク" "ク"))
- ((("k" "e"). ())("け" "ケ" "ケ"))
- ((("k" "o"). ())("こ" "コ" "コ"))
- ((("k" "y" "a"). ())(("き" "キ" "キ") ("ゃ" "ャ" "ャ")))
- ((("k" "y" "i"). ())(("き" "キ" "キ") ("ぃ" "ィ" "ィ")))
- ((("k" "y" "u"). ())(("き" "キ" "キ") ("ゅ" "ュ" "ュ")))
- ((("k" "y" "e"). ())(("き" "キ" "キ") ("ぇ" "ェ" "ェ")))
- ((("k" "y" "o"). ())(("き" "キ" "キ") ("ょ" "ョ" "ョ")))
-
- ((("g" "g"). ("g"))("っ" "ッ" "ッ"))
-
-
- ((("g" "a"). ())("が" "ガ" "ガ"))
- ((("g" "i"). ())("ぎ" "ギ" "ギ"))
- ((("g" "u"). ())("ぐ" "グ" "グ"))
- ((("g" "e"). ())("げ" "ゲ" "ゲ"))
- ((("g" "o"). ())("ご" "ゴ" "ゴ"))
-
- ((("g" "y" "a"). ())(("ぎ" "ギ" "ギ") ("ゃ" "ャ" "ャ")))
- ((("g" "y" "i"). ())(("ぎ" "ギ" "ギ") ("ぃ" "ィ" "ィ")))
- ((("g" "y" "u"). ())(("ぎ" "ギ" "ギ") ("ゅ" "ュ" "ュ")))
- ((("g" "y" "e"). ())(("ぎ" "ギ" "ギ") ("ぇ" "ェ" "ェ")))
- ((("g" "y" "o"). ())(("ぎ" "ギ" "ギ") ("ょ" "ョ" "ョ")))
-
- ((("q" "a"). ())(("く" "ク" "ク") ("ぁ" "ァ" "ァ")))
- ((("q" "i"). ())(("く" "ク" "ク") ("ぃ" "ィ" "ィ")))
- ((("q" "u"). ())("く" "ク" "ク"))
- ((("q" "e"). ())(("く" "ク" "ク") ("ぇ" "ェ" "ェ")))
- ((("q" "o"). ())(("く" "ク" "ク") ("ぉ" "ォ" "ォ")))
-
- ((("s" "s"). ("s"))("っ" "ッ" "ッ"))
-
- ((("s" "a"). ())("さ" "サ" "サ"))
- ((("s" "i"). ())("し" "シ" "シ"))
- ((("s" "u"). ())("す" "ス" "ス"))
- ((("s" "e"). ())("せ" "セ" "セ"))
- ((("s" "o"). ())("そ" "ソ" "ソ"))
-
- ((("s" "y" "a"). ())(("し" "シ" "シ") ("ゃ" "ャ" "ャ")))
- ((("s" "y" "i"). ())(("し" "シ" "シ") ("ぃ" "ィ" "ィ")))
- ((("s" "y" "u"). ())(("し" "シ" "シ") ("ゅ" "ュ" "ュ")))
- ((("s" "y" "e"). ())(("し" "シ" "シ") ("ぇ" "ェ" "ェ")))
- ((("s" "y" "o"). ())(("し" "シ" "シ") ("ょ" "ョ" "ョ")))
-
- ((("z" "z"). ("z"))("っ" "ッ" "ッ"))
-
- ((("z" "a"). ())("ざ" "ザ" "ザ"))
- ((("z" "i"). ())("じ" "ジ" "ジ"))
- ((("z" "u"). ())("ず" "ズ" "ズ"))
- ((("z" "e"). ())("ぜ" "ゼ" "ゼ"))
- ((("z" "o"). ())("ぞ" "ゾ" "ゾ"))
- ((("z" "y" "a"). ())(("じ" "ジ" "ジ") ("ゃ" "ャ" "ャ")))
- ((("z" "y" "i"). ())(("じ" "ジ" "ジ") ("ぃ" "ィ" "ィ")))
- ((("z" "y" "u"). ())(("じ" "ジ" "ジ") ("ゅ" "ュ" "ュ")))
- ((("z" "y" "e"). ())(("じ" "ジ" "ジ") ("ぇ" "ェ" "ェ")))
- ((("z" "y" "o"). ())(("じ" "ジ" "ジ") ("ょ" "ョ" "ョ")))
-
- ((("j" "j"). ("j"))("っ" "ッ" "ッ"))
-
- ((("j" "a"). ())(("じ" "ジ" "ジ") ("ゃ" "ャ" "ャ")))
- ((("j" "i"). ())("じ" "ジ" "ジ"))
- ((("j" "u"). ())(("じ" "ジ" "ジ") ("ゅ" "ュ" "ュ")))
- ((("j" "e"). ())(("じ" "ジ" "ジ") ("ぇ" "ェ" "ェ")))
- ((("j" "o"). ())(("じ" "ジ" "ジ") ("ょ" "ョ" "ョ")))
-
- ((("j" "y" "a"). ())(("じ" "ジ" "ジ") ("ゃ" "ャ" "ャ")))
- ((("j" "y" "i"). ())(("じ" "ジ" "ジ") ("ぃ" "ィ" "ィ")))
- ((("j" "y" "u"). ())(("じ" "ジ" "ジ") ("ゅ" "ュ" "ュ")))
- ((("j" "y" "e"). ())(("じ" "ジ" "ジ") ("ぇ" "ェ" "ェ")))
- ((("j" "y" "o"). ())(("じ" "ジ" "ジ") ("ょ" "ョ" "ョ")))
-
- ((("t" "t"). ("t"))("っ" "ッ" "ッ"))
- ((("t" "c"). ("c"))("っ" "ッ" "ッ"))
-
- ((("t" "a"). ())("た" "タ" "タ"))
- ((("t" "i"). ())("ち" "チ" "チ"))
- ((("t" "u"). ())("つ" "ツ" "ツ"))
- ((("t" "e"). ())("て" "テ" "テ"))
- ((("t" "o"). ())("と" "ト" "ト"))
-
- ((("t" "y" "a"). ())(("ち" "チ" "チ") ("ゃ" "ャ" "ャ")))
- ((("t" "y" "i"). ())(("ち" "チ" "チ") ("ぃ" "ィ" "ィ")))
- ((("t" "y" "u"). ())(("ち" "チ" "チ") ("ゅ" "ュ" "ュ")))
- ((("t" "y" "e"). ())(("ち" "チ" "チ") ("ぇ" "ェ" "ェ")))
- ((("t" "y" "o"). ())(("ち" "チ" "チ") ("ょ" "ョ" "ョ")))
-
- ((("t" "s" "a"). ())(("つ" "ツ" "ツ") ("ぁ" "ァ" "ァ")))
- ((("t" "s" "i"). ())(("つ" "ツ" "ツ") ("ぃ" "ィ" "ィ")))
- ((("t" "s" "u"). ())("つ" "ツ" "ツ"))
- ((("t" "s" "e"). ())(("つ" "ツ" "ツ") ("ぇ" "ェ" "ェ")))
- ((("t" "s" "o"). ())(("つ" "ツ" "ツ") ("ぉ" "ォ" "ォ")))
-
- ((("c" "y" "a"). ())(("ち" "チ" "チ") ("ゃ" "ャ" "ャ")))
- ((("c" "y" "i"). ())(("ち" "チ" "チ") ("ぃ" "ィ" "ィ")))
- ((("c" "y" "u"). ())(("ち" "チ" "チ") ("ゅ" "ュ" "ュ")))
- ((("c" "y" "e"). ())(("ち" "チ" "チ") ("ぇ" "ェ" "ェ")))
- ((("c" "y" "o"). ())(("ち" "チ" "チ") ("ょ" "ョ" "ョ")))
-
- ((("x" "t" "u"). ())("っ" "ッ" "ッ"))
- ((("x" "t" "s" "u"). ())("っ" "ッ" "ッ"))
- ((("c" "c"). ("c"))("っ" "ッ" "ッ"))
-
- ((("d" "d"). ("d"))("っ" "ッ" "ッ"))
-
- ((("d" "a"). ())("だ" "ダ" "ダ"))
- ((("d" "i"). ())("ぢ" "ヂ" "ヂ"))
- ((("d" "u"). ())("づ" "ヅ" "ヅ"))
- ((("d" "e"). ())("で" "デ" "デ"))
- ((("d" "o"). ())("ど" "ド" "ド"))
-
- ((("d" "y" "a"). ())(("ぢ" "ヂ" "ヂ") ("ゃ" "ャ" "ャ")))
- ((("d" "y" "i"). ())(("ぢ" "ヂ" "ヂ") ("ぃ" "ィ" "ィ")))
- ((("d" "y" "u"). ())(("ぢ" "ヂ" "ヂ") ("ゅ" "ュ" "ュ")))
- ((("d" "y" "e"). ())(("ぢ" "ヂ" "ヂ") ("ぇ" "ェ" "ェ")))
- ((("d" "y" "o"). ())(("ぢ" "ヂ" "ヂ") ("ょ" "ョ" "ョ")))
-
- ((("n" "n"). ())("ん" "ン" "ン"))
- ((("n" "'"). ())("ん" "ン" "ン"))
- ((("n"). ())("ん" "ン" "ン"))
-
- ((("n" "a"). ())("な" "ナ" "ナ"))
- ((("n" "i"). ())("に" "ニ" "ニ"))
- ((("n" "u"). ())("ぬ" "ヌ" "ヌ"))
- ((("n" "e"). ())("ね" "ネ" "ネ"))
- ((("n" "o"). ())("の" "ノ" "ノ"))
-
- ((("n" "y" "a"). ())(("に" "ニ" "ニ") ("ゃ" "ャ" "ャ")))
- ((("n" "y" "i"). ())(("に" "ニ" "ニ") ("ぃ" "ィ" "ィ")))
- ((("n" "y" "u"). ())(("に" "ニ" "ニ") ("ゅ" "ュ" "ュ")))
- ((("n" "y" "e"). ())(("に" "ニ" "ニ") ("ぇ" "ェ" "ェ")))
- ((("n" "y" "o"). ())(("に" "ニ" "ニ") ("ょ" "ョ" "ョ")))
-
- ((("h" "h"). ("h"))("っ" "ッ" "ッ"))
-
- ((("h" "a"). ())("は" "ハ" "ハ"))
- ((("h" "i"). ())("ひ" "ヒ" "ヒ"))
- ((("h" "u"). ())("ふ" "フ" "フ"))
- ((("h" "e"). ())("へ" "ヘ" "ヘ"))
- ((("h" "o"). ())("ほ" "ホ" "ホ"))
-
- ((("h" "y" "a"). ())(("ひ" "ヒ" "ヒ") ("ゃ" "ャ" "ャ")))
- ((("h" "y" "i"). ())(("ひ" "ヒ" "ヒ") ("ぃ" "ィ" "ィ")))
- ((("h" "y" "u"). ())(("ひ" "ヒ" "ヒ") ("ゅ" "ュ" "ュ")))
- ((("h" "y" "e"). ())(("ひ" "ヒ" "ヒ") ("ぇ" "ェ" "ェ")))
- ((("h" "y" "o"). ())(("ひ" "ヒ" "ヒ") ("ょ" "ョ" "ョ")))
-
- ((("f" "f"). ("f"))("っ" "ッ" "ッ"))
-
- ((("f" "a"). ())(("ふ" "フ" "フ") ("ぁ" "ァ" "ァ")))
- ((("f" "i"). ())(("ふ" "フ" "フ") ("ぃ" "ィ" "ィ")))
- ((("f" "u"). ())("ふ" "フ" "フ"))
- ((("f" "e"). ())(("ふ" "フ" "フ") ("ぇ" "ェ" "ェ")))
- ((("f" "o"). ())(("ふ" "フ" "フ") ("ぉ" "ォ" "ォ")))
-
- ((("f" "y" "a"). ())(("ふ" "フ" "フ") ("ゃ" "ャ" "ャ")))
- ((("f" "y" "i"). ())(("ふ" "フ" "フ") ("ぃ" "ィ" "ィ")))
- ((("f" "y" "u"). ())(("ふ" "フ" "フ") ("ゅ" "ュ" "ュ")))
- ((("f" "y" "e"). ())(("ふ" "フ" "フ") ("ぇ" "ェ" "ェ")))
- ((("f" "y" "o"). ())(("ふ" "フ" "フ") ("ょ" "ョ" "ョ")))
-
- ((("b" "b"). ("b"))("っ" "ッ" "ッ"))
-
- ((("b" "a"). ())("ば" "バ" "バ"))
- ((("b" "i"). ())("び" "ビ" "ビ"))
- ((("b" "u"). ())("ぶ" "ブ" "ブ"))
- ((("b" "e"). ())("べ" "ベ" "ベ"))
- ((("b" "o"). ())("ぼ" "ボ" "ボ"))
-
- ((("b" "y" "a"). ())(("び" "ビ" "ビ") ("ゃ" "ャ" "ャ")))
- ((("b" "y" "i"). ())(("び" "ビ" "ビ") ("ぃ" "ィ" "ィ")))
- ((("b" "y" "u"). ())(("び" "ビ" "ビ") ("ゅ" "ュ" "ュ")))
- ((("b" "y" "e"). ())(("び" "ビ" "ビ") ("ぇ" "ェ" "ェ")))
- ((("b" "y" "o"). ())(("び" "ビ" "ビ") ("ょ" "ョ" "ョ")))
-
- ((("p" "p"). ("p"))("っ" "ッ" "ッ"))
-
- ((("p" "a"). ())("ぱ" "パ" "パ"))
- ((("p" "i"). ())("ぴ" "ピ" "ピ"))
- ((("p" "u"). ())("ぷ" "プ" "プ"))
- ((("p" "e"). ())("ぺ" "ペ" "ペ"))
- ((("p" "o"). ())("ぽ" "ポ" "ポ"))
-
- ((("p" "y" "a"). ())(("ぴ" "ピ" "ピ") ("ゃ" "ャ" "ャ")))
- ((("p" "y" "i"). ())(("ぴ" "ピ" "ピ") ("ぃ" "ィ" "ィ")))
- ((("p" "y" "u"). ())(("ぴ" "ピ" "ピ") ("ゅ" "ュ" "ュ")))
- ((("p" "y" "e"). ())(("ぴ" "ピ" "ピ") ("ぇ" "ェ" "ェ")))
- ((("p" "y" "o"). ())(("ぴ" "ピ" "ピ") ("ょ" "ョ" "ョ")))
-
- ((("m" "m"). ("m"))("っ" "ッ" "ッ"))
-
- ((("m" "b"). ("b"))("ん" "ン" "ン"))
- ((("m" "p"). ("p"))("ん" "ン" "ン"))
-
- ((("m" "a"). ())("ま" "マ" "マ"))
- ((("m" "i"). ())("み" "ミ" "ミ"))
- ((("m" "u"). ())("む" "ム" "ム"))
- ((("m" "e"). ())("め" "メ" "メ"))
- ((("m" "o"). ())("も" "モ" "モ"))
-
- ((("m" "y" "a"). ())(("み" "ミ" "ミ") ("ゃ" "ャ" "ャ")))
- ((("m" "y" "i"). ())(("み" "ミ" "ミ") ("ぃ" "ィ" "ィ")))
- ((("m" "y" "u"). ())(("み" "ミ" "ミ") ("ゅ" "ュ" "ュ")))
- ((("m" "y" "e"). ())(("み" "ミ" "ミ") ("ぇ" "ェ" "ェ")))
- ((("m" "y" "o"). ())(("み" "ミ" "ミ") ("ょ" "ョ" "ョ")))
-
- ((("y" "y"). ("y"))("っ" "ッ" "ッ"))
-
- ((("y" "a"). ())("や" "ヤ" "ヤ"))
- ((("y" "u"). ())("ゆ" "ユ" "ユ"))
- ((("y" "e"). ())(("い" "イ" "イ") ("ぇ" "ェ" "ェ")))
- ((("y" "o"). ())("よ" "ヨ" "ヨ"))
-
- ((("x" "c" "a"). ())("ヵ" "ヵ" "カ"))
- ((("x" "k" "a"). ())("ヵ" "ヵ" "カ"))
- ((("x" "k" "e"). ())("ヶ" "ヶ" "ケ"))
-
- ((("x" "y" "a"). ())("ゃ" "ャ" "ャ"))
- ((("x" "y" "u"). ())("ゅ" "ュ" "ュ"))
- ((("x" "y" "o"). ())("ょ" "ョ" "ョ"))
-
- ((("r" "r"). ("r"))("っ" "ッ" "ッ"))
-
- ((("r" "a"). ())("ら" "ラ" "ラ"))
- ((("r" "i"). ())("り" "リ" "リ"))
- ((("r" "u"). ())("る" "ル" "ル"))
- ((("r" "e"). ())("れ" "レ" "レ"))
- ((("r" "o"). ())("ろ" "ロ" "ロ"))
-
- ((("l" "t" "u"). ())("っ" "ッ" "ッ"))
- ((("l" "t" "s" "u"). ())("っ" "ッ" "ッ"))
-
- ((("l" "y" "a"). ())("ゃ" "ャ" "ャ"))
- ((("l" "y" "i"). ())("ぃ" "ィ" "ィ"))
- ((("l" "y" "u"). ())("ゅ" "ュ" "ュ"))
- ((("l" "y" "e"). ())("ぇ" "ェ" "ェ"))
- ((("l" "y" "o"). ())("ょ" "ョ" "ョ"))
-
- ((("r" "y" "a"). ())(("り" "リ" "リ") ("ゃ" "ャ" "ャ")))
- ((("r" "y" "i"). ())(("り" "リ" "リ") ("ぃ" "ィ" "ィ")))
- ((("r" "y" "u"). ())(("り" "リ" "リ") ("ゅ" "ュ" "ュ")))
- ((("r" "y" "e"). ())(("り" "リ" "リ") ("ぇ" "ェ" "ェ")))
- ((("r" "y" "o"). ())(("り" "リ" "リ") ("ょ" "ョ" "ョ")))
-
- ((("w" "w"). ("w"))("っ" "ッ" "ッ"))
-
- ((("w" "a"). ())("わ" "ワ" "ワ"))
- ((("w" "i"). ())(("う" "ウ" "ウ") ("ぃ" "ィ" "ィ")))
- ((("w" "u"). ())("う" "ウ" "ウ"))
- ((("w" "e"). ())(("う" "ウ" "ウ") ("ぇ" "ェ" "ェ")))
- ((("w" "o"). ())("を" "ヲ" "ヲ"))
- ((("w" "h" "a"). ())(("う" "ウ" "ウ") ("ぁ" "ァ" "ァ")))
- ((("w" "h" "i"). ())(("う" "ウ" "ウ") ("ぃ" "ィ" "ィ")))
- ((("w" "h" "u"). ())("う" "ウ" "ウ"))
- ((("w" "h" "e"). ())(("う" "ウ" "ウ") ("ぇ" "ェ" "ェ")))
- ((("w" "h" "o"). ())(("う" "ウ" "ウ") ("ぉ" "ォ" "ォ")))
-
- ((("v" "v"). ("v"))("っ" "ッ" "ッ"))
-
- ((("v" "a"). ())(("う゛" "ヴ" "ヴ") ("ぁ" "ァ" "ァ")))
- ((("v" "i"). ())(("う゛" "ヴ" "ヴ") ("ぃ" "ィ" "ィ")))
- ((("v" "u"). ())("う゛" "ヴ" "ヴ"))
- ((("v" "e"). ())(("う゛" "ヴ" "ヴ") ("ぇ" "ェ" "ェ")))
- ((("v" "o"). ())(("う゛" "ヴ" "ヴ") ("ぉ" "ォ" "ォ")))
-
- ((("v" "y" "a"). ())(("う゛" "ヴ" "ヴ") ("ゃ" "ャ" "ャ")))
- ((("v" "y" "u"). ())(("う゛" "ヴ" "ヴ") ("ゅ" "ュ" "ュ")))
- ((("v" "y" "o"). ())(("う゛" "ヴ" "ヴ") ("ょ" "ョ" "ョ")))
-
- ((("z" "k"). ())("↑" "↑" ""))
- ((("z" "j"). ())("↓" "↓" ""))
- ((("z" "h"). ())("←" "←" ""))
- ((("z" "l"). ())("→" "→" ""))
- ((("z" "-"). ())("〜" "〜" ""))
- ((("z" "["). ())("『" "『" ""))
- ((("z" "]"). ())("』" "』" ""))
- ((("z" ","). ())("‥" "‥" ""))
- ((("z" "."). ())("…" "…" ""))
- ((("z" "/"). ())("・" "・" "・"))
- ))
-
-(define ja-rk-rule-additional
- '(
- ((("d" "s" "u"). ())("づ" "ヅ" "ヅ"))
-
- ((("d" "h" "a"). ())(("で" "デ" "デ") ("ゃ" "ャ" "ャ")))
- ((("d" "h" "i"). ())(("で" "デ" "デ") ("ぃ" "ィ" "ィ")))
- ((("d" "h" "u"). ())(("で" "デ" "デ") ("ゅ" "ュ" "ュ")))
- ((("d" "h" "e"). ())(("で" "デ" "デ") ("ぇ" "ェ" "ェ")))
- ((("d" "h" "o"). ())(("で" "デ" "デ") ("ょ" "ョ" "ョ")))
-
- ((("d" "w" "a"). ())(("ど" "ド" "ド") ("ぁ" "ァ" "ァ")))
- ((("d" "w" "i"). ())(("ど" "ド" "ド") ("ぃ" "ィ" "ィ")))
- ((("d" "w" "u"). ())(("ど" "ド" "ド") ("ぅ" "ゥ" "ゥ")))
- ((("d" "w" "e"). ())(("ど" "ド" "ド") ("ぇ" "ェ" "ェ")))
- ((("d" "w" "o"). ())(("ど" "ド" "ド") ("ぉ" "ォ" "ォ")))
-
- ((("k" "w" "a"). ())(("く" "ク" "ク") ("ぁ" "ァ" "ァ")))
- ((("k" "w" "i"). ())(("く" "ク" "ク") ("ぃ" "ィ" "ィ")))
- ((("k" "w" "u"). ())(("く" "ク" "ク") ("ぅ" "ゥ" "ゥ")))
- ((("k" "w" "e"). ())(("く" "ク" "ク") ("ぇ" "ェ" "ェ")))
- ((("k" "w" "o"). ())(("く" "ク" "ク") ("ぉ" "ォ" "ォ")))
-
- ((("s" "h" "a"). ())(("し" "シ" "シ") ("ゃ" "ャ" "ャ")))
- ((("s" "h" "i"). ())("し" "シ" "シ"))
- ((("s" "h" "u"). ())(("し" "シ" "シ") ("ゅ" "ュ" "ュ")))
- ((("s" "h" "e"). ())(("し" "シ" "シ") ("ぇ" "ェ" "ェ")))
- ((("s" "h" "o"). ())(("し" "シ" "シ") ("ょ" "ョ" "ョ")))
-
- ((("s" "w" "a"). ())(("す" "ス" "ス") ("ぁ" "ァ" "ァ")))
- ((("s" "w" "i"). ())(("す" "ス" "ス") ("ぃ" "ィ" "ィ")))
- ((("s" "w" "u"). ())(("す" "ス" "ス") ("ぅ" "ゥ" "ゥ")))
- ((("s" "w" "e"). ())(("す" "ス" "ス") ("ぇ" "ェ" "ェ")))
- ((("s" "w" "o"). ())(("す" "ス" "ス") ("ぉ" "ォ" "ォ")))
-
- ((("t" "w" "a"). ())(("と" "ト" "ト") ("ぁ" "ァ" "ァ")))
- ((("t" "w" "i"). ())(("と" "ト" "ト") ("ぃ" "ィ" "ィ")))
- ((("t" "w" "u"). ())(("と" "ト" "ト") ("ぅ" "ゥ" "ゥ")))
- ((("t" "w" "e"). ())(("と" "ト" "ト") ("ぇ" "ェ" "ェ")))
- ((("t" "w" "o"). ())(("と" "ト" "ト") ("ぉ" "ォ" "ォ")))
-
- ((("t" "h" "a"). ())(("て" "テ" "テ") ("ゃ" "ャ" "ャ")))
- ((("t" "h" "i"). ())(("て" "テ" "テ") ("ぃ" "ィ" "ィ")))
- ((("t" "h" "u"). ())(("て" "テ" "テ") ("ゅ" "ュ" "ュ")))
- ((("t" "h" "e"). ())(("て" "テ" "テ") ("ぇ" "ェ" "ェ")))
- ((("t" "h" "o"). ())(("て" "テ" "テ") ("ょ" "ョ" "ョ")))
-
- ((("h" "w" "a"). ())(("ふ" "フ" "フ") ("ぁ" "ァ" "ァ")))
- ((("h" "w" "i"). ())(("ふ" "フ" "フ") ("ぃ" "ィ" "ィ")))
- ((("h" "w" "e"). ())(("ふ" "フ" "フ") ("ぇ" "ェ" "ェ")))
- ((("h" "w" "o"). ())(("ふ" "フ" "フ") ("ぉ" "ォ" "ォ")))
-
- ((("f" "w" "a"). ())(("ふ" "フ" "フ") ("ぁ" "ァ" "ァ")))
- ((("f" "w" "i"). ())(("ふ" "フ" "フ") ("ぃ" "ィ" "ィ")))
- ((("f" "w" "u"). ())(("ふ" "フ" "フ") ("ぅ" "ゥ" "ゥ")))
- ((("f" "w" "e"). ())(("ふ" "フ" "フ") ("ぇ" "ェ" "ェ")))
- ((("f" "w" "o"). ())(("ふ" "フ" "フ") ("ぉ" "ォ" "ォ")))
-
- ((("x" "w" "a"). ())("ゎ" "ヮ" "ワ"))
- ((("x" "w" "i"). ())("ゐ" "ヰ" "ィ"))
- ((("x" "w" "e"). ())("ゑ" "ヱ" "ェ"))
-
- ((("w" "y" "i"). ())("ゐ" "ヰ" "ィ"))
- ((("w" "y" "e"). ())("ゑ" "ヱ" "ェ"))
-
- ((("c" "h" "a"). ())(("ち" "チ" "チ") ("ゃ" "ャ" "ャ")))
- ((("c" "h" "i"). ())("ち" "チ" "チ"))
- ((("c" "h" "u"). ())(("ち" "チ" "チ") ("ゅ" "ュ" "ュ")))
- ((("c" "h" "e"). ())(("ち" "チ" "チ") ("ぇ" "ェ" "ェ")))
- ((("c" "h" "o"). ())(("ち" "チ" "チ") ("ょ" "ョ" "ョ")))
-
- ((("q" "w" "a"). ())(("く" "ク" "ク") ("ぁ" "ァ" "ァ")))
- ((("q" "w" "i"). ())(("く" "ク" "ク") ("ぃ" "ィ" "ィ")))
- ((("q" "w" "u"). ())(("く" "ク" "ク") ("ぅ" "ゥ" "ゥ")))
- ((("q" "w" "e"). ())(("く" "ク" "ク") ("ぇ" "ェ" "ェ")))
- ((("q" "w" "o"). ())(("く" "ク" "ク") ("ぉ" "ォ" "ォ")))
-
- ((("q" "y" "a"). ())(("く" "ク" "ク") ("ゃ" "ャ" "ャ")))
- ((("q" "y" "i"). ())(("く" "ク" "ク") ("ぃ" "ィ" "ィ")))
- ((("q" "y" "u"). ())(("く" "ク" "ク") ("ゅ" "ュ" "ュ")))
- ((("q" "y" "e"). ())(("く" "ク" "ク") ("ぇ" "ェ" "ェ")))
- ((("q" "y" "o"). ())(("く" "ク" "ク") ("ょ" "ョ" "ョ")))
-
- ((("g" "w" "a"). ())(("ぐ" "グ" "グ") ("ぁ" "ァ" "ァ")))
- ((("g" "w" "i"). ())(("ぐ" "グ" "グ") ("ぃ" "ィ" "ィ")))
- ((("g" "w" "u"). ())(("ぐ" "グ" "グ") ("ぅ" "ゥ" "ゥ")))
- ((("g" "w" "e"). ())(("ぐ" "グ" "グ") ("ぇ" "ェ" "ェ")))
- ((("g" "w" "o"). ())(("ぐ" "グ" "グ") ("ぉ" "ォ" "ォ")))
-
- ((("z" "w" "a"). ())(("ず" "ズ" "ズ") ("ぁ" "ァ" "ァ")))
- ((("z" "w" "i"). ())(("ず" "ズ" "ズ") ("ぃ" "ィ" "ィ")))
- ((("z" "w" "u"). ())(("ず" "ズ" "ズ") ("ぅ" "ゥ" "ゥ")))
- ((("z" "w" "e"). ())(("ず" "ズ" "ズ") ("ぇ" "ェ" "ェ")))
- ((("z" "w" "o"). ())(("ず" "ズ" "ズ") ("ぉ" "ォ" "ォ")))
-
- ;((("n" "w" "a"). ())(("ぬ" "ヌ" "ヌ") ("ぁ" "ァ" "ァ")))
- ;((("n" "w" "i"). ())(("ぬ" "ヌ" "ヌ") ("ぃ" "ィ" "ィ")))
- ;((("n" "w" "u"). ())(("ぬ" "ヌ" "ヌ") ("ぅ" "ゥ" "ゥ")))
- ;((("n" "w" "e"). ())(("ぬ" "ヌ" "ヌ") ("ぇ" "ェ" "ェ")))
- ;((("n" "w" "o"). ())(("ぬ" "ヌ" "ヌ") ("ぉ" "ォ" "ォ")))
-
- ((("b" "w" "a"). ())(("ぶ" "ブ" "ブ") ("ぁ" "ァ" "ァ")))
- ((("b" "w" "i"). ())(("ぶ" "ブ" "ブ") ("ぃ" "ィ" "ィ")))
- ((("b" "w" "u"). ())(("ぶ" "ブ" "ブ") ("ぅ" "ゥ" "ゥ")))
- ((("b" "w" "e"). ())(("ぶ" "ブ" "ブ") ("ぇ" "ェ" "ェ")))
- ((("b" "w" "o"). ())(("ぶ" "ブ" "ブ") ("ぉ" "ォ" "ォ")))
-
- ((("p" "w" "a"). ())(("ぷ" "プ" "プ") ("ぁ" "ァ" "ァ")))
- ((("p" "w" "i"). ())(("ぷ" "プ" "プ") ("ぃ" "ィ" "ィ")))
- ((("p" "w" "u"). ())(("ぷ" "プ" "プ") ("ぅ" "ゥ" "ゥ")))
- ((("p" "w" "e"). ())(("ぷ" "プ" "プ") ("ぇ" "ェ" "ェ")))
- ((("p" "w" "o"). ())(("ぷ" "プ" "プ") ("ぉ" "ォ" "ォ")))
-
- ((("m" "w" "a"). ())(("む" "ム" "ム") ("ぁ" "ァ" "ァ")))
- ((("m" "w" "i"). ())(("む" "ム" "ム") ("ぃ" "ィ" "ィ")))
- ((("m" "w" "u"). ())(("む" "ム" "ム") ("ぅ" "ゥ" "ゥ")))
- ((("m" "w" "e"). ())(("む" "ム" "ム") ("ぇ" "ェ" "ェ")))
- ((("m" "w" "o"). ())(("む" "ム" "ム") ("ぉ" "ォ" "ォ")))
-
- ((("y" "w" "a"). ())(("ゆ" "ユ" "ユ") ("ぁ" "ァ" "ァ")))
- ((("y" "w" "i"). ())(("ゆ" "ユ" "ユ") ("ぃ" "ィ" "ィ")))
- ((("y" "w" "u"). ())(("ゆ" "ユ" "ユ") ("ぅ" "ゥ" "ゥ")))
- ((("y" "w" "e"). ())(("ゆ" "ユ" "ユ") ("ぇ" "ェ" "ェ")))
- ((("y" "w" "o"). ())(("ゆ" "ユ" "ユ") ("ぉ" "ォ" "ォ")))
-
- ((("r" "w" "a"). ())(("る" "ル" "ル") ("ぁ" "ァ" "ァ")))
- ((("r" "w" "i"). ())(("る" "ル" "ル") ("ぃ" "ィ" "ィ")))
- ((("r" "w" "u"). ())(("る" "ル" "ル") ("ぅ" "ゥ" "ゥ")))
- ((("r" "w" "e"). ())(("る" "ル" "ル") ("ぇ" "ェ" "ェ")))
- ((("r" "w" "o"). ())(("る" "ル" "ル") ("ぉ" "ォ" "ォ")))
-
- ((("d" "'" "i"). ())(("で" "デ" "デ") ("ぃ" "ィ" "ィ")))
- ((("d" "'" "y" "u"). ())(("で" "デ" "デ") ("ゅ" "ュ" "ュ")))
-
- ((("d" "'" "u"). ())(("ど" "ド" "ド") ("ぅ" "ゥ" "ゥ")))
-
- ((("t" "'" "i"). ())(("て" "テ" "テ") ("ぃ" "ィ" "ィ")))
- ((("t" "'" "y" "u"). ())(("て" "テ" "テ") ("ゅ" "ュ" "ュ")))
-
- ((("t" "'" "u"). ())(("と" "ト" "ト") ("ぅ" "ゥ" "ゥ")))
-
- ))
-
-(define ja-rk-rule (append ja-rk-rule-basic ja-rk-rule-additional))
-
(define ja-wide-rule
'(("a" "a")
("b" "b")
@@ -861,13 +360,6 @@
(ja-make-kana-str-list (cdr sl)))
'())))
-(define ja-type-direct -1)
-(define ja-type-hiragana 0)
-(define ja-type-katakana 1)
-(define ja-type-halfkana 2)
-(define ja-type-halfwidth-alnum 3)
-(define ja-type-fullwidth-alnum 4)
-
(define ja-opposite-kana
(lambda (kana)
(cond
@@ -877,27 +369,6 @@
ja-type-hiragana)
((= kana ja-type-halfkana)
ja-type-hiragana))))
-
-;; getting required type of kana string from above kana-str-list
-;; (ja-make-kana-str
-;; (("じ" "ジ" "ジ") ("ん" "ン" "ン") ("か" "カ" "カ"))
-;; ja-type-katakana)
-;; -> "カンジ"
-(define ja-make-kana-str
- (lambda (sl type)
- (let ((get-str-by-type
- (lambda (l)
- (cond
- ((= type ja-type-hiragana)
- (caar l))
- ((= type ja-type-katakana)
- (car (cdar l)))
- ((= type ja-type-halfkana)
- (cadr (cdar l)))))))
- (if (not (null? sl))
- (string-append (ja-make-kana-str (cdr sl) type)
- (get-str-by-type sl))
- ""))))
(define japanese-roma-set-yen-representation
(lambda ()
@@ -924,6 +395,8 @@
(define ja-rk-rule-update
(lambda ()
+ (set! ja-rk-rule-basic
+ (ja-rk-rule-table->rule ja-rk-rule-table-basic))
(if ja-rk-rule-keep-consonant?
(set! ja-rk-rule (append ja-rk-rule-consonant-to-keep
ja-rk-rule-basic
diff --git a/test/test-custom.scm b/test/test-custom.scm
index 6b82677..cda24fd 100755
--- a/test/test-custom.scm
+++ b/test/test-custom.scm
@@ -322,6 +322,45 @@
(assert-false (uim-bool '(custom-key?
'(test-nonexistent-key "<Alt>a")))))
+ ("test custom-table?"
+ (assert-true (uim-bool '(custom-table?
+ '())))
+ (assert-true (uim-bool '(custom-table?
+ '(("")))))
+ (assert-true (uim-bool '(custom-table?
+ '(("Alice")))))
+ (assert-true (uim-bool '(custom-table?
+ '(("Alice" "Bob")))))
+ (assert-true (uim-bool '(custom-table?
+ '(("Alice" "Bob") ("Carol" "Dave")))))
+ (assert-true (uim-bool '(custom-table?
+ '(("Alice" "Bob") ("Carol" "Dave" "Eve")))))
+
+ (assert-false (uim-bool '(custom-table?
+ #t)))
+ (assert-false (uim-bool '(custom-table?
+ "Alice")))
+ (assert-false (uim-bool '(custom-table?
+ 'Alice)))
+ (assert-false (uim-bool '(custom-table?
+ 1)))
+
+ (assert-false (uim-bool '(custom-table?
+ '(("Alice" "Bob") #t))))
+ (assert-false (uim-bool '(custom-table?
+ '(("Alice" "Bob") "Carol"))))
+ (assert-false (uim-bool '(custom-table?
+ '(("Alice" "Bob") 'Carol))))
+ (assert-false (uim-bool '(custom-table?
+ '(("Alice" "Bob") 1))))
+
+ (assert-false (uim-bool '(custom-table?
+ '(("Alice" "Bob") ("Carol" "Dave" #t)))))
+ (assert-false (uim-bool '(custom-table?
+ '(("Alice" "Bob") ("Carol" "Dave" 'Eve)))))
+ (assert-false (uim-bool '(custom-table?
+ '(("Alice" "Bob") ("Carol" "Dave" 1))))))
+
("test custom-expand-key-references"
(assert-equal '("<Control>g" "escape")
(uim '(custom-value 'test-cancel-key)))
@@ -1763,6 +1802,11 @@
(latin "latin" "latin")
(wide-latin "wide-latin" "wide-latin"))
"Mode list"
+ "long description will be here."))
+ (uim '(define-custom 'test-case-table '(("abc" "ABC") ("def" "DEF"))
+ '(test)
+ '(table)
+ "alphabet table"
"long description will be here."))))
("test custom-valid?"
@@ -1834,7 +1878,9 @@
(assert-equal "a string"
(uim '(custom-value 'test-string)))
(assert-equal "/usr/share/skk/SKK-JISYO.L"
- (uim '(custom-value 'test-dic-file-name))))
+ (uim '(custom-value 'test-dic-file-name)))
+ (assert-equal '(("abc" "ABC") ("def" "DEF"))
+ (uim '(custom-value 'test-case-table))))
("test custom-set-value!"
;;; choice
@@ -1957,7 +2003,21 @@
;; invalid value is ignored
(assert-false (uim-bool '(custom-set-value! 'test-modelist 'kanji)))
(assert-equal 'latin
- (uim '(custom-value 'test-modelist))))
+ (uim '(custom-value 'test-modelist)))
+ ;;; table
+ ;; default value
+ (assert-equal '(("abc" "ABC") ("def" "DEF"))
+ (uim '(custom-value 'test-case-table)))
+ ;; valid value
+ (assert-true (uim-bool '(custom-set-value!
+ 'test-case-table
+ '(("ghi" "GHI") ("jkl" "JKL")))))
+ (assert-equal '(("ghi" "GHI") ("jkl" "JKL"))
+ (uim '(custom-value 'test-case-table)))
+ ;; invalid value is ignored
+ (assert-false (uim-bool '(custom-set-value! 'test-case-table #f)))
+ (assert-equal '(("ghi" "GHI") ("jkl" "JKL"))
+ (uim '(custom-value 'test-case-table))))
("test custom-default?"
;;; choice
@@ -2045,7 +2105,21 @@
;; come back to default
(assert-true (uim-bool '(custom-set-value! 'test-dic-file-name
"/usr/share/skk/SKK-JISYO.L")))
- (assert-true (uim-bool '(custom-default? 'test-dic-file-name))))
+ (assert-true (uim-bool '(custom-default? 'test-dic-file-name)))
+
+ ;;; table
+ ;; default value
+ (assert-equal '(("abc" "ABC") ("def" "DEF"))
+ (uim '(custom-value 'test-case-table)))
+ (assert-true (uim-bool '(custom-default? 'test-case-table)))
+ ;; valid, but non-default value
+ (assert-true (uim-bool '(custom-set-value! 'test-case-table
+ '(("ghi" "GHI") ("jkl" "JKL")))))
+ (assert-false (uim-bool '(custom-default? 'test-case-table)))
+ ;; come back to default
+ (assert-true (uim-bool '(custom-set-value! 'test-case-table
+ '(("abc" "ABC") ("def" "DEF")))))
+ (assert-true (uim-bool '(custom-default? 'test-case-table))))
("test custom-default-value"
;;; choice
@@ -2134,7 +2208,21 @@
(assert-equal "/usr/local/share/skk/SKK-JISYO.ML"
(uim '(custom-value 'test-dic-file-name)))
(assert-equal "/usr/share/skk/SKK-JISYO.L"
- (uim '(custom-default-value 'test-dic-file-name))))
+ (uim '(custom-default-value 'test-dic-file-name)))
+
+ ;;; table
+ ;; default value
+ (assert-equal '(("abc" "ABC") ("def" "DEF"))
+ (uim '(custom-value 'test-case-table)))
+ (assert-equal '(("abc" "ABC") ("def" "DEF"))
+ (uim '(custom-default-value 'test-case-table)))
+ ;; default value is not affected by current value
+ (assert-true (uim-bool '(custom-set-value! 'test-case-table
+ '(("ghi" "GHI") ("jkl" "JKL")))))
+ (assert-equal '(("ghi" "GHI") ("jkl" "JKL"))
+ (uim '(custom-value 'test-case-table)))
+ (assert-equal '(("abc" "ABC") ("def" "DEF"))
+ (uim '(custom-default-value 'test-case-table))))
("test custom-groups"
(assert-equal '(global main)
@@ -2150,7 +2238,9 @@
(assert-equal '(test main)
(uim '(custom-groups 'test-string)))
(assert-equal '(test main)
- (uim '(custom-groups 'test-dic-file-name))))
+ (uim '(custom-groups 'test-dic-file-name)))
+ (assert-equal '(test main)
+ (uim '(custom-groups 'test-case-table))))
("test custom-type"
(assert-equal 'choice
@@ -2166,7 +2256,9 @@
(assert-equal 'string
(uim '(custom-type 'test-string)))
(assert-equal 'pathname
- (uim '(custom-type 'test-dic-file-name))))
+ (uim '(custom-type 'test-dic-file-name)))
+ (assert-equal 'table
+ (uim '(custom-type 'test-case-table))))
("test custom-type-attrs"
(assert-equal '((test-style-uim "uim" "uim native")
@@ -2186,7 +2278,9 @@
(assert-equal '(".+")
(uim '(custom-type-attrs 'test-string)))
(assert-equal '(regular-file)
- (uim '(custom-type-attrs 'test-dic-file-name))))
+ (uim '(custom-type-attrs 'test-dic-file-name)))
+ (assert-equal '()
+ (uim '(custom-type-attrs 'test-case-table))))
("test custom-range"
(assert-equal '(test-style-uim test-style-ddskk test-style-canna)
@@ -2202,7 +2296,9 @@
(assert-equal '(".+")
(uim '(custom-range 'test-string)))
(assert-equal ()
- (uim '(custom-range 'test-dic-file-name))))
+ (uim '(custom-range 'test-dic-file-name)))
+ (assert-equal ()
+ (uim '(custom-range 'test-case-table))))
("test custom-label"
(assert-equal "Test style"
@@ -2218,7 +2314,9 @@
(assert-equal "A string for testing purpose"
(uim '(custom-label 'test-string)))
(assert-equal "Dictionary file"
- (uim '(custom-label 'test-dic-file-name))))
+ (uim '(custom-label 'test-dic-file-name)))
+ (assert-equal "alphabet table"
+ (uim '(custom-label 'test-case-table))))
("test custom-desc"
(assert-equal "long description will be here."
@@ -2234,7 +2332,9 @@
(assert-equal "long description will be here."
(uim '(custom-desc 'test-style)))
(assert-equal "long description will be here."
- (uim '(custom-desc 'test-dic-file-name))))
+ (uim '(custom-desc 'test-dic-file-name)))
+ (assert-equal "long description will be here."
+ (uim '(custom-desc 'test-case-table))))
("test custom-value-as-literal"
(assert-equal "'test-style-ddskk"
@@ -2256,7 +2356,9 @@
(assert-equal "\"a string\""
(uim '(custom-value-as-literal 'test-string)))
(assert-equal "\"/usr/share/skk/SKK-JISYO.L\""
- (uim '(custom-value-as-literal 'test-dic-file-name))))
+ (uim '(custom-value-as-literal 'test-dic-file-name)))
+ (assert-equal "'((\"abc\" \"ABC\") (\"def\" \"DEF\"))"
+ (uim '(custom-value-as-literal 'test-case-table))))
("test custom-definition-as-literal"
(assert-equal "(define test-style 'test-style-ddskk)"
@@ -2279,6 +2381,8 @@
(uim '(custom-definition-as-literal 'test-string)))
(assert-equal "(define test-dic-file-name \"/usr/share/skk/SKK-JISYO.L\")"
(uim '(custom-definition-as-literal 'test-dic-file-name)))
+ (assert-equal "(define test-case-table '((\"abc\" \"ABC\") (\"def\" \"DEF\")))"
+ (uim '(custom-definition-as-literal 'test-case-table)))
;; hooked
(assert-equal "(define test-style 'test-style-ddskk)"
(uim '(custom-definition-as-literal 'test-style)))
diff --git a/uim/uim-custom.c b/uim/uim-custom.c
index 5fe3402..b5409f7 100644
--- a/uim/uim-custom.c
+++ b/uim/uim-custom.c
@@ -206,6 +206,12 @@ static void uim_custom_key_free(struct uim_custom_key *custom_key);
static char *extract_key_literal(const struct uim_custom_key *custom_key);
static char *key_list_to_str(const struct uim_custom_key *const *list, const char *sep);
+static char ***uim_custom_table_get(const char *custom_sym, const char *getter_proc);
+static char *literalized_strdup(const char *str);
+static char *row_list_to_str(const char *const *list);
+static char *table_to_str(const char** const *list, const char *sep);
+
+
static union uim_custom_value *uim_custom_value_internal(const char *custom_sym, const char *getter_proc);
static union uim_custom_value *uim_custom_value(const char *custom_sym);
static union uim_custom_value *uim_custom_default_value(const char *custom_sym);
@@ -439,6 +445,8 @@ uim_custom_type(const char *custom_sym)
return UCustom_OrderedList;
} else if (uim_custom_type_eq(custom_sym, "key")) {
return UCustom_Key;
+ } else if (uim_custom_type_eq(custom_sym, "table")) {
+ return UCustom_Table;
} else {
return UCustom_Bool;
}
@@ -793,6 +801,67 @@ uim_custom_key_list_free(struct uim_custom_key **list)
(uim_scm_c_list_free_func)uim_custom_key_free);
}
+/* table */
+static char ***
+uim_custom_table_get(const char *custom_sym, const char *getter_proc)
+{
+ char ***custom_table;
+ int row_count;
+ int row;
+
+ UIM_EVAL_FSTRING1(NULL, "(length %s)", custom_sym);
+ row_count = uim_scm_c_int(uim_scm_return_value());
+
+ custom_table = (char ***)malloc(sizeof(char **) * (row_count + 1));
+ if (!custom_table)
+ return NULL;
+
+ custom_table[row_count] = NULL;
+ for (row = 0; row < row_count; row++) {
+ int column_count;
+ int column;
+ UIM_EVAL_FSTRING2(NULL, "(length (nth %d %s))", row, custom_sym);
+ column_count = uim_scm_c_int(uim_scm_return_value());
+
+ custom_table[row] = (char **)malloc(sizeof(char *) * (column_count + 1));
+ if (!custom_table[row])
+ return NULL;
+ custom_table[row][column_count] = NULL;
+ for (column = 0; column < column_count; column++) {
+ char *str;
+ UIM_EVAL_FSTRING3(NULL, "(nth %d (nth %d %s))", column, row, custom_sym);
+ str = uim_scm_c_str(uim_scm_return_value());
+ if (!str)
+ return NULL;
+ custom_table[row][column] = malloc(sizeof(char) * (strlen(str) + 1));
+ if (!custom_table[row][column])
+ return NULL;
+ custom_table[row][column] = str;
+ }
+ }
+
+ return custom_table;
+}
+
+static char *
+literalized_strdup(const char *str)
+{
+ return strdup(literalize_string(str));
+}
+
+static char *
+row_list_to_str(const char *const *list)
+{
+ return c_list_to_str((const void *const *)list, literalized_strdup, " ");
+}
+
+static char *
+table_to_str(const char** const *list, const char *sep)
+{
+ return c_list_to_str((const void *const *)list,
+ (char *(*)(const void *))row_list_to_str, sep);
+}
+
static union uim_custom_value *
uim_custom_value_internal(const char *custom_sym, const char *getter_proc)
{
@@ -834,6 +903,9 @@ uim_custom_value_internal(const char *custom_sym, const char *getter_proc)
case UCustom_Key:
value->as_key = uim_custom_key_get(custom_sym, getter_proc);
break;
+ case UCustom_Table:
+ value->as_table = uim_custom_table_get(custom_sym, getter_proc);
+ break;
default:
value = NULL;
}
@@ -1466,6 +1538,15 @@ uim_custom_set(const struct uim_custom *custom)
free(val);
}
break;
+ case UCustom_Table:
+ {
+ char *val
+ = table_to_str((const char ** const *)custom->value->as_table, ") (");
+ UIM_EVAL_FSTRING2(NULL, "(custom-set-value! '%s '((%s)))",
+ custom->symbol, val);
+ free(val);
+ }
+ break;
default:
return UIM_FALSE;
}
diff --git a/uim/uim-custom.h b/uim/uim-custom.h
index dcfdfbc..10fbf1a 100644
--- a/uim/uim-custom.h
+++ b/uim/uim-custom.h
@@ -48,7 +48,8 @@ enum UCustomType {
UCustom_Pathname,
UCustom_Choice,
UCustom_OrderedList,
- UCustom_Key
+ UCustom_Key,
+ UCustom_Table
};
enum UCustomPathnameType {
@@ -74,6 +75,7 @@ union uim_custom_value {
struct uim_custom_choice *as_choice;
struct uim_custom_choice **as_olist;
struct uim_custom_key **as_key;
+ char ***as_table;
};
struct uim_custom_pathname {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment