Topic: creating a highligted columnar block (1 of 14), Read 27 times
Conf: VEDIT Macro Language Support
From: Bernd Richert
Date: Sunday, January 02, 2005 11:21 AM

Dear all,

I am observing different behaviour of Vedit, when submitting a sequence of commands to the command window, opposed to submitting the same commands one by one.

The command sequence is:
bb(CLEAR);cm(SET);bb(cp);cb(crn);ri(0);c(-1);be(cp);ce(crn)

Assume the block "ab\nab" is in the scratchpad.
The result then is "Ab\nAb" - capital letters indicating selected text - and the cursor on the last b.
Consequently cb=1 and ce=1.

This is not what I expected to get.

What I expected is "AB\nAB" - capital letters indicating selected text - and the cursor on the last char.
Consequently: cb=1 and ce=2.

Very interesting: This is exactly what I get, if I submit the above commands one by one.

Is there anybody who can help?

Regards
Bernd

 


Topic: Re: creating a highligted columnar block (2 of 14), Read 26 times
Conf: VEDIT Macro Language Support
From: Christian Ziemski
Date: Sunday, January 02, 2005 12:39 PM

On Sun, 02 Jan 2005 11:21:00 -0500, Bernd Richert wrote:

>[problems with]
>bb(CLEAR);cm(SET);bb(cp);cb(crn);ri(0);c(-1);be(cp);ce(crn)
>
>Assume the block "ab\nab" is in the scratchpad.
>[...]

Testing your example with VEDIT64 6.13.1 replicates your findings.
Using the 32-Bit VEDIT behaves differently (but also wrong according
to your expectations).

But both versions disable the correct function of Backspace!
It is impossible to delete the text only with Backspace (beginning at
your last "b" in the second line).
It stops at BoL.

There seems to be a little bug somewhere?


Christian

 


Topic: Re: creating a highligted columnar block (3 of 14), Read 26 times
Conf: VEDIT Macro Language Support
From: Christian Ziemski
Date: Sunday, January 02, 2005 02:14 PM

Some minutes ago I wrote:

>But both versions disable the correct function of Backspace!
>It is impossible to delete the text only with Backspace
>(beginning at your last "b" in the second line.
>It stops at BoL.
>
>There seems to be a little bug somewhere?

Ouch, one bug is sitting in front of my computer...

The main reason for the stopping Backspace is it's function of
"undenting a highlighted block".

(I often forget about that special function.)

Deleting the block markers enables Backspace again.
(There was no VISIBLE highlighted block here, see below).


But anyway: there IS a bug somewhere in VEDITs block marker handling.

Consider the following situation, created with Bernd's example
commands (Capitals are highlighted, the underscore is the cursor):

ab
A_b

Hitting Backspace deletes the highlighted "a" in line 2!
That is not correct. It should undent the block, which is
"do nothing" here because the block is already at BOL.


Christian

 


Topic: Re: creating a highligted columnar block (4 of 14), Read 24 times
Conf: VEDIT Macro Language Support
From: Bernd Richert
Date: Sunday, January 02, 2005 03:04 PM

Christian,

Sorry, but I don't understand your discussion regarding the 'Backspace'.
There is no Backspace in the command sequence
bb(CLEAR);cm(SET);bb(cp);cb(crn);ri(0);c(-1);be(cp);ce(crn)
..and I didn't want to delete any character.

c(-1) is necessary, because ri(0) places the cursor behind the last inserted
character, producing
AB
AB_
..wereas visual mode requires the cursor to be placed ON the last inserted
character.

By the way: Up to c(-1) the command sequence works ok with my version of Vedit
(which is 6.12.1). The result up to here is
AB
AB
.. with the cursor on the last B.

If be(cp) is added to the command sequence, the result is
Ab
Ab
..and this remains unchanged with ce(crn) added to the sequence.


Regards
Bernd

 


Topic: Re: creating a highligted columnar block (5 of 14), Read 26 times
Conf: VEDIT Macro Language Support
From: Christian Ziemski
Date: Monday, January 03, 2005 01:55 AM

Bernd:

On Sun, 02 Jan 2005 15:04:00 -0500, you wrote:

>Christian,
>
>Sorry, but I don't understand your discussion regarding the
>'Backspace'.
>There is no Backspace in the command sequence
>bb(CLEAR);cm(SET);bb(cp);cb(crn);ri(0);c(-1);be(cp);ce(crn)
>..and I didn't want to delete any character.

Yes, I know. I simply wanted to describe an additional (probably
related) problem I found while playing with your case.

Sorry to have been confusing! That info was directed towards Ted.
(I'm throwing all quirks and bugs I'm finding in VEDIT at him ;-) )



