PDA

View Full Version : Problem with column blocks



jbrandwood
April 4th, 2014, 06:26 PM
I've just been trying to fix the Numpad+ and Numpad- functioning of the Brief-emulation keyboard mapping when running on Win7 x64.

These keys map to [T-REG COPY][RETURN] and [T-REG MOVE][RETURN], neither of which works on my Win7 because Vedit doesn't seem to be able to pass the [RETURN] key to the dialog box popup.

I've rewritten the keyboard mapping as these macros ...

Numpad+ [VISUAL EXIT] if(BB==-1){BM(LINEBLOCK)BB(CP)}if(BE==-1){BE(CP)}RCB(0,BB,BE,BM)BB(-1)

Numpad- [VISUAL EXIT] if(BB==-1){BM(LINEBLOCK)BB(CP)}if(BE==-1){BE(CP)}RCB(0,BB,BE,BM)DB(BB,BE,BM)BB(-1)

... which basically seems to work, EXCEPT for one major problem, and then only in column selection mode.

On the RCB() column copy, the rightmost highlighted column is not included in the copy, but on the DB() column delete, the rightmost highlighted column IS included in the delete.

When I manually do the copy/move with a [T-REG COPY] or [T-REG MOVE], then the rightmost highlighted column IS included in the copy.

Is this a bug or a known inconsistency between the behavior of RCB() and DB() in column mode?

Scott Lambert
April 17th, 2014, 02:49 PM
Hi,

Interesting problem. Here is my test block:

aaaaaaaaaaaaaaa
bbbbbbbbbbbbbbb
ccccccccccccccc
ddddddddddddddd

I highlight the block as a columnar block starting at the first a and ending at last d, and then drop to command mode and enter:

rcb(0,bb,be)

Then return to Visual mode and select paste from scratchpad, I get:

aaaaaaaaaaaaaaa
bbbbbbbbbbbbbbb
ccccccccccccccc
dddddddddddddd

It drops the last d.

If I instead highlight the block as a colmnar block, drop to command mode and type:

rcb(0,bb,be,column)

Return to visual mode and paste, I get:

aaaaaaaaaaaaaa
bbbbbbbbbbbbbb
cccccccccccccc
dddddddddddddd

It does indeed drop rightmost column.

If I instead highlight the block as a colmnar block, drop to command mode and type:

rcb(0,bb,be,colset,1,15)

aaaaaaaaaaaaaaa
bbbbbbbbbbbbbbb
ccccccccccccccc
ddddddddddddddd

Which is correct.

In the line:

rcb(0,bb,be,colset,1,15)

In the above the 1 is the starting column of the block and the 15 is the ending column of the block.

So, it is my opinion, that your macros must get the start and end columns of the block before using the rcb command and then using above format of rcb command.

Hope that helps you.

Scott

jbrandwood
April 17th, 2014, 09:53 PM
Hi Scott, thanks for the confirmation of the issue, and the suggested work aound.

I've actually found my own work-around, but I don't know why it works!

Numpad+ [VISUAL EXIT] if(BB==-1){BM(LINEBLOCK)BB(CP)}if(BE==-1){BE(CP)}if(BM==COLUMN){BE(BE+1)}RCB(0,BB,BE,BM)B B(-1)

Numpad- [VISUAL EXIT] if(BB==-1){BM(LINEBLOCK)BB(CP)}if(BE==-1){BE(CP)}if(BM==COLUMN){BE(BE+1)}RCB(0,BB,BE,BM)D B(BB,BE,BM)BB(-1)

Now, based upon the previous behavior, you'd expect that moving the BE by 1 would cause the DB() to delete one extra column to the right ... but it doesn't!

This definitely seems to be some kind of voodoo bug.

jbrandwood
May 22nd, 2014, 01:21 PM
OK, more tests and it just seems like both RCB() and DB() ignore the last column in "COLUMN" mode, and that my previous work-around sort-of-worked because of that.

Unfortunately, I forgot that you can sometimes start at the end of the block instead of the beginning. The next shift-drag selection was also funky because I didn't clear the block mode.

So here's a much better macro that does work all the time.

I've added extra line-breaks for clarity, but they should all be removed so that the macro is on one line for pasting into the actual keyboard layout.

Numpad+ [VISUAL EXIT]
if(BB==-1)
{BM(LINEBLOCK)BB(CP)}
if(BE==-1)
{BE(CP)}
if(BM==COLUMN)
{RCB(0,BB,BE,COLSET,CB,CE)}
else
{RCB(0,BB,BE,BM)}
BB(-1)
BM(0)

Numpad- [VISUAL EXIT]
if(BB==-1)
{BM(LINEBLOCK)BB(CP)}
if(BE==-1)
{BE(CP)}
if(BM==COLUMN)
{RCB(0,BB,BE,COLSET,CB,CE)DB(BB,BE,COLSET,CB,CE)}
else
{RCB(0,BB,BE,BM)DB(BB,BE,BM)}
BB(-1)
BM(0)

pal
May 26th, 2014, 08:40 AM
This is probably related to the fact that highlighting a block works differently in column mode and normal mode.

When you highlight a stream block, the last character included in the block is the one to the left of cursor.
When you highlight a columnar block, the last character (and last column) included is the one to the right of cursor.

That is why you need to check the mode if you implement the function in macro language.

pal
May 26th, 2014, 08:56 AM
I think the simplest way to implement the required functionality is:


Numpad+ [MENU]esc
Numpad- [MENU]est

jbrandwood
May 31st, 2014, 02:37 PM
Hahaha! I was totally over-thinking things and focused in on how I'd accomplish the task with a macro.

I'd forgotten that those scratchpad functions existed in the menu ... of course I should just be using "[MENU]ESC" and "[MENU]EST"!

Thanks for reminding me of them.