X-Git-Url: https://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fdoc%2FContextManual.pl;h=45d00dc80ab5e12279bc6091424d5a5fe442106c;hb=5dd11b748e5409f8376376f51d0a18d111cbcfdc;hp=cbb143416adfd34762ceb844ed12c725f987e18d;hpb=b104b77f5296719bd5e6de8472eb71542ddaedec;p=goodguy%2Fcinelerra.git diff --git a/cinelerra-5.1/doc/ContextManual.pl b/cinelerra-5.1/doc/ContextManual.pl index cbb14341..45d00dc8 100755 --- a/cinelerra-5.1/doc/ContextManual.pl +++ b/cinelerra-5.1/doc/ContextManual.pl @@ -12,10 +12,14 @@ # On empty keyphrase do nothing # The special keyphrase "TOC" shows Contents, "IDX" shows Index # The keyphrase starting with "FILE:" shows the file named after colon +# The special keyphrase "API" shows the numeric version of the script itself # Several important definitions -# Web browser executable +# ContextManual.pl script API version. Must not be changed ! +$cin_cm_api = 2; + +# Web browser executable, can be redefined on user's demand $cin_browser = $ENV{'CIN_BROWSER'}; # a likely default browser $cin_browser = 'firefox' if $cin_browser eq ''; @@ -24,17 +28,19 @@ $cin_browser = 'firefox' if $cin_browser eq ''; # a fake browser for debugging #$cin_browser = 'echo'; +# The following definitions depend on the HTML manual structure +# There is nothing to change below this line + # The node with the manual contents $contents_node = 'Contents.html'; -# The node with the manual index -$index_node = 'Index.html'; +# The node with the actual index if needed will be found after parsing contents +$index_node = ''; +$index = ''; # Several special plugin names necessary to rewrite %rewrite = ( # Rendered effects and transitions are not segmented in the Contents - # CD Ripper is an audio effect but erroneously placed - # under Rendered Video Effects in the manual "CD Ripper" => "Rendered Audio Effects", "Normalize" => "Rendered Audio Effects", "Resample" => "Rendered Audio Effects", @@ -75,14 +81,50 @@ $cin_dat = '.' if $cin_dat eq ''; # Cinelerra HTML manual must reside here $cin_man = "$cin_dat/doc/CinelerraGG_Manual"; $contents = $cin_man.'/'.$contents_node; -$index = $cin_man.'/'.$index_node; #print "ContextManual: using contents $contents\n"; +# Cinelerra user's config directory +$cin_config = $ENV{'CIN_CONFIG'}; +$cin_config = $ENV{'HOME'}.'/.bcast5' + if $cin_config eq '' && $ENV{'HOME'} ne ''; +$cin_config = '.' if $cin_config eq ''; +$me_config = "$cin_config/ContextManual.pl"; +#print "ContextManual: user script=$me_config\n"; + # 1st argument is the requested key $help_key = $ARGV[0]; #print "ContextManual: request=$help_key\n"; # Do nothing if no key requested exit 0 if $help_key eq ''; + +# A special internal request: output own API version +if ($help_key eq 'API') +{ + print "$cin_cm_api\n"; + exit 0; +} + +# If a system (not user's) script instance is executed, and the API versions +# of both scripts do not match, then copy the system script to the user's one +# (making a backup copy of the latter). Then execute it with the same key. +if ($0 ne $me_config) +{ + $me_api = 0; + $me_api = `\"$me_config\" API` if -x $me_config; + if ($me_api != $cin_cm_api) + { + print "ContextManual: copying \"$0\" to \"$me_config\"\n"; + unlink "$me_config.bak" if -f "$me_config.bak"; + rename "$me_config", "$me_config.bak" if -f $me_config; + system "cp \"$0\" \"$me_config\""; + system "chmod +x \"$me_config\""; + } + exec "\"$me_config\" \"$help_key\"" if -x $me_config; +} + +# If a user's script instance is executed, do everything by myself +#print "ContextManual: executing \"$0\" \"$help_key\"\n"; + # Show contents on this special request if ($help_key eq 'TOC') { @@ -92,6 +134,21 @@ if ($help_key eq 'TOC') # Show index on this special request if ($help_key eq 'IDX') { + # Index node will be needed now, find it + if ($index_node eq '') + { + $node = ''; + open CONTENTS, $contents or die "Cannot open $contents: $!"; + while () + { + chomp; + last if ($node) = /^\s*HREF=\"(.+?\.html)\">\s*Index\s*<\/A>(?:<\/B>)?$/; + } + close CONTENTS; + $index_node = $node if $node ne ''; + $index_node = 'Index.html' if $index_node eq ''; + $index = $cin_man.'/'.$index_node; + } system "$cin_browser \"file://$index\" &"; exit 0; } @@ -116,6 +173,21 @@ if ($help_key eq 'TOC') # Show index on this special request if ($help_key eq 'IDX') { + # Index node will be needed now, find it + if ($index_node eq '') + { + $node = ''; + open CONTENTS, $contents or die "Cannot open $contents: $!"; + while () + { + chomp; + last if ($node) = /^\s*HREF=\"(.+?\.html)\">\s*Index\s*<\/A>(?:<\/B>)?$/; + } + close CONTENTS; + $index_node = $node if $node ne ''; + $index_node = 'Index.html' if $index_node eq ''; + $index = $cin_man.'/'.$index_node; + } system "$cin_browser \"file://$index\" &"; exit 0; } @@ -148,6 +220,21 @@ if ($node eq '') } } +# Index node will be needed now, find it +if ($node eq '' && $index_node eq '') +{ + seek CONTENTS, 0, 0; + while () + { + chomp; + last if ($node) = /^\s*HREF=\"(.+?\.html)\">\s*Index\s*<\/A>(?:<\/B>)?$/; + } + $index_node = $node if $node ne ''; + $index_node = 'Index.html' if $index_node eq ''; + $index = $cin_man.'/'.$index_node; + $node = ''; +} + # If not found, search index for the exact key if ($node eq '') { @@ -180,13 +267,13 @@ if ($node eq '') # If not found, grep manual for exact key instance if ($node eq '') { - $_ = `grep -l \"$help_key\" $cin_dat/doc/CinelerraGG_Manual/*.html`; + $_ = `grep -l \"$help_key\" \"$cin_dat\"/doc/CinelerraGG_Manual/*.html`; ($node) = split; } # If not found, grep manual for case insensitive key instance if ($node eq '') { - $_ = `grep -il \"$help_key\" $cin_dat/doc/CinelerraGG_Manual/*.html`; + $_ = `grep -il \"$help_key\" \"$cin_dat\"/doc/CinelerraGG_Manual/*.html`; ($node) = split; }