mirror of https://github.com/odrling/Aegisub
Convert newlines to \N when pasting rather than trying to clean them up later
Originally committed to SVN as r5727.
This commit is contained in:
parent
6e30ff633c
commit
a260a998b3
|
@ -292,7 +292,6 @@ SubsEditBox::SubsEditBox(wxWindow *parent, agi::Context *context)
|
||||||
bind_focus_handler(ActorBox, wxEVT_KILL_FOCUS, "Actor", "", grey);
|
bind_focus_handler(ActorBox, wxEVT_KILL_FOCUS, "Actor", "", grey);
|
||||||
ActorBox->SetForegroundColour(grey);
|
ActorBox->SetForegroundColour(grey);
|
||||||
|
|
||||||
TextEdit->Bind(wxEVT_STC_STYLENEEDED, &SubsEditBox::OnNeedStyle, this);
|
|
||||||
TextEdit->Bind(wxEVT_STC_MODIFIED, &SubsEditBox::OnChange, this);
|
TextEdit->Bind(wxEVT_STC_MODIFIED, &SubsEditBox::OnChange, this);
|
||||||
TextEdit->SetModEventMask(wxSTC_MOD_INSERTTEXT | wxSTC_MOD_DELETETEXT);
|
TextEdit->SetModEventMask(wxSTC_MOD_INSERTTEXT | wxSTC_MOD_DELETETEXT);
|
||||||
|
|
||||||
|
@ -545,16 +544,6 @@ void SubsEditBox::OnSize(wxSizeEvent &evt) {
|
||||||
evt.Skip();
|
evt.Skip();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SubsEditBox::OnNeedStyle(wxStyledTextEvent &event) {
|
|
||||||
// Check if it needs to fix text
|
|
||||||
wxString text = TextEdit->GetText();
|
|
||||||
if (text.Contains("\n") || text.Contains("\r")) {
|
|
||||||
TextEdit->SetTextTo(text);
|
|
||||||
}
|
|
||||||
// Just update style
|
|
||||||
else TextEdit->UpdateStyle();
|
|
||||||
}
|
|
||||||
|
|
||||||
void SubsEditBox::OnFrameTimeRadio(wxCommandEvent &event) {
|
void SubsEditBox::OnFrameTimeRadio(wxCommandEvent &event) {
|
||||||
bool byFrame = ByFrame->GetValue();
|
bool byFrame = ByFrame->GetValue();
|
||||||
StartTime->SetByFrame(byFrame);
|
StartTime->SetByFrame(byFrame);
|
||||||
|
|
|
@ -131,7 +131,6 @@ class SubsEditBox : public wxPanel, protected SelectionListener<AssDialogue> {
|
||||||
int commitId;
|
int commitId;
|
||||||
wxString lastCommitType;
|
wxString lastCommitType;
|
||||||
|
|
||||||
void OnNeedStyle(wxStyledTextEvent &event);
|
|
||||||
void OnChange(wxStyledTextEvent &event);
|
void OnChange(wxStyledTextEvent &event);
|
||||||
void OnKeyDown(wxKeyEvent &event);
|
void OnKeyDown(wxKeyEvent &event);
|
||||||
|
|
||||||
|
|
|
@ -421,6 +421,8 @@ void SubsTextEditCtrl::UpdateStyle() {
|
||||||
|
|
||||||
/// @brief Update call tip
|
/// @brief Update call tip
|
||||||
void SubsTextEditCtrl::UpdateCallTip(wxStyledTextEvent &) {
|
void SubsTextEditCtrl::UpdateCallTip(wxStyledTextEvent &) {
|
||||||
|
UpdateStyle();
|
||||||
|
|
||||||
if (!OPT_GET("App/Call Tips")->GetBool()) return;
|
if (!OPT_GET("App/Call Tips")->GetBool()) return;
|
||||||
|
|
||||||
// Get position and text
|
// Get position and text
|
||||||
|
@ -666,10 +668,6 @@ void SubsTextEditCtrl::SetTextTo(wxString text) {
|
||||||
SetEvtHandlerEnabled(false);
|
SetEvtHandlerEnabled(false);
|
||||||
Freeze();
|
Freeze();
|
||||||
|
|
||||||
text.Replace("\r\n","\\N");
|
|
||||||
text.Replace("\r","\\N");
|
|
||||||
text.Replace("\n","\\N");
|
|
||||||
|
|
||||||
int from=0,to=0;
|
int from=0,to=0;
|
||||||
GetSelection(&from,&to);
|
GetSelection(&from,&to);
|
||||||
|
|
||||||
|
@ -683,6 +681,34 @@ void SubsTextEditCtrl::SetTextTo(wxString text) {
|
||||||
Thaw();
|
Thaw();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SubsTextEditCtrl::Paste() {
|
||||||
|
wxString data;
|
||||||
|
if (wxTheClipboard->Open()) {
|
||||||
|
if (wxTheClipboard->IsSupported(wxDF_TEXT)) {
|
||||||
|
wxTextDataObject rawdata;
|
||||||
|
wxTheClipboard->GetData(rawdata);
|
||||||
|
data = rawdata.GetText();
|
||||||
|
}
|
||||||
|
wxTheClipboard->Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
data.Replace("\r\n", "\\N");
|
||||||
|
data.Replace("\n", "\\N");
|
||||||
|
data.Replace("\r", "\\N");
|
||||||
|
|
||||||
|
int from = GetReverseUnicodePosition(GetSelectionStart());
|
||||||
|
int to = GetReverseUnicodePosition(GetSelectionEnd());
|
||||||
|
|
||||||
|
wxString old = GetText();
|
||||||
|
SetText(old.Left(from) + data + old.Mid(to));
|
||||||
|
|
||||||
|
int sel_start = GetUnicodePosition(from + data.size());
|
||||||
|
SetSelectionStart(sel_start);
|
||||||
|
SetSelectionEnd(sel_start);
|
||||||
|
UpdateStyle();
|
||||||
|
}
|
||||||
|
|
||||||
void SubsTextEditCtrl::OnContextMenu(wxContextMenuEvent &event) {
|
void SubsTextEditCtrl::OnContextMenu(wxContextMenuEvent &event) {
|
||||||
if (!grid->GetActiveLine())
|
if (!grid->GetActiveLine())
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -95,12 +95,14 @@ class SubsTextEditCtrl : public ScintillaTextCtrl {
|
||||||
void UpdateCallTip(wxStyledTextEvent &);
|
void UpdateCallTip(wxStyledTextEvent &);
|
||||||
void SetStyles();
|
void SetStyles();
|
||||||
|
|
||||||
|
void UpdateStyle();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SubsTextEditCtrl(wxWindow* parent, wxSize size, long style, SubtitlesGrid *grid);
|
SubsTextEditCtrl(wxWindow* parent, wxSize size, long style, SubtitlesGrid *grid);
|
||||||
~SubsTextEditCtrl();
|
~SubsTextEditCtrl();
|
||||||
|
|
||||||
void SetTextTo(wxString text);
|
void SetTextTo(wxString text);
|
||||||
void UpdateStyle();
|
void Paste();
|
||||||
|
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue