rabbit 2.2.0 → 2.2.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.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/doc/_layouts/skeleton.html +1 -0
  3. data/doc/css/rabbit.css +2 -1
  4. data/doc/css/syntax.scss +67 -0
  5. data/doc/en/development.rd +31 -0
  6. data/doc/en/index.rd +0 -4
  7. data/doc/en/news.rd +55 -0
  8. data/doc/en/sample/markdown/rabbit.md +250 -246
  9. data/doc/en/usage/rabbit.rd +16 -0
  10. data/doc/ja/development.rd +30 -0
  11. data/doc/ja/index.rd +0 -5
  12. data/doc/ja/news.rd +55 -0
  13. data/doc/ja/sample/markdown/rabbit.md +251 -247
  14. data/doc/ja/usage/rabbit.rd +16 -1
  15. data/lib/rabbit/command/rabbit.rb +5 -1
  16. data/lib/rabbit/element/index-slide.rb +1 -1
  17. data/lib/rabbit/element/text-renderer.rb +7 -7
  18. data/lib/rabbit/gtk.rb +17 -10
  19. data/lib/rabbit/image/svg.rb +25 -23
  20. data/lib/rabbit/info-window.rb +1 -0
  21. data/lib/rabbit/parser/ext/rouge.rb +126 -0
  22. data/lib/rabbit/parser/markdown/converter.rb +4 -4
  23. data/lib/rabbit/parser/rd/ext/block-verbatim.rb +13 -1
  24. data/lib/rabbit/parser/rd/rt/rt2rabbit-lib.rb +3 -3
  25. data/lib/rabbit/parser/wiki/output.rb +9 -3
  26. data/lib/rabbit/progress.rb +16 -8
  27. data/lib/rabbit/renderer/display/drawing-area-base.rb +8 -8
  28. data/lib/rabbit/renderer/display/drawing-area-primitive.rb +3 -3
  29. data/lib/rabbit/renderer/display/graffiti.rb +39 -39
  30. data/lib/rabbit/renderer/display/progress.rb +3 -2
  31. data/lib/rabbit/renderer/display/search.rb +1 -1
  32. data/lib/rabbit/renderer/kernel.rb +1 -1
  33. data/lib/rabbit/search-window.rb +2 -2
  34. data/lib/rabbit/source/memory.rb +4 -0
  35. data/lib/rabbit/theme/background-image-toolkit/background-image-toolkit.rb +1 -1
  36. data/lib/rabbit/theme/color-circle-title-slide/color-circle-title-slide.rb +1 -1
  37. data/lib/rabbit/theme/default-block-quote/default-block-quote.rb +1 -1
  38. data/lib/rabbit/theme/image-slide-number/image-slide-number.rb +13 -2
  39. data/lib/rabbit/theme/lightning-talk-toolkit/lightning-talk-toolkit.rb +2 -2
  40. data/lib/rabbit/theme/slide-number/slide-number.rb +1 -1
  41. data/lib/rabbit/theme/syntax-highlighting/syntax-highlighting.rb +3 -0
  42. data/lib/rabbit/theme/table/table.rb +1 -1
  43. data/lib/rabbit/theme/title-on-image-toolkit/title-on-image-toolkit.rb +1 -1
  44. data/lib/rabbit/utils.rb +1 -1
  45. data/lib/rabbit/version.rb +2 -2
  46. data/po/en/rabbit.edit.po +107 -107
  47. data/po/fr/rabbit.edit.po +107 -107
  48. data/po/ja/rabbit.edit.po +107 -107
  49. data/rabbit.gemspec +3 -2
  50. data/sample/rabbit-en.rd +12 -0
  51. data/sample/rabbit.rd +12 -0
  52. data/test/parser/test-markdown.rb +9 -57
  53. metadata +20 -4
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2007-2015 Kouhei Sutou <kou@cozmixng.org>
1
+ # Copyright (C) 2007-2017 Kouhei Sutou <kou@cozmixng.org>
2
2
  #
