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.
 
 
 
 
 
 

85 line
1.9 KiB

  1. /* $Id$ */ /** \page libcaca-ruby-api Libcaca Ruby API
  2. The classes available for libcaca are :
  3. \li \b Caca::Display
  4. \li \b Caca::Event
  5. \li \b Caca::Event::Key
  6. \li \b Caca::Event::Key::Press
  7. \li \b Caca::Event::Key::Release
  8. \li \b Caca::Event::Mouse
  9. \li \b Caca::Event::Mouse::Press
  10. \li \b Caca::Event::Mouse::Release
  11. \li \b Caca::Event::Mouse::Motion
  12. \li \b Caca::Event::Resize
  13. \li \b Caca::Event::Quit
  14. \code
  15. $ irb -rcaca
  16. irb(main):001:0> class Object
  17. irb(main):002:1> def Object.my_instance_methods
  18. irb(main):003:2> instance_methods.sort - ancestors[1].instance_methods
  19. irb(main):004:2> end
  20. irb(main):005:1> def Object.my_methods
  21. irb(main):006:2> methods.sort - ancestors[1].methods
  22. irb(main):007:2> end
  23. irb(main):008:1> end
  24. irb(main):009:0> Caca::Display.my_instance_methods
  25. => ["get_event", "height", "mouse=", "mouse_x", "mouse_y", "refresh",
  26. "set_mouse", "set_time", "set_title", "time", "time=", "title=", "width"]
  27. \endcode
  28. \code
  29. irb(main):010:0> Caca::Event.constants
  30. => ["Key", "Quit", "TYPE", "Mouse", "Resize"]
  31. \endcode
  32. \code
  33. irb(main):011:0> Caca::Event.my_instance_methods
  34. => ["quit?"]
  35. \endcode
  36. \code
  37. irb(main):012:0> Caca::Event::Key.my_instance_methods
  38. => ["ch", "utf32", "utf8"]
  39. \endcode
  40. \code
  41. irb(main):013:0> Caca::Event::Mouse.my_instance_methods
  42. => ["button", "x", "y"]
  43. \endcode
  44. \code
  45. irb(main):014:0> Caca::Event::Resize.my_instance_methods
  46. => ["w", "h"]
  47. \endcode
  48. \section Samples
  49. \code
  50. require 'caca'
  51. c = Cucul::Canvas.new(20,10)
  52. c.put_str(2, 3, "plop!")
  53. c.draw_thin_polyline([[0,0], [0,2], [5,2], [0,0]])
  54. d = Caca::Display.new(c)
  55. d.title = "Test !"
  56. d.refresh
  57. # Redefine Event::Key#quit? so that q, Q, and Esc become exit keys
  58. module Caca
  59. class Event::Key
  60. def quit?
  61. "qQ^[".split('').member?(@ch.chr)
  62. end
  63. end
  64. end
  65. while((e = d.get_event(Caca::Event, -1)) && ! e.quit?)
  66. p e
  67. d.refresh
  68. end
  69. \endcode
  70. */