nyle 0.6.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/.gitignore +2 -3
 - data/CHANGELOG.md +21 -0
 - data/Gemfile.lock +61 -0
 - data/README.md +2 -2
 - data/doc/.gitkeep +0 -0
 - data/lib/nyle.rb +53 -44
 - data/lib/nyle/frame.rb +18 -3
 - data/lib/nyle/screen.rb +5 -4
 - data/lib/nyle/version.rb +1 -1
 - data/nyle.gemspec +2 -2
 - data/samples/{nyle_block.rb → application/block.rb} +0 -1
 - data/samples/{nyle_clock.rb → application/clock.rb} +0 -1
 - data/samples/{nyle_falling.rb → application/falling.rb} +5 -7
 - data/samples/{nyle_flight.rb → application/flight.rb} +6 -9
 - data/samples/{nyle_sketch.rb → application/sketch.rb} +0 -1
 - data/samples/{nyle_sugar.rb → application/sugar.rb} +1 -1
 - data/samples/{nyle_tree.rb → application/tree.rb} +2 -3
 - data/samples/basic/color_chart.rb +316 -0
 - data/samples/{nyle_pixel.rb → basic/color_pixel.rb} +1 -1
 - data/samples/basic/draw_circle.rb +52 -0
 - data/samples/basic/draw_line.rb +82 -0
 - data/samples/basic/draw_rect.rb +58 -0
 - data/samples/{nyle_shape.rb → basic/draw_shape.rb} +70 -70
 - data/samples/basic/draw_text.rb +55 -0
 - data/samples/basic/image_click.rb +33 -0
 - data/samples/basic/image_rotate.rb +42 -0
 - data/samples/{nyle_rpg.rb → basic/image_rpg.rb} +15 -15
 - data/samples/basic/keyboard.rb +84 -0
 - data/samples/{nyle_walk_notrace.rb → basic/random_walk.rb} +3 -3
 - data/samples/{nyle_walk_trace.rb → basic/random_walk_trace.rb} +3 -3
 - data/samples/image/n_c_mogura.png +0 -0
 - data/samples/launcher.rb +125 -0
 - data/samples/tips/.gitkeep +0 -0
 - data/samples/tutorial/img.jpg +0 -0
 - data/samples/tutorial/tut_a10.rb +10 -0
 - data/samples/tutorial/tut_a20.rb +13 -0
 - data/samples/tutorial/tut_a30.rb +18 -0
 - data/samples/tutorial/tut_a40.rb +19 -0
 - data/samples/tutorial/tut_a45.rb +21 -0
 - data/samples/tutorial/tut_a50.rb +25 -0
 - data/samples/tutorial/tut_a60.rb +30 -0
 - data/samples/tutorial/tut_a70.rb +34 -0
 - data/samples/tutorial/tut_b10.rb +14 -0
 - data/samples/tutorial/tut_b20.rb +14 -0
 - data/samples/tutorial/tut_b30.rb +14 -0
 - data/samples/tutorial/tut_b40.rb +18 -0
 - metadata +42 -23
 - data/doc/Nyle_reference.pdf +0 -0
 - data/samples/image/n_b_river.gif +0 -0
 - data/samples/nyle_basics.rb +0 -69
 - data/samples/nyle_basics2.rb +0 -70
 - data/samples/nyle_click.rb +0 -34
 - data/samples/nyle_colors.rb +0 -315
 - data/samples/readme_samples.txt +0 -36
 
| 
         @@ -0,0 +1,84 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'nyle'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            class Screen < Nyle::Screen
         
     | 
| 
      
 4 
     | 
    
         
            +
              def initialize
         
     | 
| 
      
 5 
     | 
    
         
            +
                super(200, 200)
         
     | 
| 
      
 6 
     | 
    
         
            +
              end
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
              def draw
         
     | 
| 
      
 9 
     | 
    
         
            +
                stat = ""
         
     | 
| 
      
 10 
     | 
    
         
            +
                stat = "[ctrl]"      if Nyle.mask_control?
         
     | 
| 
      
 11 
     | 
    
         
            +
                stat = "[shift]"     if Nyle.mask_shift?
         
     | 
| 
      
 12 
     | 
    
         
            +
                stat = "[space]"     if Nyle.key_down?(KEY_space)
         
     | 
| 
      
 13 
     | 
    
         
            +
                stat = "[backspace]" if Nyle.key_down?(KEY_BackSpace)
         
     | 
| 
      
 14 
     | 
    
         
            +
                stat = "[tab]"       if Nyle.key_down?(KEY_Tab)
         
     | 
| 
      
 15 
     | 
    
         
            +
                stat = "[enter]"     if Nyle.key_down?(KEY_Return)
         
     | 
| 
      
 16 
     | 
    
         
            +
                stat = "[escape]"    if Nyle.key_down?(KEY_Escape)
         
     | 
| 
      
 17 
     | 
    
         
            +
                stat = "[left]"      if Nyle.key_down?(KEY_Left)
         
     | 
| 
      
 18 
     | 
    
         
            +
                stat = "[up]"        if Nyle.key_down?(KEY_Up)
         
     | 
| 
      
 19 
     | 
    
         
            +
                stat = "[down]"      if Nyle.key_down?(KEY_Right)
         
     | 
| 
      
 20 
     | 
    
         
            +
                stat = "[right]"     if Nyle.key_down?(KEY_Down)
         
     | 
