canis 0.0.7 → 0.0.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
2
  SHA1:
3
- metadata.gz: f94ffa2e37387dc50fb96d5f40cbd6b97cd60143
4
- data.tar.gz: 2323ea61ad5c4403628a6932665aed0a5ab7901d
3
+ metadata.gz: d4779cdb032e8834979001fd88ebae06c9c1c3db
4
+ data.tar.gz: 7065221a532c59f322d51c4514ec48193d240988
5
5
  SHA512:
6
- metadata.gz: 981c442662ac2c991dde00187fa1dc2210c5ce3a901a3d0d249599c08b56effc13929c1ae14b373c91f828a28b50c5b8d4664c9e338b3a710bc3b8342fe1f1be
7
- data.tar.gz: 943dab012e46633bfe16fc35bab8dfad406abd700dae2bd4d97a44a22bff4ecfcd61e959cc99d552a1795a1c4e266300f412de3a177721b14bbe9693a1a451bf
6
+ metadata.gz: 8109f9043da601a306f3ebf12b1f5272853a8d6f9295cc649e26129063fdb3358d4619a0d8e255ada027dd0f4c0d10488c314b51cd7e7eec0c8132d0540de05e
7
+ data.tar.gz: bc1fd4348a75ddd4db70249715582aaa1f1b0d4b9f8b29613dfa45c5efbdd6c72c9a91b583c578dd210e1da196cfd7aa899f5b62b874c8c208c2e7bb45780e6a
data/CHANGES CHANGED
@@ -65,3 +65,7 @@ Built 0.0.2 but i did not release it.
65
65
  2014-09-02
66
66
  - for 0.0.7
67
67
  rdialog.rb introduced a syntax error while adding names to windows, had to yank 0.0.6
68
+
69
+ 2014-09-11
70
+ - for 0.0.8
71
+ fix in colorparser.rb : wrong default was picked, now sending in textpads color and attr
@@ -5,7 +5,7 @@
5
5
  # Author: jkepler http://github.com/mare-imbrium/canis/
6
6
  # Date: 07.11.11 - 12:31
7
7
  # Same as Ruby's License (http://www.ruby-lang.org/LICENSE.txt)
8
- # Last update: 2014-09-01 11:57
8
+ # Last update: 2014-09-11 19:51
9
9
  # ------------------------------------------------------------ #
10
10
  #
11
11
 
@@ -320,10 +320,12 @@ module Canis
320
320
  # parse array of Strings into array of Chunks (Chunklines)
321
321
  # @param [Array<String>] formatted text to be parsed into chunks
322
322
  # @return [Array<Abstractchunkline>] array of text in our native format (chunklines)
323
- def parse_text formatted_text
323
+ # 2014-09-11 - 19:48 added colorp and attr so that incorrect default is not picked
324
+ # object such as textpad can send in default, textdocument not does so.
325
+ def parse_text formatted_text, colorp=nil, attr=nil
324
326
  l = []
325
327
  formatted_text.each { |e|
326
- l << convert_to_chunk(e)
328
+ l << convert_to_chunk(e, colorp, attr)
327
329
  }
328
330
  return l
329
331
  end
@@ -4,7 +4,7 @@
4
4
  # Author: jkepler http://github.com/mare-imbrium/canis/
5
5
  # Date: 2011-12-11 - 12:58
6
6
  # License: Same as Ruby's License (http://www.ruby-lang.org/LICENSE.txt)
7
- # Last update: 2014-06-03 14:10
7
+ # Last update: 2014-09-11 19:09
8
8
  # ----------------------------------------------------------------------------- #
9
9
  #
10
10
  module Canis
@@ -84,6 +84,80 @@ module Canis
84
84
  bind_key([?\C-x, ?e], :edit_external)
85
85
 
86
86
  end # def
