e760818007
Base-level replacement of the Vision-derived text RunView― a couple important features supported by the replacee haven't been implemented yet, including: * Right-click menu * URL-highlighting/selection * Emote support
45 lines
778 B
C++
45 lines
778 B
C++
/*
|
|
* Copyright 2021, Jaidyn Levesque <jadedctrl@teknik.io>
|
|
* All rights reserved. Distributed under the terms of the MIT license.
|
|
*/
|
|
|
|
#include "RunView.h"
|
|
|
|
|
|
RunView::RunView(const char* name)
|
|
:
|
|
BTextView(name),
|
|
fLastStyled(false)
|
|
{
|
|
MakeEditable(false);
|
|
SetStylable(true);
|
|
AdoptSystemColors();
|
|
|
|
text_run run = { 0, BFont(), ui_color(B_PANEL_TEXT_COLOR) };
|
|
fDefaultRun = { 1, {run} };
|
|
}
|
|
|
|
|
|
void
|
|
RunView::Append(const char* text, rgb_color color, uint16 fontFace)
|
|
{
|
|
BFont font;
|
|
font.SetFace(fontFace);
|
|
text_run run = { 0, font, color };
|
|
text_run_array array = { 1, {run} };
|
|
|
|
Insert(text, &array);
|
|
fLastStyled = true;
|
|
}
|
|
|
|
|
|
void
|
|
RunView::Append(const char* text)
|
|
{
|
|
if (fLastStyled == false)
|
|
Insert(text);
|
|
else
|
|
Insert(text, &fDefaultRun);
|
|
fLastStyled = false;
|
|
}
|