|
- /*
- Copyright (c) 2023 : Ognjen 'xolatile' Milan Robovic
-
- Xhartae is free software! You will redistribute it or modify it under the terms of the GNU General Public License by Free Software Foundation.
- And when you do redistribute it or modify it, it will use either version 3 of the License, or (at yours truly opinion) any later version.
- It is distributed in the hope that it will be useful or harmful, it really depends... But no warranty what so ever, seriously. See GNU/GPLv3.
- */
-
- #ifndef CHAPTER_4_SOURCE
- #define CHAPTER_4_SOURCE
-
- #include "chapter_4.h"
-
- /*
-
- void program_view_c_file (char * text_file, int width, int height, int x, int y) {
- char * text_data;
-
- curses_active = 1;
-
- text_data = file_record (text_file);
-
- while (curses_active != 0) {
- curses_render_background (' ', COLOUR_WHITE, EFFECT_NORMAL);
- curses_render_string (text_data, COLOUR_WHITE, EFFECT_NORMAL, x, x);
-
- curses_synchronize ();
- }
-
- text_data = deallocate (text_data);
- }
-
- */
-
- void program_view_c_file (char * text_file, int width, int height, int x, int y) {
- char * text_data;
-
- int reset_x = x;
- int reset_y = y;
-
- curses_active = 1;
-
- text_data = file_record (text_file);
-
- while (curses_active != 0) {
- int offset, colour, effect, string;
-
- curses_render_background (' ', COLOUR_WHITE, EFFECT_NORMAL);
-
- x = reset_x;
- y = reset_y;
-
- string = 0;
- colour = COLOUR_WHITE;
- effect = EFFECT_NORMAL;
-
- for (offset = 0; offset != string_length (text_data); ++offset) {
- switch (text_data [offset]) {
- case '"':
- string = ! string;
- colour = (string != 0) ? COLOUR_RED : COLOUR_WHITE;
- effect = (string != 0) ? EFFECT_BOLD : EFFECT_NORMAL;
- break;
- default:
- break;
- }
-
- curses_render_character (text_data [offset], colour, effect, x, y);
-
- switch (text_data [offset]) {
- case '\t': x += 8; break;
- case '\n': y += 1; x = reset_x; break;
- default: x += 1; break;
- }
- }
-
- curses_synchronize ();
- }
-
- text_data = deallocate (text_data);
- }
-
- #endif
|