Ctrl+Shift+End ?
Ctrl+Shift+End ?
Using the latest release of Zeus to date (in Win 10), I've been looking through the list of keyboard functions in help and have "cut my teeth" a bit modifying keyboard templates for other purposes. Now, I want to enable [Ctrl]+[Shift]+[End] as a "select starting at the current cursor position through to the end of the doc" similar to default behaviors in Notepad, EditPad Pro, Notepad++, EmEditor, Visual Studio, etc. Can anyone suggest a good way to do this
Thank you in advance 
Re: Ctrl+Shift+End ?
The easiest way to do things like this is to just create a macro and bind it to the keybaord.
This is what you need to do:
1. Start macro recording
2. Replicate the steps required using the keyboard
3. Stop macro recording
4. Save the macro to file
5. Bind that macro to the keyboard
If I do this I get this macro:
NOTE: The macro that was actually recorded had MarkBlockToggle but I changed it to MarkBlockSet.
I would then clean up the macro and make it a little more robust as shown below:
Cheers Jussi
This is what you need to do:
1. Start macro recording
2. Replicate the steps required using the keyboard
3. Stop macro recording
4. Save the macro to file
5. Bind that macro to the keyboard
If I do this I get this macro:
Code: Select all
function key_macro()
screen_update_disable()
MarkBlockSet()
MoveDocumentEndEx()
MoveDocumentEndEx()
screen_update_enable()
screen_update()
end
key_macro() -- run the macroI would then clean up the macro and make it a little more robust as shown below:
Code: Select all
function key_macro()
-- macro only works for documents
local document = is_document()
if (document == 0) then
message("This macro only works for documents.");
beep();
return;
end
screen_update_disable()
MarkBlockSet()
MoveDocumentEndEx()
MoveDocumentEndEx()
screen_update_enable()
screen_update()
end
key_macro() -- run the macroRe: Ctrl+Shift+End ?
Very cool. Thank you very kindly for both your time and example(s). I appreciate it. 
Re: Ctrl+Shift+End ?
I modified your second example slightly, using only one MoveDocumentEnd() - I found I had to use (3) MoveDocumentEndEx() calls in a COBOL file for whatever reason. 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.
Re: Ctrl+Shift+End ?
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. So a selection made this way is different than other selections. 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. Similarly, if I press [Shift]+[End] to select a portion of a line and then scroll using my mouse, the selection remains highlighted. Using a macro such as the above, when I press [Ctrl]+[Shift]+[End], I see my selection but when I scroll with my mouse, viola! the selection is gone. 
Re: Ctrl+Shift+End ?
Regarding my reply:
"I modified your second example slightly, using only one MoveDocumentEnd() - I found I had to use (3) MoveDocumentEndEx() calls in a COBOL file for whatever reason. 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."
Sorry to be a PITA. I figured this out by adding a MarkBlockToggleEx() call so I now have:
The selection still disappears when I scroll using my mouse wheel, though.
"I modified your second example slightly, using only one MoveDocumentEnd() - I found I had to use (3) MoveDocumentEndEx() calls in a COBOL file for whatever reason. 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."
Sorry to be a PITA. I figured this out by adding a MarkBlockToggleEx() call so I now have:
Code: Select all
function SelectCursorToDocEnd()
local document = is_document()
if (document == 0) then
return
end
screen_update_disable()
MarkBlockSet()
MoveDocumentEnd()
screen_update_enable()
screen_update()
MarkBlockToggleEx()
end
SelectCursorToDocEnd() -- run the macroRe: Ctrl+Shift+End ?
The MoveDocumentEndEx function was in the macro I recorded because this is a Brief specific function and I run the Brief keyboard mapping.I modified your second example slightly, using only one MoveDocumentEnd
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
This is because the marked mode is still active.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.
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 macroThat is because, Zeus by design makes sure the cursor is always on the screen.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.
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.
I can replicate this behaviour at this end and will look into why they are not consistent.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.
Cheers Jussi
