Document frozen

Usage of the framework, compiler and tools

Document frozen

Postby DGDanforth » Mon Jan 23, 2017 4:15 am

I just encountered a situation I haven't seen before.
A document that I could access and had been editing for several days suddenly
became uneditable. It behaves as if it were in mask mode but when I do
Dev->
none of the Edit, Layout, Browser, or Mask modes are checked. I can not change the mode.

I have exited and restarted BB but nothing changes.

There must be hidden attributes of the file which I can not access.

Help is requested to solve this problem.

-Doug Danforth
User avatar
DGDanforth
 
Posts: 46
Joined: Tue Sep 17, 2013 1:16 am
Location: Palo Alto, CA, U.S.A.

Re: Document frozen

Postby DGDanforth » Mon Jan 23, 2017 5:08 am

Wow, I just learned something.
It turns out that a wrapped view retains the fact that it was wrapped when one saves the document.

I have been experimenting with wrapping and unwrapping views so I can switch between passing
characters to the view (standard mode) and passing them to a command interpreter.
In order to inhibit a character in command mode also going to the view I implemented a BOOLEAN
'forward' variable associated with the wrapping view. But if forwarding is inhibited AND the
file is saved THEN the file (document) can no longer be edited even if BlackBox is restarted for
the module controlling the behavior of the wrapped view is reloaded at startup.

Hence I had to make the default to be "forward" and only under careful control to allow dontForward.
Very subtle and dangerous.

-Doug Danforth
User avatar
DGDanforth
 
Posts: 46
Joined: Tue Sep 17, 2013 1:16 am
Location: Palo Alto, CA, U.S.A.

Re: Document frozen

Postby Robert » Wed Jan 25, 2017 12:18 pm

Not enough details to really know, but ...

1 - Can you turn forwarding back on when you don't save the View?
2 - Do you Externalise the forward flag (variable) when you externalize the Wrapper?
3 - Does the Wrapper have other state that should be kept from session to session?
User avatar
Robert
 
Posts: 108
Joined: Sat Sep 28, 2013 11:04 am
Location: Edinburgh, Scotland

Re: Document frozen

Postby DGDanforth » Thu Jan 26, 2017 4:52 am

Robert wrote:Not enough details to really know, but ...

1 - Can you turn forwarding back on when you don't save the View?
2 - Do you Externalise the forward flag (variable) when you externalize the Wrapper?
3 - Does the Wrapper have other state that should be kept from session to session?

"1 - Can you turn forwarding back on when you don't save the View?" YES
"2 - Do you Externalise the forward flag (variable) when you externalize the Wrapper?" I just did Ctrl-S to save the file (my mistake in doing that).
"3 - Does the Wrapper have other state that should be kept from session to session?" Ah, not sure.

-Doug
User avatar
DGDanforth
 
Posts: 46
Joined: Tue Sep 17, 2013 1:16 am
Location: Palo Alto, CA, U.S.A.

Re: Document frozen

Postby Josef Templ » Thu Jan 26, 2017 10:10 am

How does the wrapper code look like?

If you save a wrapped view to a file you must
implement the Externalize and Internalize methods
appropriately.

In my experience, wrapping a view is not a trivial task
but it should be possible to get it working.

- Josef
Josef Templ
 
Posts: 206
Joined: Tue Sep 17, 2013 6:50 am

Re: Document frozen

Postby DGDanforth » Mon Jan 30, 2017 4:38 am

Josef Templ wrote:How does the wrapper code look like?

If you save a wrapped view to a file you must
implement the Externalize and Internalize methods
appropriately.

In my experience, wrapping a view is not a trivial task
but it should be possible to get it working.

- Josef

I have adopted the Obx version of wrapping (as of 2006) and have made
small changes to the code every few years.
Here is what my current interface looks like
Code: Select all
DEFINITION MyWrappers;

   IMPORT Views, Models;

   CONST
      altKey = 28;
      cmdKey = 27;
      ctrlKey = 25;
      leftMouse = 16;
      middleMouse = 17;
      rightMouse = 18;
      shiftKey = 24;

   TYPE
      View = POINTER TO RECORD (Views.View)
         (v: View) DontForward (dontForward: BOOLEAN), NEW;
         (v: View) HandleCtrlMsg (f: Views.Frame; VAR msg: Views.CtrlMessage; VAR focus: Views.View);
         (v: View) InitContext (context: Models.Context);
         (v: View) Neutralize;
         (v: View) Restore (f: Views.Frame; l, t, r, b: INTEGER);
         (v: View) ThisModel (): Models.Model
      END;

      KeyHandler = PROCEDURE (v: Views.View; char: CHAR);

      MouseHandler = PROCEDURE (x, y: INTEGER; modifiers: SET);

   VAR
      view-: View;

   PROCEDURE IsDown (inner: Views.View): BOOLEAN;
   PROCEDURE Unwrap (inner: Views.View);
   PROCEDURE Wrap (inner: Views.View; keyHandler: KeyHandler; mouseHandler: MouseHandler);

END MyWrappers.

Yes, I do have Internalize and Externalize implemented. That's not the problem.
Its the effect of
Code: Select all
      (v: View) DontForward (dontForward: BOOLEAN), NEW;

whose state is retained when the view is saved. The purpose of that call is to temporarily turn off and on
forwarding of messages to the wrapped view so that they are caught and processed without the wrapped
view knowing that. If the view is saved in that mode then when the file is opened it is still blocked
from seeing input. One must unload both the wrapped view and my Wrapping module to get the
wrapped view back in editable form.
-Doug
User avatar
DGDanforth
 
Posts: 46
Joined: Tue Sep 17, 2013 1:16 am
Location: Palo Alto, CA, U.S.A.

Re: Document frozen

Postby Josef Templ » Mon Jan 30, 2017 9:24 am

DGDanforth wrote:One must unload both the wrapped view and my Wrapping module to get the
wrapped view back in editable form.
-Doug


If you disable message forwarding and store the view (including this forwarding behavior)
it is the expected behavior that after opening the view it will again be in
a state where message forwarding is disabled.
If you don't want this behavior you must not store the message forwarding behavior
or you have to reset it upon loading the view.

Why can't you call DontForward(FALSE) in order to get the
forwarding behavior back after opening the view?

In general, if unloading a module is required, it seems that
there is some global state involved. In the case of a wrapper a
global variable is highly suspicious.

Another potential source of confusion may be this:
Did you close the stored view before opening it again?
It may be that the view is not newly opened when it is already open.

- Josef
Josef Templ
 
Posts: 206
Joined: Tue Sep 17, 2013 6:50 am


Return to Common questions

Who is online

Users browsing this forum: No registered users and 1 guest

cron