Fix Fl_Help_View <OL> numbers (Issue #153, STR 3290)
Started with @wcout's patch (see Issue #153, STR 3290), modified patch for CMP conformance, restructured methods, and finally: - used Fl_Int_Vector instead of 'fl_data_container' - removed fl_data_container Thanks for the working patch to @wcout.
This commit is contained in:
parent
bb7129dae2
commit
f904f4c4ec
@ -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
|
||||
};
|
||||
|
||||
//
|
||||
|
||||
@ -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 (•) 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 (•) 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"))
|
||||
|
||||
Loading…
Reference in New Issue
Block a user