MCPcopy Create free account
hub / github.com/LemonOSProject/LemonOS / DoAnsiSGR

Function DoAnsiSGR

System/FTerm/main.cpp:110–179  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

108}
109
110void DoAnsiSGR(){
111 int r = -1;
112 if(strchr(escBuf, ';')){
113 char temp[strchr(escBuf, ';') - escBuf + 1];
114 temp[strchr(escBuf, ';') - escBuf] = 0;
115 strncpy(temp, escBuf, (int)(strchr(escBuf, ';') - escBuf));
116 r = atoi(escBuf);
117
118 } else r = atoi(escBuf);
119 if(r < 30){
120 switch (r)
121 {
122 case 0:
123 state = defaultState;
124 break;
125 case 1:
126 state.bold = true;
127 break;
128 case 2:
129 state.faint = true;
130 break;
131 case 3:
132 state.italic = true;
133 break;
134 case 4:
135 state.underline = true;
136 break;
137 case 5:
138 case 6:
139 state.blink = true;
140 break;
141 case 7:
142 state.reverse = true;
143 break;
144 case 9:
145 state.strikethrough = true;
146 break;
147 case 21:
148 state.underline = true;
149 break;
150 case 24:
151 state.underline = false;
152 break;
153 case 25:
154 state.blink = false;
155 break;
156 case 27:
157 state.reverse = false;
158 break;
159 default:
160 break;
161 }
162 } else if (r >= ANSI_CSI_SGR_FG_BLACK && r <= ANSI_CSI_SGR_FG_WHITE){ // Foreground Colour
163 state.fgColour = r - ANSI_CSI_SGR_FG_BLACK;
164 } else if (r >= ANSI_CSI_SGR_BG_BLACK && r <= ANSI_CSI_SGR_BG_WHITE){ // Background Colour
165 state.bgColour = r - ANSI_CSI_SGR_BG_BLACK;
166 } else if (r >= ANSI_CSI_SGR_FG_BLACK_BRIGHT && r <= ANSI_CSI_SGR_FG_WHITE_BRIGHT){ // Foreground Colour (Bright)
167 state.fgColour = r - ANSI_CSI_SGR_FG_BLACK_BRIGHT + 8;

Callers 1

DoAnsiCSIFunction · 0.70

Calls 2

strchrFunction · 0.85
strncpyFunction · 0.85

Tested by

no test coverage detected