Early "Paste Over" functionality (basically it all works, but it needs a popup dialog asking which fields to paste over)

Originally committed to SVN as r565.
This commit is contained in:
Rodrigo Braz Monteiro 2006-12-17 18:30:19 +00:00
parent 8b95b2a3f7
commit c5e479875f
7 changed files with 65 additions and 9 deletions

View File

@ -27,6 +27,7 @@ Please visit http://aegisub.net to download latest version
- Added support for reading ASS, SSA and SRT softsubs directly from Matroska files. (AMZ) - Added support for reading ASS, SSA and SRT softsubs directly from Matroska files. (AMZ)
- Fixed line selection after pasting. (AMZ) - Fixed line selection after pasting. (AMZ)
- Times can now be copy and pasted with ctrl+c and ctrl+v, as well as from context menu, in the time edit boxes. (AMZ) - Times can now be copy and pasted with ctrl+c and ctrl+v, as well as from context menu, in the time edit boxes. (AMZ)
- Plain-text lines can now be pasted into the grid. They will be inserted as default lines with the text as their content. (AMZ)
= 1.10 beta - 2006.08.07 =========================== = 1.10 beta - 2006.08.07 ===========================

View File

@ -247,6 +247,7 @@ void FrameMain::InitMenu() {
AppendBitmapMenuItem (editMenu,Menu_Edit_Cut, _("Cut...\t") + Hotkeys.GetText(_T("Cut")), _("Cut subtitles"), wxBITMAP(cut_button)); AppendBitmapMenuItem (editMenu,Menu_Edit_Cut, _("Cut...\t") + Hotkeys.GetText(_T("Cut")), _("Cut subtitles"), wxBITMAP(cut_button));
AppendBitmapMenuItem (editMenu,Menu_Edit_Copy, _("Copy...\t") + Hotkeys.GetText(_T("Copy")), _("Copy subtitles"), wxBITMAP(copy_button)); AppendBitmapMenuItem (editMenu,Menu_Edit_Copy, _("Copy...\t") + Hotkeys.GetText(_T("Copy")), _("Copy subtitles"), wxBITMAP(copy_button));
AppendBitmapMenuItem (editMenu,Menu_Edit_Paste, _("Paste...\t") + Hotkeys.GetText(_T("Paste")), _("Paste subtitles"), wxBITMAP(paste_button)); AppendBitmapMenuItem (editMenu,Menu_Edit_Paste, _("Paste...\t") + Hotkeys.GetText(_T("Paste")), _("Paste subtitles"), wxBITMAP(paste_button));
editMenu->Append(Menu_Edit_Paste_Over, _("Paste Over...\t") + Hotkeys.GetText(_T("Paste Over")) , _("Paste subtitles over others"));
MenuBar->Append(editMenu, _("&Edit")); MenuBar->Append(editMenu, _("&Edit"));
// Create view menu // Create view menu

View File

@ -175,6 +175,7 @@ private:
void OnCut (wxCommandEvent &event); void OnCut (wxCommandEvent &event);
void OnCopy (wxCommandEvent &event); void OnCopy (wxCommandEvent &event);
void OnPaste (wxCommandEvent &event); void OnPaste (wxCommandEvent &event);
void OnPasteOver (wxCommandEvent &event);
void OnFind (wxCommandEvent &event); void OnFind (wxCommandEvent &event);
void OnFindNext (wxCommandEvent &event); void OnFindNext (wxCommandEvent &event);
void OnReplace (wxCommandEvent &event); void OnReplace (wxCommandEvent &event);
@ -307,6 +308,7 @@ enum {
Menu_Edit_Cut, Menu_Edit_Cut,
Menu_Edit_Copy, Menu_Edit_Copy,
Menu_Edit_Paste, Menu_Edit_Paste,
Menu_Edit_Paste_Over,
Menu_View_Language, Menu_View_Language,
Menu_View_Standard, Menu_View_Standard,

View File

@ -157,6 +157,7 @@ BEGIN_EVENT_TABLE(FrameMain, wxFrame)
EVT_MENU(Menu_Edit_Cut, FrameMain::OnCut) EVT_MENU(Menu_Edit_Cut, FrameMain::OnCut)
EVT_MENU(Menu_Edit_Copy, FrameMain::OnCopy) EVT_MENU(Menu_Edit_Copy, FrameMain::OnCopy)
EVT_MENU(Menu_Edit_Paste, FrameMain::OnPaste) EVT_MENU(Menu_Edit_Paste, FrameMain::OnPaste)
EVT_MENU(Menu_Edit_Paste_Over, FrameMain::OnPasteOver)
EVT_MENU(Menu_Edit_Find, FrameMain::OnFind) EVT_MENU(Menu_Edit_Find, FrameMain::OnFind)
EVT_MENU(Menu_Edit_Find_Next, FrameMain::OnFindNext) EVT_MENU(Menu_Edit_Find_Next, FrameMain::OnFindNext)
EVT_MENU(Menu_Edit_Replace, FrameMain::OnReplace) EVT_MENU(Menu_Edit_Replace, FrameMain::OnReplace)
@ -380,6 +381,7 @@ void FrameMain::OnMenuOpen (wxMenuEvent &event) {
RebuildMenuItem(editMenu,Menu_Edit_Cut,wxBITMAP(cut_button),wxBITMAP(cut_disable_button),state); RebuildMenuItem(editMenu,Menu_Edit_Cut,wxBITMAP(cut_button),wxBITMAP(cut_disable_button),state);
RebuildMenuItem(editMenu,Menu_Edit_Copy,wxBITMAP(copy_button),wxBITMAP(copy_disable_button),state); RebuildMenuItem(editMenu,Menu_Edit_Copy,wxBITMAP(copy_button),wxBITMAP(copy_disable_button),state);
RebuildMenuItem(editMenu,Menu_Edit_Paste,wxBITMAP(paste_button),wxBITMAP(paste_disable_button),state); RebuildMenuItem(editMenu,Menu_Edit_Paste,wxBITMAP(paste_button),wxBITMAP(paste_disable_button),state);
MenuBar->Enable(Menu_Edit_Paste_Over,state);
} }
//Thaw(); //Thaw();
@ -1115,6 +1117,13 @@ void FrameMain::OnPaste (wxCommandEvent &event) {
} }
//////////////
// Paste over
void FrameMain::OnPasteOver (wxCommandEvent &event) {
SubsBox->PasteLines(SubsBox->GetFirstSelRow(),true);
}
//////////////////////// ////////////////////////
// Select visible lines // Select visible lines
void FrameMain::OnSelectVisible (wxCommandEvent &event) { void FrameMain::OnSelectVisible (wxCommandEvent &event) {

View File

@ -324,6 +324,7 @@ void HotkeyManager::LoadDefaults() {
SetHotkey(_("Copy"),_T("Ctrl-C")); SetHotkey(_("Copy"),_T("Ctrl-C"));
SetHotkey(_("Cut"),_T("Ctrl-X")); SetHotkey(_("Cut"),_T("Ctrl-X"));
SetHotkey(_("Paste"),_T("Ctrl-V")); SetHotkey(_("Paste"),_T("Ctrl-V"));
SetHotkey(_("Paste Over"),_T("Ctrl-Shift-V"));
SetHotkey(_("Video Jump"),_T("Ctrl-G")); SetHotkey(_("Video Jump"),_T("Ctrl-G"));
SetHotkey(_("Jump Video to Start"),_T("Ctrl-1")); SetHotkey(_("Jump Video to Start"),_T("Ctrl-1"));

View File

@ -846,7 +846,7 @@ void SubtitlesGrid::CutLines(wxArrayInt target) {
////////////////////////////// //////////////////////////////
// Paste lines from clipboard // Paste lines from clipboard
void SubtitlesGrid::PasteLines(int n) { void SubtitlesGrid::PasteLines(int n,bool pasteOver) {
BeginBatch(); BeginBatch();
// Prepare text // Prepare text
@ -864,21 +864,60 @@ void SubtitlesGrid::PasteLines(int n) {
// Check if it actually got anything // Check if it actually got anything
if (!data.empty()) { if (!data.empty()) {
// Insert data
int inserted = 0; int inserted = 0;
bool asked = false;
wxArrayInt pasteOverOptions;
wxStringTokenizer token (data,_T("\r\n"),wxTOKEN_STRTOK); wxStringTokenizer token (data,_T("\r\n"),wxTOKEN_STRTOK);
while (token.HasMoreTokens()) { while (token.HasMoreTokens()) {
// Convert data into an AssDialogue
wxString curdata = token.GetNextToken(); wxString curdata = token.GetNextToken();
curdata.Trim(true); curdata.Trim(true);
curdata.Trim(false); curdata.Trim(false);
AssDialogue *curdiag;
try { try {
AssDialogue *curdiag = new AssDialogue(curdata); curdiag = new AssDialogue(curdata);
InsertLine(curdiag,n+inserted,false,false);
inserted++;
} }
catch (...) { catch (...) {
curdiag = new AssDialogue();
curdiag->Text = curdata;
} }
// Paste over
if (pasteOver) {
if (n+inserted < GetRows()) {
// Get list of options to paste over, if not asked yet
if (asked == false) {
asked = true;
// TODO: Replace this with dialog
for (int i=0;i<10;i++) pasteOverOptions.Add(0);
pasteOverOptions[9] = 1;
}
// Paste over
AssDialogue *target = GetDialogue(n+inserted);
if (pasteOverOptions[0]) target->Layer = curdiag->Layer;
if (pasteOverOptions[1]) target->Start = curdiag->Start;
if (pasteOverOptions[2]) target->End = curdiag->End;
if (pasteOverOptions[3]) target->Style = curdiag->Style;
if (pasteOverOptions[4]) target->Actor = curdiag->Actor;
if (pasteOverOptions[5]) target->MarginL = curdiag->MarginL;
if (pasteOverOptions[6]) target->MarginR = curdiag->MarginR;
if (pasteOverOptions[7]) target->MarginV = curdiag->MarginV;
if (pasteOverOptions[8]) target->Effect = curdiag->Effect;
if (pasteOverOptions[9]) target->Text = curdiag->Text;
}
delete curdiag;
}
// Paste normally
else InsertLine(curdiag,n+inserted,false,false);
// Increment insertion
inserted++;
} }
// Update data post-insertion
if (inserted > 0) { if (inserted > 0) {
// Commit // Commit
UpdateMaps(); UpdateMaps();
@ -887,14 +926,17 @@ void SubtitlesGrid::PasteLines(int n) {
CommitChanges(); CommitChanges();
// Set selection // Set selection
SelectRow(n); if (!pasteOver) {
for (int i=n+1;i<n+inserted;i++) { SelectRow(n);
SelectRow(i,true); for (int i=n+1;i<n+inserted;i++) {
SelectRow(i,true);
}
editBox->SetToLine(n);
} }
editBox->SetToLine(n);
} }
} }
// Done
EndBatch(); EndBatch();
} }

View File

@ -126,7 +126,7 @@ public:
void CopyLines(wxArrayInt lines); void CopyLines(wxArrayInt lines);
void CutLines(wxArrayInt lines); void CutLines(wxArrayInt lines);
void PasteLines(int pos); void PasteLines(int pos,bool over=false);
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };