[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: Add switching from/to unfilled and change in inde
From: |
Patrice Dumas |
Subject: |
branch master updated: Add switching from/to unfilled and change in indenting in Paragraph |
Date: |
Sun, 23 Jul 2023 16:23:59 -0400 |
This is an automated email from the git hooks/post-receive script.
pertusus pushed a commit to branch master
in repository texinfo.
The following commit(s) were added to refs/heads/master by this push:
new 6c76fad2a0 Add switching from/to unfilled and change in indenting in
Paragraph
6c76fad2a0 is described below
commit 6c76fad2a04ca57318da065914a1d207cfe19a24
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Jul 23 22:23:45 2023 +0200
Add switching from/to unfilled and change in indenting in Paragraph
* tp/Texinfo/Convert/ParagraphNonXS.pm (set_unfilled_indent),
tp/Texinfo/XS/XSParagraph.xs (xspara_set_unfilled_indent),
tp/Texinfo/XS/xspara.c (xspara_set_unfilled_indent):
* t/paragraph.t: test set_unfilled_indent.
---
ChangeLog | 12 +++++++++-
tp/Texinfo/Convert/Paragraph.pm | 1 +
tp/Texinfo/Convert/ParagraphNonXS.pm | 22 ++++++++++++++++++
tp/Texinfo/XS/XSParagraph.xs | 44 +++++++++++++++++++++++++++++++++++-
tp/Texinfo/XS/xspara.c | 21 +++++++++++++++++
tp/Texinfo/XS/xspara.h | 2 ++
tp/t/paragraph.t | 32 +++++++++++++++++++++++++-
7 files changed, 131 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index f0cf7eec75..6b21b94ad7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2023-07-23 Patrice Dumas <pertusus@free.fr>
+
+ Add switching from/to unfilled and change in indenting in Paragraph
+
+ * tp/Texinfo/Convert/ParagraphNonXS.pm (set_unfilled_indent),
+ tp/Texinfo/XS/XSParagraph.xs (xspara_set_unfilled_indent),
+ tp/Texinfo/XS/xspara.c (xspara_set_unfilled_indent):
+
+ * t/paragraph.t: test set_unfilled_indent.
+
2023-07-23 Gavin Smith <gavinsmith0123@gmail.com>
Fix parsetexi compilation errors
@@ -9,7 +19,7 @@
2023-07-23 Patrice Dumas <pertusus@free.fr>
- @nodedescription parsing in texi1any
+ @nodedescription parsing in texi2any
* tp/Texinfo/ParserNonXS.pm (%contain_full_text_commands)
(_handle_line_command), tp/Texinfo/XS/parsetexi/handle_commands.c
diff --git a/tp/Texinfo/Convert/Paragraph.pm b/tp/Texinfo/Convert/Paragraph.pm
index c5d5e0839c..ed836be225 100644
--- a/tp/Texinfo/Convert/Paragraph.pm
+++ b/tp/Texinfo/Convert/Paragraph.pm
@@ -39,6 +39,7 @@ sub import {
end_line
add_pending_word
get_pending
+ set_unfilled_indent
);
my ($callpkg, $filename, $line) = caller(0);
diff --git a/tp/Texinfo/Convert/ParagraphNonXS.pm
b/tp/Texinfo/Convert/ParagraphNonXS.pm
index 1c074121c5..4f7627b76b 100644
--- a/tp/Texinfo/Convert/ParagraphNonXS.pm
+++ b/tp/Texinfo/Convert/ParagraphNonXS.pm
@@ -291,6 +291,28 @@ sub set_space_protection($$;$$$$)
}
}
+sub set_unfilled_indent($;$$$)
+{
+ my $paragraph = shift;
+ my $unfilled = shift;
+ my $indent_length = shift;
+ my $indent_length_next = shift;
+
+ my $result = '';
+
+ if (defined($unfilled)) {
+ if (!$paragraph->{'unfilled'} and $unfilled) {
+ $result .= _add_pending_word($paragraph, 1);
+ }
+ $paragraph->{'unfilled'} = $unfilled;
+ }
+ $paragraph->{'indent_length'} = $indent_length
+ if defined($indent_length);
+ $paragraph->{'indent_length_next'} = $indent_length_next
+ if defined($indent_length_next);
+ return $result;
+}
+
# Wrap $TEXT, returning the wrapped text, taking into account the current
state
# of $PARAGRAPH. Any end of sentence punctuation in $TEXT that should be
# allowed to end a sentence but which would otherwise be preceded by an
diff --git a/tp/Texinfo/XS/XSParagraph.xs b/tp/Texinfo/XS/XSParagraph.xs
index 02f8875da8..763284ddf7 100644
--- a/tp/Texinfo/XS/XSParagraph.xs
+++ b/tp/Texinfo/XS/XSParagraph.xs
@@ -228,7 +228,7 @@ xspara_allow_end_sentence (paragraph)
CODE:
xspara_set_state (paragraph);
xspara_allow_end_sentence ();
-
+
# Optional parameters are IGNORE_COLUMNS, KEEP_END_LINES, FRENCHSPACING,
# DOUBLE_WIDTH_NO_BREAK.
# Pass them to the C function as -1 if not given or undef.
@@ -282,3 +282,45 @@ xspara_set_space_protection (paragraph,
space_protection_in, ...)
(space_protection, ignore_columns, keep_end_lines,
french_spacing, double_width_no_break);
+SV *
+xspara_set_unfilled_indent (paragraph, ...)
+ SV *paragraph
+ PREINIT:
+ int unfilled = -1;
+ int indent_length = -1;
+ int indent_length_next = -1;
+ TEXT retval;
+ SV *arg_in;
+ CODE:
+ /* Get optional arguments from stack. */
+ items -= 1;
+ if (items > 0)
+ {
+ items--;
+ arg_in = ST(1);
+ if (SvOK(arg_in))
+ unfilled = (int)SvIV(arg_in);
+ }
+ if (items > 0)
+ {
+ items--;
+ arg_in = ST(2);
+ if (SvOK(arg_in))
+ indent_length = (int)SvIV(arg_in);
+ }
+ if (items > 0)
+ {
+ items--;
+ arg_in = ST(3);
+ if (SvOK(arg_in))
+ indent_length_next = (int)SvIV(arg_in);
+ }
+
+ xspara_set_state (paragraph);
+ retval = xspara_set_unfilled_indent (unfilled, indent_length,
+ indent_length_next);
+
+ RETVAL = newSVpv (retval.text ? retval.text : "", retval.end);
+ SvUTF8_on (RETVAL);
+ OUTPUT:
+ RETVAL
diff --git a/tp/Texinfo/XS/xspara.c b/tp/Texinfo/XS/xspara.c
index 6832da328c..2522ca866a 100644
--- a/tp/Texinfo/XS/xspara.c
+++ b/tp/Texinfo/XS/xspara.c
@@ -1061,4 +1061,25 @@ xspara_add_text (char *text, int len)
return result;
}
+TEXT
+xspara_set_unfilled_indent (int unfilled, int indent_length,
+ int indent_length_next)
+{
+ static TEXT result;
+ text_reset (&result);
+ if (unfilled != -1)
+ {
+ if (unfilled && !state.unfilled)
+ xspara__add_pending_word (&result, 1);
+ state.unfilled = unfilled;
+ }
+
+ if (indent_length != -1)
+ state.indent_length = indent_length;
+
+ if (indent_length_next != -1)
+ state.indent_length_next = indent_length_next;
+
+ return result;
+}
diff --git a/tp/Texinfo/XS/xspara.h b/tp/Texinfo/XS/xspara.h
index 57520efb51..9483b933e6 100644
--- a/tp/Texinfo/XS/xspara.h
+++ b/tp/Texinfo/XS/xspara.h
@@ -18,3 +18,5 @@ void xspara_allow_end_sentence (void);
void xspara_remove_end_sentence (void);
void xspara_add_end_sentence (int value);
int xspara_end_line_count (void);
+TEXT xspara_set_unfilled_indent (int unfilled, int indent_length,
+ int indent_length_next);
diff --git a/tp/t/paragraph.t b/tp/t/paragraph.t
index c89f17184c..6f26eb0f9c 100644
--- a/tp/t/paragraph.t
+++ b/tp/t/paragraph.t
@@ -7,7 +7,7 @@ use File::Basename;
use lib '.';
use Texinfo::ModulePath (undef, undef, undef, 'updirs' => 2);
-BEGIN { plan tests => 119 ; }
+BEGIN { plan tests => 120 ; }
use Texinfo::Convert::Paragraph;
@@ -689,4 +689,34 @@ $result .= add_text($line, " after");
$result .= Texinfo::Convert::Paragraph::end($line);
is ($result, "protected after", 'line 2 spaces after end space protection with
dot');
+$para = Texinfo::Convert::Paragraph->new();
+$result = '';
+$result .= add_text($para, 'As para');
+$result .= set_unfilled_indent($para, 1, 30, 60);
+$result .= add_text($para, "uuuuuuuuuuuuu uuu uu uu uuuuuuuuuu uu uu uuuuu\n");
+$result .= add_text($para, "ttttttttttttu ttu tt tt tttttttttt tt tt ttttu
tt\n");
+$result .= set_unfilled_indent($para, 0, 0, 20);
+$result .= add_text($para, 'Now the description which we make long to test
better if things are going our way');
+$result .= add_text($para, "\n");
+$result .= add_text($para, "and more text going on");
+$result .= set_unfilled_indent($para, 1, 0, 0);
+$result .= add_text($para, "mmmmmmmmmmmmmmmmmmmmmmm m m m mmmmmmmmmmmmmmmmmmm
m mmmmmmmmmmmmm");
+$result .= add_text($para, "\n");
+$result .= add_text($para, "* more text unfilled");
+$result .= add_text($para, "\n");
+$result .= Texinfo::Convert::Paragraph::end($para);
+
+is ($result, 'As para uuuuuuuuuuuuu uuu uu uu uuuuuuuuuu
uu uu
+ uuuuu
+ ttttttttttttu
+ ttu tt tt
+ tttttttttt
+ tt tt ttttu
+ tt
+Now the description which we make long to test better if things are
+ going our way and more text going on
+mmmmmmmmmmmmmmmmmmmmmmm m m m mmmmmmmmmmmmmmmmmmm m mmmmmmmmmmmmm
+* more text unfilled
+', 'test set_unfilled_indent');
+
1;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: Add switching from/to unfilled and change in indenting in Paragraph,
Patrice Dumas <=