26
26
// Implementation of the system behind displaying/rendering the information
27
27
28
28
#include " display.hpp"
29
+ #include < cstddef>
29
30
30
31
#ifndef GUI_MODE
31
32
# define STB_IMAGE_IMPLEMENTATION
@@ -97,13 +98,23 @@ static std::vector<std::string> render_with_image(systemInfo_t& systemInfo, std:
97
98
stbi_image_free (img);
98
99
99
100
std::string _;
100
- parse_args_t parse_args{ systemInfo, _, config, colors, true };
101
- for (std::string& line : layout)
101
+ std::vector<std::string> tmp_layout;
102
+ parse_args_t parse_args{ systemInfo, _, layout, tmp_layout, config, colors, true };
103
+ for (size_t i = 0 ; i < layout.size (); ++i)
102
104
{
103
- line = parse (line, parse_args);
104
- if (!config.m_disable_colors )
105
- line.insert (0 , NOCOLOR);
105
+ layout[i] = parse (layout[i], parse_args);
106
106
parse_args.no_more_reset = false ;
107
+ if (!config.gui && !config.m_disable_colors )
108
+ {
109
+ layout[i].insert (0 , NOCOLOR);
110
+ }
111
+
112
+ if (!tmp_layout.empty ())
113
+ {
114
+ layout.erase (layout.begin ()+i);
115
+ layout.insert (layout.begin ()+i, tmp_layout.begin (), tmp_layout.end ());
116
+ tmp_layout.clear ();
117
+ }
107
118
}
108
119
109
120
// erase each element for each instance of MAGIC_LINE
@@ -116,9 +127,9 @@ static std::vector<std::string> render_with_image(systemInfo_t& systemInfo, std:
116
127
const size_t height = image_height / font_height;
117
128
118
129
if (config.m_image_backend == " kitty" )
119
- taur_exec ({ " kitty" , " +kitten" , " icat" , " --align " ,
120
- (config.logo_position == " top" ? " center" : config.logo_position ), " --place " ,
121
- fmt::format (" {}x{}@0x0" , width, height), path });
130
+ taur_exec ({ " kitty" , " +kitten" , " icat" ,
131
+ " --align " , (config.logo_position == " top" ? " center" : config.logo_position ),
132
+ " --place " , fmt::format (" {}x{}@0x0" , width, height), path });
122
133
else if (config.m_image_backend == " viu" )
123
134
taur_exec ({ " viu" , " -t" , " -w" , fmt::to_string (width), " -h" , fmt::to_string (height), path });
124
135
else
@@ -243,7 +254,8 @@ std::vector<std::string> Display::render(const Config& config, const colors_t& c
243
254
// this is just for parse() to auto add the distro colors
244
255
std::ifstream distro_file (distro_path);
245
256
std::string line, _;
246
- parse_args_t parse_args{ systemInfo, _, config, colors, false };
257
+ std::vector<std::string> tmp_layout;
258
+ parse_args_t parse_args{ systemInfo, _, layout, tmp_layout, config, colors, false };
247
259
248
260
while (std::getline (distro_file, line))
249
261
{
@@ -296,7 +308,8 @@ std::vector<std::string> Display::render(const Config& config, const colors_t& c
296
308
while (std::getline (file, line))
297
309
{
298
310
std::string pureOutput;
299
- parse_args_t parse_args{ systemInfo, pureOutput, config, colors, false };
311
+ std::vector<std::string> tmp_layout;
312
+ parse_args_t parse_args{ systemInfo, pureOutput, layout, tmp_layout, config, colors, false };
300
313
301
314
std::string asciiArt_s = parse (line, parse_args);
302
315
parse_args.no_more_reset = false ;
@@ -325,13 +338,23 @@ std::vector<std::string> Display::render(const Config& config, const colors_t& c
325
338
return asciiArt;
326
339
327
340
std::string _;
328
- parse_args_t parse_args{ systemInfo, _, config, colors, true };
329
- for (std::string& line : layout)
341
+ std::vector<std::string> tmp_layout;
342
+ parse_args_t parse_args{ systemInfo, _, layout, tmp_layout, config, colors, true };
343
+ for (size_t i = 0 ; i < layout.size (); ++i)
330
344
{
331
- line = parse (line , parse_args);
345
+ layout[i] = parse (layout[i] , parse_args);
332
346
parse_args.no_more_reset = false ;
333
347
if (!config.gui && !config.m_disable_colors )
334
- line.insert (0 , NOCOLOR);
348
+ {
349
+ layout[i].insert (0 , NOCOLOR);
350
+ }
351
+
352
+ if (!tmp_layout.empty ())
353
+ {
354
+ layout.erase (layout.begin ()+i);
355
+ layout.insert (layout.begin ()+i, tmp_layout.begin (), tmp_layout.end ());
356
+ tmp_layout.clear ();
357
+ }
335
358
}
336
359
337
360
auto_colors.clear ();
0 commit comments