Stock Market Simulator main e8c3612
A game that provides a realistic stock buying experience with unpredictable trends to test investment strategies.
Loading...
Searching...
No Matches
format.cpp File Reference

ANSI Escape Code related functions. More...

#include "format.h"
Include dependency graph for format.cpp:

Go to the source code of this file.

Functions

void fetchConsoleDimensions (int &row, int &col)
 
string setCursorPosition (int offsetY, int offsetX)
 

Variables

const string bgBlack = "\x1b[40m"
 
const string bgBlue = "\x1b[44m"
 
const string bgCyan = "\x1b[46m"
 
const string bgDefault = "\x1b[49m"
 
const string bgGreen = "\x1b[42m"
 
const string bgMagenta = "\x1b[45m"
 
const string bgRed = "\x1b[41m"
 
const string bgWhite = "\x1b[47m"
 
const string bgYellow = "\x1b[43m"
 
const int sleepLong = 1000
 
const int sleepMedium = 500
 
const int sleepShort = 100
 
const string textBlack = "\x1b[30m"
 
const string textBlue = "\x1b[34m"
 
const string textBold = "\x1b[1m"
 
const string textClear = "\x1b[2J"
 
const string textCyan = "\x1b[36m"
 
const string textDefault = "\x1b[39m"
 
const string textGreen = "\x1b[32m"
 
const string textItalic = "\x1b[3m"
 
const string textMagenta = "\x1b[35m"
 
const string textRed = "\x1b[31m"
 
const string textReset = "\x1b[0m"
 
const string textStrikethrough = "\x1b[9m"
 
const string textUnderline = "\x1b[4m"
 
const string textWhite = "\x1b[37m"
 
const string textYellow = "\x1b[33m"
 

Detailed Description

ANSI Escape Code related functions.

Definition in file format.cpp.

Function Documentation

◆ fetchConsoleDimensions()

void fetchConsoleDimensions ( int & row,
int & col )
Todo
Suggest terminal sizes. Dynamic size needs testing on windows. Not implemented because of time constraints.

Definition at line 62 of file format.cpp.

62 {
63 /** @todo Suggest terminal sizes.
64 * Dynamic size needs testing on windows.
65 * Not implemented because of time constraints.
66 */
67 int mode = 2;
68 // Before moving to production, we use the printTable() function with
69 // the mode parameter set to "dev" for testing purposes.
70 // However, in production, we will use the mode parameter set to "normal"
71 // which will result in fewer columns being printed. This reduction in columns
72 // may cause misalignment of the table, so we need to adjust the offset accordingly.
73 // for dev mode, the offset is 0
74 const int normalTableModeOffset = 20;
75 switch (mode) {
76 case 1:
77 row = 30;
78 col = 80 - normalTableModeOffset;
79 break;
80 case 2:
81 row = 36;
82 col = 120 - normalTableModeOffset;
83 break;
84 case 3:
85 row = 48;
86 col = 160 - normalTableModeOffset;
87 break;
88 default:
89 row = 36;
90 col = 120 - normalTableModeOffset;
91 break;
92 }
93}
mode
hiding mean/sd/uplim/lowlim/event_id columns in the table
Definition main.cpp:104

Referenced by main().

Here is the caller graph for this function:

◆ setCursorPosition()

string setCursorPosition ( int offsetY,
int offsetX )

Definition at line 56 of file format.cpp.

56 {
57 string base = "\x1b[";
58 base = base + to_string(offsetY) + ";" + to_string(offsetX) + "H";
59 return base;
60}

Referenced by advanceConfirmation(), buyStocks(), drawButton(), drawEventBar(), drawLogo(), drawRoundInfo(), integerInput(), listEvents(), main(), optionsInput(), print_table(), quitConfirmation(), and sellStocks().

Here is the caller graph for this function:

Variable Documentation

◆ bgBlack

const string bgBlack = "\x1b[40m"

Definition at line 39 of file format.cpp.

Referenced by drawButton().

◆ bgBlue

const string bgBlue = "\x1b[44m"

Definition at line 43 of file format.cpp.

◆ bgCyan

const string bgCyan = "\x1b[46m"

Definition at line 45 of file format.cpp.

◆ bgDefault

const string bgDefault = "\x1b[49m"

Definition at line 38 of file format.cpp.

◆ bgGreen

const string bgGreen = "\x1b[42m"

Definition at line 41 of file format.cpp.

◆ bgMagenta

const string bgMagenta = "\x1b[45m"

Definition at line 44 of file format.cpp.

◆ bgRed

const string bgRed = "\x1b[41m"

Definition at line 40 of file format.cpp.

◆ bgWhite

const string bgWhite = "\x1b[47m"

Definition at line 46 of file format.cpp.

Referenced by drawButton().

◆ bgYellow

const string bgYellow = "\x1b[43m"

Definition at line 42 of file format.cpp.

◆ sleepLong

const int sleepLong = 1000

Definition at line 50 of file format.cpp.

Referenced by main().

◆ sleepMedium

const int sleepMedium = 500

Definition at line 49 of file format.cpp.

Referenced by buyStocks(), drawLogo(), integerInput(), main(), optionsInput(), and sellStocks().

◆ sleepShort

const int sleepShort = 100

Definition at line 48 of file format.cpp.

Referenced by drawLogo().

◆ textBlack

const string textBlack = "\x1b[30m"

Definition at line 29 of file format.cpp.

Referenced by drawButton().

◆ textBlue

const string textBlue = "\x1b[34m"

Definition at line 33 of file format.cpp.

◆ textBold

const string textBold = "\x1b[1m"

Definition at line 23 of file format.cpp.

Referenced by drawButton().

◆ textClear

const string textClear = "\x1b[2J"

Definition at line 20 of file format.cpp.

Referenced by drawLogo(), and main().

◆ textCyan

const string textCyan = "\x1b[36m"

Definition at line 35 of file format.cpp.

◆ textDefault

const string textDefault = "\x1b[39m"

Definition at line 28 of file format.cpp.

Referenced by printgraphblocks().

◆ textGreen

const string textGreen = "\x1b[32m"

Definition at line 31 of file format.cpp.

Referenced by graph_plotting(), print_table(), and printgraphblocks().

◆ textItalic

const string textItalic = "\x1b[3m"

Definition at line 24 of file format.cpp.

◆ textMagenta

const string textMagenta = "\x1b[35m"

Definition at line 34 of file format.cpp.

◆ textRed

const string textRed = "\x1b[31m"

Definition at line 30 of file format.cpp.

Referenced by graph_plotting(), print_table(), and printgraphblocks().

◆ textReset

const string textReset = "\x1b[0m"

Definition at line 21 of file format.cpp.

Referenced by drawButton().

◆ textStrikethrough

const string textStrikethrough = "\x1b[9m"

Definition at line 26 of file format.cpp.

◆ textUnderline

const string textUnderline = "\x1b[4m"

Definition at line 25 of file format.cpp.

◆ textWhite

const string textWhite = "\x1b[37m"

Definition at line 36 of file format.cpp.

Referenced by drawButton(), graph_plotting(), and print_table().

◆ textYellow

const string textYellow = "\x1b[33m"

Definition at line 32 of file format.cpp.