Make source view navigable and scrollable via the usual keyboard shortcuts. Still lots to do including drawing a focus highlight and text selection/copying via keyboard and/or mouse.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31531 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -206,6 +206,12 @@ public:
|
|||||||
|
|
||||||
virtual void Draw(BRect updateRect);
|
virtual void Draw(BRect updateRect);
|
||||||
|
|
||||||
|
virtual void KeyDown(const char* bytes, int32 numBytes);
|
||||||
|
|
||||||
|
virtual void MouseDown(BPoint where);
|
||||||
|
virtual void MouseMoved(BPoint where, uint32 transit,
|
||||||
|
const BMessage* dragMessage);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
float _MaxLineWidth();
|
float _MaxLineWidth();
|
||||||
void _FormatLine(const char* line,
|
void _FormatLine(const char* line,
|
||||||
@@ -803,6 +809,7 @@ SourceView::TextView::TextView(SourceView* sourceView, FontInfo* fontInfo)
|
|||||||
{
|
{
|
||||||
SetViewColor(ui_color(B_DOCUMENT_BACKGROUND_COLOR));
|
SetViewColor(ui_color(B_DOCUMENT_BACKGROUND_COLOR));
|
||||||
fTextColor = ui_color(B_DOCUMENT_TEXT_COLOR);
|
fTextColor = ui_color(B_DOCUMENT_TEXT_COLOR);
|
||||||
|
SetFlags(Flags() | B_NAVIGABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -851,6 +858,63 @@ SourceView::TextView::Draw(BRect updateRect)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
SourceView::TextView::KeyDown(const char* bytes, int32 numBytes)
|
||||||
|
{
|
||||||
|
BScrollBar* vertical = fSourceView->ScrollBar(B_VERTICAL);
|
||||||
|
if (!vertical)
|
||||||
|
return;
|
||||||
|
|
||||||
|
float value = vertical->Value();
|
||||||
|
switch(bytes[0]) {
|
||||||
|
case B_UP_ARROW:
|
||||||
|
vertical->SetValue(value - fFontInfo->lineHeight);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case B_DOWN_ARROW:
|
||||||
|
vertical->SetValue(value + fFontInfo->lineHeight);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case B_PAGE_UP:
|
||||||
|
vertical->SetValue(value - fSourceView->Frame().Size().height);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case B_PAGE_DOWN:
|
||||||
|
vertical->SetValue(value + fSourceView->Frame().Size().height);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case B_HOME:
|
||||||
|
vertical->SetValue(0.0);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case B_END:
|
||||||
|
float min, max;
|
||||||
|
vertical->GetRange(&min, &max);
|
||||||
|
vertical->SetValue(max);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
SourceView::BaseView::KeyDown(bytes, numBytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
SourceView::TextView::MouseDown(BPoint where)
|
||||||
|
{
|
||||||
|
MakeFocus(true);
|
||||||
|
SourceView::BaseView::MouseDown(where);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
SourceView::TextView::MouseMoved(BPoint where, uint32 transit,
|
||||||
|
const BMessage* dragMessage)
|
||||||
|
|
||||||
|
{
|
||||||
|
SourceView::BaseView::MouseMoved(where, transit, dragMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
float
|
float
|
||||||
SourceView::TextView::_MaxLineWidth()
|
SourceView::TextView::_MaxLineWidth()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user