textbringer 0.2.7 → 0.2.8

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 57386322dcb1c04c07b26ccc281b10dc86fff8e1
4
- data.tar.gz: 1dc85e31122a28561a9e47bb750b0602ec8619f7
2
+ SHA256:
3
+ metadata.gz: 7c42284ec820a6074794ed19f174f9ac393d5caa316f8408db5c5e43d5e87041
4
+ data.tar.gz: 95d805f94fbce11d2858c44a2fd275af3b8cdbfe6aed396a7807ac8543282d31
5
5
  SHA512:
6
- metadata.gz: 29a2f745379f31d22b838691f1f61ef8fd5502786cdd32a9fd698cd603b96ffb9d48c93091ed3186ee6c677d5c495bc9a51d6b358deb1a21da93b9ab179ded7f
7
- data.tar.gz: c9e02c3d2161d3f5a4d1fe52bee20c7bb66972fa9c716737e94fbdd56fc59db1b5bd3a22500a5d34d48629dfea8bf324f9d9b748c1c4645e803adc284a80787e
6
+ metadata.gz: a849309d4b2d77f350619fced9d26555598777fcde6f42d26439576c0933316a796027c9bc82fa427c4f698cbe581fb3b3428db8cd09ea2b7ecdaf0b6f690e47
7
+ data.tar.gz: 186933b3607392f5b28d32ab22df7324f960821fb8abb651403db281973e92bd1715d8d0e7841d0a1e1bc57ed50659f28095684e9c7a199e44bc118190aa4c23
data/.travis.yml CHANGED
@@ -4,21 +4,28 @@ matrix:
4
4
  - os: linux
5
5
  dist: trusty
6
6
  sudo: false
7
- rvm: 2.3.4
7
+ rvm: 2.3.5
8
8
  - os: linux
9
9
  dist: trusty
10
10
  sudo: false
11
- rvm: 2.4.1
11
+ rvm: 2.4.3
12
+ - os: linux
13
+ dist: trusty
14
+ sudo: false
15
+ rvm: 2.5.0
12
16
  - os: linux
13
17
  dist: trusty
14
18
  sudo: false
15
19
  rvm: ruby-head
16
20
  - os: osx
17
21
  osx_image: xcode8.2
18
- rvm: 2.3.3
22
+ rvm: 2.3.5
23
+ - os: osx
24
+ osx_image: xcode8.2
25
+ rvm: 2.4.3
19
26
  - os: osx
20
27
  osx_image: xcode8.2
21
- rvm: 2.4.0
28
+ rvm: 2.5.0
22
29
  - os: osx
23
30
  osx_image: xcode8.2
24
31
  rvm: ruby-head
@@ -27,6 +34,7 @@ matrix:
27
34
  - rvm: ruby-head
28
35
  fast_finish: true
29
36
  cache: bundler
37
+ before_install: gem update --system
30
38
  script:
31
39
  - if [ "$TRAVIS_OS_NAME" == "linux" ]; then
32
40
  xvfb-run bundle exec rake test;
data/CHANGES.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.2.8
2
+
3
+ * Highlight control characters.
4
+
1
5
  ## 0.2.7
2
6
 
3
7
  * Add isearch_yank_word_or_char.
data/appveyor.yml CHANGED
@@ -2,7 +2,6 @@
2
2
  clone_depth: 10
3
3
  install:
4
4
  - SET PATH=C:\Ruby%ruby_version%\bin;%PATH%
5
- - gem install bundler --no-document
6
5
  - bundle install
7
6
  - ps: '[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12'
8
7
  - ps: Invoke-WebRequest -Uri https://curl.haxx.se/ca/cacert.pem -OutFile C:\projects\textbringer\cacert.pem
@@ -13,7 +13,7 @@ module Textbringer
13
13
  global_mark_ring_max: 16,
14
14
  window_min_height: 4,
15
15
  syntax_highlight: true,
16
- highlight_buffer_size_limit: 102400,
16
+ highlight_buffer_size_limit: 1024,
17
17
  shell_file_name: ENV["SHELL"],
18
18
  shell_command_switch: "-c",
19
19
  grep_command: "grep -nH -e",
@@ -3,4 +3,5 @@
3
3
  module Textbringer
4
4
  Face.define :mode_line, reverse: true
5
5
  Face.define :link, foreground: "blue", bold: true
6
+ Face.define :control
6
7
  end
