Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .github/workflows/kanso-cd.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
name: Kanso-CD
on:
push:
branches:
- main
workflow_dispatch:

jobs:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/kanso-ci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: Kanso-CI
on:
push:
branches:
- main
pull_request:
workflow_dispatch:

Expand Down
4 changes: 4 additions & 0 deletions cmake/Toolchains/riscv-common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,7 @@ endif()
set(CMAKE_C_FLAGS "${_COMMON} -march=${_MARCH} -mabi=${_MABI} ${_MODEL}")
set(CMAKE_ASM_FLAGS "--target=${COMPILE_TARGET} -march=${_MARCH} -mabi=${_MABI} -Wno-unused-command-line-argument -x assembler-with-cpp")

set(CMAKE_EXE_LINKER_FLAGS_INIT "-fuse-ld=lld")
set(CMAKE_SHARED_LINKER_FLAGS_INIT "-fuse-ld=lld")
set(CMAKE_MODULE_LINKER_FLAGS_INIT "-fuse-ld=lld")
set(CMAKE_C_LINK_FLAGS_INIT "-fuse-ld=lld")
77 changes: 77 additions & 0 deletions src/Common/Console.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#include "Console.h"

void FormatBoxedMessage(SpanChar destination, ReadOnlySpanChar message)
{
auto upLeftCorner = String("┌");
auto upRightCorner = String("┐");
auto downLeftCorner = String("└");
auto downRightCorner = String("┘");
auto horizontalLine = String("─");
auto verticalLine = String("│");

MemoryCopy(destination, upLeftCorner);
destination = SpanSliceFrom(destination, upLeftCorner.Length);

for (uint32_t i = 0; i < message.Length + 2; i++)
{
MemoryCopy(destination, horizontalLine);
destination = SpanSliceFrom(destination, horizontalLine.Length);
}

MemoryCopy(destination, upRightCorner);
destination = SpanSliceFrom(destination, upRightCorner.Length);

MemoryCopy(destination, String("\n"));
destination = SpanSliceFrom(destination, 1);

MemoryCopy(destination, verticalLine);
destination = SpanSliceFrom(destination, verticalLine.Length);

MemoryCopy(destination, String(" "));
destination = SpanSliceFrom(destination, 1);

MemoryCopy(destination, message);
destination = SpanSliceFrom(destination, message.Length);

MemoryCopy(destination, String(" "));
destination = SpanSliceFrom(destination, 1);

MemoryCopy(destination, verticalLine);
destination = SpanSliceFrom(destination, verticalLine.Length);

MemoryCopy(destination, String("\n"));
destination = SpanSliceFrom(destination, 1);

MemoryCopy(destination, downLeftCorner);
destination = SpanSliceFrom(destination, downLeftCorner.Length);

for (uint32_t i = 0; i < message.Length + 2; i++)
{
MemoryCopy(destination, horizontalLine);
destination = SpanSliceFrom(destination, horizontalLine.Length);
}

MemoryCopy(destination, downRightCorner);
destination = SpanSliceFrom(destination, downRightCorner.Length);

// TODO: There is a problem here with null terminator not present
}

void ConsoleSetForegroundColor(Color color)
{
ConsolePrint(String("\x1b[38;2;%d;%d;%dm"), (int32_t)color.Red, (int32_t)color.Green, (int32_t)color.Blue);
}

void ConsoleResetStyle()
{
ConsolePrint(String("\x1b[0m"));
ConsoleSetForegroundColor(ConsoleColorNormal);
}

void ConsolePrintBoxMessage(ReadOnlySpanChar message)
{
// TODO: Use the stack memory arena here
auto boxedMessage = StackAlloc(char, 512);
FormatBoxedMessage(boxedMessage, message);
ConsolePrint(String("\n%s\n"), boxedMessage);
}
23 changes: 23 additions & 0 deletions src/Common/Console.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#pragma once

#include "Memory.h"
#include "String.h"
#include "Types.h"

const Color ConsoleColorNormal = { 212, 212, 212, 255 };
const Color ConsoleColorHighlight = { 250, 250, 250, 255 };
const Color ConsoleColorAccent = { 79, 193, 255, 255 };
const Color ConsoleColorSuccess = { 106, 153, 85, 255 };
const Color ConsoleColorWarning = { 255, 135, 100, 255 };
const Color ConsoleColorError = { 255, 105, 105, 255 };
const Color ConsoleColorInfo = { 220, 220, 170, 255 };
const Color ConsoleColorAction = { 197, 134, 192, 255 };
const Color ConsoleColorKeyword = { 86, 156, 214, 255 };
const Color ConsoleColorNumeric = { 181, 206, 168, 255 };

void ConsolePrint(ReadOnlySpanChar message, ...);

void ConsoleSetForegroundColor(Color color);
void ConsoleResetStyle();

void ConsolePrintBoxMessage(ReadOnlySpanChar message);
Loading