Re: [Github-comments] [geany/geany] Folding code: more advanced commands (#2920)
I'll have to leave others to take it from here, as I found out windows32 bit OS (which unfortunately I have) won't be supported any more. Maybe I'll come back to this after I install Linux. -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/geany/geany/issues/2920#issuecomment-939704008
Re: [Github-comments] [geany/geany] Folding code: more advanced commands (#2920)
> Btw looks like "Toggle current fold" use that "Fold/unfold all children of a > fold point" configuration too. Right; except the Shift switch doesn't work to change the behavior of the Toggle current command. So then your (un)fold recursive is almost the same as what I got to in C3/C4. With just one difference: to apply to descendants (= to children, recursively) only, not to parent node. Here's why it may be better: when you come to a parent node: 1. if it's initially closed, your first action will probably be just to toggle it open. You wouldn't want to open it and its children recursively, as that will reveal too much infor at once. 2. Now once you opened it, if children happen to be closed, that's fine, you can select one of them to explore (in particular with CO1/CO2 if want). If you really want to pop them all open at once, then the Unfold All descendants I suggest still does the job. But if all/most chilren are already opened (let alone if their descendants too), you'll want to close them (too much info at once!). So here the Fold All Descendants will come in very handy: will fold the children of children, but you'll still see curent (parent) and its children. 3. If instead the node is initially open... see 2. (This formulation also logically agrees with what (Un)Fold All does, if imagine that the ancestor node of all nodes in file is the file itself..) So we have 3 existing, + 4 new suggested. In addition, we could also include a command to open/unfold All nodes of Ist (top) level, and another to close/fold them - just b/c we're at it... Though I'm personally not convinced these fixed-level of all nodes are useful; or at least not useful beyond Ist level (b/c usually you dont' want to see too much at once, and you'll work in a local region anyway, where toggle current and/or (Un)Fold Descendants and CO1/CO2 will do a better job ). -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/geany/geany/issues/2920#issuecomment-939412742
Re: [Github-comments] [geany/geany] Folding code: more advanced commands (#2920)
Fold All folds all nodes and subnodes in document. I can click on folding icon and unpack that node and subnodes stay folded. If i use Shift + click, i can unfold subnodes too (or Shift key may unfold only one level, depends on "Editor / Features / Fold/unfold all children of a fold point" configuration). -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/geany/geany/issues/2920#issuecomment-939370102
Re: [Github-comments] [geany/geany] Folding code: more advanced commands (#2920)
Since the primary motivation for folding is to prevent visual information overload, I think there's not much value in expanding nodes, at same level, across _all trees _ in the entire file. (By the way, for the same reason, I'd choose to have all my files open by default with all nodes folded. ) So that's why I made the changes above to C3 and C4, to be able to fold/unfold all nodes _locally_, belonging to same parent node/subtree (As complement to fold/unfold at whole file level, and individual node level). @intact , what did you have in mind with Fold Recursively, Unfold Recursively ? -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/geany/geany/issues/2920#issuecomment-939368110
Re: [Github-comments] [geany/geany] Folding code: more advanced commands (#2920)
Here's a first draft for CO1, based on https://www.scintilla.org/ScintillaDoc.html, especially https://www.scintilla.org/ScintillaDoc.html#Folding. **But** I'm a beginner in C, I've never contributed code to online projects before, and I have no idea where exactly this would be integrated in Geany. So any advice/info is welcome to make this more fun :) ``` c // for `line` type, https://www.scintilla.org/ScintillaDoc.html #include "ScintillaTypes.h" #include "ScintillaMessages.h" /* move cursor to parent line (if current line has a parent) and fold it (hide its children lines). * if currently at level 0 (no parents), then effect will be folding current line */ void moveToParentAndFold() { currentLine = SCI_LINEFROMPOSITION(SCI_GETCURRENTPOS); line parentLine= SCI_GETFOLDPARENT(currentLine); if (parentLine == -1) parentLine=currentLine; //set caret at first non-whitespace char in parentLine SCI_GOTOPOS(SCI_GETLINEINDENTPOSITION(parentLine) ); SCI_FOLDLINE(parentLine, SC_FOLDACTION_CONTRACT); } ``` -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/geany/geany/issues/2920#issuecomment-939267034
Re: [Github-comments] [geany/geany] Folding code: more advanced commands (#2920)
Here's a first draft for CO1, based on https://www.scintilla.org/ScintillaDoc.html, especially https://www.scintilla.org/ScintillaDoc.html#Folding*/. **But** I'm a beginner in C, I've never contributed code to online projects before, and I have no idea where exactly this would be integrated in Geany. So any advice/info is welcome to make this more fun :) ``` c #include "ScintillaTypes.h" #include "ScintillaMessages.h" /* move cursor to parent line (if current line has a parent) and fold it (hide its children lines). */ void moveToParentAndFold(line currentLine) { line parentLine= SCI_GETFOLDPARENT(currentLine); // if currently at level 0 (no parents), then effect will be folding current line if (parentLine == -1) parentLine=currentLine; //set caret at first non-whitespace char in parentLine SCI_GOTOPOS(SCI_GETLINEINDENTPOSITION(parentLine) ); // fold parentLine SCI_FOLDLINE(parentLine, SC_FOLDACTION_CONTRACT); } ``` -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/geany/geany/issues/2920#issuecomment-939264649
Re: [Github-comments] [geany/geany] Folding code: more advanced commands (#2920)
A few more thoughts: **a)** C1/C2 (Moving to parent node, or child node ), whether or not provided separately from CO1/2, should ideally place the cursor at a regular position in the line ( I guess either Ist non-white space char, or the last one). **b)** CO1 and CO2, (moving to parent/child **+** fold/unfold) , to be useful for repeated manual invocation, probably need to be based not on "toggle current fold" but "fold current node (line)" and "unfold current node (line)", each with no effect if line is not a folding point. **c)** C3, C4 ( parallel folding, and unfolding, of all nodes in the file, of same level as current node ) should also be based on "fold current node (line)" and "unfold current node (line)" , instead of "toggle current fold", to ensure the invocation, each tree will be folded or unfolded to the same depth, regardless of the initial state (folded or not) of particular nodes in those trees. These C3 and C4 could be stanalone, or (perhaps even better ) be based on CO1 and CO2, via an added switch. -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/geany/geany/issues/2920#issuecomment-939193012