Handle colors.
This commit is contained in:
@@ -8,6 +8,8 @@
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <Entry.h>
|
||||
#include <File.h>
|
||||
#include <Layout.h>
|
||||
|
||||
#include "SerialApp.h"
|
||||
@@ -72,6 +74,28 @@ void TermView::Draw(BRect updateRect)
|
||||
VTermScreenCell cell;
|
||||
vterm_screen_get_cell(fTermScreen, pos, &cell);
|
||||
|
||||
rgb_color foreground, background;
|
||||
foreground.red = cell.fg.red;
|
||||
foreground.green = cell.fg.green;
|
||||
foreground.blue = cell.fg.blue;
|
||||
background.red = cell.bg.red;
|
||||
background.green = cell.bg.green;
|
||||
background.blue = cell.bg.blue;
|
||||
|
||||
if(cell.attrs.reverse) {
|
||||
SetLowColor(foreground);
|
||||
SetViewColor(foreground);
|
||||
SetHighColor(background);
|
||||
} else {
|
||||
SetLowColor(background);
|
||||
SetViewColor(background);
|
||||
SetHighColor(foreground);
|
||||
}
|
||||
|
||||
BPoint penLocation = PenLocation();
|
||||
FillRect(BRect(penLocation.x, penLocation.y - height.ascent,
|
||||
penLocation.x + cell.width * fFontWidth, penLocation.y), B_SOLID_LOW);
|
||||
|
||||
if (cell.chars[0] == 0) {
|
||||
DrawString(" ");
|
||||
pos.col ++;
|
||||
@@ -89,6 +113,14 @@ void TermView::Draw(BRect updateRect)
|
||||
}
|
||||
|
||||
|
||||
void TermView::FrameResized(float width, float height)
|
||||
{
|
||||
VTermRect newSize = PixelsToGlyphs(BRect(0, 0, width - 2 * kBorderSpacing,
|
||||
height - 2 * kBorderSpacing));
|
||||
vterm_set_size(fTerm, newSize.end_row, newSize.end_col);
|
||||
}
|
||||
|
||||
|
||||
void TermView::GetPreferredSize(float* width, float* height)
|
||||
{
|
||||
if (width != NULL)
|
||||
@@ -106,11 +138,23 @@ void TermView::KeyDown(const char* bytes, int32 numBytes)
|
||||
}
|
||||
|
||||
|
||||
void TermView::FrameResized(float width, float height)
|
||||
void TermView::MessageReceived(BMessage* message)
|
||||
{
|
||||
VTermRect newSize = PixelsToGlyphs(BRect(0, 0, width - 2 * kBorderSpacing,
|
||||
height - 2 * kBorderSpacing));
|
||||
vterm_set_size(fTerm, newSize.end_row, newSize.end_col);
|
||||
switch(message->what)
|
||||
{
|
||||
case 'DATA':
|
||||
{
|
||||
entry_ref ref;
|
||||
if(message->FindRef("refs", &ref) == B_OK)
|
||||
{
|
||||
// The user just dropped a file on us
|
||||
// TODO send it by XMODEM or so
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
BView::MessageReceived(message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -120,6 +164,9 @@ void TermView::PushBytes(const char* bytes, size_t length)
|
||||
}
|
||||
|
||||
|
||||
//#pragma mark -
|
||||
|
||||
|
||||
VTermRect TermView::PixelsToGlyphs(BRect pixels) const
|
||||
{
|
||||
pixels.OffsetBy(-kBorderSpacing, -kBorderSpacing);
|
||||
|
||||
@@ -18,9 +18,10 @@ class TermView: public BView
|
||||
|
||||
void AttachedToWindow();
|
||||
void Draw(BRect updateRect);
|
||||
void FrameResized(float width, float height);
|
||||
void GetPreferredSize(float* width, float* height);
|
||||
void KeyDown(const char* bytes, int32 numBytes);
|
||||
void FrameResized(float width, float height);
|
||||
void MessageReceived(BMessage* message);
|
||||
void PushBytes(const char* bytes, const size_t length);
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user