This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Kate - move to end of document

Tags: None
(comma "," separated)
jmoellers
Registered Member
Posts
1
Karma
0

Kate - move to end of document

Tue Apr 20, 2021 2:09 pm
Hi,
I'm using kate as an editor to keep track of my software development and maintenance activities.
My primary tool is a self-written small list management tool which, upon double-clicking an item in the list, will open the corresponding document in a/the kate window using a qdbus message:
qdbus org.kde.kate-XXXXX /MainApplication org.kde.Kate.Application.openUrl file:<pathname> utf-8
Now, when I first open a document the cursor is at the top, but I usually want to add text at the bottom.
The qdbus interface has a method
Code: Select all
org.kde.Kate.Application.setCursor
but to use that, I would need to have the number of lines in the document.
OTOH if I hit Ctrl-End, the cursor goes to the end of the text.
Is there a way to send keystrokes to kate to emulate me hitting Ctrl-End?
User avatar
pvzh
Registered Member
Posts
24
Karma
1
OS

Re: Kate - move to end of document

Wed Apr 28, 2021 11:14 am
Hi! This is a very interesting problem. I will also follow the discussion. So far, I can only offer an option with counting the number of lines. But wc and grep ignore the last blank line. Full path is required, there is no validation now. Here is a draft of the bash function:

Code: Select all
k () {
    if [[ -e $1 ]]; then
        k=`qdbus | grep kate`
        c=`wc -l <$1`
        qdbus $k /MainApplication org.kde.Kate.Application.tokenOpenUrlAt "file:$1" $(($c?($c-1):0)) 0 utf-8 0
    fi
}


Bookmarks



Who is online

Registered users: abc72656, Bing [Bot], daret, Google [Bot], lockheed, Sogou [Bot], Yahoo [Bot]