| 
      
 21 
     | 
    
         
            +
                stat = "[insert]"    if Nyle.key_down?(KEY_Insert)
         
     | 
| 
      
 22 
     | 
    
         
            +
                stat = "[delete]"    if Nyle.key_down?(KEY_Delete)
         
     | 
| 
      
 23 
     | 
    
         
            +
                stat = "[home]"      if Nyle.key_down?(KEY_Home)
         
     | 
| 
      
 24 
     | 
    
         
            +
                stat = "[end]"       if Nyle.key_down?(KEY_End)
         
     | 
| 
      
 25 
     | 
    
         
            +
                stat = "[f1]"        if Nyle.key_down?(KEY_F1)
         
     | 
| 
      
 26 
     | 
    
         
            +
                stat = "[f2]"        if Nyle.key_down?(KEY_F2)
         
     | 
| 
      
 27 
     | 
    
         
            +
                stat = "[f3]"        if Nyle.key_down?(KEY_F3)
         
     | 
| 
      
 28 
     | 
    
         
            +
                stat = "[f4]"        if Nyle.key_down?(KEY_F4)
         
     | 
| 
      
 29 
     | 
    
         
            +
                stat = "[f5]"        if Nyle.key_down?(KEY_F5)
         
     | 
| 
      
 30 
     | 
    
         
            +
                stat = "[f6]"        if Nyle.key_down?(KEY_F6)
         
     | 
| 
      
 31 
     | 
    
         
            +
                stat = "[f7]"        if Nyle.key_down?(KEY_F7)
         
     | 
| 
      
 32 
     | 
    
         
            +
                stat = "[f8]"        if Nyle.key_down?(KEY_F8)
         
     | 
| 
      
 33 
     | 
    
         
            +
                stat = "[f9]"        if Nyle.key_down?(KEY_F9)
         
     | 
| 
      
 34 
     | 
    
         
            +
                stat = "[f10]"       if Nyle.key_down?(KEY_F10)
         
     | 
| 
      
 35 
     | 
    
         
            +
                stat = "[f11]"       if Nyle.key_down?(KEY_F11)
         
     | 
| 
      
 36 
     | 
    
         
            +
                stat = "[f12]"       if Nyle.key_down?(KEY_F12)
         
     | 
| 
      
 37 
     | 
    
         
            +
                stat = "[0]"         if Nyle.key_down?(KEY_0)
         
     | 
| 
      
 38 
     | 
    
         
            +
                stat = "[1]"         if Nyle.key_down?(KEY_1)
         
     | 
| 
      
 39 
     | 
    
         
            +
                stat = "[2]"         if Nyle.key_down?(KEY_2)
         
     | 
| 
      
 40 
     | 
    
         
            +
                stat = "[3]"         if Nyle.key_down?(KEY_3)
         
     | 
| 
      
 41 
     | 
    
         
            +
                stat = "[4]"         if Nyle.key_down?(KEY_4)
         
     | 
| 
      
 42 
     | 
    
         
            +
                stat = "[5]"         if Nyle.key_down?(KEY_5)
         
     | 
| 
      
 43 
     | 
    
         
            +
                stat = "[6]"         if Nyle.key_down?(KEY_6)
         
     | 
| 
      
 44 
     | 
    
         
            +
                stat = "[7]"         if Nyle.key_down?(KEY_7)
         
     | 
| 
      
 45 
     | 
    
         
            +
                stat = "[8]"         if Nyle.key_down?(KEY_8)
         
     | 
| 
      
 46 
     | 
    
         
            +
                stat = "[9]"         if Nyle.key_down?(KEY_9)
         
     | 
| 
      
 47 
     | 
    
         
            +
                stat = "[a/A]"       if Nyle.key_down?(KEY_A) or Nyle.key_down?(KEY_a)
         
     | 
| 
      
 48 
     | 
    
         
            +
                stat = "[b/B]"       if Nyle.key_down?(KEY_B) or Nyle.key_down?(KEY_b)
         
     | 
| 
      
 49 
     | 
    
         
            +
                stat = "[c/C]"       if Nyle.key_down?(KEY_C) or Nyle.key_down?(KEY_c)
         
     | 
| 
      
 50 
     | 
    
         
            +
                stat = "[d/D]"       if Nyle.key_down?(KEY_D) or Nyle.key_down?(KEY_d)
         
     | 
| 
      
 51 
     | 
    
         
            +
                stat = "[e/E]"       if Nyle.key_down?(KEY_E) or Nyle.key_down?(KEY_e)
         
     | 
| 
      
 52 
     | 
    
         
            +
                stat = "[f/F]"       if Nyle.key_down?(KEY_F) or Nyle.key_down?(KEY_f)
         
     | 
| 
      
 53 
     | 
    
         
            +
                stat = "[g/G]"       if Nyle.key_down?(KEY_G) or Nyle.key_down?(KEY_g)
         
     | 
| 
      
 54 
     | 
    
         
            +
                stat = "[h/H]"       if Nyle.key_down?(KEY_H) or Nyle.key_down?(KEY_h)
         
     | 
| 
      
 55 
     | 
    
         
            +
                stat = "[i/I]"       if Nyle.key_down?(KEY_I) or Nyle.key_down?(KEY_i)
         
     | 
| 
      
 56 
     | 
    
         
            +
                stat = "[j/J]"       if Nyle.key_down?(KEY_J) or Nyle.key_down?(KEY_j)
         
     | 