3
3
  # This program is free software; you can redistribute it and/or modify
4
4
  # it under the terms of the GNU General Public License as published by
@@ -27,6 +27,7 @@ require "rabbit/parser/ext/blockdiag"
27
27
  require "rabbit/parser/ext/coderay"
28
28
  require "rabbit/parser/ext/emacs"
29
29
  require "rabbit/parser/ext/entity"
30
+ require "rabbit/parser/ext/rouge"
30
31
 
31
32
  module Rabbit
32
33
  module Parser
@@ -248,7 +249,7 @@ module Rabbit
248
249
  @table_head << @parent if @parent.parent.nil?
249
250
  header = TableHeader.new(item)
250
251
  def header.default_align
251
- Pango::Layout::ALIGN_CENTER
252
+ Pango::Alignment::CENTER
252
253
  end
253
254
  @parent << header
254
255
  end
@@ -282,7 +283,7 @@ module Rabbit
282
283
  result = nil
283
284
 
284
285
  if lang
285
- result = Ext::CodeRay.highlight(lang, contents, @canvas.logger)
286
+ result = Ext::Rouge.highlight(lang, contents, @canvas.logger)
286
287
  end
287
288
 
288
289
  if result
@@ -534,6 +535,11 @@ module Rabbit
534
535
  Ext::Emacs.highlight(source, logger, mode_line)
535
536
  end
536
537
 
538
+ def rouge(lang, source)
539
+ logger = @output.canvas.logger
540
+ Ext::Rouge.highlight(lang, source, logger)
541
+ end
542
+
537
543
  def tag(name, value=nil)
538
544
  if value
539
545
  CustomTag.new(name, @output.text(value))
@@ -4,51 +4,59 @@ module Rabbit
4
4
  class Progress
5
5
  attr_reader :window, :foreground, :background
6
6
  def initialize
7
- @window = Gtk::Window.new(:popup)
8
- @window.app_paintable = true
9
- @bar = Gtk::ProgressBar.new
10
- @bar.show_text = true
11
- @window.add(@bar)
12
7
  @foreground = nil
13
8
  @background = nil
14
9
  end
15
10
 
16
11
  def foreground=(color)
17
12
  @foreground = color
18
- setup_progress_color
19
13
  end
20
14
 
21
15
  def background=(color)
22
16
  @background = color
23
- setup_progress_color
24
17
  end
25
18
 
26
19
  def clear_color
27
20
  @foreground = nil
28
21
  @background = nil
29
- setup_progress_color
30
22
  end
31
23
 
32
24
  def start_progress(max, parent)
33
25
  return if max.zero?
26
+
27
+ @window = Gtk::Window.new(:popup)
34
28
  @window.transient_for = parent
29
+ @window.app_paintable = true
30
+ @bar = Gtk::ProgressBar.new
31
+ @bar.show_text = true
32
+ @window.add(@bar)
35
33
  @window.show_all
36
34
  @bar.fraction = @current = 0
37
35
  @max = max.to_f
36
+
37
+ setup_progress_color
38
38
  end
39
39
 
40
40
  def update_progress(i)
41
41
  return if @max.nil?
42
+
42
43
  @current = i
43
44
  @bar.fraction = @current / @max
44
45
  end
45
46
 
46
47
  def end_progress
47
48
  return if @max.nil?
49
+
48
50
  @current = @max
49
51
  @bar.fraction = @current / @max
50
52
  end
51
53
 
54
+ def hide
55
+ @window.destroy
56
+ @bar = nil
57
+ @window = nil
58
+ end
59
+
52
60
  private
53
61
  def setup_progress_color
54
62
  if Gtk.const_defined?(:CssProvider)
@@ -241,6 +241,13 @@ module Rabbit
241
241
  def post_init_gui
242
242
  end
243
243
 
