shithub: scric

Download patch

ref: da05aec370be82e1a5b52e0fa576a33594322d24
author: glenda <glenda@ship.of.fools>
date: Sat Nov 8 08:17:17 EST 2025

made scric

--- /dev/null
+++ b/schtml
@@ -1,0 +1,105 @@
+#!/bin/rc
+rfork e 
+
+# declare your intentions:
+# page_width = page width
+# column_width = width of dialogue
+# mezzo_width = width of everything else
+
+page_width = 72
+column_width = 40
+mezzo_width = 60
+
+fn ind_math {
+  echo '('$page_width-$1')'/2 | bc
+}
+
+c_ind = `{ind_math $column_width}
+m_ind = `{ind_math $mezzo_width}
+sw = 0
+
+file = $1
+if (~ $#file 0) { echo needs a file; exit }
+if (! test -f $file) { echo bad file; exit }
+
+
+
+ln = `{ echo `{ wc -l < $file} + 1 | bc}
+fn rl { sed -n $x^p $file }
+
+fn indenter {
+  for (i in `{seq $1} ) echo -n ' '
+}
+
+fn chardent {
+  ch = ` { echo $rl | sed -e 's,@,,' -e 's,#,,'}
+  l_len = `{ echo $ch | awk '{print length}' }
+  ch_len = `{ ind_math $l_len }
+  for (n in `{ seq $ch_len } ) echo -n ' '
+}
+
+fn diag {
+rl = `{rl}
+
+  while (! ~ $#rl 0) {
+    rl = `{rl}
+    echo $"rl
+    x = `{ echo $x + 1 | bc }
+    }
+}
+
+fn format_diag {
+  diag | fmt -l $column_width -i `{echo $c_ind^*2 |bc } | awk '{gsub(/\t/, "    "); print }'
+}
+
+fn format_mezzo {
+  diag | fmt -l $mezzo_width -i `{echo $m_ind^*2 |bc } | awk '{gsub(/\t/, "    "); print }'
+}
+
+
+fn caser {
+  switch($1) {
+    case @* ; echo '<p class="char">'; chardent ; echo -n $"ch^: ; echo '</p>'; sw = d
+    case '#'* ; echo '<h2>'; chardent ; echo -n $"ch ;echo '</h2>'; echo
+    case '' ; sw = m
+    case * 
+
+      if (~ $sw d ) {
+        echo '<p class="diag">'
+        format_diag
+        echo '</p>'
+        sw = 0
+      }
+
+      if (~ $sw m ) {
+        echo '<p>'
+        format_mezzo
+        echo '</p>'
+        sw = 0
+      }
+
+  }
+
+}
+
+
+# TITLE DESIGN
+x= 1; rl = `{rl}
+chardent; echo '<h1>' $"ch '</h1>'
+x= 2; rl = `{rl}
+chardent; echo '<p>' $"ch '</p>'
+echo; echo; echo
+
+# BEGIN
+x = 3
+while (! test $x -gt $ln) {
+
+  rl = `{rl}
+
+  caser $"rl
+  diag_l=0
+
+  x = `{ echo $x + 1 | bc }
+
+}
+
--- /dev/null
+++ b/scric
@@ -1,0 +1,108 @@
+#!/bin/rc
+rfork e 
+
+# declare your intentions:
+# page_width = page width
+# column_width = width of dialogue
+# mezzo_width = width of everything else
+
+page_width = 72
+column_width = 40
+mezzo_width = 60
+
+fn ind_math {
+  echo '('$page_width-$1')'/2 | bc
+}
+
+c_ind = `{ind_math $column_width}
+m_ind = `{ind_math $mezzo_width}
+sw = 0
+
+file = $1
+if (~ $#file 0) { echo needs a file; exit }
+if (! test -f $file) { echo bad file; exit }
+
+
+
+ln = `{ echo `{ wc -l < $file} + 1 | bc}
+fn rl { sed -n $x^p $file }
+
+fn indenter {
+  for (i in `{seq $1} ) echo -n ' '
+}
+
+fn chardent {
+  ch = ` { echo $rl | sed -e 's,@,,' -e 's,#,,'}
+  l_len = `{ echo $ch | awk '{print length}' }
+  ch_len = `{ ind_math $l_len }
+  for (n in `{ seq $ch_len } ) echo -n ' '
+}
+
+fn repush {
+ y = $1
+}
+
+fn diag {
+rl = `{rl}
+
+  while (! ~ $#rl 0) {
+    rl = `{rl}
+    echo $"rl
+    x = `{ echo $x + 1 | bc }
+    }
+}
+
+fn format_diag {
+  diag | fmt -l $column_width -i `{echo $c_ind^*2 |bc } | awk '{gsub(/\t/, "    "); print }'
+}
+
+fn format_mezzo {
+  diag | fmt -l $mezzo_width -i `{echo $m_ind^*2 |bc } | awk '{gsub(/\t/, "    "); print }'
+}
+
+
+fn caser {
+  switch($1) {
+    case @* ; chardent ; echo -n $"ch^: ; echo; sw = d
+    case '#'* ; echo; chardent ; echo -n $"ch ;echo; echo
+    case '' ; sw = m
+    case * 
+
+      if (~ $sw d ) {
+        format_diag
+        sw = 0
+      }
+
+      if (~ $sw m ) {
+        format_mezzo
+        sw = 0
+      }
+
+  }
+
+}
+
+for ( i in `{seq $page_width} ) echo -n '.'
+
+# TITLE DESIGN
+x = 1; rl = `{rl}
+echo; echo
+chardent; echo -n $"ch | tr 'a-z' 'A-Z'
+echo; echo
+x= 2; rl = `{rl}
+chardent; echo -n $"ch
+echo; echo; echo
+
+# BEGIN
+x = 3
+while (! test $x -gt $ln) {
+
+  rl = `{rl}
+
+  caser $"rl
+  diag_l=0
+
+  x = `{ echo $x + 1 | bc }
+
+}
+
--- /dev/null
+++ b/temp2
@@ -1,0 +1,26 @@
+First line is a title
+Second line is subtitle/author name/whatever
+
+#lines beginning with '#' are centered
+
+FADE IN
+
+Blocks of text separated by
+spaces are formated
+as full-page-width paragraphs
+
+@CHARACTER NAME
+Followed by a block of
+text are formatted as
+dialogue
+
+@CHARACTER NAME (CONT)
+Notice that the line width is irrelevant. The only
+requirement is that blocks of text must be separated
+by 
+empty
+lines.
+
+She said calmly.
+
+#END SCRIC
\ No newline at end of file
--- /dev/null
+++ b/template
@@ -1,0 +1,80 @@
+Line 1 is title
+Line 2 is subtitle/autor, whatever
+
+test length of a long paragraph that will break into more than 
+one line just so i can count the indentations ok ok should be enough
+now
+
+@TEST 
+Test the same length but for conversation, doesnt have to be as long
+
+#ACT 3 (subheader or whatever)
+# ACT N
+# ACT B
+
+# ACT     7  whitespace doesnt      matter
+
+FADE IN
+
+NAME1 and NAME2 are lying on a green carpet inside of an airplane
+hangar. What could this mean?
+
+Suddently a large dog
+enters the scene
+and begins chewing
+on ema's leg.
+
+@EMA
+first line of a dialogue
+second line of a dialogue
+third line of a dialogue
+fourth
+fifth
+sixth
+seventh
+
+EMA spits on the ground.
+
+@EMA (CONT)
+Dumb computers! This is insane
+how could
+anyone even attempt to 
+comprehend
+what you're 
+saying?
+
+@PETE MELVIN SR
+Wow, this is absolutely
+horrendous, how did you 
+expect this
+to work
+you dum
+whore?1
+
+@mike from PA
+what?
+
+
+
+A bullet flies through the mezzanine and drills inside PETE's skull.  
+
+FADEOUT
+
+# ACT 4 RETURNAL
+
+@ name 
+dialogue dialogue
+dialogue dialogue
+
+Mezzo mezzo mezzo mezzo
+mezzo mezzo mezzo
+
+mezzo mezzo
+
+@character two
+yo yo wassup
+
+
+# END SCRIC
+
+
--