BEEP-8 Helper Lib 1.0.0
Loading...
Searching...
No Matches
esc_decoder.h
Go to the documentation of this file.
1
248#pragma once
249#include <b8/type.h>
250
252
266
295
304 ANSI_NULL = 0,
305
306 ANSI_COLOR_BLACK = 30, // Black (0, 0, 0)
307 ANSI_COLOR_RED, // Red (255, 0, 0)
308 ANSI_COLOR_GREEN, // Green (0, 255, 0)
309 ANSI_COLOR_YELLOW, // Yellow (255, 255, 0)
310 ANSI_COLOR_BLUE, // Blue (0, 0, 255)
311 ANSI_COLOR_MAGENTA, // Magenta (255, 0, 255) // Magenta can also be seen as purple
312 ANSI_COLOR_CYAN, // Cyan (0, 255, 255)
313 ANSI_COLOR_WHITE, // White (255, 255, 255)
314
315 ANSI_COLOR_BLACK_BG = 40,
316 ANSI_COLOR_RED_BG,
317 ANSI_COLOR_GREEN_BG,
318 ANSI_COLOR_YELLOW_BG,
319 ANSI_COLOR_BLUE_BG,
320 ANSI_COLOR_MAGENTA_BG,
321 ANSI_COLOR_CYAN_BG,
322 ANSI_COLOR_WHITE_BG,
323
324 ANSI_COLOR_B8_BLACK = 50, // BEEP-8 Black
325 ANSI_COLOR_B8_DARK_BLUE , // BEEP-8 Dark Blue
326 ANSI_COLOR_B8_DARK_PURPLE , // BEEP-8 Dark Purple
327 ANSI_COLOR_B8_DARK_GREEN , // BEEP-8 Dark Green
328 ANSI_COLOR_B8_BROWN , // BEEP-8 Brown
329 ANSI_COLOR_B8_DARK_GREY , // BEEP-8 Dark Grey
330 ANSI_COLOR_B8_LIGHT_GREY , // BEEP-8 Light Grey
331 ANSI_COLOR_B8_WHITE , // BEEP-8 White
332 ANSI_COLOR_B8_RED , // BEEP-8 Red
333 ANSI_COLOR_B8_ORANGE , // BEEP-8 Orange
334 ANSI_COLOR_B8_YELLOW , // BEEP-8 Yellow
335 ANSI_COLOR_B8_GREEN , // BEEP-8 Green
336 ANSI_COLOR_B8_BLUE , // BEEP-8 Blue
337 ANSI_COLOR_B8_LAVENDER , // BEEP-8 Lavender
338 ANSI_COLOR_B8_PINK , // BEEP-8 Pink
339 ANSI_COLOR_B8_LIGHT_PEACH , // BEEP-8 Light Peach
340
341 ANSI_COLOR_B8_BLACK_BG = 70,
342 ANSI_COLOR_B8_DARK_BLUE_BG ,
343 ANSI_COLOR_B8_DARK_PURPLE_BG ,
344 ANSI_COLOR_B8_DARK_GREEN_BG ,
345 ANSI_COLOR_B8_BROWN_BG ,
346 ANSI_COLOR_B8_DARK_GREY_BG ,
347 ANSI_COLOR_B8_LIGHT_GREY_BG ,
348 ANSI_COLOR_B8_WHITE_BG ,
349 ANSI_COLOR_B8_RED_BG ,
350 ANSI_COLOR_B8_ORANGE_BG ,
351 ANSI_COLOR_B8_YELLOW_BG ,
352 ANSI_COLOR_B8_GREEN_BG ,
353 ANSI_COLOR_B8_BLUE_BG ,
354 ANSI_COLOR_B8_LAVENDER_BG ,
355 ANSI_COLOR_B8_PINK_BG ,
356 ANSI_COLOR_B8_LIGHT_PEACH_BG ,
357
358 // High-intensity (Bright) colors
359 ANSI_COLOR_BRIGHT_BLACK = 90, // Bright Black (Gray) (128, 128, 128)
360 ANSI_COLOR_BRIGHT_RED , // Bright Red (255, 85, 85)
361 ANSI_COLOR_BRIGHT_GREEN , // Bright Green (85, 255, 85)
362 ANSI_COLOR_BRIGHT_YELLOW , // Bright Yellow (255, 255, 85)
363 ANSI_COLOR_BRIGHT_BLUE , // Bright Blue (85, 85, 255)
364 ANSI_COLOR_BRIGHT_MAGENTA , // Bright Magenta (Purple) (255, 85, 255)
365 ANSI_COLOR_BRIGHT_CYAN , // Bright Cyan (85, 255, 255)
366 ANSI_COLOR_BRIGHT_WHITE , // Bright White (255, 255, 255)
367
368 ANSI_COLOR_BRIGHT_BLACK_BG = 100,
369 ANSI_COLOR_BRIGHT_RED_BG ,
370 ANSI_COLOR_BRIGHT_GREEN_BG ,
371 ANSI_COLOR_BRIGHT_YELLOW_BG ,
372 ANSI_COLOR_BRIGHT_BLUE_BG ,
373 ANSI_COLOR_BRIGHT_MAGENTA_BG ,
374 ANSI_COLOR_BRIGHT_CYAN_BG ,
375 ANSI_COLOR_BRIGHT_WHITE_BG
376};
377
379 u16 _code;
380 EscapePAL _EscapePAL;
381 EscapeSeqOpe _Ope;
382 s16 _x;
383 s16 _y;
384 u8 _attr : 4; // Holds values 0-15 (commonly used range is 0-9 for terminal attributes)
385 AnsiColor _fg; // Supports ANSI standard colors (0-15 for basic colors)
386 AnsiColor _bg;
387 u16 _otz;
388
389 void ResetSetColor(){
390 _Ope = ESO_SET_COLOR;
391 _fg = ANSI_COLOR_WHITE;
392 _bg = ANSI_NULL;
393 }
394
395 void ResetMoveCursor(){
396 _Ope = ESO_MOVE_CURSOR;
397 _x = _y = 0;
398 }
399
400 void ResetZ(){
401 _Ope = ESO_SET_Z;
402 _otz = 0;
403 }
404
405 inline void ResetAll(){
406 _code = 0x0000;
407 _EscapePAL = PAL_0;
408 _Ope = ESO_NONE;
409 _x = 0;
410 _y = 0;
411 _attr = 0;
412 _fg = ANSI_COLOR_WHITE;
413 _bg = ANSI_NULL;
414 _otz = 0;
415 }
416
417 EscapeOut(){
418 ResetAll();
419 }
420};
421
424public:
425 EscapeOut& Stream( s32 code_ );
428};
429
438extern void EscClearEntireScreen(FILE* fp);
439
451extern void EscMoveCursor(FILE* fp, s32 x_, s32 y_);
Definition esc_decoder.h:422
Definition esc_decoder.cpp:24
AnsiColor
Enumeration for ANSI color codes.
Definition esc_decoder.h:303
void EscMoveCursor(FILE *fp, s32 x_, s32 y_)
Moves the cursor to a specific position.
Definition esc_decoder.cpp:279
EscapePAL
Enumeration for selecting a palette in the terminal.
Definition esc_decoder.h:260
@ PAL_2
Palette 2.
Definition esc_decoder.h:263
@ PAL_1
Palette 1.
Definition esc_decoder.h:262
@ PAL_3
Palette 3.
Definition esc_decoder.h:264
@ PAL_0
Palette 0.
Definition esc_decoder.h:261
EscapeSeqOpe
Enumeration for escape sequence operations.
Definition esc_decoder.h:274
@ ESO_CLEAR_LINE_FROM_CURSOR_RIGHT
Clears the line from the cursor to the right.
Definition esc_decoder.h:287
@ ESO_DISABLE_SHADOW
Disables the shadow effect.
Definition esc_decoder.h:291
@ ESO_SEL_PAL
Selects a palette.
Definition esc_decoder.h:282
@ ESO_UP
Moves the cursor up.
Definition esc_decoder.h:276
@ ESO_SET_Z
Sets the z value.
Definition esc_decoder.h:292
@ ESO_CLEAR_ENTIRE_LINE
Clears the entire line.
Definition esc_decoder.h:289
@ ESO_LEFT
Moves the cursor left.
Definition esc_decoder.h:279
@ ESO_SET_COLOR
Sets the foreground and background color.
Definition esc_decoder.h:283
@ ESO_DEL
Deletes a character.
Definition esc_decoder.h:280
@ ESO_DOWN
Moves the cursor down.
Definition esc_decoder.h:277
@ ESO_CLEAR_SCREEN_FROM_CURSOR_DOWN
Clears the screen from the cursor down.
Definition esc_decoder.h:284
@ ESO_ENABLE_SHADOW
Enables the shadow effect.
Definition esc_decoder.h:290
@ ESO_ONE_CHAR
Processes a single character.
Definition esc_decoder.h:275
@ ESO_CLEAR_ENTIRE_SCREEN
Clears the entire screen.
Definition esc_decoder.h:286
@ ESO_MOVE_CURSOR
Moves the cursor to a specified position.
Definition esc_decoder.h:281
@ ESO_NONE
No operation.
Definition esc_decoder.h:293
@ ESO_CLEAR_SCREEN_FROM_CURSOR_UP
Clears the screen from the cursor up.
Definition esc_decoder.h:285
@ ESO_RIGHT
Moves the cursor right.
Definition esc_decoder.h:278
@ ESO_CLEAR_LINE_FROM_CURSOR_LEFT
Clears the line from the cursor to the left.
Definition esc_decoder.h:288
void EscClearEntireScreen(FILE *fp)
Clears the entire screen.
Definition esc_decoder.cpp:274
Definition esc_decoder.h:378