Guest User

Untitled

a guest
Oct 19th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.03 KB | None | 0 0
  1. using Curses;
  2. using GLib;
  3.  
  4. namespace OmegaDawn {
  5. public class BoxLayout : Object {
  6. top_pane t_pane;
  7.  
  8. weak Window MainWin;
  9. Window test_win;
  10. bool running;
  11.  
  12. // Setup signals
  13. signal void WinRefresh();
  14.  
  15. public BoxLayout(string[] args) {
  16. // Aight... Initialize everything
  17. MainWin = initscr();
  18. initscr();
  19. start_color();
  20. cbreak();
  21. noecho();
  22. MainWin.keypad(true);
  23. //keypad(true);
  24. running = true;
  25.  
  26. // Setup color pairs
  27. //init_pair(1, Color.BLUE, Color.YELLOW);
  28. //init_pair(2, Color.WHITE, Color.BLUE);
  29. //init_pair(3, Color.GREEN, Color.RED);
  30. // init_color(color_index, r_value, g_value, b_value);
  31. // init_pair(pair_index, color_fg, color_bg);
  32. // 256 colors, 32767 pairs
  33. // init_color(0, 1000, 1000, 1000); // 0: WHITE
  34. // init_color(1, 0, 0, 0); // 1: BLACK
  35. // init_color(2, 1000, 0, 0); // 2: 100% Red
  36. init_color(0, 0, 0, 0); // 0: Black
  37. init_color(1, 100, 100, 100); // 1: 90% Grey
  38. init_color(2, 200, 200, 200); // 2: 80% Grey
  39. init_color(3, 300, 300, 300); // 3: 70% Grey
  40. init_color(4, 400, 400, 400); // 4: 60% Grey
  41. init_color(5, 500, 500, 500); // 5: 50% Grey
  42. init_color(6, 600, 600, 600); // 6: 40% Grey
  43. init_color(7, 700, 700, 700); // 7: 30% Grey
  44. init_color(8, 800, 800, 800); // 8: 20% Grey
  45. init_color(9, 900, 900, 900); // 9: 10% Grey
  46. init_color(10, 1000, 1000, 1000); // 10: White
  47. init_color(11, 1000, 0, 0); // 11: Full Yellow
  48. init_color(12, 0, 1000, 0); //
  49. init_color(13, 0, 0, 1000); //
  50.  
  51. init_color(20, 1000, 0, 1000); // black
  52. init_color(21, 1000, 1000, 1000); // white
  53.  
  54. init_pair(0, (short)10, (short)0); // 0: White on Black
  55. init_pair(1, (short)0, (short)10); // 1: Black on White
  56. init_pair(2, 0, 0); // 2: Red on Red
  57. init_pair(3, 0, 7); // 3: Black on 70% gray
  58.  
  59. init_pair(10, 10, 5);
  60. }
  61.  
  62. void initialize_views() {
  63. // Initialize layouts
  64. t_pane = new top_pane(2, COLS, 0, 0);
  65.  
  66. t_vars tv = new t_vars();
  67.  
  68. //t_pane.write(0, 0, tv.print_vars(), 10);
  69. t_pane.write(0,0, tv.output_string, 10);
  70.  
  71. // Initialize signals
  72. WinRefresh.connect(t_pane.refresh);
  73. }
  74.  
  75. void do_refresh() {
  76. // TESTING: new blank window
  77. test_win = new Window(2, COLS, LINES-2, 0);
  78. test_win.bkgdset(COLOR_PAIR(1));
  79. test_win.clrtobot();
  80.  
  81. MainWin.refresh();
  82. // Signal
  83. WinRefresh();
  84. }
  85.  
  86. public void main_loop() {
  87. initialize_views();
  88.  
  89. var ch = 0;
  90.  
  91. while (running) {
  92. do_refresh();
  93. ch = getch();
  94. if (ch == -1)
  95. continue;
  96. switch (ch) {
  97. case ('q'):
  98. running = false;
  99. break;
  100. }
  101. }
  102. }
  103. }
  104.  
  105. class t_vars {
  106. public short f_red = 0;
  107. public short f_green = 0;
  108. public short f_blue = 0;
  109.  
  110. public short b_red = 0;
  111. public short b_green = 0;
  112. public short b_blue = 0;
  113.  
  114. public short csfg;
  115. public short csbg;
  116.  
  117. public short fg;
  118. public short bg;
  119.  
  120. //private int* NULL = null;
  121.  
  122. private string hc;
  123. private string ccc;
  124.  
  125. public string output_string {public get; set; }
  126.  
  127. public t_vars() {
  128. csfg = 10;
  129. csbg = 5;
  130. hc = has_colors().to_string();
  131. ccc = can_change_color().to_string();
  132. pair_content(10, ref fg, ref bg);
  133. color_content(fg, ref f_red, ref f_green, ref f_blue);
  134. color_content(bg, ref b_red, ref b_green, ref b_blue);
  135.  
  136. output_string = "Diagnostics: " +
  137. "has_color: " + hc +
  138. " can_change_color: " + ccc +
  139. " pair: (fg: " + fg.to_string() + ", bg: " + bg.to_string() + ")" +
  140. // string istats = "COLs: " + COLORS.to_string() + ", CPs: " + COLOR_PAIRS.to_string();
  141. " colors: (csfg: " + fg.to_string() +
  142. " FR: " + f_red.to_string() +
  143. " FG: " + f_green.to_string() +
  144. " FB: " + f_blue.to_string() +
  145. "), (csbg: " + bg.to_string() +
  146. " BR: " + b_red.to_string() +
  147. " BG: " + b_green.to_string() +
  148. " BB: " + b_blue.to_string() +
  149. ")";
  150. }
  151.  
  152. // public string print_vars() {
  153. // return "red: " + red.to_string() + ", green: " + green.to_string() + ", blue: " + blue.to_string();
  154. // }
  155.  
  156. // public string pairs() {
  157. // return "fg: " + fg.to_string() + ", bg: " + bg.to_string();
  158. // }
  159. }
  160. }
Add Comment
Please, Sign In to add comment