Tune the looks
This commit is contained in:
44
src/text_editor/colors.cpp
Normal file
44
src/text_editor/colors.cpp
Normal file
@@ -0,0 +1,44 @@
|
||||
Color GruvboxDark0Hard = {0x1d, 0x20, 0x21, 0xff};
|
||||
Color GruvboxDark0 = {0x28, 0x28, 0x28, 0xff};
|
||||
Color GruvboxDark0Soft = {0x32, 0x30, 0x2f, 0xff};
|
||||
Color GruvboxDark1 = {0x3c, 0x38, 0x36, 0xff};
|
||||
Color GruvboxDark2 = {0x50, 0x49, 0x45, 0xff};
|
||||
Color GruvboxDark3 = {0x66, 0x5c, 0x54, 0xff};
|
||||
Color GruvboxDark4 = {0x7c, 0x6f, 0x64, 0xff};
|
||||
Color GruvboxGray245 = {0x92, 0x83, 0x74, 0xff};
|
||||
Color GruvboxGray244 = {0x92, 0x83, 0x74, 0xff};
|
||||
Color GruvboxLight0Hard = {0xf9, 0xf5, 0xd7, 0xff};
|
||||
Color GruvboxLight0 = {0xfb, 0xf1, 0xc7, 0xff};
|
||||
Color GruvboxLight0Soft = {0xf2, 0xe5, 0xbc, 0xff};
|
||||
Color GruvboxLight1 = {0xeb, 0xdb, 0xb2, 0xff};
|
||||
Color GruvboxLight2 = {0xd5, 0xc4, 0xa1, 0xff};
|
||||
Color GruvboxLight3 = {0xbd, 0xae, 0x93, 0xff};
|
||||
Color GruvboxLight4 = {0xa8, 0x99, 0x84, 0xff};
|
||||
Color GruvboxBrightRed = {0xfb, 0x49, 0x34, 0xff};
|
||||
Color GruvboxBrightGreen = {0xb8, 0xbb, 0x26, 0xff};
|
||||
Color GruvboxBrightYellow = {0xfa, 0xbd, 0x2f, 0xff};
|
||||
Color GruvboxBrightBlue = {0x83, 0xa5, 0x98, 0xff};
|
||||
Color GruvboxBrightPurple = {0xd3, 0x86, 0x9b, 0xff};
|
||||
Color GruvboxBrightAqua = {0x8e, 0xc0, 0x7c, 0xff};
|
||||
Color GruvboxBrightOrange = {0xfe, 0x80, 0x19, 0xff};
|
||||
Color GruvboxNeutralRed = {0xcc, 0x24, 0x1d, 0xff};
|
||||
Color GruvboxNeutralGreen = {0x98, 0x97, 0x1a, 0xff};
|
||||
Color GruvboxNeutralYellow = {0xd7, 0x99, 0x21, 0xff};
|
||||
Color GruvboxNeutralBlue = {0x45, 0x85, 0x88, 0xff};
|
||||
Color GruvboxNeutralPurple = {0xb1, 0x62, 0x86, 0xff};
|
||||
Color GruvboxNeutralAqua = {0x68, 0x9d, 0x6a, 0xff};
|
||||
Color GruvboxNeutralOrange = {0xd6, 0x5d, 0x0e, 0xff};
|
||||
Color GruvboxFadedRed = {0x9d, 0x00, 0x06, 0xff};
|
||||
Color GruvboxFadedGreen = {0x79, 0x74, 0x0e, 0xff};
|
||||
Color GruvboxFadedYellow = {0xb5, 0x76, 0x14, 0xff};
|
||||
Color GruvboxFadedBlue = {0x07, 0x66, 0x78, 0xff};
|
||||
Color GruvboxFadedPurple = {0x8f, 0x3f, 0x71, 0xff};
|
||||
Color GruvboxFadedAqua = {0x42, 0x7b, 0x58, 0xff};
|
||||
Color GruvboxFadedOrange = {0xaf, 0x3a, 0x03, 0xff};
|
||||
|
||||
Color ColorText = GruvboxDark0Hard;
|
||||
Color ColorBackground = GruvboxLight0Hard;
|
||||
Color ColorSelection = GruvboxLight3;
|
||||
Color ColorLineHighlight = GruvboxLight2;
|
||||
Color ColorMainCaret = GruvboxBrightRed;
|
||||
Color ColorSubCaret = GruvboxGray245;
|
||||
@@ -17,12 +17,11 @@
|
||||
|
||||
#include "raylib.h"
|
||||
#include "raylib_utils.cpp"
|
||||
#include "colors.cpp"
|
||||
#include "view.cpp"
|
||||
#include "view_draw.cpp"
|
||||
|
||||
/*
|
||||
- when no new line at the end - END button sets cursor before last char
|
||||
|
||||
- Ctrl + Z, Ctrl + C - Undo redo history
|
||||
- Ctrl + D - create new cursor at next occurence of word
|
||||
- Ctrl + X, Ctrl + C, Ctrl + V - Copy paste
|
||||
@@ -39,6 +38,7 @@
|
||||
- file info bar at bottom
|
||||
- multiple windows
|
||||
- multiple views per window
|
||||
- Font cache
|
||||
*/
|
||||
|
||||
int main(void) {
|
||||
@@ -89,11 +89,10 @@ int main(void) {
|
||||
view.rect = GetScreenRect();
|
||||
|
||||
BeginDrawing();
|
||||
ClearBackground(RAYWHITE);
|
||||
ClearBackground(ColorBackground);
|
||||
{
|
||||
HandleKeybindings(&view);
|
||||
DrawVisibleCells(view);
|
||||
For(view.carets) DrawCaret(view, it);
|
||||
DrawView(view);
|
||||
}
|
||||
EndDrawing();
|
||||
}
|
||||
|
||||
@@ -214,10 +214,10 @@ void HandleKeybindings(View *_view) {
|
||||
if (key_page_up || key_page_down) {
|
||||
Rect2I visible_cells_rect = GetVisibleCells(view);
|
||||
Int y = GetSize(visible_cells_rect).y - 2;
|
||||
if (key_page_up) y = -y;
|
||||
For(view.carets) {
|
||||
XY xy = PosToXY(buf, GetFront(it));
|
||||
if (key_page_down) xy.line += y;
|
||||
if (key_page_up) xy.line -= y;
|
||||
xy.line += y;
|
||||
Int pos = XYToPos(buf, xy);
|
||||
if (IsKeyDown(KEY_LEFT_SHIFT)) {
|
||||
it = ChangeFront(it, pos);
|
||||
|
||||
@@ -21,7 +21,7 @@ Rect2I GetVisibleCells(const View &view) {
|
||||
|
||||
void DrawVisibleCells(const View &view) {
|
||||
ProfileFunction();
|
||||
Color tint = BLACK;
|
||||
Color tint = ColorText;
|
||||
Rect2I visible = GetVisibleCells(view);
|
||||
for (Int line_index = visible.min.y; line_index < visible.max.y && line_index >= 0 && line_index < view.buffer->line_starts.len; line_index += 1) {
|
||||
Range line_range = GetLineRange(*view.buffer, line_index);
|
||||
@@ -73,28 +73,17 @@ void DrawLineHighlight(const View &view, XY fxy, Color color) {
|
||||
DrawRectangleRec(ToRectangle(rect), color);
|
||||
}
|
||||
|
||||
void DrawCaret(const View &view, Caret &it) {
|
||||
void DrawSelection(const View &view, Caret &it) {
|
||||
ProfileFunction();
|
||||
Buffer &buf = *view.buffer;
|
||||
Int front = GetFront(it);
|
||||
XY fxy = PosToXY(buf, front);
|
||||
DrawCaret(view, fxy, 0.3f, RED);
|
||||
|
||||
Int back = GetBack(it);
|
||||
XY bxy = PosToXY(buf, back);
|
||||
DrawCaret(view, bxy, 0.15f, GREEN);
|
||||
|
||||
// Line highlight
|
||||
bool main_caret = &it == &view.carets.data[0];
|
||||
unsigned char red = main_caret ? 0 : 120;
|
||||
DrawLineHighlight(view, fxy, {0, red, red, 10});
|
||||
DrawLineHighlight(view, fxy, {0, red, red, 5});
|
||||
|
||||
// Draw selection
|
||||
Int back = GetBack(it);
|
||||
if (front != back) {
|
||||
XY bxy = PosToXY(buf, back);
|
||||
XY min = PosToXY(buf, it.range.min);
|
||||
XY max = PosToXY(buf, it.range.max);
|
||||
|
||||
Color color = ColorSelection;
|
||||
Rect2I vlines = GetVisibleCells(view);
|
||||
for (Int line = vlines.min.y; line <= vlines.max.y && line >= 0 && line < view.buffer->line_starts.len; line += 1) {
|
||||
Range range = GetLineRange(buf, line);
|
||||
@@ -112,9 +101,36 @@ void DrawCaret(const View &view, Caret &it) {
|
||||
Vec2I pos = {col * view.char_spacing, line * view.line_spacing};
|
||||
pos -= view.scroll;
|
||||
Rectangle rectangle = {(float)pos.x, (float)pos.y, (float)view.char_spacing, (float)view.line_spacing};
|
||||
DrawRectangleRec(rectangle, {0, 50, 150, 20});
|
||||
|
||||
DrawRectangleRec(rectangle, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DrawView(View &view) {
|
||||
// Line highlight
|
||||
Buffer &buf = *view.buffer;
|
||||
For(view.carets) {
|
||||
Int front = GetFront(it);
|
||||
XY fxy = PosToXY(buf, front);
|
||||
Int back = GetBack(it);
|
||||
XY bxy = PosToXY(buf, back);
|
||||
|
||||
DrawLineHighlight(view, fxy, ColorLineHighlight);
|
||||
DrawSelection(view, it);
|
||||
}
|
||||
|
||||
DrawVisibleCells(view);
|
||||
|
||||
For(view.carets) {
|
||||
Int front = GetFront(it);
|
||||
XY fxy = PosToXY(buf, front);
|
||||
Int back = GetBack(it);
|
||||
XY bxy = PosToXY(buf, back);
|
||||
|
||||
bool main_caret = &it == &view.carets.data[0];
|
||||
DrawCaret(view, fxy, 0.3f, main_caret ? ColorMainCaret : ColorSubCaret);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user