Mail: Make quote and unquote work better

Always quote and unquote starting from the beginning of the line
instead of the current cursor position.
This commit is contained in:
John Scipione
2014-01-30 19:48:32 -05:00
parent c40938ad1f
commit 37fa8227e3
2 changed files with 38 additions and 1 deletions
+35 -1
View File
@@ -3121,6 +3121,7 @@ TTextView::AddQuote(int32 start, int32 finish)
int32 lineStart;
GoToLine(CurrentLine());
GetSelection(&lineStart, &lineStart);
lineStart = LineStart(lineStart);
// make sure that we're changing the whole last line, too
int32 lineEnd = finish > lineStart ? finish - 1 : finish;
@@ -3198,6 +3199,7 @@ TTextView::RemoveQuote(int32 start, int32 finish)
GoToLine(CurrentLine());
int32 lineStart;
GetSelection(&lineStart, &lineStart);
lineStart = LineStart(lineStart);
// make sure that we're changing the whole last line, too
int32 lineEnd = finish > lineStart ? finish - 1 : finish;
@@ -3280,6 +3282,39 @@ TTextView::RemoveQuote(int32 start, int32 finish)
}
int32
TTextView::LineStart(int32 offset)
{
if (offset <= 0)
return 0;
while (offset > 0) {
offset = PreviousByte(offset);
if (ByteAt(offset) == B_ENTER)
return offset + 1;
}
return offset;
}
int32
TTextView::PreviousByte(int32 offset) const
{
if (offset <= 0)
return 0;
int32 count = 6;
for (--offset; offset > 0 && count; --offset, --count) {
if ((ByteAt(offset) & 0xC0) != 0x80)
break;
}
return count ? offset : 0;
}
void
TTextView::Undo(BClipboard */*clipboard*/)
{
@@ -3374,4 +3409,3 @@ TTextView::Redo()
fUndoBuffer.On();
}
}
+3
View File
@@ -208,6 +208,9 @@ class TTextView : public BTextView {
void ContentChanged(void);
int32 LineStart(int32 offset);
int32 PreviousByte(int32 offset) const;
class Reader;
friend class TTextView::Reader;