MCPcopy
hub / github.com/wavetermdev/waveterm / updateStateWithCodes

Function updateStateWithCodes

frontend/app/element/ansiline.tsx:71–98  ·  view source on GitHub ↗
(state, codes)

Source from the content-addressed store, hash-verified

69});
70
71const updateStateWithCodes = (state, codes) => {
72 codes.forEach((code) => {
73 if (code === 0) {
74 // Reset state
75 state.modifiers.clear();
76 state.textColor = null;
77 state.bgColor = null;
78 state.reverse = false;
79 return;
80 }
81 // Instead of swapping immediately, we set a flag
82 if (code === 7) {
83 state.reverse = true;
84 return;
85 }
86 const tailwindClass = ANSI_TAILWIND_MAP[code];
87 if (tailwindClass && tailwindClass !== "reset") {
88 if (tailwindClass.startsWith("text-")) {
89 state.textColor = tailwindClass;
90 } else if (tailwindClass.startsWith("bg-")) {
91 state.bgColor = tailwindClass;
92 } else {
93 state.modifiers.add(tailwindClass);
94 }
95 }
96 });
97 return state;
98};
99
100const stateToClasses = (state: InternalStateType) => {
101 const classes = [];

Callers 1

AnsiLineFunction · 0.85

Calls 1

clearMethod · 0.80

Tested by

no test coverage detected