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:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user