From 6998914adc0bacd41398ab0ed3d2f0bf5af74358 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Fri, 28 Dec 2012 12:18:24 -0500 Subject: v4 v3: debug (internal code use), color markers for line number & file name * colored location markers to show when line passed within running code --- data/doc/sisu/CHANGELOG_v3 | 3 ++ data/doc/sisu/CHANGELOG_v4 | 3 ++ lib/sisu/v3/constants.rb | 21 +++++++++ lib/sisu/v3/debug.rb | 109 +++++++++++++++++++++++++++++++++++++++++++++ lib/sisu/v3/hub.rb | 1 + lib/sisu/v4/constants.rb | 27 +++++++++++ lib/sisu/v4/debug.rb | 109 +++++++++++++++++++++++++++++++++++++++++++++ lib/sisu/v4/hub.rb | 1 + 8 files changed, 274 insertions(+) create mode 100644 lib/sisu/v3/debug.rb create mode 100644 lib/sisu/v4/debug.rb diff --git a/data/doc/sisu/CHANGELOG_v3 b/data/doc/sisu/CHANGELOG_v3 index 9a9d5c30..654ddb4c 100644 --- a/data/doc/sisu/CHANGELOG_v3 +++ b/data/doc/sisu/CHANGELOG_v3 @@ -36,6 +36,9 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_3.3.4.orig.tar.xz sisu_3.3.4-1.dsc sisu_3.3.4-1.debian.tar.gz +* v3: debug (internal code use), color markers for line number & file name + (colored location markers to show when line passed within running code) + %% 3.3.3.orig.tar.xz (2012-10-03:40/3) http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=shortlog;h=refs/tags/sisu_3.3.3 http://www.jus.uio.no/sisu/pkg/src/sisu_3.3.3.orig.tar.xz diff --git a/data/doc/sisu/CHANGELOG_v4 b/data/doc/sisu/CHANGELOG_v4 index 16f6532d..51922303 100644 --- a/data/doc/sisu/CHANGELOG_v4 +++ b/data/doc/sisu/CHANGELOG_v4 @@ -25,6 +25,9 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_4.0.1.orig.tar.xz sisu_4.0.1-1.dsc sisu_4.0.1-1.debian.tar.gz +* v4: debug (internal code use), color markers for line number & file name + (colored location markers to show when line passed within running code) + %% 4.0.0.orig.tar.xz (2012-12-12:50/3) http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=shortlog;h=refs/tags/sisu_4.0.0 http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=shortlog;h=refs/tags/debian/sisu_4.0.0-1 diff --git a/lib/sisu/v3/constants.rb b/lib/sisu/v3/constants.rb index b38e3313..927e3ed2 100644 --- a/lib/sisu/v3/constants.rb +++ b/lib/sisu/v3/constants.rb @@ -241,6 +241,27 @@ Gt={ conf: 'doc/_sisu', skin: 'doc/_sisu/skin', #Gt[:skin: 'conf/skin/doc' } +ANSI_C={ + red: "\033[#{31}m", + green: "\033[#{32}m", + yellow: "\033[#{33}m", + blue: "\033[#{34}m", + fuchsia: "\033[#{35}m", + cyan: "\033[#{36}m", + inv_red: "\033[#{41}m", + inv_green: "\033[#{42}m", + inv_yellow: "\033[#{43}m", + inv_blue: "\033[#{44}m", + inv_fuchsia: "\033[#{45}m", + inv_cyan: "\033[#{46}m", + b_red: "\033[#{91}m", + b_green: "\033[#{92}m", + b_yellow: "\033[#{93}m", + b_blue: "\033[#{94}m", + b_fuchsia: "\033[#{95}m", + b_cyan: "\033[#{96}m", + off: "\033[m" +} DISABLE={ epub: { internal_navigation: true, diff --git a/lib/sisu/v3/debug.rb b/lib/sisu/v3/debug.rb new file mode 100644 index 00000000..6be60576 --- /dev/null +++ b/lib/sisu/v3/debug.rb @@ -0,0 +1,109 @@ +# encoding: utf-8 +=begin + + * Name: SiSU + + * Description: a framework for document structuring, publishing and search + + * Author: Ralph Amissah + + * Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2007, 2008, 2009, 2010, 2011, 2012 Ralph Amissah, All Rights Reserved. + + * License: GPL 3 or later: + + SiSU, a framework for document structuring, publishing and search + + Copyright (C) Ralph Amissah + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along with + this program. If not, see . + + If you have Internet connection, the latest version of the GPL should be + available at these locations: + + + + + + * SiSU uses: + * Standard SiSU markup syntax, + * Standard SiSU meta-markup syntax, and the + * Standard SiSU object citation numbering and system + + * Hompages: + + + + * Download: + + + * Ralph Amissah + + + + ** Description: system environment, debug related + +=end +module SiSU_Debug + class Mark + def initialize(line,file,color=:red) + @line,@file,@color=line.to_s,file,color + end + def ansi(color=nil) + @color=color ? color : @color + c={} + c[:on]=case @color + when :red; ANSI_C[:red] + when :green; ANSI_C[:green] + when :yellow; ANSI_C[:yellow] + when :blue; ANSI_C[:blue] + when :fuchsia; ANSI_C[:fuchsia] + when :cyan; ANSI_C[:cyan] + when :inv_red; ANSI_C[:inv_red] + when :inv_green; ANSI_C[:inv_green] + when :inv_yellow; ANSI_C[:inv_yellow] + when :inv_blue; ANSI_C[:inv_blue] + when :inv_fuchsia; ANSI_C[:inv_fuchsia] + when :inv_cyan; ANSI_C[:inv_cyan] + when :b_red; ANSI_C[:b_red] + when :b_green; ANSI_C[:b_green] + when :b_yellow; ANSI_C[:b_yellow] + when :b_blue; ANSI_C[:b_blue] + when :b_fuchsia; ANSI_C[:b_fuchsia] + when :b_cyan; ANSI_C[:b_cyan] + else ANSI_C[:red] + end + c[:off]= ANSI_C[:off] + #ansi_color + @line.to_s + ansi_color_off + ' ' + @file.gsub(/([^\/]+$)/,"#{ansi_color}\\1#{ansi_color_off}") + c + end + def set(color=nil) + c=ansi(color) + file,path=File.basename(@file),File.dirname(@file) + c[:on] + @line + c[:off] + ' ' + path + '/' "#{c[:on]}#{file}#{c[:off]}" + end + def set_(color=nil) + c=ansi(color) + c[:on] + @line + c[:off] + ' ' + + @file.gsub(/([^\/]+$)/,"#{c[:on]}\\1#{c[:off]}") + end + end +end +__END__ +puts SiSU_Debug::Mark.new(__LINE__,__FILE__).set(:red) +puts SiSU_Debug::Mark.new(__LINE__,__FILE__).set(:green) +puts SiSU_Debug::Mark.new(__LINE__,__FILE__).set(:inv_red) +puts SiSU_Debug::Mark.new(__LINE__,__FILE__,:red).set +puts SiSU_Debug::Mark.new(__LINE__,__FILE__,:green).set +puts SiSU_Debug::Mark.new(__LINE__,__FILE__,:inv_red).set diff --git a/lib/sisu/v3/hub.rb b/lib/sisu/v3/hub.rb index 2e0fb92c..56f7631d 100644 --- a/lib/sisu/v3/hub.rb +++ b/lib/sisu/v3/hub.rb @@ -68,6 +68,7 @@ module SiSU include SiSU_Viz require_relative 'help' # help.rb include SiSU_Help + require_relative 'debug' # debug.rb require 'uri' class HubMaster def initialize(argv) diff --git a/lib/sisu/v4/constants.rb b/lib/sisu/v4/constants.rb index af5c13a4..02bbc286 100644 --- a/lib/sisu/v4/constants.rb +++ b/lib/sisu/v4/constants.rb @@ -243,6 +243,27 @@ S_CONF={ header_make: 'sisu_document_make', rc_yml: 'sisurc.yml', } +ANSI_C={ + red: "\033[#{31}m", + green: "\033[#{32}m", + yellow: "\033[#{33}m", + blue: "\033[#{34}m", + fuchsia: "\033[#{35}m", + cyan: "\033[#{36}m", + inv_red: "\033[#{41}m", + inv_green: "\033[#{42}m", + inv_yellow: "\033[#{43}m", + inv_blue: "\033[#{44}m", + inv_fuchsia: "\033[#{45}m", + inv_cyan: "\033[#{46}m", + b_red: "\033[#{91}m", + b_green: "\033[#{92}m", + b_yellow: "\033[#{93}m", + b_blue: "\033[#{94}m", + b_fuchsia: "\033[#{95}m", + b_cyan: "\033[#{96}m", + off: "\033[m" +} DISABLE={ epub: { internal_navigation: true, @@ -254,6 +275,12 @@ DEVELOPER={ maintenance: :false, } __END__ +puts SiSU_Debug::Mark.new(__LINE__,__FILE__,:red).set +puts SiSU_Debug::Mark.new(__LINE__,__FILE__).set(:green) +puts ANSI_C[:red] + __LINE__.to_s + ANSI_C[:off] + ' ' + __FILE__ +puts "#{ANSI_C[:red]} #{__LINE__.to_s} #{ANSI_C[:off]} #{__FILE__}" +puts ANSI_C[:fuchsia] + __LINE__.to_s + ANSI_C[:off] + ' ' + __FILE__.gsub(/([^\/]+$)/,"#{ANSI_C[:fuchsia]}\\1#{ANSI_C[:off]}") +puts ANSI_C[:red] + __LINE__.to_s + ANSI_C[:off] + ' ' + __FILE__.gsub(/([^\/]+$)/,"#{ANSI_C[:red]}\\1#{ANSI_C[:off]}") consider: 〔comment〕 〔links?????〕 diff --git a/lib/sisu/v4/debug.rb b/lib/sisu/v4/debug.rb new file mode 100644 index 00000000..6be60576 --- /dev/null +++ b/lib/sisu/v4/debug.rb @@ -0,0 +1,109 @@ +# encoding: utf-8 +=begin + + * Name: SiSU + + * Description: a framework for document structuring, publishing and search + + * Author: Ralph Amissah + + * Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2007, 2008, 2009, 2010, 2011, 2012 Ralph Amissah, All Rights Reserved. + + * License: GPL 3 or later: + + SiSU, a framework for document structuring, publishing and search + + Copyright (C) Ralph Amissah + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along with + this program. If not, see . + + If you have Internet connection, the latest version of the GPL should be + available at these locations: + + + + + + * SiSU uses: + * Standard SiSU markup syntax, + * Standard SiSU meta-markup syntax, and the + * Standard SiSU object citation numbering and system + + * Hompages: + + + + * Download: + + + * Ralph Amissah + + + + ** Description: system environment, debug related + +=end +module SiSU_Debug + class Mark + def initialize(line,file,color=:red) + @line,@file,@color=line.to_s,file,color + end + def ansi(color=nil) + @color=color ? color : @color + c={} + c[:on]=case @color + when :red; ANSI_C[:red] + when :green; ANSI_C[:green] + when :yellow; ANSI_C[:yellow] + when :blue; ANSI_C[:blue] + when :fuchsia; ANSI_C[:fuchsia] + when :cyan; ANSI_C[:cyan] + when :inv_red; ANSI_C[:inv_red] + when :inv_green; ANSI_C[:inv_green] + when :inv_yellow; ANSI_C[:inv_yellow] + when :inv_blue; ANSI_C[:inv_blue] + when :inv_fuchsia; ANSI_C[:inv_fuchsia] + when :inv_cyan; ANSI_C[:inv_cyan] + when :b_red; ANSI_C[:b_red] + when :b_green; ANSI_C[:b_green] + when :b_yellow; ANSI_C[:b_yellow] + when :b_blue; ANSI_C[:b_blue] + when :b_fuchsia; ANSI_C[:b_fuchsia] + when :b_cyan; ANSI_C[:b_cyan] + else ANSI_C[:red] + end + c[:off]= ANSI_C[:off] + #ansi_color + @line.to_s + ansi_color_off + ' ' + @file.gsub(/([^\/]+$)/,"#{ansi_color}\\1#{ansi_color_off}") + c + end + def set(color=nil) + c=ansi(color) + file,path=File.basename(@file),File.dirname(@file) + c[:on] + @line + c[:off] + ' ' + path + '/' "#{c[:on]}#{file}#{c[:off]}" + end + def set_(color=nil) + c=ansi(color) + c[:on] + @line + c[:off] + ' ' + + @file.gsub(/([^\/]+$)/,"#{c[:on]}\\1#{c[:off]}") + end + end +end +__END__ +puts SiSU_Debug::Mark.new(__LINE__,__FILE__).set(:red) +puts SiSU_Debug::Mark.new(__LINE__,__FILE__).set(:green) +puts SiSU_Debug::Mark.new(__LINE__,__FILE__).set(:inv_red) +puts SiSU_Debug::Mark.new(__LINE__,__FILE__,:red).set +puts SiSU_Debug::Mark.new(__LINE__,__FILE__,:green).set +puts SiSU_Debug::Mark.new(__LINE__,__FILE__,:inv_red).set diff --git a/lib/sisu/v4/hub.rb b/lib/sisu/v4/hub.rb index 02762d4a..da5b785e 100644 --- a/lib/sisu/v4/hub.rb +++ b/lib/sisu/v4/hub.rb @@ -68,6 +68,7 @@ module SiSU include SiSU_Viz require_relative 'help' # help.rb include SiSU_Help + require_relative 'debug' # debug.rb require 'uri' class HubMaster def initialize(argv) -- cgit v1.2.3