mireru 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ac1e35de74d8cb4f531e906e8a63160ad994296f
4
- data.tar.gz: 65fd4237832ccb0b88f44a4a36e122d004192c38
3
+ metadata.gz: 4af6b308832832e50dca8694b82fa42b30620a10
4
+ data.tar.gz: ff89a104fb6b23923092d96215abfa0a0e96afe1
5
5
  SHA512:
6
- metadata.gz: 7b340d980af27c6f4733c83cf47981b078d98d2933359a10d322f07ca8aa9d44ae66fa39109046faf072528e3087ce3e11748fbe97e1428e809d379fa735a7a5
7
- data.tar.gz: 3f6e380aed270fa5243098c15c1ad14b28cbeee18fc6b0309719eedd5088e03800d265aed81321da53b19bfa3a8d2dd4049de74fce1fce353e75b462c5561545
6
+ metadata.gz: ebfdd64bdfd0b9fd2806cbf721952a3175c75982a45f4179649190e714d4525fa4f800713797a5b5f47097c3dfb772ec06c20dccf6922ab574f2264c14d77c7e
7
+ data.tar.gz: d8a4448a9adb13d360aa2f0dfc8ef326502911a3e831063d8f3ac6a90aa6c95ac7c574a0b7cb5182cd6727315eced4c3fcb88a9628c1710bf6465af7434d122d
data/NEWS.md ADDED
@@ -0,0 +1,12 @@
1
+ # NEWS
2
+
3
+ ## mireru 0.1.2: 2013-05-09
4
+
5
+ Improve Font handling.
6
+
7
+ ### Changes
8
+
9
+ * Improvements
10
+ * Use monospace font as default.
11
+ * Add change font keybind "f" (at random).
12
+ * Support font option.
data/README.md CHANGED
@@ -18,7 +18,11 @@ If no argument, then search current directory.
18
18
 
19
19
  ### Options
20
20
 
21
- -d, --deep: deep search
21
+ -d, --deep
22
+ deep search as "**/*"
23
+
24
+ -f, --font
25
+ set font such as "Monospace 16"
22
26
 
23
27
  ### Keybind
24
28
 
@@ -28,6 +28,8 @@ module Mireru
28
28
  exit(true)
29
29
  end
30
30
 
31
+ font = purge_option(arguments, /\A(-f|--font)\z/, true)
32
+
31
33
  files = files_from_arguments(arguments)
32
34
  file_container = ::Mireru::Container.new(files)
33
35
 
@@ -37,6 +39,7 @@ module Mireru
37
39
  end
38
40
 
39
41
  window = ::Mireru::Window.new
42
+ window.font = font if font
40
43
  window.add_container(file_container)
41
44
 
42
45
  Gtk.main
@@ -46,8 +49,7 @@ module Mireru
46
49
  def files_from_arguments(arguments)
47
50
  if arguments.empty?
48
51
  files = Dir.glob("*")
49
- elsif /\A(-d|--deep)\z/ =~ arguments[0]
50
- arguments.shift
52
+ elsif purge_option(arguments, /\A(-d|--deep)\z/)
51
53
  if arguments.empty?
52
54
  files = Dir.glob("**/*")
53
55
  else
@@ -73,12 +75,26 @@ module Mireru
73
75
  files
74
76
  end
75
77
 
78
+ def purge_option(arguments, regexp, has_value=false)
79
+ index = arguments.find_index {|arg| regexp =~ arg }
80
+ return false unless index
81
+ if has_value
82
+ arguments.delete_at(index) # flag
83
+ arguments.delete_at(index) # value
84
+ else
85
+ arguments.delete_at(index)
86
+ end
87
+ end
88
+
76
89
  def write_help_message
77
90
  message = <<-EOM
78
91
  #{USAGE}
79
92
  If no argument, then search current directory.
80
93
  Options:
81
- -d, --deep: deep search
94
+ -d, --deep
95
+ deep search as "**/*"
96
+ -f, --font
97
+ set font such as "Monospace 16"
82
98
  Keybind:
83
99
  n: next
84
100
  p: prev
@@ -112,7 +128,10 @@ Warning: file not found.
112
128
  #{USAGE}
113
129
  If no argument, then search current directory.
114
130
  Options:
115
- -d, --deep: deep search
131
+ -d, --deep
132
+ deep search as "**/*"
133
+ -f, --font
134
+ set font such as "Monospace 16"
116
135
  EOM
117
136
  @logger.error(message)
118
137
  end
@@ -1,3 +1,3 @@
1
1
  module Mireru
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -26,6 +26,7 @@ module Mireru
26
26
  view.buffer.highlight_syntax = true
27
27
  view.buffer.highlight_matching_brackets = true
28
28
  view.editable = false
29
+ view.override_font(Pango::FontDescription.new("Monospace"))
29
30
  widget = view
30
31
  end
31
32
  widget
@@ -3,6 +3,7 @@ require "mireru/widget"
3
3
 
4
4
  module Mireru
5
5
  class Window < Gtk::Window
6
+ attr_accessor :font
6
7
  def initialize
7
8
  super
8
9
  @scroll = Gtk::ScrolledWindow.new
@@ -36,6 +37,10 @@ module Mireru
36
37
  if Mireru::Widget.image?(@file)
37
38
  pixbuf = Gdk::Pixbuf.new(@file, *self.size)
38
39
  @widget.pixbuf = pixbuf
40
+ elsif @widget.is_a?(Gtk::TextView)
41
+ font = @widget.pango_context.families.sample.name
42
+ @widget.override_font(Pango::FontDescription.new(font))
43
+ self.title = "#{File.basename(@file)} (#{font})"
39
44
  end
40
45
  when Gdk::Keyval::GDK_KEY_o
41
46
  if Mireru::Widget.image?(@file)
@@ -69,6 +74,7 @@ module Mireru
69
74
  @scroll.vadjustment.value = 0
70
75
  @scroll.each {|child| @scroll.remove(child) }
71
76
  @widget = Mireru::Widget.create(file, *self.size)
77
+ @widget.override_font(Pango::FontDescription.new(@font)) if @font
72
78
  if @widget.is_a?(Gtk::Scrollable)
73
79
  @scroll.add(@widget)
74
80
  else
@@ -88,4 +88,14 @@ class MireruTest < Test::Unit::TestCase
88
88
  files = @mireru.__send__(:files_from_arguments, arguments)
89
89
  assert_equal(files, arguments)
90
90
  end
91
+
92
+ def test_purge_option
93
+ arguments = %w(--deep -f ubuntu dir1 file1 dir2)
94
+ flag = @mireru.__send__(:purge_option, arguments, /\A(-d|--deep)\z/)
95
+ assert_not_nil(flag)
96
+ assert_equal(%w(-f ubuntu dir1 file1 dir2), arguments)
97
+ value = @mireru.__send__(:purge_option, arguments, /\A-f\z/, true)
98
+ assert_equal("ubuntu", value)
99
+ assert_equal(%w(dir1 file1 dir2), arguments)
100
+ end
91
101
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mireru
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masafumi Yokoyama
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-04-11 00:00:00.000000000 Z
11
+ date: 2013-05-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gtk3
@@ -121,6 +121,7 @@ files:
121
121
  - .travis.yml
122
122
  - Gemfile
123
123
  - LICENSE.txt
124
+ - NEWS.md
124
125
  - README.md
125
126
  - Rakefile
126
127
  - bin/mireru