summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--FL/Fl_Help_View.H3
-rw-r--r--src/Fl_Help_View.cxx48
2 files changed, 47 insertions, 4 deletions
diff --git a/FL/Fl_Help_View.H b/FL/Fl_Help_View.H
index 32e993aec..9b3a1a242 100644
--- a/FL/Fl_Help_View.H
+++ b/FL/Fl_Help_View.H
@@ -3,6 +3,7 @@
//
// Copyright 1997-2010 by Easy Software Products.
// Image support by Matthias Melcher, Copyright 2000-2009.
+// Copyright 2011-2022 by Bill Spitzak and others.
//
// This library is free software. Distribution and use rights are outlined in
// the file "COPYING" which should have been included with this file. If this
@@ -52,6 +53,8 @@ struct Fl_Help_Block {
w, // Width
h; // Height
int line[32]; // Left starting position for each line
+ int ol; // is ordered list <OL> element
+ int ol_num; // item number in ordered list
};
//
diff --git a/src/Fl_Help_View.cxx b/src/Fl_Help_View.cxx
index 3ccafc2a8..68b92690d 100644
--- a/src/Fl_Help_View.cxx
+++ b/src/Fl_Help_View.cxx
@@ -5,7 +5,7 @@
// Image support by Matthias Melcher, Copyright 2000-2009.
//
// Buffer management (HV_Edit_Buffer) and more by AlbrechtS and others.
-// Copyright 2011-2019 by Bill Spitzak and others.
+// Copyright 2011-2022 by Bill Spitzak and others.
//
// This library is free software. Distribution and use rights are outlined in
// the file "COPYING" which should have been included with this file. If this
@@ -51,6 +51,7 @@
#include <FL/Fl_Shared_Image.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Pixmap.H>
+#include <FL/Fl_Int_Vector.H>
#include <stdio.h>
#include <stdlib.h>
@@ -902,9 +903,16 @@ Fl_Help_View::draw()
if (buf.cmp("LI"))
{
- // draw bullet (&bull;) Unicode: U+2022, UTF-8 (hex): e2 80 a2
- unsigned char bullet[4] = { 0xe2, 0x80, 0xa2, 0x00 };
- hv_draw((char *)bullet, xx - fsize + x() - leftline_, yy + y());
+ if (block->ol) {
+ char buf[10];
+ snprintf(buf, sizeof(buf), "%d. ", block->ol_num);
+ hv_draw(buf, xx - (int)fl_width(buf) + x() - leftline_, yy + y());
+ }
+ else {
+ // draw bullet (&bull;) Unicode: U+2022, UTF-8 (hex): e2 80 a2
+ unsigned char bullet[4] = { 0xe2, 0x80, 0xa2, 0x00 };
+ hv_draw((char *)bullet, xx - fsize + x() - leftline_, yy + y());
+ }
}
pushfont(font, fsize);
@@ -1306,6 +1314,9 @@ void Fl_Help_View::format() {
Fl_Boxtype b = box() ? box() : FL_DOWN_BOX;
// Box to draw...
fl_margins margins; // Left margin stack...
+ Fl_Int_Vector OL_num; // if nonnegative, in OL mode and this is the item number
+
+ OL_num.push_back(-1);
DEBUG_FUNCTION(__LINE__,__FUNCTION__);
@@ -1541,6 +1552,20 @@ void Fl_Help_View::format() {
xx = block->x;
block->h += hh;
+ if (buf.cmp("OL")) {
+ int ol_num = 1;
+ if (get_attr(attrs, "START", attr, sizeof(attr)) != NULL) {
+ errno = 0;
+ char *endptr = 0;
+ ol_num = strtol(attr, &endptr, 10);
+ if (errno || endptr == attr || ol_num < 0)
+ ol_num = 1;
+ }
+ OL_num.push_back(ol_num);
+ }
+ else if (buf.cmp("UL"))
+ OL_num.push_back(-1);
+
if (buf.cmp("UL") ||
buf.cmp("OL") ||
buf.cmp("DL"))
@@ -1632,6 +1657,16 @@ void Fl_Help_View::format() {
else
block = add_block(start, xx, yy, hsize_, 0);
+ if (buf.cmp("LI")) {
+ block->ol = 0;
+ if (OL_num.back()>=0) {
+ block->ol = 1;
+ block->ol_num = (int)OL_num.back();
+ int nnum = OL_num.pop_back() + 1;
+ OL_num.push_back(nnum);
+ }
+ }
+
needspace = 0;
line = 0;
@@ -1658,6 +1693,11 @@ void Fl_Help_View::format() {
xx = block->x;
block->end = ptr;
+ if (buf.cmp("/OL") ||
+ buf.cmp("/UL")) {
+ OL_num.pop_back();
+ }
+
if (buf.cmp("/UL") ||
buf.cmp("/OL") ||
buf.cmp("/DL"))