I modified your second example slightly, using only one MoveDocumentEnd
The
MoveDocumentEndEx function was in the macro I recorded because this is a Brief specific function and I run the Brief keyboard mapping.
Brief has a special way of handling the end key and that is defined by the
MoveDocumentEndEx function.
So the
MoveDocumentEnd is the better choice
Although I have the "Keypress removes mark" mapping option selected, up, down, right or left arrow (only) keypresses adjust the marked block rather than dispensing/removing the selection as I would have hoped.
This is because the marked mode is still active.
The
MarkBlockSet does nothing more than
turn on block marking and when marking is on the area is always adjusted whenever the cursor is moved.
If you want to just set the marked area you will have to use the none keyboard macro functions with something like this:
Code: Select all
function SelectCursorToDocEnd()
local document = is_document()
if (document == 0) then
return
end
screen_update_disable()
-- differnet marking modes
local MARK_COLUMN = 0
local MARK_LINE = 1
local MARK_BLOCK = 2
local MARK_RAGGED = 3
local MARK_CUA = 4
-- define the marked region
local top = get_line_pos()
local left = get_cursor_pos()
local bottom = get_line_count() + 1
local right = 0 -- no marked area for the last line
local mode = MARK_BLOCK
-- remove any active marked area
MarkHide()
-- move cursor to end of file
set_line_pos(bottom, right + 1)
-- apply the new marked region
set_marked_area(mode, top, left, bottom, right)
screen_update_enable()
screen_update()
end
SelectCursorToDocEnd() -- run the macro
This macro macro just sets the marked area outright, meaning there will be no active marking mode.
I guess another thing that fails in this example is that, after I make a selection using a macro such as this, the moment I use my mouse to scroll the window, my selection disappears.
That is because, Zeus by design makes sure the cursor is always on the screen.
Now some might say this is in fact a Zeus bug, but it is most certainly a thing that has been coded into the editor
What happens is when you do a scroll and it then moves the cursor for it to stay on the screen and that movement removes the marked area.
For example, if I make a selection using my mouse by clicking (and holding) and dragging my mouse, release the button and then scroll, my selection remains highlighted.
I can replicate this behaviour at this end and will look into why they are not consistent.
Cheers Jussi