Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Headings collapse / expand #513

Closed
alexisargyris opened this issue Dec 6, 2020 · 7 comments
Closed

Headings collapse / expand #513

alexisargyris opened this issue Dec 6, 2020 · 7 comments
Assignees
Labels
discussion Meta: Feature discussions enhancement Request: New feature or improvement potential feature Request: May be considered later

Comments

@alexisargyris
Copy link

Being able to collapse / expand the headings of a text file would be very useful, I think. An approximation of this functionality is to have a folder and lots of files inside. However this is not very practical when there is a large number of headings. One possible use for such a feature would be to be able to gather in a single file lots of brief notes (each a couple of senteces long) and be able to browse quickly through them.

@alexisargyris alexisargyris added the enhancement Request: New feature or improvement label Dec 6, 2020
@vkbo
Copy link
Owner

vkbo commented Dec 6, 2020

Do you mean to collapse/expand headings in the editor itself, or the ability to expand the headings in a file in the project tree under its entry?

The former ties into the functionality needed to implement #399, and I am considering this, although it is a bit clunky to implement as it isn't a feature the QTextEdit widget supports by itself.

The latter, if that is the intent, can also be achieved with a document outline view as an optional panel under the project tree. This is a feature I want to add, and have in my personal ideas document. Many text and code editors I draw inspiration from have this. For instance zim, GhostWriter and VSCode.

@vkbo vkbo self-assigned this Dec 6, 2020
@vkbo vkbo added discussion Meta: Feature discussions potential feature Request: May be considered later labels Dec 6, 2020
@alexisargyris
Copy link
Author

Here are two VSCode examples of markdown text in fully collapsed and partially uncollapsed states.

image

VSCode also supports the second functionality you described (if I understand you correctly), which is useful, but not the reason for submitting this request.

What I'd like to be able to do is to collapse / expand (+level support?) a document with headings in the editor window with one key combination.

@vkbo
Copy link
Owner

vkbo commented Dec 6, 2020

Yes, collapsing sections is a common feature in code editors, but not so common in text editors.

The outline in the left panel is a feature I intend to add together with a version history panel when I'm implementing versions. Since the index already knows of all the headings and their location in a document, the clickable outline is relatively simple to implement. It will in any case be optional or at least collapsible.

However, adding features to the QTextEdit widget, which is needed for the expand/collapse buttons for the feature you describe here, may run into some of the limitations that exist because I chose to write novelWriter in Python. Since the Qt library is written in C++, adding features that involve subclassing and overloading C++ classes and functions on the Python side sometimes become bottlenecks due to the passing back and forth between the languages. I've run into this with the spell checking for instance, which means novelWriter quickly runs into the wall when presented with large documents. The Qt widget can handle just fine documents up to the 50 MB range, but the spell checking starts to become a massive CPU hog well before 1 MB. The issue is related to looping over blocks (the Qt object representing a line of text) in a document, which I may need to do here. For some reason I haven't figured out yet, this is very slow.

I have considered writing my own version of QTextEdit tailored for novelWriter, in C++, and link it into Python, but it will then add a dependency to novelWriter that needs to be compiled on the host computer. I haven't decided what to do about this yet.

But I'll investigate whether this is a feature that can be added without running into these limitations.

@alexisargyris
Copy link
Author

I think I see what you mean. The implementation of the "left panel outline" may cover most of what I need (i.e. to review a number of notes and locate a particular one in a note hierarchy) so that you avoid to disturb the depths of the QTextEdit widget. Thanks anyway.

@vkbo
Copy link
Owner

vkbo commented Dec 6, 2020

Hmm, I see a potential need of a way to browse notes that mirrors the Outline for the Novel root folder.

Combining the ideas in #498, as well as things @johnblommers has mentioned in the past, it may be an idea to be able to switch the project tree between the current folder/file view (project layout) and a stripped down version of the Outline panel tree, as well as a third option with an outline of all notes. The latter would also be a hierarchy view of all notes.

Alternative 1

I could implement three tabs in a Tab widget in the left-most panel. The first, named "Project" viewing the current project tree. The second, named "Novel" would be for instance the first column from the Outline tab, and perhaps also the word count column. The third tab, named "Notes" would be a list of each note group, with the folders below, then the files, then the headings in each file.

Alternative 2

I could simply add an option to allow expanding a document like it was a folder, and below it show all the headers it contains. This could be done directly in the existing project tree. It could potentially massively increase the number of nodes in the tree, but that may not be an issue.

@alexisargyris
Copy link
Author

Short-term, I think "alternative 2" would work very well for what I had in mind. On the other hand, "alternative 1" seems to open up new possibilities for the long-term evolution of novelWriter.

@vkbo vkbo added this to the Visualisation Tools for Story Elements milestone Dec 11, 2020
@vkbo vkbo removed this from the Visualisation Tools for Story Elements milestone Apr 9, 2021
@vkbo
Copy link
Owner

vkbo commented May 11, 2022

I've mad a new issue for adding a document outline feature, #1059. So therefore I'm closing this.

The document outline feature has also been requested by others. Since the expand/collapse feature in the editor is a bit heavy, and novelWriter isn't really intended for writing very long documents, this may be sufficient in most cases.

I am working on a rich text novel editor written in C++ where this specific feature request may be more relevant.

@vkbo vkbo closed this as completed May 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Meta: Feature discussions enhancement Request: New feature or improvement potential feature Request: May be considered later
Projects
None yet
Development

No branches or pull requests

2 participants