244
+ def draw_slide(slide, simulation, &block)
245
+ super do |*args|
246
+ block.call(*args)
247
+ magnify {block.call(*args)} unless simulation
248
+ end
249
+ end
250
+
244
251
  private
245
252
  def add_widgets_to_container(container)
246
253
  @hbox = Gtk::Box.new(:horizontal)
@@ -288,7 +295,7 @@ module Rabbit
288
295
  context.paint
289
296
  end
290
297
 
291
- def draw(widget, context)
298
+ def draw(widget)
292
299
  reload_source unless @caching
293
300
 
294
301
  if whiteouting?
@@ -303,13 +310,6 @@ module Rabbit
303
310
  end
304
311
  end
305
312
 
306
- def draw_slide(slide, simulation, &block)
307
- super do |*args|
308
- block.call(*args)
309
- magnify {block.call(*args)} unless simulation
310
- end
311
- end
312
-
313
313
  def draw_current_slide_pixbuf(pixbuf)
314
314
  width, height = pixbuf.width, pixbuf.height
315
315
  x = @adjustment_x * width
@@ -140,21 +140,21 @@ module Rabbit
140
140
  if @area.class.signals.include?("draw")
141
141
  @area.signal_connect("draw") do |widget, context|
142
142
  init_context(context)
143
- draw(widget, context)
143
+ draw(widget)
144
144
  finish_renderer
145
145
  stop_events
146
146
  end
147
147
  else
148
148
  @area.signal_connect("expose_event") do |widget, event|
149
149
  init_renderer(@drawable)
150
- draw(widget, @drawable.create_cairo_context)
150
+ draw(widget)
151
151
  finish_renderer
152
152
  stop_events
153
153
  end
154
154
  end
155
155
  end
156
156
 
157
- def draw(widget, context)
157
+ def draw(widget)
158
158
  draw_current_slide
159
159
  end
160
160
 
@@ -25,6 +25,45 @@ module Rabbit
25
25
  graffiti_mode_action.active = false
26
26
  end
27
27
 
28
+ def graffiti_mode?
29
+ graffiti_mode_action.active?
30
+ end
31
+
32
+ def have_graffiti?
33
+ @graffiti.have_graffiti?
34
+ end
35
+
36
+ def can_undo_graffiti?
37
+ @graffiti.can_undo?
38
+ end
39
+
40
+ def toggle_graffiti_mode
41
+ if graffiti_mode?
42
+ update_cursor(:pencil)
43
+ else
44
+ restore_cursor(nil)
45
+ end
46
+ update_menu
47
+ end
48
+
49
+ def clear_graffiti
50
+ @graffiti.clear
51
+ Action.update_graffiti_action_status(@canvas)
52
+ @area.queue_draw
53
+ end
54
+
55
+ def undo_graffiti
56
+ @graffiti.undo
57
+ Action.update_graffiti_action_status(@canvas)
58
+ @area.queue_draw
59
+ end
60
+
61
+ def change_graffiti_color
62
+ @graffiti.change_color do
63
+ redraw
64
+ end
65
+ end
66
+
28
67
  private
29
68
  def init_graffiti
30
69
  @graffiti = Rabbit::Graffiti::Processor.new
@@ -75,45 +114,6 @@ module Rabbit
75
114
  def graffiti_mode_action
76
115
  @canvas.action("ToggleGraffitiMode")
77
116
  end
78
-
79
- def graffiti_mode?
80
- graffiti_mode_action.active?
81
- end
82
-
83
- def have_graffiti?
84
- @graffiti.have_graffiti?
85
- end
86
-
87
- def can_undo_graffiti?
88
- @graffiti.can_undo?
89
- end
90
-
91
- def toggle_graffiti_mode
92
- if graffiti_mode?
93
- update_cursor(:pencil)
94
- else
95
- restore_cursor(nil)
96
- end
97
- update_menu
98
- end
99
-
100
- def clear_graffiti
101
- @graffiti.clear
102
- Action.update_graffiti_action_status(@canvas)
103
- @area.queue_draw
104
- end
105
-
106
- def undo_graffiti
107
- @graffiti.undo
108
- Action.update_graffiti_action_status(@canvas)
109
- @area.queue_draw
110
- end
111
-
112
- def change_graffiti_color
113
- @graffiti.change_color do
114
- redraw
115
- end
116
- end
117
117
  end
