hrev47675 adds 1 changeset to branch 'master' old head: ea7fbc874f27b3911ef191033736fde4c845eae0 new head: 30636d2eb6364d45ffb804c51662eefbf6c03671 overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=30636d2+%5Eea7fbc8 ---------------------------------------------------------------------------- 30636d2: SerialConnect: draw the cursor. * Drawn as "inverse video" for now. * Should use VTerm state to get the cursor shape (rect, underline or left line) * Should also handle blinking if enabled, and visibility. [ Adrien Destugues <pulkomandy@xxxxxxxxxxxxx> ] ---------------------------------------------------------------------------- Revision: hrev47675 Commit: 30636d2eb6364d45ffb804c51662eefbf6c03671 URL: http://cgit.haiku-os.org/haiku/commit/?id=30636d2 Author: Adrien Destugues <pulkomandy@xxxxxxxxxxxxx> Date: Wed Aug 13 08:02:32 2014 UTC ---------------------------------------------------------------------------- 2 files changed, 41 insertions(+), 5 deletions(-) src/apps/serialconnect/TermView.cpp | 42 +++++++++++++++++++++++++++++---- src/apps/serialconnect/TermView.h | 4 ++++ ---------------------------------------------------------------------------- diff --git a/src/apps/serialconnect/TermView.cpp b/src/apps/serialconnect/TermView.cpp index d568693..6d99faa 100644 --- a/src/apps/serialconnect/TermView.cpp +++ b/src/apps/serialconnect/TermView.cpp @@ -74,6 +74,9 @@ TermView::Draw(BRect updateRect) font_height height; GetFontHeight(&height); + VTermPos cursorPos; + vterm_state_get_cursorpos(vterm_obtain_state(fTerm), &cursorPos); + for (pos.row = updatedChars.start_row; pos.row <= updatedChars.end_row; pos.row++) { float x = updatedChars.start_col * fFontWidth + kBorderSpacing; @@ -96,7 +99,8 @@ TermView::Draw(BRect updateRect) background.blue = cell.bg.blue; background.alpha = 255; - if (cell.attrs.reverse) { + if ((cell.attrs.reverse != 0) ^ (pos.col == cursorPos.col + && pos.row == cursorPos.row)) { SetLowColor(foreground); SetViewColor(foreground); SetHighColor(background); @@ -107,9 +111,10 @@ TermView::Draw(BRect updateRect) } BPoint penLocation = PenLocation(); - FillRect(BRect(penLocation.x, penLocation.y - height.ascent, + FillRect(BRect(penLocation.x, + penLocation.y - ceil(height.ascent) + 1, penLocation.x + cell.width * fFontWidth - 1, - penLocation.y + height.descent + height.leading), + penLocation.y + ceil(height.descent) + ceil(height.leading)), B_SOLID_LOW); if (cell.chars[0] == 0) { @@ -308,12 +313,29 @@ TermView::_GetCell(VTermPos pos, VTermScreenCell& cell) void TermView::_Damage(VTermRect rect) { -// Invalidate(); Invalidate(_GlyphsToPixels(rect)); } void +TermView::_MoveCursor(VTermPos pos, VTermPos oldPos, int visible) +{ + VTermRect r; + r.start_row = pos.row; + r.start_col = pos.col; + r.end_col = pos.col + 1; + r.end_row = pos.row + 1; + Invalidate(_GlyphsToPixels(r)); + + r.start_row = oldPos.row; + r.start_col = oldPos.col; + r.end_col = oldPos.col + 1; + r.end_row = oldPos.row + 1; + Invalidate(_GlyphsToPixels(r)); +} + + +void TermView::_PushLine(int cols, const VTermScreenCell* cells) { ScrollBufferItem* item = (ScrollBufferItem*)malloc(sizeof(int) @@ -360,6 +382,16 @@ TermView::_Damage(VTermRect rect, void* user) /* static */ int +TermView::_MoveCursor(VTermPos pos, VTermPos oldPos, int visible, void* user) +{ + TermView* view = (TermView*)user; + view->_MoveCursor(pos, oldPos, visible); + + return 0; +} + + +/* static */ int TermView::_PushLine(int cols, const VTermScreenCell* cells, void* user) { TermView* view = (TermView*)user; @@ -373,7 +405,7 @@ const VTermScreenCallbacks TermView::sScreenCallbacks = { &TermView::_Damage, /*.moverect =*/ NULL, - /*.movecursor =*/ NULL, + &TermView::_MoveCursor, /*.settermprop =*/ NULL, /*.setmousefunc =*/ NULL, /*.bell =*/ NULL, diff --git a/src/apps/serialconnect/TermView.h b/src/apps/serialconnect/TermView.h index 47c661a..c42f8ca 100644 --- a/src/apps/serialconnect/TermView.h +++ b/src/apps/serialconnect/TermView.h @@ -37,9 +37,13 @@ class TermView: public BView void _GetCell(VTermPos pos, VTermScreenCell& cell); void _Damage(VTermRect rect); + void _MoveCursor(VTermPos pos, VTermPos oldPos, + int visible); void _PushLine(int cols, const VTermScreenCell* cells); static int _Damage(VTermRect rect, void* user); + static int _MoveCursor(VTermPos pos, VTermPos oldPos, + int visible, void* user); static int _PushLine(int cols, const VTermScreenCell* cells, void* user); static int _PopLine(int cols, const VTermScreenCell* cells,