From 155642a3f9c0d377954e725931e61b7acfb8687a Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Mon, 27 Mar 2017 14:10:43 +0200 Subject: [PATCH] "Composition" and "Decomposition" renamed to more general terms "Translation" and "Inverse translation" to extend its use for transliteration --- ZRCola/ZRCola.fbp | 88 +++---- ZRCola/ZRCola.rc | Bin 5912 -> 5908 bytes ...rn.ico => copy_destination_and_return.ico} | Bin ...rn.pdf => copy_destination_and_return.pdf} | 0 ..._return.ico => copy_source_and_return.ico} | Bin ..._return.pdf => copy_source_and_return.pdf} | 0 ...send_composed.ico => send_destination.ico} | Bin ...send_composed.pdf => send_destination.pdf} | 0 .../{send_decomposed.ico => send_source.ico} | Bin .../{send_decomposed.pdf => send_source.pdf} | 0 ZRCola/zrcolachrcatpnl.cpp | 16 +- ZRCola/zrcolachrcatpnl.h | 4 +- ZRCola/zrcolacomppnl.cpp | 240 +++++++++--------- ZRCola/zrcolacomppnl.h | 34 +-- ZRCola/zrcolafrm.cpp | 76 +++--- ZRCola/zrcolafrm.h | 16 +- ZRCola/zrcolagui.cpp | 202 +++++++-------- ZRCola/zrcolagui.h | 60 ++--- ZRCola/zrcolasettings.cpp | 4 +- ZRCola/zrcolasettings.h | 4 +- ZRColaCompile/dbsource.cpp | 8 +- ZRColaCompile/dbsource.h | 4 +- ZRColaCompile/main.cpp | 56 ++-- lib/libZRCola/include/zrcola/common.h | 2 +- lib/libZRCola/include/zrcola/normalize.h | 2 +- lib/libZRCola/include/zrcola/translate.h | 150 +++++------ lib/libZRCola/src/translate.cpp | 106 ++++---- 27 files changed, 536 insertions(+), 536 deletions(-) rename ZRCola/res/{copy_composed_and_return.ico => copy_destination_and_return.ico} (100%) rename ZRCola/res/{copy_composed_and_return.pdf => copy_destination_and_return.pdf} (100%) rename ZRCola/res/{copy_decomposed_and_return.ico => copy_source_and_return.ico} (100%) rename ZRCola/res/{copy_decomposed_and_return.pdf => copy_source_and_return.pdf} (100%) rename ZRCola/res/{send_composed.ico => send_destination.ico} (100%) rename ZRCola/res/{send_composed.pdf => send_destination.pdf} (100%) rename ZRCola/res/{send_decomposed.ico => send_source.ico} (100%) rename ZRCola/res/{send_decomposed.pdf => send_source.pdf} (100%) diff --git a/ZRCola/ZRCola.fbp b/ZRCola/ZRCola.fbp index 44c55d5..733e6d0 100644 --- a/ZRCola/ZRCola.fbp +++ b/ZRCola/ZRCola.fbp @@ -245,14 +245,14 @@ none - Load From Icon Resource; send_composed.ico; [16; 16] + Load From Icon Resource; send_destination.ico; [16; 16] 0 1 Send composed text to source window - wxID_SEND_COMPOSED + wxID_SEND_DESTINATION wxITEM_NORMAL &Send Composed - m_menuItemSendComposed + m_menuItemSendDestination none F5 @@ -260,14 +260,14 @@ - Load From Icon Resource; copy_composed_and_return.ico; [16; 16] + Load From Icon Resource; copy_destination_and_return.ico; [16; 16] 0 1 Copy composed text to clipboard and return focus to source window - wxID_COPY_COMPOSED_AND_RETURN + wxID_COPY_DESTINATION_AND_RETURN wxITEM_NORMAL Copy Composed and &Return - m_menuItemCopyComposedAndReturn + m_menuItemCopyDestinationAndReturn none Ctrl+F5 @@ -275,14 +275,14 @@ - Load From Icon Resource; send_decomposed.ico; [16; 16] + Load From Icon Resource; send_source.ico; [16; 16] 0 1 Send decomposed text to source window - wxID_SEND_DECOMPOSED + wxID_SEND_SOURCE wxITEM_NORMAL Send &Decomposed - m_menuItemSendDecomposed + m_menuItemSendSource none F6 @@ -290,14 +290,14 @@ - Load From Icon Resource; copy_decomposed_and_return.ico; [16; 16] + Load From Icon Resource; copy_source_and_return.ico; [16; 16] 0 1 Copy decomposed text to clipboard and return focus to source window - wxID_COPY_DECOMPOSED_AND_RETURN + wxID_COPY_SOURCE_AND_RETURN wxITEM_NORMAL Copy Decomposed and Re&turn - m_menuItemCopyDecomposedAndReturn + m_menuItemCopySourceAndReturn none Ctrl+F6 @@ -363,7 +363,7 @@ 0 1 Toggle compose toolbar - wxID_TOOLBAR_COMPOSE + wxID_TOOLBAR_TRANSLATE wxITEM_CHECK &Compose Toolbar m_menuItemToolbarCompose @@ -666,7 +666,7 @@ 0 1 - m_toolbarCompose + m_toolbarTranslate 1 1 -1,-1 @@ -732,12 +732,12 @@ - Load From Icon Resource; send_composed.ico; [24; 24] + Load From Icon Resource; send_destination.ico; [24; 24] 0 - wxID_SEND_COMPOSED + wxID_SEND_DESTINATION wxITEM_NORMAL Send Composed - m_toolSendComposed + m_toolSendDestination protected Send composed text to source window Send Composed @@ -753,12 +753,12 @@ - Load From Icon Resource; send_decomposed.ico; [24; 24] + Load From Icon Resource; send_source.ico; [24; 24] 0 - wxID_SEND_DECOMPOSED + wxID_SEND_SOURCE wxITEM_NORMAL Send Decomposed - m_toolSendDecomposed + m_toolSendSource protected Send decomposed text to source window Send Decomposed @@ -1078,7 +1078,7 @@ 0 1 - m_splitterDecomposed + m_splitterSource 1 @@ -1162,7 +1162,7 @@ 0 1 - m_panelDecomposedEdit + m_panelSourceEdit 1 @@ -1203,7 +1203,7 @@ - bSizerDecomposedEdit + bSizerSourceEdit wxVERTICAL none @@ -1214,7 +1214,7 @@ wxID_ANY Decomposed Text - bSizerDecomposedEdit2 + bSizerSourceEdit2 wxVERTICAL none @@ -1258,7 +1258,7 @@ 0 100,25 1 - m_decomposed + m_source 1 @@ -1296,13 +1296,13 @@ - OnDecomposedPaint + OnSourcePaint - OnDecomposedText + OnSourceText @@ -1350,7 +1350,7 @@ 0 1 - m_panelDecomposedHex + m_panelSourceHex 1 @@ -1391,7 +1391,7 @@ - bSizerDecomposedHex + bSizerSourceHex wxVERTICAL none @@ -1402,7 +1402,7 @@ wxID_ANY Decomposed Unicode Dump - bSizerDecomposedHex2 + bSizerSourceHex2 wxVERTICAL none @@ -1446,7 +1446,7 @@ 0 1 - m_decomposedHex + m_sourceHex 1 @@ -1484,7 +1484,7 @@ - OnDecomposedHexPaint + OnSourceHexPaint @@ -1544,7 +1544,7 @@ 0 1 - m_splitterComposed + m_splitterDestination 1 @@ -1628,7 +1628,7 @@ 0 1 - m_panelComposedEdit + m_panelDestinationEdit 1 @@ -1669,7 +1669,7 @@ - bSizerComposedEdit + bSizerDestinationEdit wxVERTICAL none @@ -1680,7 +1680,7 @@ wxID_ANY Composed Text - bSizerComposedEdit2 + bSizerDestinationEdit2 wxVERTICAL none @@ -1724,7 +1724,7 @@ 0 100,25 1 - m_composed + m_destination 1 @@ -1762,13 +1762,13 @@ - OnComposedPaint + OnDestinationPaint - OnComposedText + OnDestinationText @@ -1816,7 +1816,7 @@ 0 1 - m_panelComposedHex + m_panelDestinationHex 1 @@ -1857,7 +1857,7 @@ - bSizerComposedHex + bSizerDestinationHex wxVERTICAL none @@ -1868,7 +1868,7 @@ wxID_ANY Composed Unicode Dump - bSizerComposedHex2 + bSizerDestinationHex2 wxVERTICAL none @@ -1912,7 +1912,7 @@ 0 1 - m_composedHex + m_destinationHex 1 @@ -1950,7 +1950,7 @@ - OnComposedHexPaint + OnDestinationHexPaint diff --git a/ZRCola/ZRCola.rc b/ZRCola/ZRCola.rc index cad221b8db2e898ac1140c04fa6e3b359171dd61..1fd69b63e7d3250c74be7fe1a5c46bf1e3fa1b10 100644 GIT binary patch delta 218 zcmbQCH$`uQ7n^7bLn=ctLkUABLmopSn9gU&oBWVXadHEj8V*@QHc9SchJ1!nh9ZV! zhE$+xAg1Mw9P*RnI0R74YUEI!{Em%d@;OeK W$p<*N(Bwes*(P^!iY=Dl(wxTheApp); if (app->m_mainWnd) { - app->m_mainWnd->m_panel->m_decomposed->WriteText(m_grid->GetCellValue(event.GetRow(), event.GetCol())); - app->m_mainWnd->m_panel->m_decomposed->SetFocus(); + app->m_mainWnd->m_panel->m_source->WriteText(m_grid->GetCellValue(event.GetRow(), event.GetCol())); + app->m_mainWnd->m_panel->m_source->SetFocus(); } event.Skip(); @@ -113,8 +113,8 @@ void wxZRColaCharacterCatalogPanel::OnGridKeyDown(wxKeyEvent& event) case WXK_NUMPAD_ENTER: auto app = dynamic_cast(wxTheApp); if (app->m_mainWnd) { - app->m_mainWnd->m_panel->m_decomposed->WriteText(m_grid->GetCellValue(m_grid->GetCursorRow(), m_grid->GetCursorColumn())); - app->m_mainWnd->m_panel->m_decomposed->SetFocus(); + app->m_mainWnd->m_panel->m_source->WriteText(m_grid->GetCellValue(m_grid->GetCursorRow(), m_grid->GetCursorColumn())); + app->m_mainWnd->m_panel->m_source->SetFocus(); event.StopPropagation(); return; @@ -135,11 +135,11 @@ void wxZRColaCharacterCatalogPanel::OnShowAll(wxCommandEvent& event) } -void wxZRColaCharacterCatalogPanel::OnFocusDecomposed(wxCommandEvent& event) +void wxZRColaCharacterCatalogPanel::OnFocusSource(wxCommandEvent& event) { auto app = dynamic_cast(wxTheApp); if (app->m_mainWnd) { - app->m_mainWnd->m_panel->m_decomposed->SetFocus(); + app->m_mainWnd->m_panel->m_source->SetFocus(); event.StopPropagation(); return; diff --git a/ZRCola/zrcolachrcatpnl.h b/ZRCola/zrcolachrcatpnl.h index c3ad67e..b9a7360 100644 --- a/ZRCola/zrcolachrcatpnl.h +++ b/ZRCola/zrcolachrcatpnl.h @@ -38,7 +38,7 @@ class wxZRColaCharacterCatalogPanel : public wxZRColaCharacterCatalogPanelBase public: enum { - wxID_FOCUS_DECOMPOSED = 6000, + wxID_FOCUS_SOURCE = 6000, }; wxZRColaCharacterCatalogPanel(wxWindow* parent); @@ -51,7 +51,7 @@ protected: virtual void OnGridClick(wxGridEvent& event); virtual void OnGridKeyDown(wxKeyEvent& event); virtual void OnShowAll(wxCommandEvent& event); - void OnFocusDecomposed(wxCommandEvent& event); + void OnFocusSource(wxCommandEvent& event); DECLARE_EVENT_TABLE() void Update(); diff --git a/ZRCola/zrcolacomppnl.cpp b/ZRCola/zrcolacomppnl.cpp index dcdbc74..8e8ce8e 100644 --- a/ZRCola/zrcolacomppnl.cpp +++ b/ZRCola/zrcolacomppnl.cpp @@ -25,42 +25,42 @@ ////////////////////////////////////////////////////////////////////////// wxZRColaComposerPanel::wxZRColaComposerPanel(wxWindow* parent) : - m_decomposedChanged(false), - m_composedChanged(false), - m_selDecomposed(0, 0), - m_selComposed(0, 0), + m_sourceChanged(false), + m_destinationChanged(false), + m_selSource(0, 0), + m_selDestination(0, 0), wxZRColaComposerPanelBase(parent) { - m_decomposed->PushEventHandler(&m_keyhandler); + m_source->PushEventHandler(&m_keyhandler); // Restore the previously saved state (if exists). wxString fileName(GetStateFileName()); if (wxFileExists(fileName)) { wxFFile file(fileName, wxT("rb")); if (file.IsOpened()) { - // Load decomposed text. + // Load source text. unsigned __int64 n; file.Read(&n, sizeof(n)); if (!file.Error()) { - wxString decomposed; - file.Read(wxStringBuffer(decomposed, n), sizeof(wchar_t)*n); + wxString source; + file.Read(wxStringBuffer(source, n), sizeof(wchar_t)*n); if (!file.Error()) { - // Load composed text. + // Load destination text. file.Read(&n, sizeof(n)); if (!file.Error()) { - wxString composed; - file.Read(wxStringBuffer(composed, n), sizeof(wchar_t)*n); + wxString destination; + file.Read(wxStringBuffer(destination, n), sizeof(wchar_t)*n); if (!file.Error()) { // Restore state. - m_decomposed->SetValue(decomposed); - m_decomposed->GetSelection(&m_selDecomposed.first, &m_selDecomposed.second); - SetHexValue(m_decomposedHex, m_selDecomposedHex, m_mappingDecomposedHex, decomposed.GetData(), decomposed.Length(), m_selDecomposed.first, m_selDecomposed.second); - m_decomposedChanged = false; + m_source->SetValue(source); + m_source->GetSelection(&m_selSource.first, &m_selSource.second); + SetHexValue(m_sourceHex, m_selSourceHex, m_mappingSourceHex, source.GetData(), source.Length(), m_selSource.first, m_selSource.second); + m_sourceChanged = false; - m_composed->SetValue(composed); - m_composed->GetSelection(&m_selComposed.first, &m_selComposed.second); - SetHexValue(m_composedHex, m_selComposedHex, m_mappingComposedHex, composed.GetData(), composed.Length(), m_selComposed.first, m_selComposed.second); - m_composedChanged = false; + m_destination->SetValue(destination); + m_destination->GetSelection(&m_selDestination.first, &m_selDestination.second); + SetHexValue(m_destinationHex, m_selDestinationHex, m_mappingDestinationHex, destination.GetData(), destination.Length(), m_selDestination.first, m_selDestination.second); + m_destinationChanged = false; } } } @@ -72,7 +72,7 @@ wxZRColaComposerPanel::wxZRColaComposerPanel(wxWindow* parent) : wxZRColaComposerPanel::~wxZRColaComposerPanel() { - m_decomposed->PopEventHandler(); + m_source->PopEventHandler(); // This is a controlled exit. Purge saved state. wxString fileName(GetStateFileName()); @@ -83,195 +83,195 @@ wxZRColaComposerPanel::~wxZRColaComposerPanel() void wxZRColaComposerPanel::SynchronizePanels() { - if (m_decomposedChanged) { + if (m_sourceChanged) { m_timerSave.Stop(); auto app = dynamic_cast(wxTheApp); wxString src; - size_t len = GetValue(m_decomposed, src); + size_t len = GetValue(m_source, src); std::wstring norm; - app->m_t_db.Decompose(src.data(), len, norm, &m_mapping1); + app->m_t_db.TranslateInv(src.data(), len, norm, &m_mapping1); std::wstring dst; - app->m_t_db.Compose(norm.data(), norm.size(), dst, &m_mapping2); + app->m_t_db.Translate(norm.data(), norm.size(), dst, &m_mapping2); - m_decomposed->GetSelection(&m_selDecomposed.first, &m_selDecomposed.second); + m_source->GetSelection(&m_selSource.first, &m_selSource.second); - // Update decomposed HEX dump. - SetHexValue(m_decomposedHex, m_selDecomposedHex, m_mappingDecomposedHex, src.data(), len, m_selDecomposed.first, m_selDecomposed.second); + // Update source HEX dump. + SetHexValue(m_sourceHex, m_selSourceHex, m_mappingSourceHex, src.data(), len, m_selSource.first, m_selSource.second); - // Update composed text, and its HEX dump. - m_composed->SetValue(dst); - m_composed->SetSelection( - m_selComposed.first = m_mapping2.to_dst(m_mapping1.to_dst(m_selDecomposed.first )), - m_selComposed.second = m_mapping2.to_dst(m_mapping1.to_dst(m_selDecomposed.second))); - SetHexValue(m_composedHex, m_selComposedHex, m_mappingComposedHex, dst.data(), dst.length(), m_selComposed.first, m_selComposed.second); + // Update destination text, and its HEX dump. + m_destination->SetValue(dst); + m_destination->SetSelection( + m_selDestination.first = m_mapping2.to_dst(m_mapping1.to_dst(m_selSource.first )), + m_selDestination.second = m_mapping2.to_dst(m_mapping1.to_dst(m_selSource.second))); + SetHexValue(m_destinationHex, m_selDestinationHex, m_mappingDestinationHex, dst.data(), dst.length(), m_selDestination.first, m_selDestination.second); // Schedule state save after 3s. m_timerSave.Start(3000, true); - } else if (m_composedChanged) { + } else if (m_destinationChanged) { m_timerSave.Stop(); wxString src; - size_t len = GetValue(m_composed, src); + size_t len = GetValue(m_destination, src); auto app = dynamic_cast(wxTheApp); std::wstring dst; wxZRColaFrame *mainWnd = dynamic_cast(wxGetActiveWindow()); if (mainWnd) - app->m_t_db.Decompose(src.data(), len, &app->m_lc_db, mainWnd->m_settings->m_lang, dst, &m_mapping2); + app->m_t_db.TranslateInv(src.data(), len, &app->m_lc_db, mainWnd->m_settings->m_lang, dst, &m_mapping2); else - app->m_t_db.Decompose(src.data(), len, dst, &m_mapping2); + app->m_t_db.TranslateInv(src.data(), len, dst, &m_mapping2); m_mapping1.clear(); m_mapping2.invert(); - m_composed->GetSelection(&m_selComposed.first, &m_selComposed.second); + m_destination->GetSelection(&m_selDestination.first, &m_selDestination.second); - // Update composed HEX dump. - SetHexValue(m_composedHex, m_selComposedHex, m_mappingComposedHex, src.data(), len, m_selComposed.first, m_selComposed.second); + // Update destination HEX dump. + SetHexValue(m_destinationHex, m_selDestinationHex, m_mappingDestinationHex, src.data(), len, m_selDestination.first, m_selDestination.second); - // Update decomposed text, and its HEX dump. - m_decomposed->SetValue(dst); - m_decomposed->SetSelection( - m_selDecomposed.first = m_mapping1.to_src(m_mapping2.to_src(m_selComposed.first )), - m_selDecomposed.second = m_mapping1.to_src(m_mapping2.to_src(m_selComposed.second))); - SetHexValue(m_decomposedHex, m_selDecomposedHex, m_mappingDecomposedHex, dst.data(), dst.length(), m_selDecomposed.first, m_selDecomposed.second); + // Update source text, and its HEX dump. + m_source->SetValue(dst); + m_source->SetSelection( + m_selSource.first = m_mapping1.to_src(m_mapping2.to_src(m_selDestination.first )), + m_selSource.second = m_mapping1.to_src(m_mapping2.to_src(m_selDestination.second))); + SetHexValue(m_sourceHex, m_selSourceHex, m_mappingSourceHex, dst.data(), dst.length(), m_selSource.first, m_selSource.second); // Schedule state save after 3s. m_timerSave.Start(3000, true); } - m_decomposedChanged = false; - m_composedChanged = false; + m_sourceChanged = false; + m_destinationChanged = false; } -void wxZRColaComposerPanel::OnDecomposedPaint(wxPaintEvent& event) +void wxZRColaComposerPanel::OnSourcePaint(wxPaintEvent& event) { event.Skip(); long from, to; - m_decomposed->GetSelection(&from, &to); + m_source->GetSelection(&from, &to); - if (m_selDecomposed.first != from || m_selDecomposed.second != to) { + if (m_selSource.first != from || m_selSource.second != to) { // Save new selection first, to avoid loop. - m_selDecomposed.first = from; - m_selDecomposed.second = to; + m_selSource.first = from; + m_selSource.second = to; - m_decomposedHex->SetSelection( - m_selDecomposedHex.first = m_mappingDecomposedHex.to_dst(from), - m_selDecomposedHex.second = m_mappingDecomposedHex.to_dst(to )); + m_sourceHex->SetSelection( + m_selSourceHex.first = m_mappingSourceHex.to_dst(from), + m_selSourceHex.second = m_mappingSourceHex.to_dst(to )); - m_composed->SetSelection( - m_selComposed.first = m_mapping2.to_dst(m_mapping1.to_dst(from)), - m_selComposed.second = m_mapping2.to_dst(m_mapping1.to_dst(to ))); + m_destination->SetSelection( + m_selDestination.first = m_mapping2.to_dst(m_mapping1.to_dst(from)), + m_selDestination.second = m_mapping2.to_dst(m_mapping1.to_dst(to ))); - m_composedHex->SetSelection( - m_selComposedHex.first = m_mappingComposedHex.to_dst(m_selComposed.first ), - m_selComposedHex.second = m_mappingComposedHex.to_dst(m_selComposed.second)); + m_destinationHex->SetSelection( + m_selDestinationHex.first = m_mappingDestinationHex.to_dst(m_selDestination.first ), + m_selDestinationHex.second = m_mappingDestinationHex.to_dst(m_selDestination.second)); } } -void wxZRColaComposerPanel::OnDecomposedHexPaint(wxPaintEvent& event) +void wxZRColaComposerPanel::OnSourceHexPaint(wxPaintEvent& event) { event.Skip(); long from, to; - m_decomposedHex->GetSelection(&from, &to); + m_sourceHex->GetSelection(&from, &to); - if (m_selDecomposedHex.first != from || m_selDecomposedHex.second != to) { + if (m_selSourceHex.first != from || m_selSourceHex.second != to) { // Save new selection first, to avoid loop. - m_selDecomposedHex.first = from; - m_selDecomposedHex.second = to; + m_selSourceHex.first = from; + m_selSourceHex.second = to; - m_decomposed->SetSelection( - m_selDecomposed.first = m_mappingDecomposedHex.to_src(from), - m_selDecomposed.second = m_mappingDecomposedHex.to_src(to )); + m_source->SetSelection( + m_selSource.first = m_mappingSourceHex.to_src(from), + m_selSource.second = m_mappingSourceHex.to_src(to )); - m_composed->SetSelection( - m_selComposed.first = m_mapping2.to_dst(m_mapping1.to_dst(m_selDecomposed.first )), - m_selComposed.second = m_mapping2.to_dst(m_mapping1.to_dst(m_selDecomposed.second))); + m_destination->SetSelection( + m_selDestination.first = m_mapping2.to_dst(m_mapping1.to_dst(m_selSource.first )), + m_selDestination.second = m_mapping2.to_dst(m_mapping1.to_dst(m_selSource.second))); - m_composedHex->SetSelection( - m_selComposedHex.first = m_mappingComposedHex.to_dst(m_selComposed.first ), - m_selComposedHex.second = m_mappingComposedHex.to_dst(m_selComposed.second)); + m_destinationHex->SetSelection( + m_selDestinationHex.first = m_mappingDestinationHex.to_dst(m_selDestination.first ), + m_selDestinationHex.second = m_mappingDestinationHex.to_dst(m_selDestination.second)); } } -void wxZRColaComposerPanel::OnDecomposedText(wxCommandEvent& event) +void wxZRColaComposerPanel::OnSourceText(wxCommandEvent& event) { event.Skip(); - // Set the flag the decomposed text changed to trigger idle-time composition. - m_decomposedChanged = true; + // Set the flag the source text changed to trigger idle-time translation. + m_sourceChanged = true; } -void wxZRColaComposerPanel::OnComposedPaint(wxPaintEvent& event) +void wxZRColaComposerPanel::OnDestinationPaint(wxPaintEvent& event) { event.Skip(); long from, to; - m_composed->GetSelection(&from, &to); + m_destination->GetSelection(&from, &to); - if (m_selComposed.first != from || m_selComposed.second != to) { + if (m_selDestination.first != from || m_selDestination.second != to) { // Save new selection first, to avoid loop. - m_selComposed.first = from; - m_selComposed.second = to; + m_selDestination.first = from; + m_selDestination.second = to; - m_composedHex->SetSelection( - m_selComposedHex.first = m_mappingComposedHex.to_dst(from), - m_selComposedHex.second = m_mappingComposedHex.to_dst(to )); + m_destinationHex->SetSelection( + m_selDestinationHex.first = m_mappingDestinationHex.to_dst(from), + m_selDestinationHex.second = m_mappingDestinationHex.to_dst(to )); - m_decomposed->SetSelection( - m_selDecomposed.first = m_mapping1.to_src(m_mapping2.to_src(from)), - m_selDecomposed.second = m_mapping1.to_src(m_mapping2.to_src(to ))); + m_source->SetSelection( + m_selSource.first = m_mapping1.to_src(m_mapping2.to_src(from)), + m_selSource.second = m_mapping1.to_src(m_mapping2.to_src(to ))); - m_decomposedHex->SetSelection( - m_selDecomposedHex.first = m_mappingDecomposedHex.to_dst(m_selDecomposed.first ), - m_selDecomposedHex.second = m_mappingDecomposedHex.to_dst(m_selDecomposed.second)); + m_sourceHex->SetSelection( + m_selSourceHex.first = m_mappingSourceHex.to_dst(m_selSource.first ), + m_selSourceHex.second = m_mappingSourceHex.to_dst(m_selSource.second)); } } -void wxZRColaComposerPanel::OnComposedHexPaint(wxPaintEvent& event) +void wxZRColaComposerPanel::OnDestinationHexPaint(wxPaintEvent& event) { event.Skip(); long from, to; - m_composedHex->GetSelection(&from, &to); + m_destinationHex->GetSelection(&from, &to); - if (m_selComposedHex.first != from || m_selComposedHex.second != to) { + if (m_selDestinationHex.first != from || m_selDestinationHex.second != to) { // Save new selection first, to avoid loop. - m_selComposedHex.first = from; - m_selComposedHex.second = to; + m_selDestinationHex.first = from; + m_selDestinationHex.second = to; - m_composed->SetSelection( - m_selComposed.first = m_mappingComposedHex.to_src(from), - m_selComposed.second = m_mappingComposedHex.to_src(to )); + m_destination->SetSelection( + m_selDestination.first = m_mappingDestinationHex.to_src(from), + m_selDestination.second = m_mappingDestinationHex.to_src(to )); - m_decomposed->SetSelection( - m_selDecomposed.first = m_mapping1.to_src(m_mapping2.to_src(m_selComposed.first )), - m_selDecomposed.second = m_mapping1.to_src(m_mapping2.to_src(m_selComposed.second))); + m_source->SetSelection( + m_selSource.first = m_mapping1.to_src(m_mapping2.to_src(m_selDestination.first )), + m_selSource.second = m_mapping1.to_src(m_mapping2.to_src(m_selDestination.second))); - m_decomposedHex->SetSelection( - m_selDecomposedHex.first = m_mappingDecomposedHex.to_dst(m_selDecomposed.first ), - m_selDecomposedHex.second = m_mappingDecomposedHex.to_dst(m_selDecomposed.second)); + m_sourceHex->SetSelection( + m_selSourceHex.first = m_mappingSourceHex.to_dst(m_selSource.first ), + m_selSourceHex.second = m_mappingSourceHex.to_dst(m_selSource.second)); } } -void wxZRColaComposerPanel::OnComposedText(wxCommandEvent& event) +void wxZRColaComposerPanel::OnDestinationText(wxCommandEvent& event) { event.Skip(); - // Set the flag the composed text changed to trigger idle-time decomposition. - m_composedChanged = true; + // Set the flag the destination text changed to trigger idle-time inverse translation. + m_destinationChanged = true; } @@ -283,13 +283,13 @@ void wxZRColaComposerPanel::OnSaveTimer(wxTimerEvent& event) wxString text; size_t len; - // Save decomposed text. - len = GetValue(m_decomposed, text); + // Save source text. + len = GetValue(m_source, text); file.Write(&len, sizeof(len)); file.Write((const wchar_t*)text, sizeof(wchar_t)*len); - // Save composed text. - len = GetValue(m_composed, text); + // Save destination text. + len = GetValue(m_destination, text); file.Write(&len, sizeof(len)); file.Write((const wchar_t*)text, sizeof(wchar_t)*len); } @@ -385,8 +385,8 @@ void wxPersistentZRColaComposerPanel::Save() const { auto const wnd = static_cast(GetWindow()); // dynamic_cast is not reliable as we are typically called late in the wxTopLevelWindowMSW destructor. - SaveValue(wxT("splitDecomposed"), wnd->m_splitterDecomposed->GetSashPosition()); - SaveValue(wxT("splitComposed" ), wnd->m_splitterComposed ->GetSashPosition()); + SaveValue(wxT("splitDecomposed"), wnd->m_splitterSource->GetSashPosition()); + SaveValue(wxT("splitComposed" ), wnd->m_splitterDestination ->GetSashPosition()); } @@ -398,14 +398,14 @@ bool wxPersistentZRColaComposerPanel::Restore() if (RestoreValue(wxT("splitDecomposed"), &sashVal)) { // wxFormBuilder sets initial splitter stash in idle event handler after GUI settles. Overriding our loaded value. Disconnect it's idle event handler. - wnd->m_splitterDecomposed->Disconnect( wxEVT_IDLE, wxIdleEventHandler( wxZRColaComposerPanelBase::m_splitterDecomposedOnIdle ), NULL, wnd ); - wnd->m_splitterDecomposed->SetSashPosition(sashVal); + wnd->m_splitterSource->Disconnect( wxEVT_IDLE, wxIdleEventHandler( wxZRColaComposerPanelBase::m_splitterSourceOnIdle ), NULL, wnd ); + wnd->m_splitterSource->SetSashPosition(sashVal); } if (RestoreValue(wxT("splitComposed"), &sashVal)) { // wxFormBuilder sets initial splitter stash in idle event handler after GUI settles. Overriding our loaded value. Disconnect it's idle event handler. - wnd->m_splitterComposed->Disconnect( wxEVT_IDLE, wxIdleEventHandler( wxZRColaComposerPanelBase::m_splitterComposedOnIdle ), NULL, wnd ); - wnd->m_splitterComposed->SetSashPosition(sashVal); + wnd->m_splitterDestination->Disconnect( wxEVT_IDLE, wxIdleEventHandler( wxZRColaComposerPanelBase::m_splitterDestinationOnIdle ), NULL, wnd ); + wnd->m_splitterDestination->SetSashPosition(sashVal); } return true; diff --git a/ZRCola/zrcolacomppnl.h b/ZRCola/zrcolacomppnl.h index 2dbd939..157f0a1 100644 --- a/ZRCola/zrcolacomppnl.h +++ b/ZRCola/zrcolacomppnl.h @@ -46,12 +46,12 @@ public: friend class wxPersistentZRColaComposerPanel; // Allow saving/restoring window state. protected: - virtual void OnDecomposedPaint(wxPaintEvent& event); - virtual void OnDecomposedHexPaint(wxPaintEvent& event); - virtual void OnDecomposedText(wxCommandEvent& event); - virtual void OnComposedPaint(wxPaintEvent& event); - virtual void OnComposedHexPaint(wxPaintEvent& event); - virtual void OnComposedText(wxCommandEvent& event); + virtual void OnSourcePaint(wxPaintEvent& event); + virtual void OnSourceHexPaint(wxPaintEvent& event); + virtual void OnSourceText(wxCommandEvent& event); + virtual void OnDestinationPaint(wxPaintEvent& event); + virtual void OnDestinationHexPaint(wxPaintEvent& event); + virtual void OnDestinationText(wxCommandEvent& event); virtual void OnSaveTimer(wxTimerEvent& event); static wxString GetStateFileName(); @@ -59,18 +59,18 @@ protected: static void SetHexValue(wxTextCtrl *wnd, std::pair &range, ZRCola::mapping_vector &mapping, const wchar_t *src, size_t len, long from, long to); protected: - bool m_decomposedChanged; ///< Boolean flag to mark decomposed text "dirty" to trigger composition - bool m_composedChanged; ///< Boolean flag to mark composed text "dirty" to trigger decomposition - ZRCola::mapping_vector m_mapping1; ///< Character index mapping vector between decomposed and normalized text - ZRCola::mapping_vector m_mapping2; ///< Character index mapping vector between normalized and composed text + bool m_sourceChanged; ///< Boolean flag to mark source text "dirty" to trigger translation + bool m_destinationChanged; ///< Boolean flag to mark destination text "dirty" to trigger inverse translation + ZRCola::mapping_vector m_mapping1; ///< Character index mapping vector between source and normalized text + ZRCola::mapping_vector m_mapping2; ///< Character index mapping vector between normalized and destination text std::pair - m_selDecomposed, ///< Character index of selected text in decomposed text control - m_selDecomposedHex, ///< Character index of selected text in decomposed HEX dump text control - m_selComposed, ///< Character index of selected text in composed text control - m_selComposedHex; ///< Character index of selected text in composed HEX dump text control - wxZRColaKeyHandler m_keyhandler; ///< Key handler for decomposed window - ZRCola::mapping_vector m_mappingDecomposedHex; ///< Character index mapping vector between decomposed text and its HEX dump - ZRCola::mapping_vector m_mappingComposedHex; ///< Character index mapping vector between composed text and its HEX dump + m_selSource, ///< Character index of selected text in source text control + m_selSourceHex, ///< Character index of selected text in source HEX dump text control + m_selDestination, ///< Character index of selected text in destination text control + m_selDestinationHex; ///< Character index of selected text in destination HEX dump text control + wxZRColaKeyHandler m_keyhandler; ///< Key handler for source window + ZRCola::mapping_vector m_mappingSourceHex; ///< Character index mapping vector between source text and its HEX dump + ZRCola::mapping_vector m_mappingDestinationHex; ///< Character index mapping vector between destination text and its HEX dump }; diff --git a/ZRCola/zrcolafrm.cpp b/ZRCola/zrcolafrm.cpp index 5008182..b4e00d0 100644 --- a/ZRCola/zrcolafrm.cpp +++ b/ZRCola/zrcolafrm.cpp @@ -34,19 +34,19 @@ wxBEGIN_EVENT_TABLE(wxZRColaFrame, wxZRColaFrameBase) EVT_MENU (wxID_CHARACTER_SELECTOR , wxZRColaFrame::OnInsertCharacter ) - EVT_UPDATE_UI_RANGE(wxID_SEND_COMPOSED , wxID_SEND_ABORT, wxZRColaFrame::OnSendUpdate ) - EVT_MENU (wxID_COPY_COMPOSED_AND_RETURN , wxZRColaFrame::OnCopyComposedAndReturn ) - EVT_MENU (wxID_SEND_COMPOSED , wxZRColaFrame::OnSendComposed ) - EVT_MENU (wxID_COPY_DECOMPOSED_AND_RETURN , wxZRColaFrame::OnCopyDecomposedAndReturn ) - EVT_MENU (wxID_SEND_DECOMPOSED , wxZRColaFrame::OnSendDecomposed ) + EVT_UPDATE_UI_RANGE(wxID_SEND_DESTINATION , wxID_SEND_ABORT, wxZRColaFrame::OnSendUpdate ) + EVT_MENU (wxID_COPY_DESTINATION_AND_RETURN , wxZRColaFrame::OnCopyDestinationAndReturn ) + EVT_MENU (wxID_SEND_DESTINATION , wxZRColaFrame::OnSendDestination ) + EVT_MENU (wxID_COPY_SOURCE_AND_RETURN , wxZRColaFrame::OnCopySourceAndReturn ) + EVT_MENU (wxID_SEND_SOURCE , wxZRColaFrame::OnSendSource ) EVT_MENU (wxID_SEND_ABORT , wxZRColaFrame::OnSendAbort ) EVT_MENU (wxID_SETTINGS , wxZRColaFrame::OnSettings ) EVT_UPDATE_UI (wxID_TOOLBAR_EDIT , wxZRColaFrame::OnToolbarEditUpdate ) EVT_MENU (wxID_TOOLBAR_EDIT , wxZRColaFrame::OnToolbarEdit ) - EVT_UPDATE_UI (wxID_TOOLBAR_COMPOSE , wxZRColaFrame::OnToolbarComposeUpdate ) - EVT_MENU (wxID_TOOLBAR_COMPOSE , wxZRColaFrame::OnToolbarCompose ) + EVT_UPDATE_UI (wxID_TOOLBAR_TRANSLATE , wxZRColaFrame::OnToolbarTranslateUpdate ) + EVT_MENU (wxID_TOOLBAR_TRANSLATE , wxZRColaFrame::OnToolbarTranslate ) EVT_UPDATE_UI (wxID_PANEL_CHRGRPS , wxZRColaFrame::OnPanelCharacterCatalogUpdate) EVT_MENU (wxID_PANEL_CHRGRPS , wxZRColaFrame::OnPanelCharacterCatalog ) EVT_MENU (wxID_FOCUS_CHARACTER_CATALOG , wxZRColaFrame::OnPanelCharacterCatalogFocus ) @@ -69,10 +69,10 @@ wxZRColaFrame::wxZRColaFrame() : { { // wxFrameBuilder 3.5 does not support wxAUI_TB_HORIZONTAL flag. Add it manually. - wxAuiPaneInfo &paneInfo = m_mgr.GetPane(m_toolbarCompose); + wxAuiPaneInfo &paneInfo = m_mgr.GetPane(m_toolbarTranslate); paneInfo.LeftDockable(false); paneInfo.RightDockable(false); - m_toolbarCompose->SetWindowStyleFlag(m_toolbarCompose->GetWindowStyleFlag() | wxAUI_TB_HORIZONTAL); + m_toolbarTranslate->SetWindowStyleFlag(m_toolbarTranslate->GetWindowStyleFlag() | wxAUI_TB_HORIZONTAL); } // Load main window icons. @@ -106,7 +106,7 @@ wxZRColaFrame::wxZRColaFrame() : wxPersistentRegisterAndRestore(m_chrReq); // Set focus. - m_panel->m_decomposed->SetFocus(); + m_panel->m_source->SetFocus(); #if defined(__WXMSW__) // Register notification sink for language detection. @@ -139,9 +139,9 @@ wxZRColaFrame::wxZRColaFrame() : wxPersistentAuiManager(&m_mgr).Restore(); // Register global hotkey(s). - if (!RegisterHotKey(wxZRColaHKID_INVOKE_COMPOSE, wxMOD_WIN, VK_F5)) + if (!RegisterHotKey(wxZRColaHKID_INVOKE_TRANSLATE, wxMOD_WIN, VK_F5)) wxMessageBox(_("ZRCola keyboard shortcut Win+F5 could not be registered. Some functionality will not be available."), _("Warning"), wxOK | wxICON_WARNING); - if (!RegisterHotKey(wxZRColaHKID_INVOKE_DECOMPOSE, wxMOD_WIN, VK_F6)) + if (!RegisterHotKey(wxZRColaHKID_INVOKE_TRANSLATE_INV, wxMOD_WIN, VK_F6)) wxMessageBox(_("ZRCola keyboard shortcut Win+F6 could not be registered. Some functionality will not be available."), _("Warning"), wxOK | wxICON_WARNING); } @@ -149,8 +149,8 @@ wxZRColaFrame::wxZRColaFrame() : wxZRColaFrame::~wxZRColaFrame() { // Unregister global hotkey(s). - UnregisterHotKey(wxZRColaHKID_INVOKE_DECOMPOSE); - UnregisterHotKey(wxZRColaHKID_INVOKE_COMPOSE); + UnregisterHotKey(wxZRColaHKID_INVOKE_TRANSLATE_INV); + UnregisterHotKey(wxZRColaHKID_INVOKE_TRANSLATE ); #if defined(__WXMSW__) if (m_tfSource) { @@ -214,8 +214,8 @@ void wxZRColaFrame::OnForwardEvent(wxCommandEvent& event) void wxZRColaFrame::OnInsertCharacter(wxCommandEvent& event) { if (m_chrSelect->ShowModal() == wxID_OK && !m_chrSelect->m_char.empty()) { - m_panel->m_decomposed->WriteText(m_chrSelect->m_char); - m_panel->m_decomposed->SetFocus(); + m_panel->m_source->WriteText(m_chrSelect->m_char); + m_panel->m_source->SetFocus(); } } @@ -226,37 +226,37 @@ void wxZRColaFrame::OnSendUpdate(wxUpdateUIEvent& event) } -void wxZRColaFrame::OnSendComposed(wxCommandEvent& event) +void wxZRColaFrame::OnSendDestination(wxCommandEvent& event) { if (m_hWndSource) - DoSend(m_panel->m_composed->GetValue()); + DoSend(m_panel->m_destination->GetValue()); event.Skip(); } -void wxZRColaFrame::OnCopyComposedAndReturn(wxCommandEvent& event) +void wxZRColaFrame::OnCopyDestinationAndReturn(wxCommandEvent& event) { if (m_hWndSource) - DoCopyAndReturn(m_panel->m_composed->GetValue()); + DoCopyAndReturn(m_panel->m_destination->GetValue()); event.Skip(); } -void wxZRColaFrame::OnSendDecomposed(wxCommandEvent& event) +void wxZRColaFrame::OnSendSource(wxCommandEvent& event) { if (m_hWndSource) - DoSend(m_panel->m_decomposed->GetValue()); + DoSend(m_panel->m_source->GetValue()); event.Skip(); } -void wxZRColaFrame::OnCopyDecomposedAndReturn(wxCommandEvent& event) +void wxZRColaFrame::OnCopySourceAndReturn(wxCommandEvent& event) { if (m_hWndSource) - DoCopyAndReturn(m_panel->m_decomposed->GetValue()); + DoCopyAndReturn(m_panel->m_source->GetValue()); event.Skip(); } @@ -272,8 +272,8 @@ void wxZRColaFrame::OnSendAbort(wxCommandEvent& event) } // Select all input in composer to prepare for the overwrite next time. - m_panel->m_decomposed->SelectAll(); - m_panel->m_composed->SelectAll(); + m_panel->m_source ->SelectAll(); + m_panel->m_destination->SelectAll(); event.Skip(); } @@ -326,15 +326,15 @@ void wxZRColaFrame::OnToolbarEdit(wxCommandEvent& event) } -void wxZRColaFrame::OnToolbarComposeUpdate(wxUpdateUIEvent& event) +void wxZRColaFrame::OnToolbarTranslateUpdate(wxUpdateUIEvent& event) { - event.Check(m_mgr.GetPane(m_toolbarCompose).IsShown()); + event.Check(m_mgr.GetPane(m_toolbarTranslate).IsShown()); } -void wxZRColaFrame::OnToolbarCompose(wxCommandEvent& event) +void wxZRColaFrame::OnToolbarTranslate(wxCommandEvent& event) { - wxAuiPaneInfo &paneInfo = m_mgr.GetPane(m_toolbarCompose); + wxAuiPaneInfo &paneInfo = m_mgr.GetPane(m_toolbarTranslate); paneInfo.Show(!paneInfo.IsShown()); m_mgr.Update(); } @@ -503,9 +503,9 @@ void wxZRColaFrame::DoSend(const wxString& str) ::SendInput(input.size(), input.data(), sizeof(INPUT)); m_hWndSource = NULL; - // Select all input in composer and decomposed to prepare for the overwrite next time. - m_panel->m_decomposed->SelectAll(); - m_panel->m_composed->SelectAll(); + // Select all input in source and destination to prepare for the overwrite next time. + m_panel->m_source ->SelectAll(); + m_panel->m_destination->SelectAll(); } @@ -521,9 +521,9 @@ void wxZRColaFrame::DoCopyAndReturn(const wxString& str) ::SetForegroundWindow(m_hWndSource); m_hWndSource = NULL; - // Select all input in composer and decomposed to prepare for the overwrite next time. - m_panel->m_decomposed->SelectAll(); - m_panel->m_composed->SelectAll(); + // Select all input in composer and source to prepare for the overwrite next time. + m_panel->m_source ->SelectAll(); + m_panel->m_destination->SelectAll(); } @@ -536,8 +536,8 @@ WXLRESULT wxZRColaFrame::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM WXHWND hWndSource = ::GetForegroundWindow(); switch (wParam) { - case wxZRColaHKID_INVOKE_COMPOSE : m_panel->m_decomposed->SetFocus(); break; - case wxZRColaHKID_INVOKE_DECOMPOSE: m_panel->m_composed ->SetFocus(); break; + case wxZRColaHKID_INVOKE_TRANSLATE : m_panel->m_source ->SetFocus(); break; + case wxZRColaHKID_INVOKE_TRANSLATE_INV: m_panel->m_destination->SetFocus(); break; default: wxFAIL_MSG(wxT("not our registered shortcut")); return wxZRColaFrameBase::MSWWindowProc(message, wParam, lParam); diff --git a/ZRCola/zrcolafrm.h b/ZRCola/zrcolafrm.h index 509e918..7eb4c36 100644 --- a/ZRCola/zrcolafrm.h +++ b/ZRCola/zrcolafrm.h @@ -40,8 +40,8 @@ class wxZRColaFrame; /// /// Global hotkey message identifiers /// -#define wxZRColaHKID_INVOKE_COMPOSE 0 -#define wxZRColaHKID_INVOKE_DECOMPOSE 1 +#define wxZRColaHKID_INVOKE_TRANSLATE 0 +#define wxZRColaHKID_INVOKE_TRANSLATE_INV 1 /// @@ -72,10 +72,10 @@ protected: void OnForwardEvent(wxCommandEvent& event); void OnInsertCharacter(wxCommandEvent& event); void OnSendUpdate(wxUpdateUIEvent& event); - void OnSendComposed(wxCommandEvent& event); - void OnCopyComposedAndReturn(wxCommandEvent& event); - void OnSendDecomposed(wxCommandEvent& event); - void OnCopyDecomposedAndReturn(wxCommandEvent& event); + void OnSendDestination(wxCommandEvent& event); + void OnCopyDestinationAndReturn(wxCommandEvent& event); + void OnSendSource(wxCommandEvent& event); + void OnCopySourceAndReturn(wxCommandEvent& event); void OnSendAbort(wxCommandEvent& event); void OnSettings(wxCommandEvent& event); virtual void OnIdle(wxIdleEvent& event); @@ -83,8 +83,8 @@ protected: virtual void OnIconize(wxIconizeEvent& event); void OnToolbarEditUpdate(wxUpdateUIEvent& event); void OnToolbarEdit(wxCommandEvent& event); - void OnToolbarComposeUpdate(wxUpdateUIEvent& event); - void OnToolbarCompose(wxCommandEvent& event); + void OnToolbarTranslateUpdate(wxUpdateUIEvent& event); + void OnToolbarTranslate(wxCommandEvent& event); void OnPanelCharacterCatalogUpdate(wxUpdateUIEvent& event); void OnPanelCharacterCatalog(wxCommandEvent& event); void OnPanelCharacterCatalogFocus(wxCommandEvent& event); diff --git a/ZRCola/zrcolagui.cpp b/ZRCola/zrcolagui.cpp index 9498eac..826be55 100644 --- a/ZRCola/zrcolagui.cpp +++ b/ZRCola/zrcolagui.cpp @@ -85,41 +85,41 @@ wxZRColaFrameBase::wxZRColaFrameBase( wxWindow* parent, wxWindowID id, const wxS m_menuEdit->AppendSeparator(); - wxMenuItem* m_menuItemSendComposed; - m_menuItemSendComposed = new wxMenuItem( m_menuEdit, wxID_SEND_COMPOSED, wxString( _("&Send Composed") ) + wxT('\t') + wxT("F5"), _("Send composed text to source window"), wxITEM_NORMAL ); + wxMenuItem* m_menuItemSendDestination; + m_menuItemSendDestination = new wxMenuItem( m_menuEdit, wxID_SEND_DESTINATION, wxString( _("&Send Composed") ) + wxT('\t') + wxT("F5"), _("Send composed text to source window"), wxITEM_NORMAL ); #ifdef __WXMSW__ - m_menuItemSendComposed->SetBitmaps( wxIcon( wxT("send_composed.ico"), wxBITMAP_TYPE_ICO_RESOURCE, 16, 16 ) ); + m_menuItemSendDestination->SetBitmaps( wxIcon( wxT("send_destination.ico"), wxBITMAP_TYPE_ICO_RESOURCE, 16, 16 ) ); #elif (defined( __WXGTK__ ) || defined( __WXOSX__ )) - m_menuItemSendComposed->SetBitmap( wxIcon( wxT("send_composed.ico"), wxBITMAP_TYPE_ICO_RESOURCE, 16, 16 ) ); + m_menuItemSendDestination->SetBitmap( wxIcon( wxT("send_destination.ico"), wxBITMAP_TYPE_ICO_RESOURCE, 16, 16 ) ); #endif - m_menuEdit->Append( m_menuItemSendComposed ); + m_menuEdit->Append( m_menuItemSendDestination ); - wxMenuItem* m_menuItemCopyComposedAndReturn; - m_menuItemCopyComposedAndReturn = new wxMenuItem( m_menuEdit, wxID_COPY_COMPOSED_AND_RETURN, wxString( _("Copy Composed and &Return") ) + wxT('\t') + wxT("Ctrl+F5"), _("Copy composed text to clipboard and return focus to source window"), wxITEM_NORMAL ); + wxMenuItem* m_menuItemCopyDestinationAndReturn; + m_menuItemCopyDestinationAndReturn = new wxMenuItem( m_menuEdit, wxID_COPY_DESTINATION_AND_RETURN, wxString( _("Copy Composed and &Return") ) + wxT('\t') + wxT("Ctrl+F5"), _("Copy composed text to clipboard and return focus to source window"), wxITEM_NORMAL ); #ifdef __WXMSW__ - m_menuItemCopyComposedAndReturn->SetBitmaps( wxIcon( wxT("copy_composed_and_return.ico"), wxBITMAP_TYPE_ICO_RESOURCE, 16, 16 ) ); + m_menuItemCopyDestinationAndReturn->SetBitmaps( wxIcon( wxT("copy_destination_and_return.ico"), wxBITMAP_TYPE_ICO_RESOURCE, 16, 16 ) ); #elif (defined( __WXGTK__ ) || defined( __WXOSX__ )) - m_menuItemCopyComposedAndReturn->SetBitmap( wxIcon( wxT("copy_composed_and_return.ico"), wxBITMAP_TYPE_ICO_RESOURCE, 16, 16 ) ); + m_menuItemCopyDestinationAndReturn->SetBitmap( wxIcon( wxT("copy_destination_and_return.ico"), wxBITMAP_TYPE_ICO_RESOURCE, 16, 16 ) ); #endif - m_menuEdit->Append( m_menuItemCopyComposedAndReturn ); + m_menuEdit->Append( m_menuItemCopyDestinationAndReturn ); - wxMenuItem* m_menuItemSendDecomposed; - m_menuItemSendDecomposed = new wxMenuItem( m_menuEdit, wxID_SEND_DECOMPOSED, wxString( _("Send &Decomposed") ) + wxT('\t') + wxT("F6"), _("Send decomposed text to source window"), wxITEM_NORMAL ); + wxMenuItem* m_menuItemSendSource; + m_menuItemSendSource = new wxMenuItem( m_menuEdit, wxID_SEND_SOURCE, wxString( _("Send &Decomposed") ) + wxT('\t') + wxT("F6"), _("Send decomposed text to source window"), wxITEM_NORMAL ); #ifdef __WXMSW__ - m_menuItemSendDecomposed->SetBitmaps( wxIcon( wxT("send_decomposed.ico"), wxBITMAP_TYPE_ICO_RESOURCE, 16, 16 ) ); + m_menuItemSendSource->SetBitmaps( wxIcon( wxT("send_source.ico"), wxBITMAP_TYPE_ICO_RESOURCE, 16, 16 ) ); #elif (defined( __WXGTK__ ) || defined( __WXOSX__ )) - m_menuItemSendDecomposed->SetBitmap( wxIcon( wxT("send_decomposed.ico"), wxBITMAP_TYPE_ICO_RESOURCE, 16, 16 ) ); + m_menuItemSendSource->SetBitmap( wxIcon( wxT("send_source.ico"), wxBITMAP_TYPE_ICO_RESOURCE, 16, 16 ) ); #endif - m_menuEdit->Append( m_menuItemSendDecomposed ); + m_menuEdit->Append( m_menuItemSendSource ); - wxMenuItem* m_menuItemCopyDecomposedAndReturn; - m_menuItemCopyDecomposedAndReturn = new wxMenuItem( m_menuEdit, wxID_COPY_DECOMPOSED_AND_RETURN, wxString( _("Copy Decomposed and Re&turn") ) + wxT('\t') + wxT("Ctrl+F6"), _("Copy decomposed text to clipboard and return focus to source window"), wxITEM_NORMAL ); + wxMenuItem* m_menuItemCopySourceAndReturn; + m_menuItemCopySourceAndReturn = new wxMenuItem( m_menuEdit, wxID_COPY_SOURCE_AND_RETURN, wxString( _("Copy Decomposed and Re&turn") ) + wxT('\t') + wxT("Ctrl+F6"), _("Copy decomposed text to clipboard and return focus to source window"), wxITEM_NORMAL ); #ifdef __WXMSW__ - m_menuItemCopyDecomposedAndReturn->SetBitmaps( wxIcon( wxT("copy_decomposed_and_return.ico"), wxBITMAP_TYPE_ICO_RESOURCE, 16, 16 ) ); + m_menuItemCopySourceAndReturn->SetBitmaps( wxIcon( wxT("copy_source_and_return.ico"), wxBITMAP_TYPE_ICO_RESOURCE, 16, 16 ) ); #elif (defined( __WXGTK__ ) || defined( __WXOSX__ )) - m_menuItemCopyDecomposedAndReturn->SetBitmap( wxIcon( wxT("copy_decomposed_and_return.ico"), wxBITMAP_TYPE_ICO_RESOURCE, 16, 16 ) ); + m_menuItemCopySourceAndReturn->SetBitmap( wxIcon( wxT("copy_source_and_return.ico"), wxBITMAP_TYPE_ICO_RESOURCE, 16, 16 ) ); #endif - m_menuEdit->Append( m_menuItemCopyDecomposedAndReturn ); + m_menuEdit->Append( m_menuItemCopySourceAndReturn ); wxMenuItem* m_menuItemSendAbort; m_menuItemSendAbort = new wxMenuItem( m_menuEdit, wxID_SEND_ABORT, wxString( _("Abort (De)composition") ) + wxT('\t') + wxT("Esc"), _("Abort composition and return focus to source window"), wxITEM_NORMAL ); @@ -144,7 +144,7 @@ wxZRColaFrameBase::wxZRColaFrameBase( wxWindow* parent, wxWindowID id, const wxS m_menuView->Append( m_menuItemToolbarEdit ); wxMenuItem* m_menuItemToolbarCompose; - m_menuItemToolbarCompose = new wxMenuItem( m_menuView, wxID_TOOLBAR_COMPOSE, wxString( _("&Compose Toolbar") ) , _("Toggle compose toolbar"), wxITEM_CHECK ); + m_menuItemToolbarCompose = new wxMenuItem( m_menuView, wxID_TOOLBAR_TRANSLATE, wxString( _("&Compose Toolbar") ) , _("Toggle compose toolbar"), wxITEM_CHECK ); m_menuView->Append( m_menuItemToolbarCompose ); m_menuView->AppendSeparator(); @@ -194,15 +194,15 @@ wxZRColaFrameBase::wxZRColaFrameBase( wxWindow* parent, wxWindowID id, const wxS m_toolbarEdit->Realize(); m_mgr.AddPane( m_toolbarEdit, wxAuiPaneInfo().Name( wxT("toolbarEdit") ).Top().Caption( _("Edit") ).PinButton( true ).Dock().Resizable().FloatingSize( wxSize( -1,-1 ) ).LeftDockable( false ).RightDockable( false ).Row( 0 ).Layer( 1 ).ToolbarPane() ); - m_toolbarCompose = new wxAuiToolBar( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxAUI_TB_HORZ_LAYOUT ); - m_toolCharSelect = m_toolbarCompose->AddTool( wxID_CHARACTER_SELECTOR, _("Find Character"), wxIcon( wxT("char_select.ico"), wxBITMAP_TYPE_ICO_RESOURCE, 24, 24 ), wxNullBitmap, wxITEM_NORMAL, _("Find Character"), _("Display character search to select character to insert into text"), NULL ); + m_toolbarTranslate = new wxAuiToolBar( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxAUI_TB_HORZ_LAYOUT ); + m_toolCharSelect = m_toolbarTranslate->AddTool( wxID_CHARACTER_SELECTOR, _("Find Character"), wxIcon( wxT("char_select.ico"), wxBITMAP_TYPE_ICO_RESOURCE, 24, 24 ), wxNullBitmap, wxITEM_NORMAL, _("Find Character"), _("Display character search to select character to insert into text"), NULL ); - m_toolSendComposed = m_toolbarCompose->AddTool( wxID_SEND_COMPOSED, _("Send Composed"), wxIcon( wxT("send_composed.ico"), wxBITMAP_TYPE_ICO_RESOURCE, 24, 24 ), wxNullBitmap, wxITEM_NORMAL, _("Send Composed"), _("Send composed text to source window"), NULL ); + m_toolSendDestination = m_toolbarTranslate->AddTool( wxID_SEND_DESTINATION, _("Send Composed"), wxIcon( wxT("send_destination.ico"), wxBITMAP_TYPE_ICO_RESOURCE, 24, 24 ), wxNullBitmap, wxITEM_NORMAL, _("Send Composed"), _("Send composed text to source window"), NULL ); - m_toolSendDecomposed = m_toolbarCompose->AddTool( wxID_SEND_DECOMPOSED, _("Send Decomposed"), wxIcon( wxT("send_decomposed.ico"), wxBITMAP_TYPE_ICO_RESOURCE, 24, 24 ), wxNullBitmap, wxITEM_NORMAL, _("Send Decomposed"), _("Send decomposed text to source window"), NULL ); + m_toolSendSource = m_toolbarTranslate->AddTool( wxID_SEND_SOURCE, _("Send Decomposed"), wxIcon( wxT("send_source.ico"), wxBITMAP_TYPE_ICO_RESOURCE, 24, 24 ), wxNullBitmap, wxITEM_NORMAL, _("Send Decomposed"), _("Send decomposed text to source window"), NULL ); - m_toolbarCompose->Realize(); - m_mgr.AddPane( m_toolbarCompose, wxAuiPaneInfo().Name( wxT("toolbarCompose") ).Top().Caption( _("Compose") ).PinButton( true ).Dock().Resizable().FloatingSize( wxSize( -1,-1 ) ).LeftDockable( false ).RightDockable( false ).Row( 0 ).Layer( 1 ).ToolbarPane() ); + m_toolbarTranslate->Realize(); + m_mgr.AddPane( m_toolbarTranslate, wxAuiPaneInfo().Name( wxT("toolbarCompose") ).Top().Caption( _("Compose") ).PinButton( true ).Dock().Resizable().FloatingSize( wxSize( -1,-1 ) ).LeftDockable( false ).RightDockable( false ).Row( 0 ).Layer( 1 ).ToolbarPane() ); m_panelChrCat = new wxZRColaCharacterCatalogPanel( this ); @@ -239,99 +239,99 @@ wxZRColaComposerPanelBase::wxZRColaComposerPanelBase( wxWindow* parent, wxWindow wxBoxSizer* bSizerMain; bSizerMain = new wxBoxSizer( wxVERTICAL ); - m_splitterDecomposed = new wxSplitterWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_3D|wxSP_LIVE_UPDATE ); - m_splitterDecomposed->SetSashGravity( 1 ); - m_splitterDecomposed->Connect( wxEVT_IDLE, wxIdleEventHandler( wxZRColaComposerPanelBase::m_splitterDecomposedOnIdle ), NULL, this ); - m_splitterDecomposed->SetMinimumPaneSize( 5 ); + m_splitterSource = new wxSplitterWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_3D|wxSP_LIVE_UPDATE ); + m_splitterSource->SetSashGravity( 1 ); + m_splitterSource->Connect( wxEVT_IDLE, wxIdleEventHandler( wxZRColaComposerPanelBase::m_splitterSourceOnIdle ), NULL, this ); + m_splitterSource->SetMinimumPaneSize( 5 ); - m_panelDecomposedEdit = new wxPanel( m_splitterDecomposed, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); - wxBoxSizer* bSizerDecomposedEdit; - bSizerDecomposedEdit = new wxBoxSizer( wxVERTICAL ); + m_panelSourceEdit = new wxPanel( m_splitterSource, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); + wxBoxSizer* bSizerSourceEdit; + bSizerSourceEdit = new wxBoxSizer( wxVERTICAL ); - wxStaticBoxSizer* bSizerDecomposedEdit2; - bSizerDecomposedEdit2 = new wxStaticBoxSizer( new wxStaticBox( m_panelDecomposedEdit, wxID_ANY, _("Decomposed Text") ), wxVERTICAL ); + wxStaticBoxSizer* bSizerSourceEdit2; + bSizerSourceEdit2 = new wxStaticBoxSizer( new wxStaticBox( m_panelSourceEdit, wxID_ANY, _("Decomposed Text") ), wxVERTICAL ); - m_decomposed = new wxTextCtrl( bSizerDecomposedEdit2->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE ); - m_decomposed->SetFont( wxFont( 20, 70, 90, 90, false, wxT("ZRCola") ) ); - m_decomposed->SetMinSize( wxSize( 100,25 ) ); + m_source = new wxTextCtrl( bSizerSourceEdit2->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE ); + m_source->SetFont( wxFont( 20, 70, 90, 90, false, wxT("ZRCola") ) ); + m_source->SetMinSize( wxSize( 100,25 ) ); - bSizerDecomposedEdit2->Add( m_decomposed, 1, wxEXPAND, 5 ); + bSizerSourceEdit2->Add( m_source, 1, wxEXPAND, 5 ); - bSizerDecomposedEdit->Add( bSizerDecomposedEdit2, 1, wxEXPAND, 5 ); + bSizerSourceEdit->Add( bSizerSourceEdit2, 1, wxEXPAND, 5 ); - m_panelDecomposedEdit->SetSizer( bSizerDecomposedEdit ); - m_panelDecomposedEdit->Layout(); - bSizerDecomposedEdit->Fit( m_panelDecomposedEdit ); - m_panelDecomposedHex = new wxPanel( m_splitterDecomposed, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); - wxBoxSizer* bSizerDecomposedHex; - bSizerDecomposedHex = new wxBoxSizer( wxVERTICAL ); + m_panelSourceEdit->SetSizer( bSizerSourceEdit ); + m_panelSourceEdit->Layout(); + bSizerSourceEdit->Fit( m_panelSourceEdit ); + m_panelSourceHex = new wxPanel( m_splitterSource, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); + wxBoxSizer* bSizerSourceHex; + bSizerSourceHex = new wxBoxSizer( wxVERTICAL ); - wxStaticBoxSizer* bSizerDecomposedHex2; - bSizerDecomposedHex2 = new wxStaticBoxSizer( new wxStaticBox( m_panelDecomposedHex, wxID_ANY, _("Decomposed Unicode Dump") ), wxVERTICAL ); + wxStaticBoxSizer* bSizerSourceHex2; + bSizerSourceHex2 = new wxStaticBoxSizer( new wxStaticBox( m_panelSourceHex, wxID_ANY, _("Decomposed Unicode Dump") ), wxVERTICAL ); - m_decomposedHex = new wxTextCtrl( bSizerDecomposedHex2->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY ); - m_decomposedHex->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 76, 90, 90, false, wxEmptyString ) ); + m_sourceHex = new wxTextCtrl( bSizerSourceHex2->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY ); + m_sourceHex->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 76, 90, 90, false, wxEmptyString ) ); - bSizerDecomposedHex2->Add( m_decomposedHex, 1, wxEXPAND, 5 ); + bSizerSourceHex2->Add( m_sourceHex, 1, wxEXPAND, 5 ); - bSizerDecomposedHex->Add( bSizerDecomposedHex2, 1, wxEXPAND, 5 ); + bSizerSourceHex->Add( bSizerSourceHex2, 1, wxEXPAND, 5 ); - m_panelDecomposedHex->SetSizer( bSizerDecomposedHex ); - m_panelDecomposedHex->Layout(); - bSizerDecomposedHex->Fit( m_panelDecomposedHex ); - m_splitterDecomposed->SplitVertically( m_panelDecomposedEdit, m_panelDecomposedHex, -5 ); - bSizerMain->Add( m_splitterDecomposed, 50, wxALL|wxEXPAND, 5 ); + m_panelSourceHex->SetSizer( bSizerSourceHex ); + m_panelSourceHex->Layout(); + bSizerSourceHex->Fit( m_panelSourceHex ); + m_splitterSource->SplitVertically( m_panelSourceEdit, m_panelSourceHex, -5 ); + bSizerMain->Add( m_splitterSource, 50, wxALL|wxEXPAND, 5 ); - m_splitterComposed = new wxSplitterWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_3D|wxSP_LIVE_UPDATE ); - m_splitterComposed->SetSashGravity( 1 ); - m_splitterComposed->Connect( wxEVT_IDLE, wxIdleEventHandler( wxZRColaComposerPanelBase::m_splitterComposedOnIdle ), NULL, this ); - m_splitterComposed->SetMinimumPaneSize( 5 ); + m_splitterDestination = new wxSplitterWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_3D|wxSP_LIVE_UPDATE ); + m_splitterDestination->SetSashGravity( 1 ); + m_splitterDestination->Connect( wxEVT_IDLE, wxIdleEventHandler( wxZRColaComposerPanelBase::m_splitterDestinationOnIdle ), NULL, this ); + m_splitterDestination->SetMinimumPaneSize( 5 ); - m_panelComposedEdit = new wxPanel( m_splitterComposed, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); - wxBoxSizer* bSizerComposedEdit; - bSizerComposedEdit = new wxBoxSizer( wxVERTICAL ); + m_panelDestinationEdit = new wxPanel( m_splitterDestination, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); + wxBoxSizer* bSizerDestinationEdit; + bSizerDestinationEdit = new wxBoxSizer( wxVERTICAL ); - wxStaticBoxSizer* bSizerComposedEdit2; - bSizerComposedEdit2 = new wxStaticBoxSizer( new wxStaticBox( m_panelComposedEdit, wxID_ANY, _("Composed Text") ), wxVERTICAL ); + wxStaticBoxSizer* bSizerDestinationEdit2; + bSizerDestinationEdit2 = new wxStaticBoxSizer( new wxStaticBox( m_panelDestinationEdit, wxID_ANY, _("Composed Text") ), wxVERTICAL ); - m_composed = new wxTextCtrl( bSizerComposedEdit2->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE ); - m_composed->SetFont( wxFont( 20, 70, 90, 90, false, wxT("ZRCola") ) ); - m_composed->SetMinSize( wxSize( 100,25 ) ); + m_destination = new wxTextCtrl( bSizerDestinationEdit2->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE ); + m_destination->SetFont( wxFont( 20, 70, 90, 90, false, wxT("ZRCola") ) ); + m_destination->SetMinSize( wxSize( 100,25 ) ); - bSizerComposedEdit2->Add( m_composed, 1, wxEXPAND, 5 ); + bSizerDestinationEdit2->Add( m_destination, 1, wxEXPAND, 5 ); - bSizerComposedEdit->Add( bSizerComposedEdit2, 1, wxEXPAND, 5 ); + bSizerDestinationEdit->Add( bSizerDestinationEdit2, 1, wxEXPAND, 5 ); - m_panelComposedEdit->SetSizer( bSizerComposedEdit ); - m_panelComposedEdit->Layout(); - bSizerComposedEdit->Fit( m_panelComposedEdit ); - m_panelComposedHex = new wxPanel( m_splitterComposed, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); - wxBoxSizer* bSizerComposedHex; - bSizerComposedHex = new wxBoxSizer( wxVERTICAL ); + m_panelDestinationEdit->SetSizer( bSizerDestinationEdit ); + m_panelDestinationEdit->Layout(); + bSizerDestinationEdit->Fit( m_panelDestinationEdit ); + m_panelDestinationHex = new wxPanel( m_splitterDestination, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); + wxBoxSizer* bSizerDestinationHex; + bSizerDestinationHex = new wxBoxSizer( wxVERTICAL ); - wxStaticBoxSizer* bSizerComposedHex2; - bSizerComposedHex2 = new wxStaticBoxSizer( new wxStaticBox( m_panelComposedHex, wxID_ANY, _("Composed Unicode Dump") ), wxVERTICAL ); + wxStaticBoxSizer* bSizerDestinationHex2; + bSizerDestinationHex2 = new wxStaticBoxSizer( new wxStaticBox( m_panelDestinationHex, wxID_ANY, _("Composed Unicode Dump") ), wxVERTICAL ); - m_composedHex = new wxTextCtrl( bSizerComposedHex2->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY ); - m_composedHex->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 76, 90, 90, false, wxEmptyString ) ); + m_destinationHex = new wxTextCtrl( bSizerDestinationHex2->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY ); + m_destinationHex->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 76, 90, 90, false, wxEmptyString ) ); - bSizerComposedHex2->Add( m_composedHex, 1, wxEXPAND, 5 ); + bSizerDestinationHex2->Add( m_destinationHex, 1, wxEXPAND, 5 ); - bSizerComposedHex->Add( bSizerComposedHex2, 1, wxEXPAND, 5 ); + bSizerDestinationHex->Add( bSizerDestinationHex2, 1, wxEXPAND, 5 ); - m_panelComposedHex->SetSizer( bSizerComposedHex ); - m_panelComposedHex->Layout(); - bSizerComposedHex->Fit( m_panelComposedHex ); - m_splitterComposed->SplitVertically( m_panelComposedEdit, m_panelComposedHex, -5 ); - bSizerMain->Add( m_splitterComposed, 50, wxALL|wxEXPAND, 5 ); + m_panelDestinationHex->SetSizer( bSizerDestinationHex ); + m_panelDestinationHex->Layout(); + bSizerDestinationHex->Fit( m_panelDestinationHex ); + m_splitterDestination->SplitVertically( m_panelDestinationEdit, m_panelDestinationHex, -5 ); + bSizerMain->Add( m_splitterDestination, 50, wxALL|wxEXPAND, 5 ); this->SetSizer( bSizerMain ); @@ -340,24 +340,24 @@ wxZRColaComposerPanelBase::wxZRColaComposerPanelBase( wxWindow* parent, wxWindow m_timerSave.SetOwner( this, wxID_TIMER_SAVE ); // Connect Events - m_decomposed->Connect( wxEVT_PAINT, wxPaintEventHandler( wxZRColaComposerPanelBase::OnDecomposedPaint ), NULL, this ); - m_decomposed->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( wxZRColaComposerPanelBase::OnDecomposedText ), NULL, this ); - m_decomposedHex->Connect( wxEVT_PAINT, wxPaintEventHandler( wxZRColaComposerPanelBase::OnDecomposedHexPaint ), NULL, this ); - m_composed->Connect( wxEVT_PAINT, wxPaintEventHandler( wxZRColaComposerPanelBase::OnComposedPaint ), NULL, this ); - m_composed->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( wxZRColaComposerPanelBase::OnComposedText ), NULL, this ); - m_composedHex->Connect( wxEVT_PAINT, wxPaintEventHandler( wxZRColaComposerPanelBase::OnComposedHexPaint ), NULL, this ); + m_source->Connect( wxEVT_PAINT, wxPaintEventHandler( wxZRColaComposerPanelBase::OnSourcePaint ), NULL, this ); + m_source->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( wxZRColaComposerPanelBase::OnSourceText ), NULL, this ); + m_sourceHex->Connect( wxEVT_PAINT, wxPaintEventHandler( wxZRColaComposerPanelBase::OnSourceHexPaint ), NULL, this ); + m_destination->Connect( wxEVT_PAINT, wxPaintEventHandler( wxZRColaComposerPanelBase::OnDestinationPaint ), NULL, this ); + m_destination->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( wxZRColaComposerPanelBase::OnDestinationText ), NULL, this ); + m_destinationHex->Connect( wxEVT_PAINT, wxPaintEventHandler( wxZRColaComposerPanelBase::OnDestinationHexPaint ), NULL, this ); this->Connect( wxID_TIMER_SAVE, wxEVT_TIMER, wxTimerEventHandler( wxZRColaComposerPanelBase::OnSaveTimer ) ); } wxZRColaComposerPanelBase::~wxZRColaComposerPanelBase() { // Disconnect Events - m_decomposed->Disconnect( wxEVT_PAINT, wxPaintEventHandler( wxZRColaComposerPanelBase::OnDecomposedPaint ), NULL, this ); - m_decomposed->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( wxZRColaComposerPanelBase::OnDecomposedText ), NULL, this ); - m_decomposedHex->Disconnect( wxEVT_PAINT, wxPaintEventHandler( wxZRColaComposerPanelBase::OnDecomposedHexPaint ), NULL, this ); - m_composed->Disconnect( wxEVT_PAINT, wxPaintEventHandler( wxZRColaComposerPanelBase::OnComposedPaint ), NULL, this ); - m_composed->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( wxZRColaComposerPanelBase::OnComposedText ), NULL, this ); - m_composedHex->Disconnect( wxEVT_PAINT, wxPaintEventHandler( wxZRColaComposerPanelBase::OnComposedHexPaint ), NULL, this ); + m_source->Disconnect( wxEVT_PAINT, wxPaintEventHandler( wxZRColaComposerPanelBase::OnSourcePaint ), NULL, this ); + m_source->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( wxZRColaComposerPanelBase::OnSourceText ), NULL, this ); + m_sourceHex->Disconnect( wxEVT_PAINT, wxPaintEventHandler( wxZRColaComposerPanelBase::OnSourceHexPaint ), NULL, this ); + m_destination->Disconnect( wxEVT_PAINT, wxPaintEventHandler( wxZRColaComposerPanelBase::OnDestinationPaint ), NULL, this ); + m_destination->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( wxZRColaComposerPanelBase::OnDestinationText ), NULL, this ); + m_destinationHex->Disconnect( wxEVT_PAINT, wxPaintEventHandler( wxZRColaComposerPanelBase::OnDestinationHexPaint ), NULL, this ); this->Disconnect( wxID_TIMER_SAVE, wxEVT_TIMER, wxTimerEventHandler( wxZRColaComposerPanelBase::OnSaveTimer ) ); } diff --git a/ZRCola/zrcolagui.h b/ZRCola/zrcolagui.h index 6833ca6..7554cf3 100644 --- a/ZRCola/zrcolagui.h +++ b/ZRCola/zrcolagui.h @@ -63,14 +63,14 @@ class wxZRColaFrameBase : public wxFrame enum { wxID_CHARACTER_SELECTOR = 1000, - wxID_SEND_COMPOSED, - wxID_COPY_COMPOSED_AND_RETURN, - wxID_SEND_DECOMPOSED, - wxID_COPY_DECOMPOSED_AND_RETURN, + wxID_SEND_DESTINATION, + wxID_COPY_DESTINATION_AND_RETURN, + wxID_SEND_SOURCE, + wxID_COPY_SOURCE_AND_RETURN, wxID_SEND_ABORT, wxID_SETTINGS, wxID_TOOLBAR_EDIT, - wxID_TOOLBAR_COMPOSE, + wxID_TOOLBAR_TRANSLATE, wxID_PANEL_CHRGRPS, wxID_HELP_INSTRUCTIONS, wxID_HELP_SHORTCUTS, @@ -87,10 +87,10 @@ class wxZRColaFrameBase : public wxFrame wxAuiToolBarItem* m_toolEditCut; wxAuiToolBarItem* m_toolEditCopy; wxAuiToolBarItem* m_toolEditPaste; - wxAuiToolBar* m_toolbarCompose; + wxAuiToolBar* m_toolbarTranslate; wxAuiToolBarItem* m_toolCharSelect; - wxAuiToolBarItem* m_toolSendComposed; - wxAuiToolBarItem* m_toolSendDecomposed; + wxAuiToolBarItem* m_toolSendDestination; + wxAuiToolBarItem* m_toolSendSource; wxZRColaCharacterCatalogPanel* m_panelChrCat; wxStatusBar* m_statusBar; @@ -123,43 +123,43 @@ class wxZRColaComposerPanelBase : public wxPanel wxID_TIMER_SAVE = 1000 }; - wxSplitterWindow* m_splitterDecomposed; - wxPanel* m_panelDecomposedEdit; - wxPanel* m_panelDecomposedHex; - wxTextCtrl* m_decomposedHex; - wxSplitterWindow* m_splitterComposed; - wxPanel* m_panelComposedEdit; - wxPanel* m_panelComposedHex; - wxTextCtrl* m_composedHex; + wxSplitterWindow* m_splitterSource; + wxPanel* m_panelSourceEdit; + wxPanel* m_panelSourceHex; + wxTextCtrl* m_sourceHex; + wxSplitterWindow* m_splitterDestination; + wxPanel* m_panelDestinationEdit; + wxPanel* m_panelDestinationHex; + wxTextCtrl* m_destinationHex; wxTimer m_timerSave; // Virtual event handlers, overide them in your derived class - virtual void OnDecomposedPaint( wxPaintEvent& event ) { event.Skip(); } - virtual void OnDecomposedText( wxCommandEvent& event ) { event.Skip(); } - virtual void OnDecomposedHexPaint( wxPaintEvent& event ) { event.Skip(); } - virtual void OnComposedPaint( wxPaintEvent& event ) { event.Skip(); } - virtual void OnComposedText( wxCommandEvent& event ) { event.Skip(); } - virtual void OnComposedHexPaint( wxPaintEvent& event ) { event.Skip(); } + virtual void OnSourcePaint( wxPaintEvent& event ) { event.Skip(); } + virtual void OnSourceText( wxCommandEvent& event ) { event.Skip(); } + virtual void OnSourceHexPaint( wxPaintEvent& event ) { event.Skip(); } + virtual void OnDestinationPaint( wxPaintEvent& event ) { event.Skip(); } + virtual void OnDestinationText( wxCommandEvent& event ) { event.Skip(); } + virtual void OnDestinationHexPaint( wxPaintEvent& event ) { event.Skip(); } virtual void OnSaveTimer( wxTimerEvent& event ) { event.Skip(); } public: - wxTextCtrl* m_decomposed; - wxTextCtrl* m_composed; + wxTextCtrl* m_source; + wxTextCtrl* m_destination; wxZRColaComposerPanelBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxTAB_TRAVERSAL, const wxString& name = wxT("ZRColaComposerPanel") ); ~wxZRColaComposerPanelBase(); - void m_splitterDecomposedOnIdle( wxIdleEvent& ) + void m_splitterSourceOnIdle( wxIdleEvent& ) { - m_splitterDecomposed->SetSashPosition( -5 ); - m_splitterDecomposed->Disconnect( wxEVT_IDLE, wxIdleEventHandler( wxZRColaComposerPanelBase::m_splitterDecomposedOnIdle ), NULL, this ); + m_splitterSource->SetSashPosition( -5 ); + m_splitterSource->Disconnect( wxEVT_IDLE, wxIdleEventHandler( wxZRColaComposerPanelBase::m_splitterSourceOnIdle ), NULL, this ); } - void m_splitterComposedOnIdle( wxIdleEvent& ) + void m_splitterDestinationOnIdle( wxIdleEvent& ) { - m_splitterComposed->SetSashPosition( -5 ); - m_splitterComposed->Disconnect( wxEVT_IDLE, wxIdleEventHandler( wxZRColaComposerPanelBase::m_splitterComposedOnIdle ), NULL, this ); + m_splitterDestination->SetSashPosition( -5 ); + m_splitterDestination->Disconnect( wxEVT_IDLE, wxIdleEventHandler( wxZRColaComposerPanelBase::m_splitterDestinationOnIdle ), NULL, this ); } }; diff --git a/ZRCola/zrcolasettings.cpp b/ZRCola/zrcolasettings.cpp index db148bc..5121a8a 100644 --- a/ZRCola/zrcolasettings.cpp +++ b/ZRCola/zrcolasettings.cpp @@ -127,9 +127,9 @@ void wxZRColaSettings::OnApplyButtonClick(wxCommandEvent& event) if (m_lang != lang.id) { m_lang = lang.id; - // Notify composed text something changed and should re-decompose. + // Notify destination text something changed and should re-inverse translate. wxCommandEvent event2(wxEVT_COMMAND_TEXT_UPDATED); - app->m_mainWnd->m_panel->m_composed->ProcessWindowEvent(event2); + app->m_mainWnd->m_panel->m_destination->ProcessWindowEvent(event2); } } } diff --git a/ZRCola/zrcolasettings.h b/ZRCola/zrcolasettings.h index 743617a..efce7ea 100644 --- a/ZRCola/zrcolasettings.h +++ b/ZRCola/zrcolasettings.h @@ -48,8 +48,8 @@ protected: virtual void OnOKButtonClick(wxCommandEvent& event); public: - bool m_lang_auto; ///< Is language for decomposing resolved using currently selected keyboard - ZRCola::langid_t m_lang; ///< Language for decomposing + bool m_lang_auto; ///< Is language for inverse translation resolved using currently selected keyboard + ZRCola::langid_t m_lang; ///< Language for inverse translation }; diff --git a/ZRColaCompile/dbsource.cpp b/ZRColaCompile/dbsource.cpp index 53cae9e..dbb22f0 100644 --- a/ZRColaCompile/dbsource.cpp +++ b/ZRColaCompile/dbsource.cpp @@ -610,25 +610,25 @@ bool ZRCola::DBSource::GetTranslation(const com_obj& rs, ZRCola::D { com_obj f; wxVERIFY(SUCCEEDED(flds->get_Item(variant(L"komb"), &f))); - wxCHECK(GetUnicodeString(f, t.dec.str), false); + wxCHECK(GetUnicodeString(f, t.src.str), false); } { com_obj f; wxVERIFY(SUCCEEDED(flds->get_Item(variant(L"rang_komb"), &f))); - wxCHECK(GetValue(f, t.dec.rank), false); + wxCHECK(GetValue(f, t.src.rank), false); } { com_obj f; wxVERIFY(SUCCEEDED(flds->get_Item(variant(L"rang_znak"), &f))); - wxCHECK(GetValue(f, t.com.rank), false); + wxCHECK(GetValue(f, t.dst.rank), false); } { com_obj f; wxVERIFY(SUCCEEDED(flds->get_Item(variant(L"znak"), &f))); - wxCHECK(GetUnicodeString(f, t.com.str), false); + wxCHECK(GetUnicodeString(f, t.dst.str), false); } return true; diff --git a/ZRColaCompile/dbsource.h b/ZRColaCompile/dbsource.h index 4cf96d1..f60d811 100644 --- a/ZRColaCompile/dbsource.h +++ b/ZRColaCompile/dbsource.h @@ -66,8 +66,8 @@ namespace ZRCola { /// class translation { public: - charseq dec; ///< Decomposed sequence - charseq com; ///< Composed character + charseq src; ///< Source sequence + charseq dst; ///< Destination sequence }; diff --git a/ZRColaCompile/main.cpp b/ZRColaCompile/main.cpp index a6e91fb..ac6471c 100644 --- a/ZRColaCompile/main.cpp +++ b/ZRColaCompile/main.cpp @@ -25,7 +25,7 @@ using namespace winstd; /// -/// (composed character rank, (decomposed character rank, decomposed character)) data holder +/// (destination character rank, (source character rank, source character)) data holder /// typedef pair com_translation; @@ -49,46 +49,46 @@ struct translation_set_less { typedef map > translation_db; -static set decompose(_In_ const translation_db &db, _In_z_ const wchar_t *str, _Inout_ set &path) +static set translate_inv(_In_ const translation_db &db, _In_z_ const wchar_t *str, _Inout_ set &path) { set res; if (*str) { - // Decompose remainder first. - auto rem = decompose(db, str + 1, path); + // Inverse translate remainder first. + auto rem = translate_inv(db, str + 1, path); if (rem.empty()) return res; translation_db::key_type _str(1, *str); auto const t = db.find(_str); if (t != db.end()) { - // Current characted decomposed. Iterate all possible decompositions and combine them with the remainder. + // Current characted inverse translated. Iterate all possible inverse translations and combine them with the remainder. auto p = path.insert(_str); if (!p.second) { // Path already contains this character: Cycle detected! return res; } for (auto d = t->second.cbegin(), d_end = t->second.cend(); d != d_end; ++d) { - auto dec = decompose(db, d->second.str.c_str(), path); - if (!dec.empty()) { - for (auto dd = dec.cbegin(), dd_end = dec.cend(); dd != dd_end; ++dd) { + auto src = translate_inv(db, d->second.str.c_str(), path); + if (!src.empty()) { + for (auto dd = src.cbegin(), dd_end = src.cend(); dd != dd_end; ++dd) { for (auto r = rem.cbegin(), r_end = rem.cend(); r != r_end; ++r) res.insert(*dd + *r); } } else { - // Cycle detected. Do not continue decomposition. + // Cycle detected. Do not continue inverse translation. for (auto r = rem.cbegin(), r_end = rem.cend(); r != r_end; ++r) res.insert(_str + *r); } } path.erase(p.first); } else { - // Current character is non-decomposable. Combine it with the remainder(s). + // Current character is non-inverse translatable. Combine it with the remainder(s). for (auto r = rem.cbegin(), r_end = rem.cend(); r != r_end; ++r) res.insert(_str + *r); } } else { - // Empty string results in empty decomposition. + // Empty string results in empty inverse translation. res.insert(L""); } @@ -187,25 +187,25 @@ int _tmain(int argc, _TCHAR *argv[]) ZRCola::DBSource::translation trans; if (src.GetTranslation(rs, trans)) { // Add translation to temporary database. - auto const t = db_temp1.find(trans.com.str); + auto const t = db_temp1.find(trans.dst.str); if (t != db_temp1.end()) - t->second.insert(com_translation(trans.com.rank, std::move(trans.dec))); + t->second.insert(com_translation(trans.dst.rank, std::move(trans.src))); else { translation_db::mapped_type d; - d.insert(com_translation(trans.com.rank, std::move(trans.dec))); - db_temp1.insert(std::move(pair(trans.com.str, std::move(d)))); + d.insert(com_translation(trans.dst.rank, std::move(trans.src))); + db_temp1.insert(std::move(pair(trans.dst.str, std::move(d)))); } } else has_errors = true; } - // Decompose decompositions down to non-decomposable characters. + // Inverse translate source sequences down to non-inverse translatable characters. translation_db db_temp2; for (auto t1 = db_temp1.cbegin(), t1_end = db_temp1.cend(); t1 != t1_end; ++t1) { for (auto d1 = t1->second.cbegin(), d1_end = t1->second.cend(); d1 != d1_end; ++d1) { set path; path.insert(t1->first); - auto str = decompose(db_temp1, d1->second.str.c_str(), path); + auto str = translate_inv(db_temp1, d1->second.str.c_str(), path); assert(!str.empty()); // Add translation to temporary database. @@ -225,35 +225,35 @@ int _tmain(int argc, _TCHAR *argv[]) ZRCola::translation_db db; // Preallocate memory. - db.idxComp .reserve(count); - db.idxDecomp.reserve(count); - db.data .reserve(count*5); + db.idxTrans .reserve(count); + db.idxTransInv.reserve(count); + db.data .reserve(count*5); // Parse translations and build index and data. for (auto t = db_temp2.cbegin(), t_end = db_temp2.cend(); t != t_end; ++t) { // Add translation to index and data. for (auto d = t->second.cbegin(), d_end = t->second.cend(); d != d_end; ++d) { unsigned __int32 idx = db.data.size(); - wxASSERT_MSG((int)0xffff8000 <= d->first && d->first <= (int)0x00007fff, wxT("composed character rank out of bounds")); + wxASSERT_MSG((int)0xffff8000 <= d->first && d->first <= (int)0x00007fff, wxT("destination character rank out of bounds")); db.data.push_back((unsigned __int16)d->first); - wxASSERT_MSG((int)0xffff8000 <= d->second.rank && d->second.rank <= (int)0x00007fff, wxT("decomposed character rank out of bounds")); + wxASSERT_MSG((int)0xffff8000 <= d->second.rank && d->second.rank <= (int)0x00007fff, wxT("source character rank out of bounds")); db.data.push_back((unsigned __int16)d->second.rank); wstring::size_type n = t->first.length(); - wxASSERT_MSG(n <= 0xffff, wxT("composition overflow")); + wxASSERT_MSG(n <= 0xffff, wxT("destination overflow")); db.data.push_back((unsigned __int16)n); n += d->second.str.length(); - wxASSERT_MSG(n <= 0xffff, wxT("decomposition overflow")); + wxASSERT_MSG(n <= 0xffff, wxT("source overflow")); db.data.push_back((unsigned __int16)n); db.data.insert(db.data.end(), t->first .cbegin(), t->first .cend()); db.data.insert(db.data.end(), d->second.str.cbegin(), d->second.str.cend()); - db.idxComp .push_back(idx); - db.idxDecomp.push_back(idx); + db.idxTrans .push_back(idx); + db.idxTransInv.push_back(idx); } } // Sort indices. - db.idxComp .sort(); - db.idxDecomp.sort(); + db.idxTrans .sort(); + db.idxTransInv.sort(); // Write translations to file. dst << ZRCola::translation_rec(db); diff --git a/lib/libZRCola/include/zrcola/common.h b/lib/libZRCola/include/zrcola/common.h index 20b7e45..e4e73e4 100644 --- a/lib/libZRCola/include/zrcola/common.h +++ b/lib/libZRCola/include/zrcola/common.h @@ -528,7 +528,7 @@ namespace ZRCola { /// - /// A vector for composed-decomposed index transformation mapping + /// A vector for destination-source index transformation mapping /// class ZRCOLA_API mapping_vector : public std::vector { public: diff --git a/lib/libZRCola/include/zrcola/normalize.h b/lib/libZRCola/include/zrcola/normalize.h index a650bad..aa72216 100644 --- a/lib/libZRCola/include/zrcola/normalize.h +++ b/lib/libZRCola/include/zrcola/normalize.h @@ -24,7 +24,7 @@ namespace ZRCola { /// - /// Normalizes a decomposed string + /// Normalizes a source string /// /// \param[in] input Input string (UTF-16) /// \param[in] inputMax Length of the input string in characters. Can be (size_t)-1 if \p input is zero terminated. diff --git a/lib/libZRCola/include/zrcola/translate.h b/lib/libZRCola/include/zrcola/translate.h index d55c628..f80cfb3 100644 --- a/lib/libZRCola/include/zrcola/translate.h +++ b/lib/libZRCola/include/zrcola/translate.h @@ -47,13 +47,13 @@ namespace ZRCola { /// struct translation { public: - unsigned __int16 com_rank; ///< Composed character rank - unsigned __int16 dec_rank; ///< Decomposed character rank + unsigned __int16 dst_rank; ///< Destination character rank + unsigned __int16 src_rank; ///< Source character rank protected: - unsigned __int16 com_to; ///< Composed character end in \c data - unsigned __int16 dec_to; ///< Decomposed string end in \c data - wchar_t data[]; ///< Decomposed string and composed character + unsigned __int16 dst_to; ///< Destination character end in \c data + unsigned __int16 src_to; ///< Source string end in \c data + wchar_t data[]; ///< Destination string and source character private: inline translation(_In_ const translation &other); @@ -63,58 +63,58 @@ namespace ZRCola { /// /// Constructs the translation /// - /// \param[in] com_rank Composed character rank - /// \param[in] com Composed character - /// \param[in] com_len Number of UTF-16 characters in \p com - /// \param[in] dec_rank Decomposed character rank - /// \param[in] dec Decomposed character - /// \param[in] dec_len Number of UTF-16 characters in \p dec + /// \param[in] dst_rank Destination character rank + /// \param[in] dst Destination character + /// \param[in] dst_len Number of UTF-16 characters in \p dst + /// \param[in] src_rank Source character rank + /// \param[in] src Source character + /// \param[in] src_len Number of UTF-16 characters in \p src /// inline translation( - _In_opt_ unsigned __int16 com_rank = 0, - _In_opt_z_count_(com_len) const wchar_t *com = NULL, - _In_opt_ size_t com_len = 0, - _In_opt_ unsigned __int16 dec_rank = 0, - _In_opt_z_count_(dec_len) const wchar_t *dec = NULL, - _In_opt_ size_t dec_len = 0) + _In_opt_ unsigned __int16 dst_rank = 0, + _In_opt_z_count_(dst_len) const wchar_t *dst = NULL, + _In_opt_ size_t dst_len = 0, + _In_opt_ unsigned __int16 src_rank = 0, + _In_opt_z_count_(src_len) const wchar_t *src = NULL, + _In_opt_ size_t src_len = 0) { - this->com_rank = com_rank; - this->dec_rank = dec_rank; - this->com_to = static_cast(com_len); - if (com_len) memcpy(this->data, com, sizeof(wchar_t)*com_len); - this->dec_to = static_cast(this->com_to + dec_len); - if (dec_len) memcpy(this->data + this->com_to, dec, sizeof(wchar_t)*dec_len); + this->dst_rank = dst_rank; + this->src_rank = src_rank; + this->dst_to = static_cast(dst_len); + if (dst_len) memcpy(this->data, dst, sizeof(wchar_t)*dst_len); + this->src_to = static_cast(this->dst_to + src_len); + if (src_len) memcpy(this->data + this->dst_to, src, sizeof(wchar_t)*src_len); } - inline const wchar_t* com () const { return data; }; - inline wchar_t* com () { return data; }; - inline const wchar_t* com_end() const { return data + com_to; }; - inline wchar_t* com_end() { return data + com_to; }; - inline unsigned __int16 com_len() const { return com_to; }; + inline const wchar_t* dst () const { return data; }; + inline wchar_t* dst () { return data; }; + inline const wchar_t* dst_end() const { return data + dst_to; }; + inline wchar_t* dst_end() { return data + dst_to; }; + inline unsigned __int16 dst_len() const { return dst_to; }; - inline wchar_t com_at(_In_ size_t i) const + inline wchar_t dst_at(_In_ size_t i) const { - return i < com_to ? data[i] : 0; + return i < dst_to ? data[i] : 0; } - inline const wchar_t* dec () const { return data + com_to; }; - inline wchar_t* dec () { return data + com_to; }; - inline const wchar_t* dec_end() const { return data + dec_to; }; - inline wchar_t* dec_end() { return data + dec_to; }; - inline unsigned __int16 dec_len() const { return dec_to - com_to; }; + inline const wchar_t* src () const { return data + dst_to; }; + inline wchar_t* src () { return data + dst_to; }; + inline const wchar_t* src_end() const { return data + src_to; }; + inline wchar_t* src_end() { return data + src_to; }; + inline unsigned __int16 src_len() const { return src_to - dst_to; }; - inline wchar_t dec_at(_In_ size_t i) const + inline wchar_t src_at(_In_ size_t i) const { - size_t ii = i + com_to; // absolute index - return ii < dec_to ? data[ii] : 0; + size_t ii = i + dst_to; // absolute index + return ii < src_to ? data[ii] : 0; } }; #pragma pack(pop) /// - /// Composition index + /// Translation index /// - class indexComp : public index + class indexTrans : public index { public: /// @@ -122,7 +122,7 @@ namespace ZRCola { /// /// \param[in] h Reference to vector holding the data /// - indexComp(_In_ std::vector &h) : index(h) {} + indexTrans(_In_ std::vector &h) : index(h) {} /// /// Compares two transformations by string (for searching) @@ -137,7 +137,7 @@ namespace ZRCola { /// virtual int compare(_In_ const translation &a, _In_ const translation &b) const { - int r = ZRCola::CompareString(a.dec(), a.dec_len(), b.dec(), b.dec_len()); + int r = ZRCola::CompareString(a.src(), a.src_len(), b.src(), b.src_len()); if (r != 0) return r; return 0; @@ -156,24 +156,24 @@ namespace ZRCola { /// virtual int compare_sort(_In_ const translation &a, _In_ const translation &b) const { - int r = ZRCola::CompareString(a.dec(), a.dec_len(), b.dec(), b.dec_len()); + int r = ZRCola::CompareString(a.src(), a.src_len(), b.src(), b.src_len()); if (r != 0) return r; - if (a.dec_rank < b.dec_rank) return -1; - else if (a.dec_rank > b.dec_rank) return +1; + if (a.src_rank < b.src_rank) return -1; + else if (a.src_rank > b.src_rank) return +1; - r = ZRCola::CompareString(a.com(), a.com_len(), b.com(), b.com_len()); + r = ZRCola::CompareString(a.dst(), a.dst_len(), b.dst(), b.dst_len()); if (r != 0) return r; return 0; } - } idxComp; ///< Composition index + } idxTrans; ///< Translation index /// - /// Decomposition index + /// Inverse translation index /// - class indexDecomp : public index + class indexTransInv : public index { public: /// @@ -181,7 +181,7 @@ namespace ZRCola { /// /// \param[in] h Reference to vector holding the data /// - indexDecomp(_In_ std::vector &h) : index(h) {} + indexTransInv(_In_ std::vector &h) : index(h) {} /// /// Compares two transformations by character (for searching) @@ -196,7 +196,7 @@ namespace ZRCola { /// virtual int compare(_In_ const translation &a, _In_ const translation &b) const { - int r = ZRCola::CompareString(a.com(), a.com_len(), b.com(), b.com_len()); + int r = ZRCola::CompareString(a.dst(), a.dst_len(), b.dst(), b.dst_len()); if (r != 0) return r; return 0; @@ -215,18 +215,18 @@ namespace ZRCola { /// virtual int compare_sort(_In_ const translation &a, _In_ const translation &b) const { - int r = ZRCola::CompareString(a.com(), a.com_len(), b.com(), b.com_len()); + int r = ZRCola::CompareString(a.dst(), a.dst_len(), b.dst(), b.dst_len()); if (r != 0) return r; - if (a.com_rank < b.com_rank) return -1; - else if (a.com_rank > b.com_rank) return +1; + if (a.dst_rank < b.dst_rank) return -1; + else if (a.dst_rank > b.dst_rank) return +1; - r = ZRCola::CompareString(a.dec(), a.dec_len(), b.dec(), b.dec_len()); + r = ZRCola::CompareString(a.src(), a.src_len(), b.src(), b.src_len()); if (r != 0) return r; return 0; } - } idxDecomp; ///< Decomposition index + } idxTransInv; ///< Inverse translation index std::vector data; ///< Transformation data @@ -235,43 +235,43 @@ namespace ZRCola { /// /// Constructs the database /// - inline translation_db() : idxComp(data), idxDecomp(data) {} + inline translation_db() : idxTrans(data), idxTransInv(data) {} /// /// Clears the database /// inline void clear() { - idxComp .clear(); - idxDecomp.clear(); - data .clear(); + idxTrans .clear(); + idxTransInv.clear(); + data .clear(); } /// - /// Composes string + /// Translates string /// /// \param[in] input Input string (UTF-16) /// \param[in] inputMax Length of the input string in characters. Can be (size_t)-1 if \p input is zero terminated. /// \param[out] output Output string (UTF-16) /// \param[out] map The vector of source to destination index mappings (optional) /// - void Compose(_In_z_count_(inputMax) const wchar_t* input, _In_ size_t inputMax, _Out_ std::wstring &output, _Out_opt_ std::vector* map = NULL) const; + void Translate(_In_z_count_(inputMax) const wchar_t* input, _In_ size_t inputMax, _Out_ std::wstring &output, _Out_opt_ std::vector* map = NULL) const; /// - /// Decomposes string + /// Inverse translates string /// /// \param[in] input Input string (UTF-16) /// \param[in] inputMax Length of the input string in characters. Can be (size_t)-1 if \p input is zero terminated. /// \param[out] output Output string (UTF-16) /// \param[out] map The vector of source to destination index mappings (optional) /// - inline void Decompose(_In_z_count_(inputMax) const wchar_t* input, _In_ size_t inputMax, _Out_ std::wstring &output, _Out_opt_ std::vector* map = NULL) const + inline void TranslateInv(_In_z_count_(inputMax) const wchar_t* input, _In_ size_t inputMax, _Out_ std::wstring &output, _Out_opt_ std::vector* map = NULL) const { - Decompose(input, inputMax, NULL, langid_t::blank, output, map); + TranslateInv(input, inputMax, NULL, langid_t::blank, output, map); } /// - /// Decomposes string according ommiting language specific characters + /// Inverse translates string according ommiting language specific characters /// /// \param[in] input Input string (UTF-16) /// \param[in] inputMax Length of the input string in characters. Can be (size_t)-1 if \p input is zero terminated. @@ -280,7 +280,7 @@ namespace ZRCola { /// \param[out] output Output string (UTF-16) /// \param[out] map The vector of source to destination index mappings (optional) /// - void Decompose(_In_z_count_(inputMax) const wchar_t* input, _In_ size_t inputMax, _In_opt_ const langchar_db *lc_db, _In_opt_ langid_t lang, _Out_ std::wstring &output, _Out_opt_ std::vector* map = NULL) const; + void TranslateInv(_In_z_count_(inputMax) const wchar_t* input, _In_ size_t inputMax, _In_opt_ const langchar_db *lc_db, _In_opt_ langid_t lang, _Out_ std::wstring &output, _Out_opt_ std::vector* map = NULL) const; }; @@ -301,13 +301,13 @@ const ZRCola::recordid_t stdex::idrec::record>(_In_ std::istream& stream, _Out_ ZRCola::translation_db &db) { - // Read composition index. - stream >> db.idxComp; + // Read translation index. + stream >> db.idxTrans; if (!stream.good()) return stream; - // Read decomposition index. - stream >> db.idxDecomp; + // Read inverse translation index. + stream >> db.idxTransInv; if (!stream.good()) return stream; // Read data count. diff --git a/lib/libZRCola/src/translate.cpp b/lib/libZRCola/src/translate.cpp index 8b82a04..0e2dfca 100644 --- a/lib/libZRCola/src/translate.cpp +++ b/lib/libZRCola/src/translate.cpp @@ -20,7 +20,7 @@ #include "stdafx.h" -void ZRCola::translation_db::Compose(_In_z_count_(inputMax) const wchar_t* input, _In_ size_t inputMax, _Out_ std::wstring &output, _Out_opt_ std::vector* map) const +void ZRCola::translation_db::Translate(_In_z_count_(inputMax) const wchar_t* input, _In_ size_t inputMax, _Out_ std::wstring &output, _Out_opt_ std::vector* map) const { assert(input || inputMax == 0); @@ -33,22 +33,22 @@ void ZRCola::translation_db::Compose(_In_z_count_(inputMax) const wchar_t* input if (map) map->clear(); - auto compositionsCount = idxComp.size(); + auto count = idxTrans.size(); for (size_t i = 0; i < inputMax;) { - // Find the longest matching composition at i-th character. + // Find the longest matching translation at i-th character. size_t l_match = (size_t)-1; - for (size_t l = 0, r = compositionsCount, ii = i, j = 0; ii < inputMax && l < r; ii++, j++) { + for (size_t l = 0, r = count, ii = i, j = 0; ii < inputMax && l < r; ii++, j++) { wchar_t c = input[ii]; while (l < r) { - // Test the composition in the middle of the search area. + // Test the translation in the middle of the search area. size_t m = (l + r) / 2; - // Get the j-th character of the composition. - // All compositions that get short on characters are lexically ordered before. + // Get the j-th character of the translation. + // All translations that get short on characters are lexically ordered before. // Thus the j-th character is considered 0. - const translation &trans = idxComp[m]; - wchar_t s = trans.dec_at(j); + const translation &trans = idxTrans[m]; + wchar_t s = trans.src_at(j); // Do the bisection test. if (c < s) r = m; @@ -56,25 +56,25 @@ void ZRCola::translation_db::Compose(_In_z_count_(inputMax) const wchar_t* input else { // Character found. - // Narrow the search area on the left to start at the first composition in the run. + // Narrow the search area on the left to start at the first translation in the run. for (size_t rr = m; l < rr;) { size_t m = (l + rr) / 2; - const translation &trans = idxComp[m]; - wchar_t s = trans.dec_at(j); + const translation &trans = idxTrans[m]; + wchar_t s = trans.src_at(j); if (c <= s) rr = m; else l = m + 1; } - // Narrow the search area on the right to end at the first composition not in the run. + // Narrow the search area on the right to end at the first translation not in the run. for (size_t ll = m + 1; ll < r;) { size_t m = (ll + r) / 2; - const translation &trans = idxComp[m]; - wchar_t s = trans.dec_at(j); + const translation &trans = idxTrans[m]; + wchar_t s = trans.src_at(j); if (s <= c) ll = m + 1; else r = m; } - const translation &trans = idxComp[l]; - if (j + 1 == trans.dec_len()) { - // The first composition of the run was a match (thus far). Save it. + const translation &trans = idxTrans[l]; + if (j + 1 == trans.src_len()) { + // The first translation of the run was a match (thus far). Save it. l_match = l; } @@ -83,12 +83,12 @@ void ZRCola::translation_db::Compose(_In_z_count_(inputMax) const wchar_t* input } } - if (l_match < compositionsCount) { - // The saved composition was an exact match. - const translation &trans = idxComp[l_match]; - output.append(trans.com(), trans.com_end()); - i += trans.dec_len(); - if (trans.dec_len() != trans.com_len() && map) { + if (l_match < count) { + // The saved translation was an exact match. + const translation &trans = idxTrans[l_match]; + output.append(trans.dst(), trans.dst_end()); + i += trans.src_len(); + if (trans.src_len() != trans.dst_len() && map) { // Mapping changed. map->push_back(ZRCola::mapping(i, output.length())); } @@ -101,7 +101,7 @@ void ZRCola::translation_db::Compose(_In_z_count_(inputMax) const wchar_t* input } -void ZRCola::translation_db::Decompose(_In_z_count_(inputMax) const wchar_t* input, _In_ size_t inputMax, _In_ const langchar_db *lc_db, _In_ langid_t lang, _Out_ std::wstring &output, _Out_opt_ std::vector* map) const +void ZRCola::translation_db::TranslateInv(_In_z_count_(inputMax) const wchar_t* input, _In_ size_t inputMax, _In_ const langchar_db *lc_db, _In_ langid_t lang, _Out_ std::wstring &output, _Out_opt_ std::vector* map) const { assert(input || inputMax == 0); @@ -114,22 +114,22 @@ void ZRCola::translation_db::Decompose(_In_z_count_(inputMax) const wchar_t* inp if (map) map->clear(); - auto decompositionsCount = idxDecomp.size(); + auto count = idxTransInv.size(); for (size_t i = 0; i < inputMax;) { - // Find the longest matching decomposition at i-th character. + // Find the longest matching inverse translation at i-th character. size_t l_match = (size_t)-1; - for (size_t l = 0, r = decompositionsCount, ii = i, j = 0; ii < inputMax && l < r; ii++, j++) { + for (size_t l = 0, r = count, ii = i, j = 0; ii < inputMax && l < r; ii++, j++) { wchar_t c = input[ii]; while (l < r) { - // Test the decomposition in the middle of the search area. + // Test the inverse translation in the middle of the search area. size_t m = (l + r) / 2; - // Get the j-th character of the decomposition. - // All decompositions that get short on characters are lexically ordered before. + // Get the j-th character of the inverse translation. + // All inverse translations that get short on characters are lexically ordered before. // Thus the j-th character is considered 0. - const translation &trans = idxDecomp[m]; - wchar_t s = trans.com_at(j); + const translation &trans = idxTransInv[m]; + wchar_t s = trans.dst_at(j); // Do the bisection test. if (c < s) r = m; @@ -137,25 +137,25 @@ void ZRCola::translation_db::Decompose(_In_z_count_(inputMax) const wchar_t* inp else { // Character found. - // Narrow the search area on the left to start at the first decomposition in the run. + // Narrow the search area on the left to start at the first inverse translation in the run. for (size_t rr = m; l < rr;) { size_t m = (l + rr) / 2; - const translation &trans = idxDecomp[m]; - wchar_t s = trans.com_at(j); + const translation &trans = idxTransInv[m]; + wchar_t s = trans.dst_at(j); if (c <= s) rr = m; else l = m + 1; } - // Narrow the search area on the right to end at the first decomposition not in the run. + // Narrow the search area on the right to end at the first inverse translation not in the run. for (size_t ll = m + 1; ll < r;) { size_t m = (ll + r) / 2; - const translation &trans = idxDecomp[m]; - wchar_t s = trans.com_at(j); + const translation &trans = idxTransInv[m]; + wchar_t s = trans.dst_at(j); if (s <= c) ll = m + 1; else r = m; } - const translation &trans = idxDecomp[l]; - if (j + 1 == trans.com_len()) { - // The first decomposition of the run was a match (thus far). Save it. + const translation &trans = idxTransInv[l]; + if (j + 1 == trans.dst_len()) { + // The first inverse translation of the run was a match (thus far). Save it. l_match = l; } @@ -164,21 +164,21 @@ void ZRCola::translation_db::Decompose(_In_z_count_(inputMax) const wchar_t* inp } } - if (l_match < decompositionsCount) { - // The saved decomposition was an exact match. - const translation &trans = idxDecomp[l_match]; - if (trans.dec_len() && trans.dec()[0] != L'#' && (!lc_db || !lc_db->IsLocalCharacter(trans.com(), trans.com_end(), lang))) { - // Append decomposed sequence. - output.append(trans.dec(), trans.dec_end()); - i += trans.com_len(); - if (trans.com_len() != trans.dec_len() && map) { + if (l_match < count) { + // The saved inverse translation was an exact match. + const translation &trans = idxTransInv[l_match]; + if (trans.src_len() && trans.src()[0] != L'#' && (!lc_db || !lc_db->IsLocalCharacter(trans.dst(), trans.dst_end(), lang))) { + // Append source sequence. + output.append(trans.src(), trans.src_end()); + i += trans.dst_len(); + if (trans.dst_len() != trans.src_len() && map) { // Mapping changed. map->push_back(ZRCola::mapping(i, output.length())); } } else { - // Character is inhibited to decompose. - output.append(trans.com(), trans.com_end()); - i += trans.com_len(); + // Character is inhibited to inverse translate. + output.append(trans.dst(), trans.dst_end()); + i += trans.dst_len(); } } else { // The match was not found.