87
+ # adding here so that textpad can also use. Earlier in textarea only
88
+ # Test out with textarea too TODO
89
+ # 2014-09-03 - 12:49
90
+ def saveas name=nil, config={}
91
+ unless name
92
+ name = rb_gets "File to save as: "
93
+ return if name.nil? || name == ""
94
+ end
95
+ overwrite_if_exists = config[:overwrite_if_exists] || false
96
+ unless overwrite_if_exists
97
+ exists = File.exists? name
98
+ if exists # need to prompt
99
+ return unless rb_confirm("Overwrite existing file? ")
100
+ end
101
+ end
102
+ # if it has been set do not prompt. or ask only if value is :ask
103
+ # But this should only be if there is someformatting provided, that is there
104
+ # is a @document
105
+ l = @list
106
+ # the check for document is to see if it is some old widget like textarea that is calling this.
107
+ if @document
108
+ if config.key? :save_with_formatting
109
+ save_with_formatting = config[:save_with_formatting]
110
+ else
111
+ save_with_formatting = rb_confirm("Save with formatting?")
112
+ end
113
+ if save_with_formatting
114
+ l = @list
115
+ else
116
+ l = @document.native_text().map do |w| w.to_s ; end
117
+ end
118
+ end
119
+ #l = getvalue
120
+ File.open(name, "w"){ |f|
121
+ l.each { |line| f.puts line }
122
+ #l.each { |line| f.write line.gsub(/\r/,"\n") }
123
+ }
124
+ rb_puts "#{name} written."
125
+ end
126
+ # save content of textpad overwriting if name exists
127
+ def saveas! name=nil, config={}
128
+ config[:overwrite_if_exists] = true
129
+ saveas name, config
130
+ end
131
+
132
+ # Edit the content of the textpad using external editor defaulting to EDITOR.
133
+ # copied from textarea, modified for textpad and document, needs to be tested TODO
134
+ # This should not be allowed as a default, some objects may not want to allow it.
135
+ # It should be enabled, or programmer should bind it to a key
136
+ def edit_external
137
+ require 'canis/core/include/appmethods'
138
+ require 'tempfile'
139
+ f = Tempfile.new("canis")
140
+ l = self.text
141
+ l.each { |line| f.puts line }
142
+ fp = f.path
143
+ f.flush
144
+
145
+ editor = ENV['EDITOR'] || 'vi'
146
+ vimp = %x[which #{editor}].chomp
147
+ ret = shell_out "#{vimp} #{fp}"
148
+ if ret
149
+ lines = File.open(f,'r').readlines
150
+ if @document
151
+ @document.text = lines
152
+ @document.parse_required
153
+ self.text(@document)
154
+ # next line works
155
+ #self.text(lines, :content_type => :tmux)
156
+ else
157
+ set_content(lines)
158
+ end
159
+ end
160
+ end
87
161
  end
88
162
  end
89
163
  include Canis::ListBindings
@@ -4,7 +4,7 @@
4
4
  # Author: j kepler http://github.com/mare-imbrium/canis/
5
5
  # Date: 2014-06-25 - 12:52
6
6
  # License: MIT
7
- # Last update: 2014-07-08 13:11
7
+ # Last update: 2014-09-11 19:48
8
8
  # ----------------------------------------------------------------------------- #
9
9
  # textdocument.rb Copyright (C) 2012-2014 j kepler
10
10
 
@@ -26,7 +26,7 @@ module Canis
26
26
 
27
27
  # returns the native or transformed format of original content. +text+ gets transformed into
28
28
  # native text. The renderer knows how to display native_text.
29
- #attr_reader :native_text
29
+ # NOTE: native_text is currently Chunklines - chunks of text with information of color
30
30
  def native_text
31
31
  unless @native_text
32
32
  preprocess_text @text
@@ -35,6 +35,7 @@ module Canis
35
35
  end
36
36
  # specify a renderer if you do not want the DefaultRenderer to be installed.
37
37
  attr_accessor :renderer
38
+ # the source object using this document
38
39
  attr_reader :source
39
40
 
40
41
  def initialize hash
@@ -47,7 +48,7 @@ module Canis
47
48
  raise "textdoc recieves nil content_type in constructor" unless @content_type
48
49
  end
49
50
  # declare that transformation of entire content is required. Currently called by fire_dimension_changed event
50
- # of textpad.
51
+ # of textpad. NOTE: not called from event, now called in text()
51
52
  def parse_required
52
53
  @parse_required = true
53
54
  end
@@ -97,7 +98,8 @@ module Canis
97
98
  create_default_content_type_handler
98
99
  end
99
100
  @parse_required = false
100
- @native_text = @content_type_handler.parse_text formatted_text
101
+ # 2014-09-11 - 19:47 sending in color from here, otherwise the wrong default is picked. TEST
102
+ @native_text = @content_type_handler.parse_text formatted_text, @source.color_pair, @source.attr
101
103
  end
102
104
  # returns title of document
103
105
  def title
@@ -10,7 +10,7 @@
10
10
  # Author: jkepler http://github.com/mare-imbrium/mancurses/
11
11
  # Date: 2011-11-09 - 16:59
12
12
  # License: Same as Ruby's License (http://www.ruby-lang.org/LICENSE.txt)
13
- # Last update: 2014-08-27 20:54
13
+ # Last update: 2014-09-03 17:54
14
14
  #
15
15
  # == CHANGES
16
16
  # - changed @content to @list since all multirow widgets use that and so do utils etc
@@ -553,6 +553,7 @@ module Canis
553
553
 
554
554
  @document = val[0]
555
555
  @document.source ||= self
556
+ @document.parse_required # added 2014-09-03 - 17:54
556
557
  @list = @document.text
557
558
  when Array
558
559
  # This is the complex case which i would like to phase out.
@@ -596,6 +597,7 @@ module Canis
596
597
 
597
598
  @document = val
598
599
  @document.source ||= self
600
+ @document.parse_required # added 2014-09-03 - 17:54
599
601
  @list = @document.text
600
602
  end
601
603
  @_populate_needed = true
@@ -683,6 +685,8 @@ module Canis
683
685
  # NOTE there are some cases where document can return a nil since native_text has not been
684
686
  # calculated yet. Happens in back button of help. Earlier preprocess was done from +text+
685
687
  # not it is only done from +repaint+
688
+ # NOTE: native_text is currently Chunklines - chunks of text with information of color, whereas
689
+ # list contains whatever the user set, which can include markup for coloring (ansi/tmux).
686
690
  def _getarray
687
691
  if @document.nil?
688
692
  return @list
@@ -1,3 +1,3 @@
1
1
  module Canis
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: canis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - kepler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-02 00:00:00.000000000 Z
11
+ date: 2014-09-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler