Display multiple files
This commit is contained in:
parent
aade06e600
commit
0da13751d5
38
src/main.zig
38
src/main.zig
|
@ -84,10 +84,8 @@ pub fn main() !void {
|
|||
|
||||
var file_paths = std.ArrayList([]const u8).init(allocator);
|
||||
defer file_paths.deinit();
|
||||
try file_paths.append("GapProbeScan.cs");
|
||||
try file_paths.append("src/main.zig");
|
||||
// const file_name = "GapProbeScan.cs";
|
||||
// const source_code = @embedFile(file_name);
|
||||
try file_paths.append("GapProbeScan.cs");
|
||||
|
||||
var file_docmaps = std.ArrayList(FileDocMap).init(allocator);
|
||||
defer file_docmaps.deinit();
|
||||
|
@ -172,6 +170,7 @@ pub fn main() !void {
|
|||
return error.SDLInitializationFailed;
|
||||
}
|
||||
|
||||
// Draw white background
|
||||
var x: c_int = 0;
|
||||
while (x < window_width) : (x += 1) {
|
||||
var y: c_int = 0;
|
||||
|
@ -187,11 +186,28 @@ pub fn main() !void {
|
|||
var i: usize = 0;
|
||||
var column: c_int = 0;
|
||||
x = 0;
|
||||
var y: c_int = file_docmaps.items[0].title_text.rect.h;
|
||||
var y: c_int = 0;
|
||||
|
||||
for (file_docmaps.items) |docmap| {
|
||||
i = 0;
|
||||
|
||||
var rect = c.SDL_Rect {
|
||||
.x = x,
|
||||
.y = y,
|
||||
.w = docmap.title_text.surface.*.w,
|
||||
.h = docmap.title_text.surface.*.h,
|
||||
};
|
||||
|
||||
// Display text
|
||||
if (c.SDL_RenderCopy(renderer, docmap.title_text.texture, null, &rect) != 0) {
|
||||
c.SDL_Log("Unable to render copy");
|
||||
}
|
||||
|
||||
y += docmap.title_text.rect.h;
|
||||
// white: false, black: true
|
||||
var color: bool = false;
|
||||
while (i < file_docmaps.items[0].contents.len) : (i += 1) {
|
||||
if (file_docmaps.items[0].contents[i] == 10) {
|
||||
while (i < docmap.contents.len) : (i += 1) {
|
||||
if (docmap.contents[i] == 10) {
|
||||
y += 1;
|
||||
if (y > window_height) {
|
||||
y = 0;
|
||||
|
@ -203,14 +219,14 @@ pub fn main() !void {
|
|||
continue;
|
||||
}
|
||||
|
||||
if (file_docmaps.items[0].contents[i] == 32 and color) {
|
||||
if (docmap.contents[i] == 32 and color) {
|
||||
color = false;
|
||||
const white_color_result = c.SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255);
|
||||
if (white_color_result != 0) {
|
||||
c.SDL_Log("Unable to set draw color: %d", white_color_result);
|
||||
return error.SDLInitializationFailed;
|
||||
}
|
||||
} else if (file_docmaps.items[0].contents[i] != 32 and !color) {
|
||||
} else if (docmap.contents[i] != 32 and !color) {
|
||||
color = true;
|
||||
const black_color_result = c.SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
|
||||
if (black_color_result != 0) {
|
||||
|
@ -255,12 +271,6 @@ pub fn main() !void {
|
|||
|
||||
x += 1;
|
||||
}
|
||||
|
||||
const text = file_docmaps.items[0].title_text;
|
||||
|
||||
// Display text
|
||||
if (c.SDL_RenderCopy(renderer, text.texture, null, &(text.rect)) != 0) {
|
||||
c.SDL_Log("Unable to render copy");
|
||||
}
|
||||
|
||||
c.SDL_RenderPresent(renderer);
|
||||
|
|
Loading…
Reference in New Issue
Block a user