#11095

Stefan
Participant

 

That sounds like an automatically scrolling feature.

Isn’t that disturbing?

I think I have never seen this feature in EmEditor.

There are only this shortcuts

Alt+PageUp – move cursor at top of screen
CTRL+UP ARROW – Scrolls the document up by one line

Hmm, but from that we can create an script
to move line with cursor into horizontal mid of screen:



////scroll line with cursor in horizontal mid screen
yPosCurr = document.selection.GetActivePointY( eePosView );
xPos = document.selection.GetActivePointX( eePosView );
editor.ExecuteCommandByID(4292); //Moves the cursor to the top of the current window.
yPosTop = document.selection.GetActivePointY( eePosView );
editor.ExecuteCommandByID(4293); //Moves the cursor to the bottom of the window
yPosBot = document.selection.GetActivePointY( eePosView );
yPosMid = parseInt(yPosTop + ((yPosBot - yPosTop) / 2) );
iDiff = parseInt( (yPosBot - yPosTop) / 2 );
if(yPosCurr < yPosTop){ iDiff += (yPosTop - yPosCurr);}
if(yPosCurr > yPosBot){ iDiff += (yPosCurr - yPosBot);}
if(yPosCurr > yPosMid){
for( i=1; i < iDiff; i++){
// Scrolls the document down by one line.
editor.ExecuteCommandByID(4171);
}
}else{
for( i=1; i < iDiff; i++){
// Scrolls the document up by one line
editor.ExecuteCommandByID(4170);
}
}
document.selection.SetActivePoint( eePosView, xPos, yPosCurr, false );

Hmm, that script is a nice feature. Could use this myself often.

But not what you are after, I understood.

I have added Ctrl+Alt+M to that script,
and now, whenever I had scrolled my cursor line
out of view, this will bring the line back to mid screen.
Nifty, thanks for idea :-D

Now I can leave the cursor in the current line and use the
scroll bar to go to another place in the document to spot
some information, then pressing Ctrl+Alt+M scrolls back to
the line with the cursor.

I wonder if this is not already implemented? I go RTFM again…

.