@@ -31,7 +31,12 @@ module Textbringer
31
31
  @map[key_sequence.first]
32
32
  else
33
33
  k, *ks = key_sequence
34
- @map[k]&.lookup(ks)
34
+ km = @map[k]
35
+ if km.is_a?(Keymap)
36
+ km.lookup(ks)
37
+ else
38
+ nil
39
+ end
35
40
  end
36
41
  end
37
42
 
@@ -6,6 +6,10 @@ module Textbringer
6
6
  include Commands
7
7
 
8
8
  @@mode_list = []
9
+
10
+ DEFAULT_SYNTAX_TABLE = {
11
+ control: /[\0-\t\v-\x1f\x7f\u{3000}]+/
12
+ }
9
13
 
10
14
  def self.list
11
15
  @@mode_list
@@ -61,7 +65,7 @@ module Textbringer
61
65
  Buffer.current.apply_mode(child)
62
66
  end
63
67
  @@mode_list.push(child)
64
- child.instance_variable_set(:@syntax_table, {})
68
+ child.instance_variable_set(:@syntax_table, DEFAULT_SYNTAX_TABLE.dup)
65
69
  end
66
70
 
67
71
  attr_reader :buffer
@@ -234,12 +234,12 @@ module Textbringer
234
234
  break
235
235
  end
236
236
  end
237
+ @buffer.looking_at?(/[ \t]*/)
238
+ base_indentation = @buffer.match_string(0).
239
+ gsub(/\t/, " " * @buffer[:tab_width]).size
237
240
  else
238
- @buffer.backward_line
241
+ base_indentation = 0
239
242
  end
240
- @buffer.looking_at?(/[ \t]*/)
241
- base_indentation = @buffer.match_string(0).
242
- gsub(/\t/, " " * @buffer[:tab_width]).size
243
243
  @buffer.goto_char(bol_pos)
244
244
  if line.nil? ||
245
245
  @buffer.looking_at?(/[ \t]*([}\])]|(end|else|elsif|when|rescue|ensure)\b)/)
@@ -311,7 +311,7 @@ module Textbringer
311
311
 
312
312
  HOOKS = Hash.new { |h, k| h[k] = [] }
313
313
 
314
- def add_hook(name, func)
314
+ def add_hook(name, func = Proc.new)
315
315
  HOOKS[name].unshift(func)
316
316
  end
317
317
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Textbringer
4
- VERSION = "0.2.7"
4
+ VERSION = "0.2.8"
5
5
  end
@@ -354,8 +354,7 @@ module Textbringer
354
354
  @highlight_on = {}
355
355
  @highlight_off = {}
356
356
  return if !@@has_colors || !CONFIG[:syntax_highlight] || @buffer.binary?
357
- syntax_table = @buffer.mode.syntax_table
358
- return if syntax_table.empty?
357
+ syntax_table = @buffer.mode.syntax_table || DEFAULT_SYNTAX_TABLE
359
358
  if @buffer.bytesize < CONFIG[:highlight_buffer_size_limit]
360
359
  base_pos = @buffer.point_min
361
360
  s = @buffer.to_s
@@ -364,6 +363,7 @@ module Textbringer
364
363
  len = columns * (lines - 1) / 2 * 3
365
364
  s = @buffer.substring(@buffer.point, @buffer.point + len).scrub("")
366
365
  end
366
+ return if !s.valid_encoding?
367
367
  re_str = syntax_table.map { |name, re|
368
368
  "(?<#{name}>#{re})"
369
369
  }.join("|")
@@ -677,6 +677,9 @@ module Textbringer
677
677
  end
678
678
 
679
679
  def escape(s)
680
+ if !s.valid_encoding?
681
+ s = s.b
682
+ end
680
683
  if @buffer.binary?
681
684
  s.gsub(/[\0-\b\v-\x1f\x7f]/) { |c|
682
685
  "^" + (c.ord ^ 0x40).chr
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: textbringer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.7
4
+ version: 0.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shugo Maeda
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-09-18 00:00:00.000000000 Z
11
+ date: 2018-05-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: curses
@@ -259,9 +259,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
259
259
  version: '0'
260
260
  requirements: []
261
261
  rubyforge_project:
262
- rubygems_version: 2.6.12
262
+ rubygems_version: 2.7.6
263
263
  signing_key:
264
264
  specification_version: 4
265
265
  summary: An Emacs-like text editor
266
266
  test_files: []
267
- has_rdoc: