forked from mia/Aegisub
Add a blank line between each group when writing ass files
Originally committed to SVN as r4802.
This commit is contained in:
parent
7d2c7c5881
commit
2324a1f197
1 changed files with 14 additions and 12 deletions
|
@ -170,25 +170,27 @@ bool ASSSubtitleFormat::CanWriteFile(wxString filename) {
|
||||||
/// @param _filename
|
/// @param _filename
|
||||||
/// @param encoding
|
/// @param encoding
|
||||||
///
|
///
|
||||||
void ASSSubtitleFormat::WriteFile(wxString _filename,wxString encoding) {
|
void ASSSubtitleFormat::WriteFile(wxString filename,wxString encoding) {
|
||||||
// Open file
|
// Open file
|
||||||
TextFileWriter file(_filename,encoding);
|
TextFileWriter file(filename,encoding);
|
||||||
bool ssa = _filename.Right(4).Lower() == _T(".ssa");
|
bool ssa = filename.Right(4).Lower() == _T(".ssa");
|
||||||
|
|
||||||
// Write lines
|
// Write lines
|
||||||
using std::list;
|
std::list<AssEntry*>::iterator last = Line->end(); --last;
|
||||||
AssEntry *entry;
|
wxString group = Line->front()->group;
|
||||||
for (list<AssEntry*>::iterator cur=Line->begin();cur!=Line->end();) {
|
for (std::list<AssEntry*>::iterator cur=Line->begin(); cur!=Line->end(); ++cur) {
|
||||||
// Get entry
|
// Add a blank line between each group
|
||||||
entry = *cur;
|
if ((*cur)->group != group) {
|
||||||
|
file.WriteLineToFile("");
|
||||||
|
group = (*cur)->group;
|
||||||
|
}
|
||||||
|
|
||||||
// Only add a line break if there is a next line
|
// Only add a line break if there is a next line
|
||||||
cur++;
|
bool lineBreak = cur != last;
|
||||||
bool lineBreak = cur != Line->end();
|
|
||||||
|
|
||||||
// Write line
|
// Write line
|
||||||
if (ssa) file.WriteLineToFile(entry->GetSSAText(),lineBreak);
|
if (ssa) file.WriteLineToFile((*cur)->GetSSAText(),lineBreak);
|
||||||
else file.WriteLineToFile(entry->GetEntryData(),lineBreak);
|
else file.WriteLineToFile((*cur)->GetEntryData(),lineBreak);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue