Files
Upsilon/apps/code/console_line_cell.cpp
Léa Saviot 239e702d37 [code] Navigation in the console history.
The user can copy previous commands or results, into the clipboard or in
the console prompt.

Change-Id: I280fff2d4937f4d17ab6c8907d6e5c359a322372
2017-11-17 11:59:50 +01:00

33 lines
1.1 KiB
C++

#include "console_line_cell.h"
#include "console_controller.h"
#include <kandinsky/point.h>
#include <kandinsky/coordinate.h>
#include <apps/i18n.h>
namespace Code {
ConsoleLineCell::ConsoleLineCell() :
HighlightCell(),
m_line()
{
}
void ConsoleLineCell::drawRect(KDContext * ctx, KDRect rect) const {
KDColor textBackgroundColor = isHighlighted() ? Palette::Select : KDColorWhite;
ctx->fillRect(bounds(), KDColorWhite);
if (m_line.type() == ConsoleLine::Type::Command) {
ctx->drawString(I18n::translate(I18n::Message::ConsolePrompt), KDPointZero, ConsoleController::k_fontSize);
KDCoordinate chevronsWidth = KDText::stringSize(I18n::translate(I18n::Message::ConsolePrompt), ConsoleController::k_fontSize).width();
ctx->drawString(m_line.text(), KDPoint(chevronsWidth, KDCoordinate(0)), ConsoleController::k_fontSize, KDColorBlack, textBackgroundColor);
} else {
ctx->drawString(m_line.text(), KDPointZero, ConsoleController::k_fontSize, KDColorBlack, textBackgroundColor);
}
}
void ConsoleLineCell::setLine(ConsoleLine line) {
m_line = line;
reloadCell();
}
}