| 
      
 57 
     | 
    
         
            +
                stat = "[k/K]"       if Nyle.key_down?(KEY_K) or Nyle.key_down?(KEY_k)
         
     | 
| 
      
 58 
     | 
    
         
            +
                stat = "[l/L]"       if Nyle.key_down?(KEY_L) or Nyle.key_down?(KEY_l)
         
     | 
| 
      
 59 
     | 
    
         
            +
                stat = "[m/M]"       if Nyle.key_down?(KEY_M) or Nyle.key_down?(KEY_m)
         
     | 
| 
      
 60 
     | 
    
         
            +
                stat = "[n/N]"       if Nyle.key_down?(KEY_N) or Nyle.key_down?(KEY_n)
         
     | 
| 
      
 61 
     | 
    
         
            +
                stat = "[o/O]"       if Nyle.key_down?(KEY_O) or Nyle.key_down?(KEY_o)
         
     | 
| 
      
 62 
     | 
    
         
            +
                stat = "[p/P]"       if Nyle.key_down?(KEY_P) or Nyle.key_down?(KEY_p)
         
     | 
| 
      
 63 
     | 
    
         
            +
                stat = "[q/Q]"       if Nyle.key_down?(KEY_Q) or Nyle.key_down?(KEY_q)
         
     | 
| 
      
 64 
     | 
    
         
            +
                stat = "[r/R]"       if Nyle.key_down?(KEY_R) or Nyle.key_down?(KEY_r)
         
     | 
| 
      
 65 
     | 
    
         
            +
                stat = "[s/S]"       if Nyle.key_down?(KEY_S) or Nyle.key_down?(KEY_s)
         
     | 
| 
      
 66 
     | 
    
         
            +
                stat = "[t/T]"       if Nyle.key_down?(KEY_T) or Nyle.key_down?(KEY_t)
         
     | 
| 
      
 67 
     | 
    
         
            +
                stat = "[u/U]"       if Nyle.key_down?(KEY_U) or Nyle.key_down?(KEY_u)
         
     | 
| 
      
 68 
     | 
    
         
            +
                stat = "[v/V]"       if Nyle.key_down?(KEY_V) or Nyle.key_down?(KEY_v)
         
     | 
| 
      
 69 
     | 
    
         
            +
                stat = "[w/W]"       if Nyle.key_down?(KEY_W) or Nyle.key_down?(KEY_w)
         
     | 
| 
      
 70 
     | 
    
         
            +
                stat = "[x/X]"       if Nyle.key_down?(KEY_X) or Nyle.key_down?(KEY_x)
         
     | 
| 
      
 71 
     | 
    
         
            +
                stat = "[y/Y]"       if Nyle.key_down?(KEY_Y) or Nyle.key_down?(KEY_y)
         
     | 
| 
      
 72 
     | 
    
         
            +
                stat = "[z/Z]"       if Nyle.key_down?(KEY_Z) or Nyle.key_down?(KEY_z)
         
     | 
| 
      
 73 
     | 
    
         
            +
             
     | 
| 
      
 74 
     | 
    
         
            +
                Nyle.draw_text(10,  60, "Press any key!" , {size: 24})
         
     | 
| 
      
 75 
     | 
    
         
            +
                Nyle.draw_text(30, 100, stat, {size: 24, color: :FOREST_GREEN})
         
     | 
| 
      
 76 
     | 
    
         
            +
             
     | 
| 
      
 77 
     | 
    
         
            +
               #Nyle.quit if Nyle.key_press?(KEY_Escape)
         
     | 
| 
      
 78 
     | 
    
         
            +
              end
         
     | 
| 
      
 79 
     | 
    
         
            +
            end
         
     | 
| 
      
 80 
     | 
    
         
            +
             
     | 
| 
      
 81 
     | 
    
         
            +
             
     | 
| 
      
 82 
     | 
    
         
            +
            Screen.new.show_all
         
     | 
| 
      
 83 
     | 
    
         
            +
            Gtk.main
         
     | 
| 
      
 84 
     | 
    
         
            +
             
     | 
| 
         @@ -1,8 +1,7 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
             
     | 
| 
       2 
1 
     | 
    
         
             
            require 'nyle'
         
     | 
| 
       3 
2 
     | 
    
         | 
| 
       4 
3 
     | 
    
         
             
            class Walker
         
     | 
| 
       5 
     | 
    
         
            -
              RADIUS =  
     | 
| 
      
 4 
     | 
    
         
            +
              RADIUS = 4
         
     | 
| 
       6 
5 
     | 
    
         
             
              def initialize(max_x, max_y)
         
     | 
| 
       7 
6 
     | 
    
         
             
                @max_x = max_x
         
     | 
| 
       8 
7 
     | 
    
         
             
                @max_y = max_y
         
     | 
| 
         @@ -26,7 +25,7 @@ class Walker 
     | 
|
| 
       26 
25 
     | 
    
         
             
              end
         
     | 
| 
       27 
26 
     | 
    
         | 
| 
       28 
27 
     | 
    
         
             
              def draw
         
     | 
