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
2 changes: 1 addition & 1 deletion build/assets/config.tic.dat

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@
// 136:0000c00000000c00000000c00cccccccc0ccccc0c00ccc00c000c00000000000
// 137:000000000ccccc000c000c000c0c0c0000000c000c0ccc000000000000000000
// 138:0000000000ccc0000000c000000c000000000000000c00000000000000000000
// 139:000000000c0ccc00000000000c0cc000000000000c0ccc000000000000000000
// 160:cccccccccceeeeeececccccccecececececcccccceceececceccccccceceecee
// 161:cccccccceeeeeeeccccccccecececececcccccceececeececcccccceeeeceece
// 162:cccccccccccccccccccccccccceeeeeececccccccecececececcccccceceecec
Expand Down
43 changes: 33 additions & 10 deletions src/studio/editors/code.c
Original file line number Diff line number Diff line change
Expand Up @@ -262,22 +262,40 @@ static void drawGutter(Code* code)
const s32 gutterWidth = getGutterWidth(code);
const s32 gutterHeight = TIC80_HEIGHT - TOOLBAR_SIZE * 2;
tic_rect rect = {0, TOOLBAR_SIZE, gutterWidth, gutterHeight};
tic_rect lineNumberButtonRect = {0, rect.y + rect.h - TIC_SPRITESIZE + 1, gutterWidth, TOOLBAR_SIZE};
bool buttonHover = checkMousePos(code->studio, &lineNumberButtonRect);
s32 mouseOverLine = -1;

// draw the background rectangle
tic_api_rect(code->tic, rect.x, rect.y, rect.w, rect.h, tic_color_grey);

// then if the mouse is hovering over the gutter...
if(checkMousePos(code->studio, &rect))
{
setCursor(code->studio, tic_cursor_hand);

showTooltip(code->studio, "BOOKMARK [ctrl+f1]");

s32 line = mouseOverLine = (tic_api_mouse(tic).y - rect.y) / STUDIO_TEXT_HEIGHT;

drawBitIcon(code->studio, tic_icon_bookmark, rect.x + gutterWidth - TIC_SPRITESIZE + 1, rect.y + line * STUDIO_TEXT_HEIGHT - 1, tic_color_dark_grey);

if(checkMouseClick(code->studio, &rect, tic_mouse_left))
toggleBookmark(code, getPosByLine(code->src, line + code->scroll.y));
// and we're inside the line number button...
if(buttonHover)
{
// draw it
setCursor(code->studio, tic_cursor_hand);
showTooltip(code->studio, "LINE# [alt+l]");
tic_api_rect(tic, rect.x, lineNumberButtonRect.y, rect.w, TIC_SPRITESIZE, tic_color_white);
drawBitIcon(code->studio, tic_icon_line_numbers, rect.x, lineNumberButtonRect.y, tic_color_black);
// and toggle line numbers if we clicked it
if(checkMouseClick(code->studio, &lineNumberButtonRect, tic_mouse_left))
code->lineNumbers = !code->lineNumbers;
}
// if we're somewhere else in the gutter...
else
{
// draw a bookmark preview
setCursor(code->studio, tic_cursor_hand);
showTooltip(code->studio, "BOOKMARK [ctrl+f1]");
s32 line = mouseOverLine = (tic_api_mouse(tic).y - rect.y) / STUDIO_TEXT_HEIGHT;
drawBitIcon(code->studio, tic_icon_bookmark, rect.x + gutterWidth - TIC_SPRITESIZE + 1, rect.y + line * STUDIO_TEXT_HEIGHT - 1, tic_color_dark_grey);
// and toggle the bookmark if we clicked it
if(checkMouseClick(code->studio, &rect, tic_mouse_left))
toggleBookmark(code, getPosByLine(code->src, line + code->scroll.y));
}
}

const char* pointer = code->src;
Expand All @@ -289,6 +307,7 @@ static void drawGutter(Code* code)
s32 cursorX, cursorY;
codeGetPos(code, &cursorX, &cursorY);

// render all the bookmarks and line numbers
while(*pointer)
{
if(syntaxPointer++->bookmark)
Expand All @@ -311,6 +330,10 @@ static void drawGutter(Code* code)
y++;
}
}

// render the button again, over the line numbers
tic_api_rect(tic, rect.x, lineNumberButtonRect.y, rect.w, lineNumberButtonRect.h, (code->lineNumbers || buttonHover) ? tic_color_white : tic_color_grey);
drawBitIcon(code->studio, tic_icon_line_numbers, rect.x, lineNumberButtonRect.y, tic_color_dark_grey);
}

static inline s32 getFontWidth(Code* code)
Expand Down
1 change: 1 addition & 0 deletions src/studio/studio.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ enum
tic_icon_bigfill = 136,
tic_icon_loop = 137,
tic_icon_random = 138,
tic_icon_line_numbers = 139,
};

void setCursor(Studio* studio, tic_cursor id);
Expand Down
Loading