forked from mia/Aegisub
Changed translation assistent to use Scintilla text controls to avoid several issues, including Right-To-Left text entry.
Originally committed to SVN as r1291.
This commit is contained in:
parent
f205d35a5a
commit
6dfcbc0cd8
5 changed files with 40 additions and 30 deletions
|
@ -146,6 +146,7 @@ Please visit http://aegisub.net to download latest version
|
||||||
- Fixed display of end frames on the subtitles grid, when set to frame mode. (demi)
|
- Fixed display of end frames on the subtitles grid, when set to frame mode. (demi)
|
||||||
- Treat comments inside {}'s as plain text, not as overrides; Also, don't assume override blocks start with a backslash, even if they probably should (Dansolo)
|
- Treat comments inside {}'s as plain text, not as overrides; Also, don't assume override blocks start with a backslash, even if they probably should (Dansolo)
|
||||||
- Removed FexTracker due to licensing problems; there are plans to implement a new motion tracker in its place (jfs)
|
- Removed FexTracker due to licensing problems; there are plans to implement a new motion tracker in its place (jfs)
|
||||||
|
- Changed translation assistent to use Scintilla text controls to avoid several issues, including Right-To-Left text entry.
|
||||||
|
|
||||||
|
|
||||||
= 1.10 beta - 2006.08.07 ===========================
|
= 1.10 beta - 2006.08.07 ===========================
|
||||||
|
|
|
@ -62,13 +62,21 @@ DialogTranslation::DialogTranslation (wxWindow *parent,AssFile *_subs,SubtitlesG
|
||||||
grid = _grid;
|
grid = _grid;
|
||||||
audio = VideoContext::Get()->audio;
|
audio = VideoContext::Get()->audio;
|
||||||
|
|
||||||
|
// Translation controls
|
||||||
|
OrigText = new ScintillaTextCtrl(this,TEXT_ORIGINAL,_T(""),wxDefaultPosition,wxSize(300,80));
|
||||||
|
OrigText->SetWrapMode(wxSTC_WRAP_WORD);
|
||||||
|
OrigText->SetMarginWidth(1,0);
|
||||||
|
OrigText->StyleSetForeground(1,wxColour(10,60,200));
|
||||||
|
OrigText->SetReadOnly(true);
|
||||||
|
//OrigText->PushEventHandler(new DialogTranslationEvent(this));
|
||||||
|
TransText = new ScintillaTextCtrl(this,TEXT_TRANS,_T(""),wxDefaultPosition,wxSize(300,80));
|
||||||
|
TransText->SetWrapMode(wxSTC_WRAP_WORD);
|
||||||
|
TransText->SetMarginWidth(1,0);
|
||||||
|
TransText->PushEventHandler(new DialogTranslationEvent(this));
|
||||||
|
TransText->SetFocus();
|
||||||
|
|
||||||
// Translation box
|
// Translation box
|
||||||
wxSizer *TranslationSizer = new wxBoxSizer(wxVERTICAL);
|
wxSizer *TranslationSizer = new wxBoxSizer(wxVERTICAL);
|
||||||
OrigText = new wxTextCtrl(this,TEXT_ORIGINAL,_T(""),wxDefaultPosition,wxSize(300,80),wxTE_MULTILINE | wxTE_RICH | wxTE_READONLY);
|
|
||||||
TransText = new wxTextCtrl(this,TEXT_TRANS,_T(""),wxDefaultPosition,wxSize(300,80),wxTE_MULTILINE | wxTE_RICH2);
|
|
||||||
OrigText->SetEventHandler(new DialogTranslationEvent(this));
|
|
||||||
TransText->SetEventHandler(new DialogTranslationEvent(this));
|
|
||||||
TransText->SetFocus();
|
|
||||||
wxSizer *OriginalTransSizer = new wxStaticBoxSizer(wxVERTICAL,this,_("Original"));
|
wxSizer *OriginalTransSizer = new wxStaticBoxSizer(wxVERTICAL,this,_("Original"));
|
||||||
wxSizer *TranslatedSizer = new wxStaticBoxSizer(wxVERTICAL,this,_("Translation"));
|
wxSizer *TranslatedSizer = new wxStaticBoxSizer(wxVERTICAL,this,_("Translation"));
|
||||||
LineCount = new wxStaticText(this,-1,_("Current line: ?"));
|
LineCount = new wxStaticText(this,-1,_("Current line: ?"));
|
||||||
|
@ -177,16 +185,9 @@ bool DialogTranslation::JumpToLine(int n,int block) {
|
||||||
grid->editBox->SetToLine(curline);
|
grid->editBox->SetToLine(curline);
|
||||||
grid->EndBatch();
|
grid->EndBatch();
|
||||||
|
|
||||||
// Set styles
|
|
||||||
wxTextAttr Normal(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
|
|
||||||
wxTextAttr Highlight(wxColour(0,0,255));
|
|
||||||
wxFont font = Normal.GetFont();
|
|
||||||
font.SetPointSize(Options.AsInt(_T("Edit Font Size")));
|
|
||||||
Normal.SetFont(font);
|
|
||||||
Highlight.SetFont(font);
|
|
||||||
|
|
||||||
// Adds blocks
|
// Adds blocks
|
||||||
OrigText->Clear();
|
OrigText->SetReadOnly(false);
|
||||||
|
OrigText->ClearAll();
|
||||||
AssDialogueBlock *curBlock;
|
AssDialogueBlock *curBlock;
|
||||||
bool found = false;
|
bool found = false;
|
||||||
int pos=-1;
|
int pos=-1;
|
||||||
|
@ -194,21 +195,18 @@ bool DialogTranslation::JumpToLine(int n,int block) {
|
||||||
curBlock = *cur;
|
curBlock = *cur;
|
||||||
if (curBlock->type == BLOCK_PLAIN) {
|
if (curBlock->type == BLOCK_PLAIN) {
|
||||||
pos++;
|
pos++;
|
||||||
|
int curLen = OrigText->GetUnicodePosition(OrigText->GetLength());
|
||||||
|
OrigText->AppendText(curBlock->text);
|
||||||
if (pos == block) {
|
if (pos == block) {
|
||||||
OrigText->SetDefaultStyle(Highlight);
|
OrigText->StartUnicodeStyling(curLen);
|
||||||
|
OrigText->SetUnicodeStyling(curLen,curBlock->text.Length(),1);
|
||||||
found = true;
|
found = true;
|
||||||
}
|
}
|
||||||
else OrigText->SetDefaultStyle(Normal);
|
|
||||||
}
|
}
|
||||||
else OrigText->SetDefaultStyle(Normal);
|
else if (curBlock->type == BLOCK_OVERRIDE) OrigText->AppendText(_T("{") + curBlock->text + _T("}"));
|
||||||
|
|
||||||
if (curBlock->type == BLOCK_OVERRIDE) OrigText->AppendText(_T("{"));
|
|
||||||
OrigText->AppendText(curBlock->text);
|
|
||||||
if (curBlock->type == BLOCK_OVERRIDE) OrigText->AppendText(_T("}"));
|
|
||||||
}
|
}
|
||||||
OrigText->SetDefaultStyle(Normal);
|
|
||||||
TransText->SetDefaultStyle(Normal);
|
|
||||||
current->ClearBlocks();
|
current->ClearBlocks();
|
||||||
|
OrigText->SetReadOnly(true);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -276,7 +274,7 @@ void DialogTranslation::OnTransBoxKey(wxKeyEvent &event) {
|
||||||
if (Hotkeys.IsPressed(_T("Translation Assistant Prev"))) {
|
if (Hotkeys.IsPressed(_T("Translation Assistant Prev"))) {
|
||||||
bool ok = JumpToLine(curline,curblock-1);
|
bool ok = JumpToLine(curline,curblock-1);
|
||||||
if (ok) {
|
if (ok) {
|
||||||
TransText->Clear();
|
TransText->ClearAll();
|
||||||
TransText->SetFocus();
|
TransText->SetFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -288,7 +286,7 @@ void DialogTranslation::OnTransBoxKey(wxKeyEvent &event) {
|
||||||
if (Hotkeys.IsPressed(_T("Translation Assistant Next")) || (Hotkeys.IsPressed(_T("Translation Assistant Accept")) && TransText->GetValue().IsEmpty())) {
|
if (Hotkeys.IsPressed(_T("Translation Assistant Next")) || (Hotkeys.IsPressed(_T("Translation Assistant Accept")) && TransText->GetValue().IsEmpty())) {
|
||||||
bool ok = JumpToLine(curline,curblock+1);
|
bool ok = JumpToLine(curline,curblock+1);
|
||||||
if (ok) {
|
if (ok) {
|
||||||
TransText->Clear();
|
TransText->ClearAll();
|
||||||
TransText->SetFocus();
|
TransText->SetFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -322,7 +320,7 @@ void DialogTranslation::OnTransBoxKey(wxKeyEvent &event) {
|
||||||
// Next
|
// Next
|
||||||
if (Hotkeys.IsPressed(_T("Translation Assistant Accept"))) {
|
if (Hotkeys.IsPressed(_T("Translation Assistant Accept"))) {
|
||||||
JumpToLine(curline,curblock+1);
|
JumpToLine(curline,curblock+1);
|
||||||
TransText->Clear();
|
TransText->ClearAll();
|
||||||
TransText->SetFocus();
|
TransText->SetFocus();
|
||||||
}
|
}
|
||||||
else JumpToLine(curline,curblock);
|
else JumpToLine(curline,curblock);
|
||||||
|
@ -340,7 +338,7 @@ void DialogTranslation::OnTransBoxKey(wxKeyEvent &event) {
|
||||||
if (curBlock->type == BLOCK_PLAIN) {
|
if (curBlock->type == BLOCK_PLAIN) {
|
||||||
pos++;
|
pos++;
|
||||||
if (pos == curblock) {
|
if (pos == curblock) {
|
||||||
TransText->WriteText(curBlock->text);
|
TransText->AddText(curBlock->text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,7 @@
|
||||||
///////////
|
///////////
|
||||||
// Headers
|
// Headers
|
||||||
#include <wx/wxprec.h>
|
#include <wx/wxprec.h>
|
||||||
|
#include "scintilla_text_ctrl.h"
|
||||||
|
|
||||||
|
|
||||||
//////////////
|
//////////////
|
||||||
|
@ -64,8 +65,8 @@ private:
|
||||||
int curblock;
|
int curblock;
|
||||||
|
|
||||||
wxStaticText *LineCount;
|
wxStaticText *LineCount;
|
||||||
wxTextCtrl *OrigText;
|
ScintillaTextCtrl *OrigText;
|
||||||
wxTextCtrl *TransText;
|
ScintillaTextCtrl *TransText;
|
||||||
wxCheckBox *PreviewCheck;
|
wxCheckBox *PreviewCheck;
|
||||||
|
|
||||||
void OnMinimize(wxIconizeEvent &event);
|
void OnMinimize(wxIconizeEvent &event);
|
||||||
|
|
|
@ -84,6 +84,13 @@ int ScintillaTextCtrl::GetReverseUnicodePosition(int pos) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////
|
||||||
|
// Start unicode-safe styling
|
||||||
|
void ScintillaTextCtrl::StartUnicodeStyling(int start,int mask) {
|
||||||
|
StartStyling(GetUnicodePosition(start),mask);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////
|
////////////////////////
|
||||||
// Unicode-safe styling
|
// Unicode-safe styling
|
||||||
void ScintillaTextCtrl::SetUnicodeStyling(int start,int length,int style) {
|
void ScintillaTextCtrl::SetUnicodeStyling(int start,int length,int style) {
|
||||||
|
|
|
@ -49,9 +49,12 @@ class ScintillaTextCtrl : public wxStyledTextCtrl {
|
||||||
public:
|
public:
|
||||||
wxString GetWordAtPosition(int pos);
|
wxString GetWordAtPosition(int pos);
|
||||||
void GetBoundsOfWordAtPosition(int pos,int &start,int &end);
|
void GetBoundsOfWordAtPosition(int pos,int &start,int &end);
|
||||||
void SetUnicodeStyling(int start,int length,int style);
|
|
||||||
int GetUnicodePosition(int pos);
|
int GetUnicodePosition(int pos);
|
||||||
int GetReverseUnicodePosition(int pos);
|
int GetReverseUnicodePosition(int pos);
|
||||||
|
wxString GetValue() { return GetText(); }
|
||||||
|
|
||||||
|
void StartUnicodeStyling(int start,int mask=31);
|
||||||
|
void SetUnicodeStyling(int start,int length,int style);
|
||||||
void SetSelectionU(int start,int end);
|
void SetSelectionU(int start,int end);
|
||||||
|
|
||||||
ScintillaTextCtrl(wxWindow* parent, wxWindowID id, const wxString& value = _T(""), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, const wxValidator& validator = wxDefaultValidator, const wxString& name = wxTextCtrlNameStr);
|
ScintillaTextCtrl(wxWindow* parent, wxWindowID id, const wxString& value = _T(""), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, const wxValidator& validator = wxDefaultValidator, const wxString& name = wxTextCtrlNameStr);
|
||||||
|
|
Loading…
Reference in a new issue