| 
       29 
     | 
    
         
            -
                Nyle.draw_circle(@x, @y, RADIUS, {color: : 
     | 
| 
      
 28 
     | 
    
         
            +
                Nyle.draw_circle(@x, @y, RADIUS, {color: :BLUE, fill: true})
         
     | 
| 
       30 
29 
     | 
    
         
             
              end
         
     | 
| 
       31 
30 
     | 
    
         
             
            end
         
     | 
| 
       32 
31 
     | 
    
         | 
| 
         @@ -49,6 +48,7 @@ class Screen < Nyle::Screen 
     | 
|
| 
       49 
48 
     | 
    
         | 
| 
       50 
49 
     | 
    
         
             
            end
         
     | 
| 
       51 
50 
     | 
    
         | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
       52 
52 
     | 
    
         
             
            Screen.new.show_all
         
     | 
| 
       53 
53 
     | 
    
         
             
            Gtk.main
         
     | 
| 
       54 
54 
     | 
    
         | 
| 
         @@ -1,8 +1,7 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
             
     | 
| 
       2 
1 
     | 
    
         
             
            require 'nyle'
         
     | 
| 
       3 
2 
     | 
    
         | 
| 
       4 
3 
     | 
    
         
             
            class Walker
         
     | 
| 
       5 
     | 
    
         
            -
              RADIUS =  
     | 
| 
      
 4 
     | 
    
         
            +
              RADIUS = 4
         
     | 
| 
       6 
5 
     | 
    
         
             
              def initialize(max_x, max_y)
         
     | 
| 
       7 
6 
     | 
    
         
             
                @max_x = max_x
         
     | 
| 
       8 
7 
     | 
    
         
             
                @max_y = max_y
         
     | 
| 
         @@ -26,7 +25,7 @@ class Walker 
     | 
|
| 
       26 
25 
     | 
    
         
             
              end
         
     | 
| 
       27 
26 
     | 
    
         | 
| 
       28 
27 
     | 
    
         
             
              def draw
         
     | 
| 
       29 
     | 
    
         
            -
                Nyle.draw_circle(@x, @y, RADIUS, {color: : 
     | 
| 
      
 28 
     | 
    
         
            +
                Nyle.draw_circle(@x, @y, RADIUS, {color: :BLUE, fill: true})
         
     | 
| 
       30 
29 
     | 
    
         
             
              end
         
     | 
| 
       31 
30 
     | 
    
         
             
            end
         
     | 
| 
       32 
31 
     | 
    
         | 
| 
         @@ -49,6 +48,7 @@ class Screen < Nyle::Screen 
     | 
|
| 
       49 
48 
     | 
    
         | 
| 
       50 
49 
     | 
    
         
             
            end
         
     | 
| 
       51 
50 
     | 
    
         | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
       52 
52 
     | 
    
         
             
            Screen.new.show_all
         
     | 
| 
       53 
53 
     | 
    
         
             
            Gtk.main
         
     | 
| 
       54 
54 
     | 
    
         | 
| 
         Binary file 
     | 
    
        data/samples/launcher.rb
    ADDED
    
    | 
         @@ -0,0 +1,125 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'gtk3'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module Samples
         
     | 
| 
      
 4 
     | 
    
         
            +
              class Launcher < Gtk::Window
         
     | 
| 
      
 5 
     | 
    
         
            +
                def initialize
         
     | 
| 
      
 6 
     | 
    
         
            +
                  super()
         
     | 
| 
      
 7 
     | 
    
         
            +
                  set_title('Nyle samples')
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
                  tree = create_tree
         
     | 
| 
      
 10 
     | 
    
         
            +
                  tree_window = Gtk::ScrolledWindow.new
         
     | 
| 
      
 11 
     | 
    
         
            +
                  tree_window.add(tree)
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
                  @text = create_text
         
     | 
| 
      
 14 
     | 
    
         
            +
                  text_window = Gtk::ScrolledWindow.new
         
     | 
| 
      
 15 
     | 
    
         
            +
                  text_window.set_shadow_type(:in)
         
     | 
| 
      
 16 
     | 
    
         
            +
                  text_window.add(@text)
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
                  hpaned = Gtk::Paned.new(:horizontal)
         
     | 
| 
      
 19 
     | 
    
         
            +
                  hpaned.add(tree_window, resize: true, shrink: false)
         
     | 
| 
      
 20 
     | 
    
         
            +
                  hpaned.add(text_window, resize: true, shrink: false)
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
                  self.add(hpaned)
         
     | 
| 
      
 23 
     | 
    
         
            +
                  self.set_size_request(640, 640)
         
     | 
| 
      
 24 
     | 
    
         
            +
                  self.signal_connect(:destroy) { Gtk.main_quit }
         
     | 
| 
      
 25 
     | 
    
         
            +
                end
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
                def create_tree
         
     | 
| 
      
 28 
     | 
    
         
            +
                  model = Gtk::TreeStore.new(String, String, String, Integer)
         
     | 
| 
      
 29 
     | 
    
         
            +
                  append_items(model, generate_source)
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
                  column = Gtk::TreeViewColumn.new
         
     | 
| 
      
 32 
     | 
    
         
            +
                  column.title = "Double click to run one at a time."
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
                  render_text = Gtk::CellRendererText.new
         
     | 
| 
      
 35 
     | 
    
         
            +
                  column.pack_start(render_text, true)
         
     | 
| 
      
 36 
     | 
    
         
            +
                  column.add_attribute(render_text,   'text',       0)
         
     | 
| 
      
 37 
     | 
    
         
            +
                  column.add_attribute(render_text,   'foreground', 2)
         
     | 
| 
      
 38 
     | 
    
         
            +
                  column.add_attribute(render_text,   'weight',     3)
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
                  tree_view = Gtk::TreeView.new
         
     | 
| 
      
 41 
     | 
    
         
            +
                  tree_view.set_model(model)
         
     | 
| 
      
 42 
     | 
    
         
            +
                  tree_view.append_column(column)
         
     | 
| 
      
 43 
     | 
    
         
            +
                  tree_view.expand_all
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
                  tree_view.signal_connect(:row_activated) do |tree_view, path, column|
         
     | 
| 
      
 46 
     | 
    
         
            +
                    row_activated_callback(tree_view.model, path)
         
     | 
| 
      
 47 
     | 
    
         
            +
                  end
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
      
 49 
     | 
    
         
            +
                  tree_view.selection.signal_connect(:changed) do |selection|
         
     | 
| 
      
 50 
     | 
    
         
            +
                    iter = selection.selected
         
     | 
| 
      
 51 
     | 
    
         
            +
                    load_file(iter.get_value(1)) if iter
         
     | 
| 
      
 52 
     | 
    
         
            +
                  end
         
     | 
| 
      
 53 
     | 
    
         
            +
                  tree_view
         
     | 
| 
      
 54 
     | 
    
         
            +
                end
         
     | 
| 
      
 55 
     | 
    
         
            +
             
     | 
| 
      
 56 
     | 
    
         
            +
                def create_text
         
     | 
| 
      
 57 
     | 
    
         
            +
                  text_view = Gtk::TextView.new
         
     | 
| 
      
 58 
     | 
    
         
            +
                  text_view.override_font(Pango::FontDescription.new('Monospace 10'))
         
     | 
| 
      
 59 
     | 
    
         
            +
                  text_view.set_wrap_mode(:none)
         
     | 
| 
      
 60 
     | 
    
         
            +
                  text_view.set_editable(false)
         
     | 
| 
      
 61 
     | 
    
         
            +
                  text_view.set_cursor_visible(false)
         
     | 
| 
      
 62 
     | 
    
         
            +
                  text_view.left_margin = 8
         
     | 
| 
      
 63 
     | 
    
         
            +
                  text_view
         
     | 
| 
      
 64 
     | 
    
         
            +
                end
         
     | 
| 
      
 65 
     | 
    
         
            +
             
     | 
| 
      
 66 
     | 
    
         
            +
                def generate_source
         
     | 
| 
      
 67 
     | 
    
         
            +
                  scripts = Dir.glob(File.join(File.dirname(__FILE__), '**/*.rb')).sort
         
     | 
| 
      
 68 
     | 
    
         
            +
                  index = []
         
     | 
| 
      
 69 
     | 
    
         
            +
                  scripts.each do |fn|
         
     | 
| 
      
 70 
     | 
    
         
            +
                    index += [[File.basename(fn), fn, File.dirname(fn)]] unless File.basename(fn) == File.basename(__FILE__)
         
     | 
| 
      
 71 
     | 
    
         
            +
                  end
         
     | 
| 
      
 72 
     | 
    
         
            +
                  index
         
     | 
| 
      
 73 
     | 
    
         
            +
                end
         
     | 
| 
      
 74 
     | 
    
         
            +
             
     | 
| 
      
 75 
     | 
    
         
            +
                def append_items(model, source)   # only 2 layers (dir/filename)
         
     | 
| 
      
 76 
     | 
    
         
            +
                  dir_iter = {}
         
     | 
| 
      
 77 
     | 
    
         
            +
                  source.each do |title, filename, dir|
         
     | 
| 
      
 78 
     | 
    
         
            +
                    if dir and !dir_iter.key?(dir)
         
     | 
| 
      
 79 
     | 
    
         
            +
                      iter = model.append(nil)
         
     | 
| 
      
 80 
     | 
    
         
            +
                      iter.set_value(0, " #{File.basename(dir)}")
         
     | 
| 
      
 81 
     | 
    
         
            +
                      dir_iter[dir] = iter
         
     | 
| 
      
 82 
     | 
    
         
            +
                    end
         
     | 
| 
      
 83 
     | 
    
         
            +
                    iter = model.append(dir_iter[dir])
         
     | 
| 
      
 84 
     | 
    
         
            +
                    iter.set_value(0, title)
         
     | 
| 
      
 85 
     | 
    
         
            +
                    iter.set_value(1, filename)      # full-path to load
         
     | 
| 
      
 86 
     | 
    
         
            +
                    iter.set_value(2, "darkgreen")   # color
         
     | 
| 
      
 87 
     | 
    
         
            +
                    iter.set_value(3, 600)           # bold
         
     | 
| 
      
 88 
     | 
    
         
            +
                  end
         
     | 
| 
      
 89 
     | 
    
         
            +
                end
         
     | 
| 
      
 90 
     | 
    
         
            +
             
     | 
| 
      
 91 
     | 
    
         
            +
                def row_activated_callback(model, path)
         
     | 
| 
      
 92 
     | 
    
         
            +
                  unless @running
         
     | 
| 
      
 93 
     | 
    
         
            +
                    begin
         
     | 
| 
      
 94 
     | 
    
         
            +
                      @running = true
         
     | 
| 
      
 95 
     | 
    
         
            +
                      lib = model.get_iter(path).get_value(1)
         
     | 
| 
      
 96 
     | 
    
         
            +
                      if lib
         
     | 
| 
      
 97 
     | 
    
         
            +
                        Dir.chdir(File.dirname(lib)) do
         
     | 
| 
      
 98 
     | 
    
         
            +
                          load(File.basename(lib), priv: true)
         
     | 
| 
      
 99 
     | 
    
         
            +
                        end
         
     | 
| 
      
 100 
     | 
    
         
            +
                      end
         
     | 
| 
      
 101 
     | 
    
         
            +
                    rescue Exception => e
         
     | 
| 
      
 102 
     | 
    
         
            +
                      puts $!
         
     | 
| 
      
 103 
     | 
    
         
            +
                    ensure
         
     | 
| 
      
 104 
     | 
    
         
            +
                      @running = false
         
     | 
| 
      
 105 
     | 
    
         
            +
                    end
         
     | 
| 
      
 106 
     | 
    
         
            +
                  end
         
     | 
| 
      
 107 
     | 
    
         
            +
                end
         
     | 
| 
      
 108 
     | 
    
         
            +
             
     | 
| 
      
 109 
     | 
    
         
            +
                def load_file(filename)1
         
     | 
| 
      
 110 
     | 
    
         
            +
                  unless @running
         
     | 
| 
      
 111 
     | 
    
         
            +
                  @text.buffer.delete(*@text.buffer.bounds)
         
     | 
| 
      
 112 
     | 
    
         
            +
                  if filename
         
     | 
| 
      
 113 
     | 
    
         
            +
                    lines = File.read(filename)
         
     | 
| 
      
 114 
     | 
    
         
            +
                    start = @text.buffer.get_iter_at(offset: 0)
         
     | 
| 
      
 115 
     | 
    
         
            +
                    @text.buffer.insert(start, lines)
         
     | 
| 
      
 116 
     | 
    
         
            +
                  end
         
     | 
| 
      
 117 
     | 
    
         
            +
                  end
         
     | 
| 
      
 118 
     | 
    
         
            +
                end
         
     | 
| 
      
 119 
     | 
    
         
            +
              end
         
     | 
| 
      
 120 
     | 
    
         
            +
            end
         
     | 
| 
      
 121 
     | 
    
         
            +
             
     | 
| 
      
 122 
     | 
    
         
            +
             
     | 
| 
      
 123 
     | 
    
         
            +
            Samples::Launcher.new.show_all
         
     | 
| 
      
 124 
     | 
    
         
            +
            Gtk.main
         
     | 
| 
      
 125 
     | 
    
         
            +
             
     | 
| 
         
            File without changes
         
     | 
| 
         Binary file 
     | 
| 
         @@ -0,0 +1,18 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'nyle'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            class Screen < Nyle::Screen
         
     | 
| 
      
 4 
     | 
    
         
            +
              def initialize
         
     | 
| 
      
 5 
     | 
    
         
            +
                super
         
     | 
| 
      
 6 
     | 
    
         
            +
              end
         
     | 
| 
      
 7 
     | 
    
         
            +
              def draw
         
     | 
| 
      
 8 
     | 
    
         
            +
                Nyle.draw_circle(320,      240,      50)
         
     | 
| 
      
 9 
     | 
    
         
            +
                Nyle.draw_circle(320 - 20, 240 - 10,  8, {fill: true})
         
     | 
| 
      
 10 
     | 
    
         
            +
                Nyle.draw_circle(320 + 20, 240 - 10,  8, {fill: true})
         
     | 
| 
      
 11 
     | 
    
         
            +
                Nyle.draw_circle(320 - 18, 240 - 10,  2, {fill: true, color: :WHITE})
         
     | 
| 
      
 12 
     | 
    
         
            +
                Nyle.draw_circle(320 + 18, 240 - 10,  2, {fill: true, color: :WHITE})
         
     | 
| 
      
 13 
     | 
    
         
            +
                Nyle.draw_circle(320,      240 + 25,  5)
         
     | 
| 
      
 14 
     | 
    
         
            +
              end
         
     | 
| 
      
 15 
     | 
    
         
            +
            end
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
            Screen.new.show_all
         
     | 
| 
      
 18 
     | 
    
         
            +
            Gtk.main
         
     | 
| 
         @@ -0,0 +1,19 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'nyle'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            class Screen < Nyle::Screen
         
     | 
| 
      
 4 
     | 
    
         
            +
              def initialize
         
     | 
| 
      
 5 
     | 
    
         
            +
                super
         
     | 
| 
      
 6 
     | 
    
         
            +
              end
         
     | 
| 
      
 7 
     | 
    
         
            +
              def draw
         
     | 
| 
      
 8 
     | 
    
         
            +
                Nyle.draw_circle(320,      240,      50)
         
     | 
| 
      
 9 
     | 
    
         
            +
                Nyle.draw_circle(320,      240,      50, {fill: true, color: :PEACH_YELLOW})
         
     | 
| 
      
 10 
     | 
    
         
            +
                Nyle.draw_circle(320 - 20, 240 - 10,  8, {fill: true})
         
     | 
| 
      
 11 
     | 
    
         
            +
                Nyle.draw_circle(320 + 20, 240 - 10,  8, {fill: true})
         
     | 
| 
      
 12 
     | 
    
         
            +
                Nyle.draw_circle(320 - 18, 240 - 10,  2, {fill: true, color: :WHITE})
         
     | 
| 
      
 13 
     | 
    
         
            +
                Nyle.draw_circle(320 + 18, 240 - 10,  2, {fill: true, color: :WHITE})
         
     | 
| 
      
 14 
     | 
    
         
            +
                Nyle.draw_circle(320,      240 + 25,  5)
         
     | 
| 
      
 15 
     | 
    
         
            +
              end
         
     | 
| 
      
 16 
     | 
    
         
            +
            end
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
            Screen.new.show_all
         
     | 
| 
      
 19 
     | 
    
         
            +
            Gtk.main
         
     | 
| 
         @@ -0,0 +1,21 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'nyle'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            class Screen < Nyle::Screen
         
     | 
| 
      
 4 
     | 
    
         
            +
              def initialize
         
     | 
| 
      
 5 
     | 
    
         
            +
                super
         
     | 
| 
      
 6 
     | 
    
         
            +
                @x = 320
         
     | 
| 
      
 7 
     | 
    
         
            +
                @y = 240
         
     | 
| 
      
 8 
     | 
    
         
            +
              end
         
     | 
| 
      
 9 
     | 
    
         
            +
              def draw
         
     | 
| 
      
 10 
     | 
    
         
            +
                Nyle.draw_circle(@x,      @y,      50)
         
     | 
| 
      
 11 
     | 
    
         
            +
                Nyle.draw_circle(@x,      @y,      50, {fill: true, color: :PEACH_YELLOW})
         
     | 
| 
      
 12 
     | 
    
         
            +
                Nyle.draw_circle(@x - 20, @y - 10,  8, {fill: true})
         
     | 
| 
      
 13 
     | 
    
         
            +
                Nyle.draw_circle(@x + 20, @y - 10,  8, {fill: true})
         
     | 
| 
      
 14 
     | 
    
         
            +
                Nyle.draw_circle(@x - 18, @y - 10,  2, {fill: true, color: :WHITE})
         
     | 
| 
      
 15 
     | 
    
         
            +
                Nyle.draw_circle(@x + 18, @y - 10,  2, {fill: true, color: :WHITE})
         
     | 
| 
      
 16 
     | 
    
         
            +
                Nyle.draw_circle(@x,      @y + 25,  5)
         
     | 
| 
      
 17 
     | 
    
         
            +
              end
         
     | 
| 
      
 18 
     | 
    
         
            +
            end
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
            Screen.new.show_all
         
     | 
| 
      
 21 
     | 
    
         
            +
            Gtk.main
         
     | 
| 
         @@ -0,0 +1,25 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'nyle'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            class Screen < Nyle::Screen
         
     | 
| 
      
 4 
     | 
    
         
            +
              def initialize
         
     | 
| 
      
 5 
     | 
    
         
            +
                super
         
     | 
| 
      
 6 
     | 
    
         
            +
                @x = 320
         
     | 
| 
      
 7 
     | 
    
         
            +
                @y = 240
         
     | 
| 
      
 8 
     | 
    
         
            +
              end
         
     | 
| 
      
 9 
     | 
    
         
            +
              def draw
         
     | 
| 
      
 10 
     | 
    
         
            +
                Nyle.draw_circle(@x,      @y,      50)
         
     | 
| 
      
 11 
     | 
    
         
            +
                Nyle.draw_circle(@x,      @y,      50, {fill: true, color: :PEACH_YELLOW})
         
     | 
| 
      
 12 
     | 
    
         
            +
                Nyle.draw_circle(@x - 20, @y - 10,  8, {fill: true})
         
     | 
| 
      
 13 
     | 
    
         
            +
                Nyle.draw_circle(@x + 20, @y - 10,  8, {fill: true})
         
     | 
| 
      
 14 
     | 
    
         
            +
                Nyle.draw_circle(@x - 18, @y - 10,  2, {fill: true, color: :WHITE})
         
     | 
| 
      
 15 
     | 
    
         
            +
                Nyle.draw_circle(@x + 18, @y - 10,  2, {fill: true, color: :WHITE})
         
     | 
| 
      
 16 
     | 
    
         
            +
                Nyle.draw_circle(@x,      @y + 25,  5)
         
     | 
| 
      
 17 
     | 
    
         
            +
              end
         
     | 
| 
      
 18 
     | 
    
         
            +
              def update
         
     | 
| 
      
 19 
     | 
    
         
            +
                @x += Nyle.cursor_x
         
     | 
| 
      
 20 
     | 
    
         
            +
                @y += Nyle.cursor_y
         
     | 
| 
      
 21 
     | 
    
         
            +
              end
         
     | 
| 
      
 22 
     | 
    
         
            +
            end
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
            Screen.new.show_all
         
     | 
| 
      
 25 
     | 
    
         
            +
            Gtk.main
         
     | 
| 
         @@ -0,0 +1,30 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'nyle'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            class Screen < Nyle::Screen
         
     | 
| 
      
 4 
     | 
    
         
            +
              def initialize
         
     | 
| 
      
 5 
     | 
    
         
            +
                super
         
     | 
| 
      
 6 
     | 
    
         
            +
                @x = 320
         
     | 
| 
      
 7 
     | 
    
         
            +
                @y = 240
         
     | 
| 
      
 8 
     | 
    
         
            +
              end
         
     | 
| 
      
 9 
     | 
    
         
            +
              def draw
         
     | 
| 
      
 10 
     | 
    
         
            +
                Nyle.draw_circle(@x,      @y,      50)
         
     | 
| 
      
 11 
     | 
    
         
            +
                Nyle.draw_circle(@x,      @y,      50, {fill: true, color: :PEACH_YELLOW})
         
     | 
| 
      
 12 
     | 
    
         
            +
                Nyle.draw_circle(@x - 20, @y - 10,  8, {fill: true})
         
     | 
| 
      
 13 
     | 
    
         
            +
                Nyle.draw_circle(@x + 20, @y - 10,  8, {fill: true})
         
     | 
| 
      
 14 
     | 
    
         
            +
                Nyle.draw_circle(@x - 18, @y - 10,  2, {fill: true, color: :WHITE})
         
     | 
| 
      
 15 
     | 
    
         
            +
                Nyle.draw_circle(@x + 18, @y - 10,  2, {fill: true, color: :WHITE})
         
     | 
| 
      
 16 
     | 
    
         
            +
                Nyle.draw_circle(@x,      @y + 25,  5)
         
     | 
| 
      
 17 
     | 
    
         
            +
              end
         
     | 
| 
      
 18 
     | 
    
         
            +
              def update
         
     | 
| 
      
 19 
     | 
    
         
            +
                if Nyle.mask_shift?
         
     | 
| 
      
 20 
     | 
    
         
            +
                  @x += Nyle.cursor_x * 5
         
     | 
| 
      
 21 
     | 
    
         
            +
                  @y += Nyle.cursor_y * 5
         
     | 
| 
      
 22 
     | 
    
         
            +
                else
         
     | 
| 
      
 23 
     | 
    
         
            +
                  @x += Nyle.cursor_x
         
     | 
| 
      
 24 
     | 
    
         
            +
                  @y += Nyle.cursor_y
         
     | 
| 
      
 25 
     | 
    
         
            +
                end
         
     | 
| 
      
 26 
     | 
    
         
            +
              end
         
     | 
| 
      
 27 
     | 
    
         
            +
            end
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
            Screen.new.show_all
         
     | 
| 
      
 30 
     | 
    
         
            +
            Gtk.main
         
     | 
| 
         @@ -0,0 +1,34 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'nyle'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            class Screen < Nyle::Screen
         
     | 
| 
      
 4 
     | 
    
         
            +
              def initialize
         
     | 
| 
      
 5 
     | 
    
         
            +
                super
         
     | 
| 
      
 6 
     | 
    
         
            +
                @x = 320
         
     | 
| 
      
 7 
     | 
    
         
            +
                @y = 240
         
     | 
| 
      
 8 
     | 
    
         
            +
              end
         
     | 
| 
      
 9 
     | 
    
         
            +
              def draw
         
     | 
| 
      
 10 
     | 
    
         
            +
                Nyle.draw_circle(@x,      @y,      50)
         
     | 
| 
      
 11 
     | 
    
         
            +
                Nyle.draw_circle(@x,      @y,      50, {fill: true, color: :PEACH_YELLOW})
         
     | 
| 
      
 12 
     | 
    
         
            +
                Nyle.draw_circle(@x - 20, @y - 10,  8, {fill: true})
         
     | 
| 
      
 13 
     | 
    
         
            +
                Nyle.draw_circle(@x + 20, @y - 10,  8, {fill: true})
         
     | 
| 
      
 14 
     | 
    
         
            +
                Nyle.draw_circle(@x - 18, @y - 10,  2, {fill: true, color: :WHITE})
         
     | 
| 
      
 15 
     | 
    
         
            +
                Nyle.draw_circle(@x + 18, @y - 10,  2, {fill: true, color: :WHITE})
         
     | 
| 
      
 16 
     | 
    
         
            +
                Nyle.draw_circle(@x,      @y + 25,  5)
         
     | 
| 
      
 17 
     | 
    
         
            +
              end
         
     | 
| 
      
 18 
     | 
    
         
            +
              def update
         
     | 
| 
      
 19 
     | 
    
         
            +
                if Nyle.mask_shift?
         
     | 
| 
      
 20 
     | 
    
         
            +
                  @x += Nyle.cursor_x * 5
         
     | 
| 
      
 21 
     | 
    
         
            +
                  @y += Nyle.cursor_y * 5
         
     | 
| 
      
 22 
     | 
    
         
            +
                else
         
     | 
| 
      
 23 
     | 
    
         
            +
                  @x += Nyle.cursor_x
         
     | 
| 
      
 24 
     | 
    
         
            +
                  @y += Nyle.cursor_y
         
     | 
| 
      
 25 
     | 
    
         
            +
                end
         
     | 
| 
      
 26 
     | 
    
         
            +
                @x = Nyle.screen_width  + 50 if @x < 0                  - 50
         
     | 
| 
      
 27 
     | 
    
         
            +
                @x = 0                  - 50 if @x > Nyle.screen_width  + 50
         
     | 
| 
      
 28 
     | 
    
         
            +
                @y = Nyle.screen_height + 50 if @y < 0                  - 50
         
     | 
| 
      
 29 
     | 
    
         
            +
                @y = 0                  - 50 if @y > Nyle.screen_height + 50
         
     | 
| 
      
 30 
     | 
    
         
            +
              end
         
     | 
| 
      
 31 
     | 
    
         
            +
            end
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
            Screen.new.show_all
         
     | 
| 
      
 34 
     | 
    
         
            +
            Gtk.main
         
     |