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.h File Reference

Header file for the ANSI Escape code related functions. More...

#include <chrono>
#include <string>
#include <thread>
Include dependency graph for format.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  time
 Mimics python sleep() behaviour, with param milliseconds. More...
 

Functions

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

Variables

const std::string bgBlack
 
const std::string bgBlue
 
const std::string bgCyan
 
const std::string bgDefault
 
const std::string bgGreen
 
const std::string bgMagenta
 
const std::string bgRed
 
const std::string bgWhite
 
const std::string bgYellow
 
const int sleepLong
 
const int sleepMedium
 
const int sleepShort
 
const std::string textBlack
 
const std::string textBlue
 
const std::string textBold
 
const std::string textClear
 
const std::string textCyan
 
const std::string textDefault
 
const std::string textGreen
 
const std::string textItalic
 
const std::string textMagenta
 
const std::string textRed
 
const std::string textReset
 
const std::string textStrikethrough
 
const std::string textUnderline
 
const std::string textWhite
 
const std::string textYellow
 

Detailed Description

Header file for the ANSI Escape code related functions.

Definition in file format.h.

Function Documentation

◆ fetchConsoleDimensions()

void fetchConsoleDimensions ( int & row,
int & col )
extern
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()

std::string setCursorPosition ( int offsetY,
int offsetX )
extern

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 std::string bgBlack
extern

Definition at line 39 of file format.cpp.

Referenced by drawButton().

◆ bgBlue

const std::string bgBlue
extern

Definition at line 43 of file format.cpp.

◆ bgCyan

const std::string bgCyan
extern

Definition at line 45 of file format.cpp.

◆ bgDefault

const std::string bgDefault
extern

Definition at line 38 of file format.cpp.

◆ bgGreen

const std::string bgGreen
extern

Definition at line 41 of file format.cpp.

◆ bgMagenta

const std::string bgMagenta
extern

Definition at line 44 of file format.cpp.

◆ bgRed

const std::string bgRed
extern

Definition at line 40 of file format.cpp.

◆ bgWhite

const std::string bgWhite
extern

Definition at line 46 of file format.cpp.

Referenced by drawButton().

◆ bgYellow

const std::string bgYellow
extern

Definition at line 42 of file format.cpp.

◆ sleepLong

const int sleepLong
extern

Definition at line 50 of file format.cpp.

Referenced by main().

◆ sleepMedium

const int sleepMedium
extern

Definition at line 49 of file format.cpp.

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

◆ sleepShort

const int sleepShort
extern

Definition at line 48 of file format.cpp.

Referenced by drawLogo().

◆ textBlack

const std::string textBlack
extern

Definition at line 29 of file format.cpp.

Referenced by drawButton().

◆ textBlue

const std::string textBlue
extern

Definition at line 33 of file format.cpp.

◆ textBold

const std::string textBold
extern

Definition at line 23 of file format.cpp.

Referenced by drawButton().

◆ textClear

const std::string textClear
extern

Definition at line 20 of file format.cpp.

Referenced by drawLogo(), and main().

◆ textCyan

const std::string textCyan
extern

Definition at line 35 of file format.cpp.

◆ textDefault

const std::string textDefault
extern

Definition at line 28 of file format.cpp.

Referenced by printgraphblocks().

◆ textGreen

const std::string textGreen
extern

Definition at line 31 of file format.cpp.

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

◆ textItalic

const std::string textItalic
extern

Definition at line 24 of file format.cpp.

◆ textMagenta

const std::string textMagenta
extern

Definition at line 34 of file format.cpp.

◆ textRed

const std::string textRed
extern

Definition at line 30 of file format.cpp.

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

◆ textReset

const std::string textReset
extern

Definition at line 21 of file format.cpp.

Referenced by drawButton().

◆ textStrikethrough

const std::string textStrikethrough
extern

Definition at line 26 of file format.cpp.

◆ textUnderline

const std::string textUnderline
extern

Definition at line 25 of file format.cpp.

◆ textWhite

const std::string textWhite
extern

Definition at line 36 of file format.cpp.

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

◆ textYellow

const std::string textYellow
extern

Definition at line 32 of file format.cpp.