File Open Show End Not Start

Post Reply
Random Void User
Posts: 61
Joined: 13.07.2024 21:19

File Open Show End Not Start

Post by Random Void User »

I would like CudaText to open all files at the end, not the start. It would always seek to, and show, the last part of every file opened. I found ui_reload_tail, but think I need a different option. Is one available? I prefer not to use "sessions" or similar data records, I just want a master switch, not a per-file switch. Thanks!
main Alexey
Posts: 2708
Joined: 25.08.2021 18:15

Re: File Open Show End Not Start

Post by main Alexey »

Here is primitive plugin. it turns Wrap-mode off (it is required for long lines) and scrolls to the end in on_open event.

1. file py/cuda_always_open_at_end/install.inf

Code: Select all

[info]
title=Always Open Files At End
desc=(Fill the description)
type=cudatext-plugin
subdir=cuda_always_open_at_end
homepage=(Fill the GitHub repo URL)

[item1]
section=events
events=on_open

2. file py/cuda_always_open_at_end/__init__.py

Code: Select all

import os
from cudatext import *

class Command:

    def on_open(self, ed_self):
        nlines = ed_self.get_line_count()
        nvis= ed_self.get_prop(PROP_VISIBLE_LINES)
        ed_self.set_caret(0, nlines-1)
        ed_self.set_prop(PROP_WRAP, False)
        ed_self.set_prop(PROP_LINE_TOP, max(0, nlines-nvis+1))
Random Void User
Posts: 61
Joined: 13.07.2024 21:19

Re: File Open Show End Not Start

Post by Random Void User »

What about just using the ctrl-end hotkey in that plugin,

Code: Select all

ed.cmd(cmds.cCommand_GotoTextEnd)
main Alexey
Posts: 2708
Joined: 25.08.2021 18:15

Re: File Open Show End Not Start

Post by main Alexey »

I tried it too, but due to context - on_open event - command don't fully work (caret jumps, but scroll position don't always jump or jumps to last_line-1). It needs investigation why it don't fully work in on_open, not sure I want it.
Post Reply