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

Function DoAnsiSGR

Applications/Terminal/main.cpp:138–207  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

136}
137
138void DoAnsiSGR(){
139 int r = -1;
140 if(strchr(escBuf, ';')){
141 char temp[strchr(escBuf, ';') - escBuf + 1];
142 temp[strchr(escBuf, ';') - escBuf] = 0;
143 strncpy(temp, escBuf, (int)(strchr(escBuf, ';') - escBuf));
144 r = atoi(escBuf);
145
146 } else r = atoi(escBuf);
147 if(r < 30){
148 switch (r)
149 {
150 case 0:
151 state = defaultState;
152 break;
153 case 1:
154 state.bold = true;
155 break;
156 case 2:
157 state.faint = true;
158 break;
159 case 3:
160 state.italic = true;
161 break;
162 case 4:
163 state.underline = true;
164 break;
165 case 5:
166 case 6:
167 state.blink = true;
168 break;
169 case 7:
170 state.reverse = true;
171 break;
172 case 9:
173 state.strikethrough = true;
174 break;
175 case 21:
176 state.underline = true;
177 break;
178 case 24:
179 state.underline = false;
180 break;
181 case 25:
182 state.blink = false;
183 break;
184 case 27:
185 state.reverse = false;
186 break;
187 default:
188 break;
189 }
190 } else if (r >= ANSI_CSI_SGR_FG_BLACK && r <= ANSI_CSI_SGR_FG_WHITE){ // Foreground Colour
191 state.fgColour = r - ANSI_CSI_SGR_FG_BLACK;
192 } else if (r >= ANSI_CSI_SGR_BG_BLACK && r <= ANSI_CSI_SGR_BG_WHITE){ // Background Colour
193 state.bgColour = r - ANSI_CSI_SGR_BG_BLACK;
194 } else if (r >= ANSI_CSI_SGR_FG_BLACK_BRIGHT && r <= ANSI_CSI_SGR_FG_WHITE_BRIGHT){ // Foreground Colour (Bright)
195 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