118
118
  end
119
119
  end
@@ -27,6 +27,7 @@ module Rabbit
27
27
 
28
28
  def start_progress(max)
29
29
  return if max.zero?
30
+
30
31
  update_menu
31
32
  @progress.start_progress(max, @canvas.window)
32
33
  adjust_progress_window
@@ -40,7 +41,7 @@ module Rabbit
40
41
  def end_progress
41
42
  @progress.end_progress
42
43
  GLib::Timeout.add(100) do
43
- @progress.window.hide
44
+ @progress.hide
44
45
  update_menu
45
46
  false
46
47
  end
@@ -52,7 +53,7 @@ module Rabbit
52
53
  end
53
54
 
54
55
  def adjust_progress_window
55
- if @window
56
+ if @window and @progress.window
56
57
  Utils.move_to_top_left(@window, @progress.window)
57
58
  end
58
59
  end
@@ -24,7 +24,7 @@ module Rabbit
24
24
  end
25
25
 
26
26
  def stop_slide_search
27
- @search_window.hide
27
+ @search_window.destroy
28
28
  @search_window = nil
29
29
  end
30
30
 
@@ -160,7 +160,7 @@ module Rabbit
160
160
  text_height, flag_height)
161
161
  base_x = x + pole_width
162
162
  layout.width = flag_width * Pango::SCALE
163
- layout.alignment = Pango::Layout::ALIGN_CENTER
163
+ layout.alignment = Pango::Alignment::CENTER
164
164
  base_y = y
165
165
  if text_height < flag_height
166
166
  base_y += (flag_height - text_height) / 2
@@ -17,9 +17,9 @@ module Rabbit
17
17
  @window.show
18
18
  end
19
19
 
20
- def hide
20
+ def destroy
21
21
  send_focus_change(false)
22
- @window.hide
22
+ @window.destroy
23
23
  end
24
24
 
25
25
  def forward=(forward)
@@ -9,14 +9,18 @@ module Rabbit
9
9
  N_("[FILENAME_OR_NOT]")
10
10
  end
11
11
 
12
+ attr_accessor :extension
13
+
12
14
  def initialize(encoding, logger, name=nil)
13
15
  super(encoding, logger)
14
16
  if name
15
17
  file_source = File.new(encoding, logger, name)
16
18
  @original_source = file_source.read
17
19
  set_base(file_source.base)
20
+ @extension = extract_extension(name)
18
21
  else
19
22
  @original_source = ""
23
+ @extension = nil
20
24
  end
21
25
  reset
22
26
  end
@@ -44,7 +44,7 @@ def apply_background_image_property(element, options={})
44
44
  image.compile(canvas, _x, _y, _w, _h)
45
45
 
46
46
  case vertical_align
47
- when "center"
47
+ when "middle"
48
48
  adjust_height = ((_h - image.height - image.padding_bottom) / 2.0).ceil
49
49
  if _y + adjust_height > 0
50
50
  _y += adjust_height
@@ -9,7 +9,7 @@ match(TitleSlide, "*") do |elements|
9
9
  element.margin_left = canvas.width * 0.2
10
10
  element.margin_right = canvas.width * 0.05
11
11
  unless [Title, Subtitle, Author].find {|type| element.is_a?(type)}
12
- element.align = Pango::Layout::ALIGN_RIGHT
12
+ element.align = Pango::Alignment::RIGHT
13
13
  end
14
14
  end
15
15
  end
