Scroll to a position
-
Hello,
I have the script below, it is work in progress for a bigger script, but I am isolating where it does not work.
In Notepad++ there are 2 identical tabs open. The first one is active.
The script should take the caret position on the active tab, switch to the second tab, and move the cursor to the same caret position there.
It all works except moving the cursor on the second tab. That is, the cursor is at the right position but the line is not visible on screen (scrolling does not take place).Can anyone look at this with me please ? Thanks in advance!
EDIT: with initially the cursor on the first position of the second tab, even this line does not jump down:
editor.setFirstVisibleLine(90)This seems strange to me.
from Npp import * def get_cursor_position(): position = editor.getCurrentPos() line = editor.lineFromPosition(position) + 1 column = editor.getColumn(position) return (position, line, column) def set_cursor_position(position): editor.gotoPos(position) def switch_tab(tab_index): notepad.activateIndex(notepad.getCurrentView(), tab_index) # Get the cursor position on the active tab current_tab_index = notepad.getCurrentDocIndex(notepad.getCurrentView()) cursor_position_info = get_cursor_position() console.write('\nFull position: ' + str(cursor_position_info)) # Switch to the next tab switch_tab(current_tab_index + 1) # Set the cursor position on the other tab set_cursor_position(cursor_position_info[0])
-
Dunno. Your script worked for fine for me.
-
Thank you for the confirmation ! I will not spend more time on it.