BlackBox 1.7.2 - Release candidate

Announces, releases and PayPal balance.
User avatar
Robert
Posts: 177
Joined: Sat Sep 28, 2013 11:04 am
Location: Edinburgh, Scotland

Re: BlackBox 1.7.2 - Release candidate

Post by Robert »

This issue has now been fixed in build 1125.
(For the issue see https://redmine.blackboxframework.org/issues/205.)
User avatar
Robert
Posts: 177
Joined: Sat Sep 28, 2013 11:04 am
Location: Edinburgh, Scotland

Re: BlackBox 1.7.2 - Release candidate

Post by Robert »

Ivan Denisov wrote:At the document P-S-I in the section Stack Size there is default font in some words. The Arial will be better like everywhere.
This issue has now been fixed in build 1126.
(For the issue see https://redmine.blackboxframework.org/issues/206.)
User avatar
adimetrius
Posts: 68
Joined: Sun Aug 04, 2019 1:02 pm

Re: BlackBox 1.7.2 - Release candidate

Post by adimetrius »

Dear colleagues,

A minor omission in documentation for Meta:

Code: Select all

PROCEDURE (IN var: Item) GetStringVal (OUT x: ARRAY OF CHAR; OUT ok: BOOLEAN)
NEW
Reads a string value from an item.

Pre
var.Valid()	20
var.typ = arrTyp & var.BaseTyp() = charTyp	21
var.obj = varObj	22
As you can see, there's no mention of OUT ok: BOOLEAN parameter neither in the description nor in the postconditions list.
User avatar
adimetrius
Posts: 68
Joined: Sun Aug 04, 2019 1:02 pm

Re: BlackBox 1.7.2 - Release candidate

Post by adimetrius »

ReadRunBugUnbug.txt
(5.38 KiB) Downloaded 338 times
Dear colleagues,
the documentation for TextModels.Reader.ReadRun states:
Read next attribute run, stops at next view.
I interpret "read next attribute run" as:
(* Not a quote, markup just for highliting *)
Post:
(attr = AttributeOf(rd.Pos() - 1)) & (rd.eot OR (attr # AttributeOf(rd.Pos()))
My example demonstrates that TextModels.StdReader.ReadRun fails to adhere to this interpretation - it does not stop the reader at exactly the end of the run having attr and thus fails to be useful in iterating text stretches of uniform attributes. While I understand that this is not exactly a bug - it fails to adhere to my interpretation, not the explicitly stated conditions - I move to amend the documentation to include my interpretation (boldface), which is I believe soundly grounded.
All in favor say I )
Now it's a bug! Just kidding.

The following text in ReadRun's documentation is also inconsistent with my interpretation:
Except for performance, equivalent to:

Code: Select all

		VAR a: Attributes;
		a := rd.attr;
		REPEAT rd.Read UNTIL (rd.attr # a) OR (rd.view # NIL) OR rd.eot;
		IF rd.eot THEN attr := NIL ELSE attr := rd.attr END
Thus I propose a fix to this issue. The fix is generic to Reader, not specific to StdReader (the reason is, I'm not competent in StdReader/StdModel internals):
REPLACE in TextModels

Code: Select all

PROCEDURE (rd: Reader) ReadRun* (OUT attr: Attributes), NEW, ABSTRACT;
With the following:

Code: Select all

	PROCEDURE (rd: Reader) ReadRun* (OUT attr: TextModels.Attributes), NEW, EXTENSIBLE;
	(** post: rd.eot OR a # NIL, rd.view = ViewAt(rd.Pos() - 1) **)
	BEGIN
		rd.Read; attr := rd.attr;
		IF rd.view = NIL THEN
			WHILE (rd.attr = attr) & (rd.view = NIL) & ~rd.eot DO rd.Read END;
			IF ~rd.eot OR (rd.view # NIL) THEN rd.ReadPrev END
		END
	END ReadRun;	
AND comment out

Code: Select all

PROCEDURE (rd: StdReader) ReadRun
- maybe someone will be willing to fix it at the level of internals.

I have searched thru standard BlackBox codebase, and found 2 uses of ReadRun, both would not be broken by my proposal (they don't use .Pos() right after .ReadRun). Good news: no dependencies will be broken. Bad news (for me): not exactly a relevant bug ;). But it bugged me nonetheless in my little tool.

Attached is the module with the aforementioned example and fix.

P.S. SOOOO unfortunate we still don't have a native BB forum to be able to easily use BB texts in posts!
User avatar
adimetrius
Posts: 68
Joined: Sun Aug 04, 2019 1:02 pm

Re: BlackBox 1.7.2 - Release candidate

Post by adimetrius »

SetNativeProp Amendment
Dear colleagues,

I propose to amend TextControllers.StdCtrl.SetNativeProp.
The proposed amendment allows the user to apply attributes (and properties in general) to the current word, not only to the current selection. Thus, pressing ^B would bolden the word that has the caret. Old functionality is guaranteed: if there's a selection, the attributes are applied to the selection.

Code: Select all

  PROCEDURE (c: StdCtrl) SetNativeProp (selection: BOOLEAN; old, p: Properties.Property);
      VAR t: TextModels.Model; beg, end: INTEGER; (*▶*)toWord: BOOLEAN;(*◀*)
   BEGIN
      t := c.text;
      IF selection THEN beg := c.selBeg; end := c.selEnd;
         (*▶*)IF beg = none THEN toWord := TRUE; c.view.ThisSetter().GetWord(c.carPos, beg, end);
            ASSERT(end <= t.Length())
         ELSE toWord := FALSE END(*◀*)
      ELSE beg := 0; end := t.Length()
      END;
      IF beg < end THEN
         t.Modify(beg, end, old, p);
         IF selection (*▶*)& ~toWord(*◀*) THEN c.SetSelection(beg, end) END
      ELSIF selection THEN
         c.insAttr := TextModels.ModifiedAttr(InsertionAttr(c), p)
      END
   END SetNativeProp;
This amendment has revealed a minor defect in TextSetters:

Code: Select all

PROCEDURE (s: StdSetter) GetWord (pos: INTEGER; OUT beg, end: INTEGER);
IF (pos = s.text.Length()) & (s.text[last character] = 0DX) THEN GetWord returns end = s.text.Length() + 1. That is, if there's an end of line at the end of a text, then GetWord returns end of word beyond end of text.

Therefore, (being incompetent in StdSetter internals) I propose to patch StdSetter.GetWord in the following way:

Code: Select all

      UNTIL ~part OR (s.rd.string[0] = 0X) OR (end - beg > wordCutoff);
      (*▶*)end := MIN(end, s.text.Length());
      ASSERT((0 <= beg) & (beg <= end) & (end <= s.text.Length()), 60)(*◀*)
   END GetWord;
The documentation for GetWord could also be amended to include:

Code: Select all

	Post
		end <= s.text.Length()
But this is not absolutely necessary: it seems to be obvious that the end of a word cannot be beyond the end of the text.

Attached is a module that allows to see the defect, and not see it after the patch is applied.

Image
Attachments
SetNativePropAmendment.txt
(6.76 KiB) Downloaded 333 times
Post Reply