More to come...
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

84 lines
2.0KB

  1. /*
  2. Copyright (c) 2023 : Ognjen 'xolatile' Milan Robovic
  3. Xhartae is free software! You will redistribute it or modify it under the terms of the GNU General Public License by Free Software Foundation.
  4. 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.
  5. 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.
  6. */
  7. #ifndef CHAPTER_4_SOURCE
  8. #define CHAPTER_4_SOURCE
  9. #include "chapter_4.h"
  10. /*
  11. void program_view_c_file (char * text_file, int width, int height, int x, int y) {
  12. char * text_data;
  13. curses_active = 1;
  14. text_data = file_record (text_file);
  15. while (curses_active != 0) {
  16. curses_render_background (' ', COLOUR_WHITE, EFFECT_NORMAL);
  17. curses_render_string (text_data, COLOUR_WHITE, EFFECT_NORMAL, x, x);
  18. curses_synchronize ();
  19. }
  20. text_data = deallocate (text_data);
  21. }
  22. */
  23. void program_view_c_file (char * text_file, int width, int height, int x, int y) {
  24. char * text_data;
  25. int reset_x = x;
  26. int reset_y = y;
  27. curses_active = 1;
  28. text_data = file_record (text_file);
  29. while (curses_active != 0) {
  30. int offset, colour, effect, string;
  31. curses_render_background (' ', COLOUR_WHITE, EFFECT_NORMAL);
  32. x = reset_x;
  33. y = reset_y;
  34. string = 0;
  35. colour = COLOUR_WHITE;
  36. effect = EFFECT_NORMAL;
  37. for (offset = 0; offset != string_length (text_data); ++offset) {
  38. switch (text_data [offset]) {
  39. case '"':
  40. string = ! string;
  41. colour = (string != 0) ? COLOUR_RED : COLOUR_WHITE;
  42. effect = (string != 0) ? EFFECT_BOLD : EFFECT_NORMAL;
  43. break;
  44. default:
  45. break;
  46. }
  47. curses_render_character (text_data [offset], colour, effect, x, y);
  48. switch (text_data [offset]) {
  49. case '\t': x += 8; break;
  50. case '\n': y += 1; x = reset_x; break;
  51. default: x += 1; break;
  52. }
  53. }
  54. curses_synchronize ();
  55. }
  56. text_data = deallocate (text_data);
  57. }
  58. #endif