[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 18/21: [troff]: Add new `hydefault` request.
From: |
G. Branden Robinson |
Subject: |
[groff] 18/21: [troff]: Add new `hydefault` request. |
Date: |
Sat, 2 Mar 2024 01:25:03 -0500 (EST) |
gbranden pushed a commit to branch master
in repository groff.
commit dc39883e9fb9a3972a7f2d11bac297ad30bb0b6a
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Fri Mar 1 22:13:59 2024 -0600
[troff]: Add new `hydefault` request.
* src/roff/troff/env.cpp (set_hyphenation_mode_default): New function
sets the environment's default hyphenation mode.
(init_env_requests): Wire up `hydefault` to foregoing function.
* src/roff/troff/env.h (class environment): Declare foregoing function
as a friend, permitting mutator access.
---
ChangeLog | 10 ++++++++++
src/roff/troff/env.cpp | 24 ++++++++++++++++++++++++
src/roff/troff/env.h | 1 +
3 files changed, 35 insertions(+)
diff --git a/ChangeLog b/ChangeLog
index 1bedea707..a1c0fd730 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2024-03-01 G. Branden Robinson <g.branden.robinson@gmail.com>
+
+ [troff]: Add new `hydefault` request.
+
+ * src/roff/troff/env.cpp (set_hyphenation_mode_default): New
+ function sets the environment's default hyphenation mode.
+ (init_env_requests): Wire up `hydefault` to foregoing function.
+ * src/roff/troff/env.h (class environment): Declare foregoing
+ function as a friend, permitting mutator access.
+
2024-03-01 G. Branden Robinson <g.branden.robinson@gmail.com>
* src/roff/troff/env.cpp (init_env_requests): Set up `hla`
diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp
index 13f9360da..aed0cfc5b 100644
--- a/src/roff/troff/env.cpp
+++ b/src/roff/troff/env.cpp
@@ -1743,6 +1743,29 @@ void hyphenate_request()
skip_line();
}
+void set_hyphenation_mode_default()
+{
+ if (!has_arg()) {
+ warning(WARN_MISSING, "hyphenation mode default setting request"
+ " expects an argument");
+ skip_line();
+ return;
+ }
+ int n;
+ if (!get_integer(&n)) {
+ // get_integer() will throw a diagnostic if necessary.
+ skip_line();
+ return;
+ }
+ if (n < 0) {
+ warning(WARN_RANGE, "hyphenation mode default cannot be negative");
+ skip_line();
+ return;
+ }
+ curenv->hyphenation_mode_default = n;
+ skip_line();
+}
+
void hyphen_char()
{
curenv->hyphen_indicator_char = get_optional_char();
@@ -4065,6 +4088,7 @@ void init_env_requests()
init_request("hla", select_hyphenation_language);
init_request("hlm", hyphen_line_max_request);
init_request("hy", hyphenate_request);
+ init_request("hydefault", set_hyphenation_mode_default);
init_request("hym", hyphenation_margin_request);
init_request("hys", hyphenation_space_request);
init_request("in", indent);
diff --git a/src/roff/troff/env.h b/src/roff/troff/env.h
index e7564bd94..0e0529174 100644
--- a/src/roff/troff/env.h
+++ b/src/roff/troff/env.h
@@ -390,6 +390,7 @@ public:
friend void leader_character();
friend void tab_character();
friend void hyphenate_request();
+ friend void set_hyphenation_mode_default();
friend void no_hyphenate();
friend void hyphen_line_max_request();
friend void hyphenation_space_request();
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 18/21: [troff]: Add new `hydefault` request.,
G. Branden Robinson <=