I'm remembering a discussion with Ted when I had a similar problem
with Reg_Ins() and Block_Begin().

Ted answered:
>BB is a text marker which "sticks" to characters.
>Therefore "BB(3)" sticks BB to the 4th character in the file.
>When you then insert anything with the cursor at the 4th character,
>the insertion is between the 3rd than 4th characters. I.e. the 4th
>character now has a bigger file-position. Hence BB has bigger
>file-position.
>
>This is not limited to Clip_Ins and Reg_Ins, but also any
>insertion command.


To take this behavior into account I tried your case with this command
sequence, but with strange results too:

Block_Begin(CLEAR)
Column_Mode(SET)
#103=Cur_Pos
Reg_Ins(0)
Char(-1)
Block_Begin(#103)
Block_End(Cur_Pos)


Hmmm, now I'm confused (about the results).

Unfortunately it's late and I'll go to bed now.
To be continued.

Christian

 


Topic: Re: creating a highligted columnar block (6 of 14), Read 26 times
Conf: VEDIT Macro Language Support
From: Christian Ziemski
Date: Monday, January 03, 2005 02:14 AM

Bernd:

The combination of our two approaches did it:

Block_Begin(CLEAR)
Column_Mode(SET)
Column_Begin(Cur_Col)
#103=Cur_Pos
Reg_Ins(0)
Char(-1)
Column_End(Cur_Col)
Block_Begin(#103)
Block_End(Cur_Pos)


Christian

 


Topic: Re: creating a highligted columnar block (7 of 14), Read 27 times
Conf: VEDIT Macro Language Support
From: Bernd Richert
Date: Monday, January 03, 2005 04:37 AM

Im trying to summarize and explain.

Sticking to my original command sequence:
ic(32,COUNT,crn-cn);bb(CLEAR);cm(SET);bb(cp);cb(crn);ri(0);c(-1);be(cp);ce(crn)
..and veryfying bb is shifted by ri(0) produces the following result after
submitting gp(bb) (capitals highlighted):
Au_
Au
This confirms, bb was shifted by 2, the number of inserted columns. - ok.

gp(be) produces the following result (Umlaut indicating the cursor position):
Au

The cursor is at the intended position - ok.

It holds: cb=ce= first inserted column. So the cb value is not shifted (of course).
BUT WHAT ABOUT CE?
ce was set at be, which - as confirmed above - is on the second inserted column.
So ce should be (cb+1).
This IS the case, when the commands are issued one by one. And consequently,
if doing so, the inserted 2*2 matrix is highlighted.

Why does the complete sequence produce a different result, ce=cb?


Obviously the visual mode takes cb and ce as columns to highlight, and it takes
the line numbers from bb and be. This may produce a highlighted area with bb
outside of it. But it should not produce one with also be outside.


Christian,
your proposal,
bb(CLEAR);cm(SET);cb(crn);#103=cp;ri(0);c(-1);ce(crn);bb(#103);be(cp)
..is setting bb at the top-left corner - ok, but it also terminates with cb=ce,
consequently only the first column highlighted (with my Vedit version, 6.12.1).


This is for further study.


Regards
Bernd

 


Topic: Re: creating a highligted columnar block (9 of 14), Read 25 times
Conf: VEDIT Macro Language Support
From: Christian Ziemski
Date: Monday, January 03, 2005 07:06 AM

Bernd:

You wrote:

>Sticking to my original command sequence:
>ic(32,COUNT,crn-cn);bb(CLEAR);cm(SET);bb(cp);cb(crn);ri(0);c(-1);
>be(cp);ce(crn)
>..and veryfying bb is shifted by ri(0) produces the following result
>after submitting gp(bb) (capitals highlighted):
>Au_
>Au
>
>This confirms, bb was shifted by 2, the number of inserted columns. - ok.

I'm getting

ab
Ax

And checking Block_Begin and Block_End shows 6 and 5!
(That means: begin is greater than end position! That may
additionally confuse the highlighting.)

Using Cur_Col instead of Cursor_Col gives

ab
AX

(Capitals are highlighted, x=cursor position)


Conclusion:
One has to be careful with "visual" commands when using them from
command mode or within macros.
(The Column_Begin and Column_End are commands for visual mode too.)


But I have to confirm, there is something strange going on in your
example. Perhaps Ted will have an idea...



Back to your initial message: What is your plan with your code?
Do you want to do something with the block or is it important to have
it highlighted visually?

If the former is true then you should try to work with
Reg_Copy_Block(...,LINESET+COLSET ...), setting the corners of the
block carefully.


Christian

 


Topic: Re: creating a highligted columnar block (8 of 14), Read 25 times
Conf: VEDIT Macro Language Support
From: Bernd Richert
Date: Monday, January 03, 2005 05:57 AM

I have got an alternative solution, which works perfectly, if commanded step by step,
but produces another strange result:

bb(CLEAR);cm(SET);bb(cp);cb(crn);ri(0);bb(bb-(crn-cb));c(-1);be(cp);ce(crn)

This terminates:
AU

..capitals indicating highlight and Umlaut indicating the cursor, bb on top-left,
be on bottom-right, ce=bb+1 - perfect.

But as a set of commands, this fails at two points:
- bb(bb-(crn-cb)) is not calculated
- ce=cb,
i.e. it terminates:
Aub

..b indicating bb, be is at the cursor position, which is correct.

Bernd

 


Topic: Re: creating a highligted columnar block (10 of 14), Read 25 times
Conf: VEDIT Macro Language Support
From: Christian Ziemski
Date: Monday, January 03, 2005 07:11 AM

On 1/3/2005 5:57:54 AM, Bernd Richert wrote:
>I have got an alternative solution, which works
>perfectly, if commanded step by step,
>but produces another strange result:
>
>bb(CLEAR);cm(SET);bb(cp);cb(crn);ri(0);bb(bb-(crn-cb));c(-1);be(cp);ce(crn)
>
>This terminates:
>AU
>AÜ
>..capitals indicating highlight and Umlaut
>indicating the cursor, bb on top-left,
>be on bottom-right, ce=bb+1 - perfect.
>
>But as a set of commands, this fails at two points:
>- bb(bb-(crn-cb)) is not
>calculated
>- ce=cb,
>i.e. it terminates:
>Aub
>Aü
>..b indicating bb, be is at the cursor position, which is
>correct.

I haven't tested the above, but I suppose the difference between the single stepping and the command sequence is that in the former the Visual Mode is entered after every command and so the visual commands are "updated" on screen.

As I wrote in my earlier message some minutes ago: Visual commands are a bit difficult to use...

Christian

 


Topic: Re: creating a highligted columnar block (11 of 14), Read 29 times
Conf: VEDIT Macro Language Support
From: Bernd Richert
Date: Monday, January 03, 2005 08:05 AM

Finally, I have got it.

The following set of commands is working as I expected.

bb(CLEAR);cm(SET);bb(cp);cb(crn);ri(0);bb(bb-(cn-cb));c(-1);be(cp);ce(cn)

You see, I am using cn now, instead of crn.
My explanation is: crn is not being updated before the execution of a subsequent command within a predefined sequence.
But it obviously is updated upon return to the command prompt.
So; calculations based on cn do work and calculations based on crn do not.

That's it.

Regards
Bernd

 


Topic: Re: creating a highligted columnar block (12 of 14), Read 23 times
Conf: VEDIT Macro Language Support
From: Ted Green
Date: Tuesday, January 04, 2005 06:35 PM

At 08:05 AM 1/3/2005, you wrote:
>From: "Bernd Richert"
>
>Finally, I have got it.
>
>The following set of commands is working as I expected.
>
>bb(CLEAR);cm(SET);bb(cp);cb(crn);ri(0);bb(bb-(cn-cb));c(-1);be(cp);ce(cn)
>
>You see, I am using cn now, instead of crn.
>My explanation is: crn is not being updated before the execution of a subsequent command within a predefined sequence.
>But it obviously is updated upon return to the command prompt.
>So; calculations based on cn do work and calculations based on crn do not.

Yes, your macro should only use Cur_Col (CN) and not Cursor_Col (CRN).

CRN is only changed when you enter Visual Mode and then return.

Visual mode lets you position the cursor past the end of a line into "virtual" space. A macro can then read this cursor position value using CRN. Hence "CRN-CN" indicates how far the cursor is past the end-of-line into virtual space.

I noticed the CRN in your macro several days ago, but at the time wasn't sure what you were trying to do. Sorry that I didn't point it out then, and that the difference between CN and CRN is not better documented.

Also, what you are doing is a bit unusual - you are starting a block and then inserting text at the beginning of the block. You already discovered that this tends to move BB past the insertion.

Ted.

 


Topic: Re: creating a highligted columnar block (13 of 14), Read 27 times
Conf: VEDIT Macro Language Support
From: Bernd Richert
Date: Wednesday, January 05, 2005 03:19 AM

Ted,

thanks for this explanation.
I will again spend some thoughts on my method of visualizing a columnar block. I need to continue learning.

Bernd

 


Topic: Re: creating a highligted columnar block (14 of 14), Read 27 times
Conf: VEDIT Macro Language Support
From: Bernd Richert
Date: Wednesday, January 05, 2005 11:44 AM

And my final solution for highlighting a columnar block is:

ic(32,COUNT,crn-cn);#103=cp;cb(cn);ri(0);bb(#103);c(-1);be(cp);ce(cn)


And the secret about all that effort?

I wanted to write some de luxe cut and paste functions.
A description of functionality and outcome is given below.


^C: Store the marked block. The current mode, stream or column, is used.
Also store the information, whether the block contains a newline (#11).
Complete block marking (so the block may be left if persistent blocks are
configured).

^X: Basic function is like that of ^C. Additionaly:
If insert mode, delete the block.
If overwrite mode, backfill the block with blanks.
Backfill is not done, if stream mode and newline contained.

^V: If insert mode, insert column/stream block. Always insert, if newline
contained in a stream block.
If overwrite mode, overwrite. If stream mode, overwrite within current
line, i.e. newline will not be overridden!
If insert mode, insert.
In any case: highlight the pasted block.

The keystroke macros are listed below - for everybody, interested.


Ctrl-C [VISUAL EXIT]if(bb==CLEAR){re(11)}else{if(be==CLEAR)
{be(cp)}if(cm){ic(32,COUNT,crn-cn)}#103=cp;if(cm){#11=0;gp(min(bb,be));
#104=bolpos+min(cb,ce)-1;gp(max(bb,be));#105=bolpos+max(cb,ce);
rcb(11,#104,#105,COLUMN)}else{#11=sb("|N",bb,be,BEGIN+NOERR);rcb(11,bb,be)}gp(#103)}v

Ctrl-X [VISUAL EXIT]if(bb==CLEAR){re(11)}else{if(be==CLEAR){be(cp)}
if(cm){ic(32,COUNT,crn-cn)}sm(0,cp);#103=cp;if(cm){#11=0;gp(min(bb,be));
#104=bolpos+min(cb,ce)-1;gp(max(bb,be));#105=bolpos+max(cb,ce);
rcb(11,#104,#105,COLUMN+DELETE+(!im)*FILL)}else{#11=sb("|N",bb,be,BEGIN+NOERR);
rcb(11,bb,be,DELETE+(!im&!#11)*FILL)}if(im){gm(0);bb(CLEAR)}else{gp(#103)}}v

Ctrl-V [VISUAL EXIT]bb(CLEAR);if(cm){ic(32,COUNT,crn-cn);#103=cp;
cb(cn);ri(11,(!im&!#11)*OVERWRITE);bb(#103);c(-1);be(cp);ce(cn)}else
{if(im|#11|eolpos-cp be(cp);gp(bb)}else{ri(11,BEGIN+OVERWRITE);bb(cp);c(rsize(11));be(cp)}}v


Regards
Bernd