@@ -112,7 +112,7 @@ create_title_layout = lambda do |close_quote, block, canvas, x, y, w, h|
112
112
  title = Text.new(_("[cited from `%s']") % block.title)
113
113
  title.font(:size => @block_quote_title_font_size,
114
114
  :style => "italic")
115
- title.align = Pango::Layout::ALIGN_RIGHT
115
+ title.align = Pango::Alignment::RIGHT
116
116
  set_font_family(title)
117
117
  title_w = w + block.padding_left + block.padding_right
118
118
  if @block_quote_image_frame
@@ -29,11 +29,20 @@ end
29
29
  :draw_scaled_pixbuf => false,
30
30
  }
31
31
 
32
+ target_n_slides = nil
33
+
32
34
  match(Slide) do |slides|
33
35
  slides.delete_post_draw_proc_by_name(proc_name)
34
36
 
35
37
  break if @image_slide_number_uninstall
36
38
 
39
+ slides.each do |slide|
40
+ if slide["image-slide-number-last-slide"] == "true"
41
+ target_n_slides = slide.index + 1
42
+ break
43
+ end
44
+ end
45
+
37
46
  loader = ImageLoader.new(find_file(@image_slide_number_image))
38
47
  unless @image_slide_number_show_text
39
48
  start_loader = ImageLoader.new(find_file(@image_slide_number_start_image))
@@ -104,10 +113,12 @@ match(Slide) do |slides|
104
113
  end
105
114
  end
106
115
 
107
- if canvas.slide_size < 3
116
+ target_n_slides ||= canvas.slide_size
117
+ if target_n_slides < 3
108
118
  ratio = 1
109
119
  else
110
- ratio = (slide.index - 1.0) / (canvas.slide_size - 2.0)
120
+ ratio = (slide.index - 1.0) / (target_n_slides - 2.0)
121
+ ratio = 1 if ratio > 1
111
122
  end
112
123
  current_base_x = base_x + max_width * ratio
113
124
  loader.draw(canvas, current_base_x, base_y,
@@ -7,7 +7,7 @@
7
7
  @lightning_talk_contact_information_color ||= nil
8
8
  @lightning_talk_contact_information_font_family ||= @font_family
9
9
  @lightning_talk_as_large_as_possible ||= false
10
- @lightning_talk_wrap_mode ||= Pango::Layout::WRAP_WORD
10
+ @lightning_talk_wrap_mode ||= Pango::WrapMode::WORD
11
11
  if @lightning_talk_horizontal_centering.nil?
12
12
  @lightning_talk_horizontal_centering = true
13
13
  end
@@ -99,7 +99,7 @@ def setup_lightning_talk_slide(slide)
99
99
  :family => contact_information_family,
100
100
  }
101
101
  text.font(params)
102
- text.align = Pango::Layout::ALIGN_RIGHT
102
+ text.align = Pango::Alignment::RIGHT
103
103
  text.compile(canvas, x, y, w, h)
104
104
  text.layout.set_width(width * Pango::SCALE)
105
105
  text_x = margin_left
@@ -17,7 +17,7 @@ match(Slide) do |slides|
17
17
  unless simulation
18
18
  text = Text.new("#{slide.index}/#{canvas.slide_size - 1}")
19
19
  text.font @slide_number_props
20
- text.align = Pango::Layout::ALIGN_RIGHT
20
+ text.align = Pango::Alignment::RIGHT
21
21
  text.compile(canvas, x, y, w, h)
22
22
  layout = text.layout
23
23
  layout.set_width(w * Pango::SCALE)
@@ -68,6 +68,9 @@ theme_exit if @syntax_highlighting_uninstall
68
68
  :operator => {
69
69
  :color => "#ce5c00",
70
70
  },
71
+ :punctuation => {
72
+ :color => "#ce5c00",
73
+ },
71
74
  :ident => {
72
75
  # :color => "#f57900",
73
76
  },