-
Notifications
You must be signed in to change notification settings - Fork 809
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
[toc2 extension feature request] highlight TOC section with executing cell #791
Comments
This could certainly be possible, but the current toc2 machinery doesn't have a mechanism to add it in simply, so it'd need a bit of a rewrite. My best guess for how to go about it would be to loop through cells backwards instead of the current forwards while rebuilding the toc, allowing you to decide whether the current 'section' is being executed, so that once you get to the section heading, you can alter its rendering... |
@jcb91 The simplest and therefore the best solution!
Do you mean this way allows me to add rules to customize toc entries (for example highlighting)? Or you talk about plugin realization in general? |
well, I meant that's how I'd make the plugin implement it, but the other also makes sense. To clarify, I'd do the customization by just applying a css class (plus adding some css rules), which would then allow you to add additional rules, or override the provided ones by adding to your own |
@dinya I don't completely understand what you mean by "executing cell". Do you mean the section of the currently selected cell, which if it is a code cell can be executed? (I mean sometimes execution is very short and it would not be as easy to catch the event). Actually we do not really loop over the cells (only for finding the index of the "toc_cell" if needed) but over the headers. So this would require finding the current "executing" (may be 'selected'?) cell, and then the corresponding nearest (above) header and adding a style attribute to it. A point is that the toc is currently refreshed only when a markdown cell is created/updated. I do not if we have an event to detect the execution of a cell; otherwise detecting execution would require to patch CodeCell prototype. Ok, while writing this I think that it is probably what you meant. Feasible, but not that easy. |
Ah, I'd thought more in terms of cells queued for execution/executing now, but yeah, maybe selected is what was meant?
Ah, true, I'd forgotten that! Yeah, in this case it makes it more additional work than it would have been! |
@jcb91 @jfbercher Thanks for clarifying the question
Customization is a very cool feature for any tool, but I don't know what it is really necessary in the context of a feature request (just highlight "selected", "executing" and "editing" cell, see bellow). If it is possible to implement, and it's not hard work, why not? Maybe it will helpful for other users.
I meant by "selected", "editing" and "executing (running)" cells the following. selected cell is the cell under cursor (blue highlighed cell in the notebook). executing (running) cell is the cell which is first queued for execution (in terms of editing cell is the currently editing cell (green highlighed cell in the notebook).
I think it's not a problem: we are talk about "long term tasks" :-) |
I have done something that highlights toc-sections with selected/edited cells. For executing cells I don't see yet how to do it (in a reasonable time). You will be welcome to test this and report comments/issues. You can update by
|
Thank you very much! It works fine for me. Now I'm in anticipation of executing cell highlighting feature :). Could you highlight it independently of the selected/edited cell (the cell is deep-yellow highlighted currently)? |
@dinya
I also make a PR for this new feature. |
@jfbercher Thanks! But I have a question about the logic of highlighting. Current selected/edited section is yellow. It's ok. But when I go to queued section, the section is still red. Why not highlight the section with yellow while it is focused and color the section with red again when it is out of focus and it is not still finished? |
When I click "Kernel -> Restart & Run All" every section is highlighted in red for a moment. But then none of the "running" sections are not highlighted (see screenshot) |
@dinya
where I tried to address the two comments above. |
@jfbercher, Many thanks! Great work! I'm so happy :) |
Is it possible to highlight TOC section which contains executing cell?
I think it will be very easy to navigate notebooks with a large number of cells.
The text was updated successfully, but these errors were encountered: