Small cleanups. Implement drag and dropping the text selection.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31572 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -26,6 +26,7 @@
|
|||||||
#include "DisassembledCode.h"
|
#include "DisassembledCode.h"
|
||||||
#include "Function.h"
|
#include "Function.h"
|
||||||
#include "FileSourceCode.h"
|
#include "FileSourceCode.h"
|
||||||
|
#include "LocatableFile.h"
|
||||||
#include "StackTrace.h"
|
#include "StackTrace.h"
|
||||||
#include "Statement.h"
|
#include "Statement.h"
|
||||||
#include "TeamDebugModel.h"
|
#include "TeamDebugModel.h"
|
||||||
@@ -202,8 +203,6 @@ public:
|
|||||||
TextView(SourceView* sourceView,
|
TextView(SourceView* sourceView,
|
||||||
FontInfo* fontInfo);
|
FontInfo* fontInfo);
|
||||||
|
|
||||||
void CopySelectionToClipboard() const;
|
|
||||||
|
|
||||||
virtual void SetSourceCode(SourceCode* sourceCode);
|
virtual void SetSourceCode(SourceCode* sourceCode);
|
||||||
|
|
||||||
virtual BSize MinSize();
|
virtual BSize MinSize();
|
||||||
@@ -237,6 +236,8 @@ private:
|
|||||||
BString& formattedLine);
|
BString& formattedLine);
|
||||||
SelectionPoint _SelectionPointAt(BPoint where) const;
|
SelectionPoint _SelectionPointAt(BPoint where) const;
|
||||||
void _GetSelectionRegion(BRegion& region) const;
|
void _GetSelectionRegion(BRegion& region) const;
|
||||||
|
void _GetSelectionText(BString& text) const;
|
||||||
|
void _CopySelectionToClipboard() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
@@ -954,7 +955,7 @@ SourceView::TextView::MessageReceived(BMessage* message)
|
|||||||
switch (message->what)
|
switch (message->what)
|
||||||
{
|
{
|
||||||
case B_COPY:
|
case B_COPY:
|
||||||
CopySelectionToClipboard();
|
_CopySelectionToClipboard();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -990,6 +991,7 @@ void
|
|||||||
SourceView::TextView::MouseMoved(BPoint where, uint32 transit,
|
SourceView::TextView::MouseMoved(BPoint where, uint32 transit,
|
||||||
const BMessage* dragMessage)
|
const BMessage* dragMessage)
|
||||||
{
|
{
|
||||||
|
BRegion region;
|
||||||
if (fSelectionMode) {
|
if (fSelectionMode) {
|
||||||
BRegion oldRegion;
|
BRegion oldRegion;
|
||||||
_GetSelectionRegion(oldRegion);
|
_GetSelectionRegion(oldRegion);
|
||||||
@@ -1014,10 +1016,23 @@ SourceView::TextView::MouseMoved(BPoint where, uint32 transit,
|
|||||||
// TODO: handle scrolling when mouse is moved outside
|
// TODO: handle scrolling when mouse is moved outside
|
||||||
// view bounds
|
// view bounds
|
||||||
}
|
}
|
||||||
BRegion region;
|
|
||||||
_GetSelectionRegion(region);
|
_GetSelectionRegion(region);
|
||||||
region.Include(&oldRegion);
|
region.Include(&oldRegion);
|
||||||
Invalidate(®ion);
|
Invalidate(®ion);
|
||||||
|
} else {
|
||||||
|
_GetSelectionRegion(region);
|
||||||
|
if (region.CountRects() > 0) {
|
||||||
|
BString text;
|
||||||
|
_GetSelectionText(text);
|
||||||
|
BMessage message;
|
||||||
|
message.AddData ("text/plain", B_MIME_TYPE, text.String(),
|
||||||
|
text.Length());
|
||||||
|
BString clipName = fSourceCode->GetSourceFile()->Name();
|
||||||
|
clipName << " clipping";
|
||||||
|
message.AddString ("be:clip_name", clipName.String());
|
||||||
|
message.AddInt32 ("be:actions", B_COPY_TARGET);
|
||||||
|
DragMessage(&message, region.Frame());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1127,12 +1142,11 @@ SourceView::TextView::_GetSelectionRegion(BRegion ®ion) const
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SourceView::TextView::CopySelectionToClipboard(void) const
|
SourceView::TextView::_GetSelectionText(BString& text) const
|
||||||
{
|
{
|
||||||
if (fSelectionStart.line == -1 || fSelectionEnd.line == -1)
|
if (fSelectionStart.line == -1 || fSelectionEnd.line == -1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
BString text;
|
|
||||||
if (fSelectionStart.line == fSelectionEnd.line) {
|
if (fSelectionStart.line == fSelectionEnd.line) {
|
||||||
text.SetTo(fSourceCode->LineAt(fSelectionStart.line)
|
text.SetTo(fSourceCode->LineAt(fSelectionStart.line)
|
||||||
+ fSelectionStart.offset, fSelectionEnd.offset
|
+ fSelectionStart.offset, fSelectionEnd.offset
|
||||||
@@ -1146,13 +1160,23 @@ SourceView::TextView::CopySelectionToClipboard(void) const
|
|||||||
text.Append(fSourceCode->LineAt(fSelectionEnd.line),
|
text.Append(fSourceCode->LineAt(fSelectionEnd.line),
|
||||||
fSelectionEnd.offset);
|
fSelectionEnd.offset);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
be_clipboard->Lock();
|
|
||||||
be_clipboard->Data()->RemoveData("text/plain");
|
void
|
||||||
be_clipboard->Data()->AddData ("text/plain",
|
SourceView::TextView::_CopySelectionToClipboard(void) const
|
||||||
B_MIME_TYPE, text.String(), text.Length());
|
{
|
||||||
be_clipboard->Commit();
|
BString text;
|
||||||
be_clipboard->Unlock();
|
_GetSelectionText(text);
|
||||||
|
|
||||||
|
if (text.Length() > 0) {
|
||||||
|
be_clipboard->Lock();
|
||||||
|
be_clipboard->Data()->RemoveData("text/plain");
|
||||||
|
be_clipboard->Data()->AddData ("text/plain",
|
||||||
|
B_MIME_TYPE, text.String(), text.Length());
|
||||||
|
be_clipboard->Commit();
|
||||||
|
be_clipboard->Unlock();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user