Skip to content

Commit 3091d0a

Browse files
committed
parse: fully fix aligning ascii art and layout
why I didn't do it in commit 326a0b5
1 parent c8ebfcb commit 3091d0a

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

src/parse.cpp

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -198,16 +198,20 @@ std::string parse(const std::string_view input, systemInfo_t& systemInfo, std::s
198198
if (static_cast<int>(endBracketIndex) == -1)
199199
die("PARSER: Opened tag is not closed at index {} in string {}", dollarSignIndex, output);
200200

201-
const std::string& strToRemove = fmt::format("${}{}{}", opentag, command, type);
202-
const size_t start_pos = pureOutput.find(strToRemove);
203-
if (start_pos != std::string::npos)
204-
pureOutput.erase(start_pos, strToRemove.length());
201+
const std::string& strToReplace = fmt::format("${}{}{}", opentag, command, type);
202+
const size_t start_pos = pureOutput.find(strToReplace);
205203

206204
switch (type)
207205
{
208206
case ')':
209-
output = output.replace(dollarSignIndex, (endBracketIndex + 1) - dollarSignIndex, shell_exec(command));
210-
break;
207+
{
208+
const std::string& shell_cmd = shell_exec(command);
209+
output = output.replace(dollarSignIndex, (endBracketIndex + 1) - dollarSignIndex, shell_cmd);
210+
211+
if (!parsingLaoyut && start_pos != std::string::npos)
212+
pureOutput.replace(start_pos, command.length() + 3, shell_cmd);
213+
214+
} break;
211215
case '>':
212216
{
213217
const size_t& dot_pos = command.find('.');
@@ -220,6 +224,10 @@ std::string parse(const std::string_view input, systemInfo_t& systemInfo, std::s
220224

221225
output = output.replace(dollarSignIndex, (endBracketIndex + 1) - dollarSignIndex,
222226
getInfoFromName(systemInfo, moduleName, moduleValueName));
227+
228+
if (!parsingLaoyut && start_pos != std::string::npos)
229+
pureOutput.replace(start_pos, command.length() + 3,
230+
getInfoFromName(systemInfo, moduleName, moduleValueName));
223231
}
224232
break;
225233
case '}': // please pay very attention when reading this unreadable and godawful code
@@ -427,7 +435,10 @@ std::string parse(const std::string_view input, systemInfo_t& systemInfo, std::s
427435
}
428436

429437
if (config.gui && firstrun_noclr)
430-
output += "</span>";
438+
output += "</span>";
439+
440+
if (!parsingLaoyut && start_pos != std::string::npos)
441+
pureOutput.erase(start_pos, strToReplace.length());
431442
}
432443
}
433444

0 commit comments

Comments
 (0)