Print: Make strings brightgreen color
This commit is contained in:
@@ -8,12 +8,14 @@
|
|||||||
#include <memory> // std::static_pointer_cast
|
#include <memory> // std::static_pointer_cast
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include "ruc/format/color.h"
|
||||||
#include "ruc/format/format.h"
|
#include "ruc/format/format.h"
|
||||||
|
|
||||||
#include "ast.h"
|
#include "ast.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
#include "lexer.h"
|
#include "lexer.h"
|
||||||
#include "printer.h"
|
#include "printer.h"
|
||||||
|
#include "settings.h"
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
@@ -64,6 +66,8 @@ void Printer::init()
|
|||||||
|
|
||||||
void Printer::printImpl(ValuePtr node, bool print_readably)
|
void Printer::printImpl(ValuePtr node, bool print_readably)
|
||||||
{
|
{
|
||||||
|
bool pretty_print = Settings::the().get("pretty-print") == "1";
|
||||||
|
|
||||||
auto printSpacing = [this]() -> void {
|
auto printSpacing = [this]() -> void {
|
||||||
if (!m_first_node && !m_previous_node_is_list) {
|
if (!m_first_node && !m_previous_node_is_list) {
|
||||||
m_print += ' ';
|
m_print += ' ';
|
||||||
@@ -109,8 +113,13 @@ void Printer::printImpl(ValuePtr node, bool print_readably)
|
|||||||
text = "\"" + text + "\"";
|
text = "\"" + text + "\"";
|
||||||
}
|
}
|
||||||
printSpacing();
|
printSpacing();
|
||||||
|
if (pretty_print) {
|
||||||
|
m_print += ::format(fg(ruc::format::TerminalColor::BrightGreen), "{}", text);
|
||||||
|
}
|
||||||
|
else {
|
||||||
m_print += ::format("{}", text);
|
m_print += ::format("{}", text);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if (is<Keyword>(node_raw_ptr)) {
|
else if (is<Keyword>(node_raw_ptr)) {
|
||||||
printSpacing();
|
printSpacing();
|
||||||
m_print += ::format(":{}", std::static_pointer_cast<Keyword>(node)->keyword().substr(1));
|
m_print += ::format(":{}", std::static_pointer_cast<Keyword>(node)->keyword().substr(1));
|
||||||
|
|||||||
Reference in New Issue
Block a user