diff options
Diffstat (limited to 'lib/sisu/v2/plaintext.rb')
-rw-r--r-- | lib/sisu/v2/plaintext.rb | 64 |
1 files changed, 37 insertions, 27 deletions
diff --git a/lib/sisu/v2/plaintext.rb b/lib/sisu/v2/plaintext.rb index 851da3f8..a57339f4 100644 --- a/lib/sisu/v2/plaintext.rb +++ b/lib/sisu/v2/plaintext.rb @@ -79,20 +79,31 @@ module SiSU_Plaintext end def read begin - @md=SiSU_Param::Parameters.new(@opt).get - @env=SiSU_Env::Info_env.new(@opt.fns) - path=@env.path.output_tell - tool=if @opt.cmd =~/[MVv]/; "#{@env.program.text_editor} #{path}/#{@md.fnb}/#{@md.fn[:plain]}" - else '' + md=SiSU_Param::Parameters.new(@opt).get + env=SiSU_Env::Info_env.new(@opt.fns) + unless @opt.cmd =~/q/ + path=env.path.output_tell + tool=(@opt.cmd =~/[MVv]/) \ + ? "#{env.program.text_editor} #{path}/#{md.fnb}/#{md.fn[:plain]}" \ + : @opt.fns + @opt.cmd=~/[MVvz]/ \ + ? SiSU_Screen::Ansi.new(@opt.cmd,'Plaintext',tool).green_hi_blue \ + : SiSU_Screen::Ansi.new(@opt.cmd,'Plaintext',tool).green_title_hi + SiSU_Screen::Ansi.new(@opt.cmd,@opt.fns,"#{path}/#{md.fnb}/#{md.fn[:plain]}").flow if @opt.cmd =~/[MV]/ end - tell=SiSU_Screen::Ansi.new(@opt.cmd,'Plaintext',tool) - tell.green_hi_blue unless @opt.cmd =~/q/ - tell=SiSU_Screen::Ansi.new(@opt.cmd,@opt.fns,"#{@env.path.output_tell}/#{@md.fnb}/#{@md.fn[:plain]}") - tell.flow if @opt.cmd =~/[MV]/ my_make=SiSU_Env::Create_file.new(@opt.cmd,@opt.fns) - @dal_array=SiSU_DAL::Source.new(@opt).get # dal file drawn here - SiSU_Plaintext::Source::Scroll.new(@dal_array,@md).songsheet - SiSU_Env::Info_skin.new(@md).select #watch + dal_array=SiSU_DAL::Source.new(@opt).get # dal file drawn here + wrap_width=if defined? md.make.plaintext_wrap \ + and md.make.plaintext_wrap + md.make.plaintext_wrap + elsif defined? env.plaintext_wrap \ + and env.plaintext_wrap + env.plaintext_wrap + else 78 + end + #wrap_width=(defined? md.make.plaintext_wrap) ? md.make.plaintext_wrap : 78 + SiSU_Plaintext::Source::Scroll.new(dal_array,md,wrap_width).songsheet + SiSU_Env::Info_skin.new(md).select #watch rescue; SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@opt.fns).error ensure end @@ -103,8 +114,8 @@ module SiSU_Plaintext require "#{SiSU_lib}/shared_txt" # shared_txt.rb include SiSU_text_utils @@endnotes={ :para=>[],:end=>[] } - def initialize(data,md) - @data,@md=data,md + def initialize(data,md,wrap_width) + @data,@md,@wrap_width=data,md,wrap_width @brace_url=SiSU_Viz::Skin.new.url_decoration @vz=SiSU_Env::Get_init.instance.skin @tab="\t" @@ -141,9 +152,9 @@ module SiSU_Plaintext end notes=@n.flatten notes.each do |e| - util=if e.to_s =~/^\[[\d*+]+\]:/; SiSU_text_utils::Wrap.new(e.to_s,78,4,1) - else SiSU_text_utils::Wrap.new(e.to_s,78,1,1) - end + util=(e.to_s =~/^\[[\d*+]+\]:/) \ + ? (SiSU_text_utils::Wrap.new(e.to_s,@wrap_width,4,1)) \ + : (SiSU_text_utils::Wrap.new(e.to_s,@wrap_width,1,1)) wrap=util.line_wrap if wrap =~ /^\s*[\d*+]+\s+.+?\s*\Z/m wrap.gsub!(/^(\s*)([\d*+]+)\s+(.+?)\s*\Z/m, <<GSUB @@ -166,7 +177,7 @@ GSUB array.each do |meta| tag,inf=meta.scan(/^.+?:\s|.+/) if tag and inf - util=SiSU_text_utils::Wrap.new(inf,78,15,1) + util=SiSU_text_utils::Wrap.new(inf,@wrap_width,15,1) txt=util.line_wrap @plaintext[:metadata] <<<<WOK @@ -220,22 +231,22 @@ WOK if dob.is=='para' if dob.indent =~/[1-9]/ util=if dob.bullet_ - SiSU_text_utils::Wrap.new("* #{dob.obj}",78,dob.indent.to_i*2) - else SiSU_text_utils::Wrap.new(dob.obj,78,dob.indent.to_i*2) + SiSU_text_utils::Wrap.new("* #{dob.obj}",@wrap_width,dob.indent.to_i*2) + else SiSU_text_utils::Wrap.new(dob.obj,@wrap_width,dob.indent.to_i*2) end else util=if dob.bullet_ - SiSU_text_utils::Wrap.new("* #{dob.obj}",78,0) - else SiSU_text_utils::Wrap.new(dob.obj,78,0) + SiSU_text_utils::Wrap.new("* #{dob.obj}",@wrap_width,0) + else SiSU_text_utils::Wrap.new(dob.obj,@wrap_width,0) end end - else util=SiSU_text_utils::Wrap.new(dob.obj,78,0) + else util=SiSU_text_utils::Wrap.new(dob.obj,@wrap_width,0) end util.line_wrap end if lv times=wrapped.length - times=78 if times > 78 + times=@wrap_width if times > @wrap_width @plaintext[:body] << case lv when 1; wrapped.upcase << @br << Px[:lv1]*times << @br when 2; wrapped.upcase << @br << Px[:lv2]*times << @br @@ -356,10 +367,9 @@ WOK content << plaintext[:head] content << plaintext[:body] content << @@endnotes[:end] if @@endnotes_ - content << "#{@br}#{divider*78}#{@br}" + content << "#{@br}#{divider*@wrap_width}#{@br}" content << plaintext[:metadata] - content << "#{@br}#{divider*78}#{@br}" if @md.stmp =~/\w+/ #not used? - content << plaintext[:owner_details] if @md.stmp =~/\w+/ #not used? + content << "#{@br}#{divider*@wrap_width}#{@br}" if @md.stmp =~/\w+/ #not used? content << plaintext[:tail] Output.new(content,@md).plaintext @@endnotes={ :para=>[],:end=>[] } |