<p></p>
<p>Here's a first draft for CO1, based on <a href="https://www.scintilla.org/ScintillaDoc.html" rel="nofollow">https://www.scintilla.org/ScintillaDoc.html</a>, especially <a href="https://www.scintilla.org/ScintillaDoc.html#Folding" rel="nofollow">https://www.scintilla.org/ScintillaDoc.html#Folding</a>.<br>
<strong>But</strong> 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.<br>
So any advice/info is welcome to make this more fun :)</p>
<div class="highlight highlight-source-c"><pre><span class="pl-c"><span class="pl-c">//</span> for `line` type, https://www.scintilla.org/ScintillaDoc.html</span>
#<span class="pl-k">include</span> <span class="pl-s"><span class="pl-pds">"</span>ScintillaTypes.h<span class="pl-pds">"</span></span>
#<span class="pl-k">include</span> <span class="pl-s"><span class="pl-pds">"</span>ScintillaMessages.h<span class="pl-pds">"</span></span>


<span class="pl-c"><span class="pl-c">/*</span> move cursor to parent line (if current line has a parent) and fold it (hide its children lines).</span>
<span class="pl-c"> * if currently at level 0 (no parents), then effect will be folding current line</span>
<span class="pl-c"> <span class="pl-c">*/</span></span>
<span class="pl-k">void</span> <span class="pl-en">moveToParentAndFold</span>()
{
        currentLine = <span class="pl-c1">SCI_LINEFROMPOSITION</span>(SCI_GETCURRENTPOS);

        line parentLine= <span class="pl-c1">SCI_GETFOLDPARENT</span>(currentLine);
        <span class="pl-k">if</span> (parentLine == -<span class="pl-c1">1</span>)
                parentLine=currentLine;

        <span class="pl-c"><span class="pl-c">//</span>set caret at first non-whitespace char in parentLine</span>
        <span class="pl-c1">SCI_GOTOPOS</span>(<span class="pl-c1">SCI_GETLINEINDENTPOSITION</span>(parentLine) );

        <span class="pl-c1">SCI_FOLDLINE</span>(parentLine, SC_FOLDACTION_CONTRACT);

}</pre></div>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/geany/geany/issues/2920#issuecomment-939267034">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AAIOWJZK2UDDYPMSZE43CLDUGAFHVANCNFSM5FSQEJ4A">unsubscribe</a>.<br />Triage notifications on the go with GitHub Mobile for <a href="https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675">iOS</a> or <a href="https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub">Android</a>.
<img src="https://github.com/notifications/beacon/AAIOWJ64OF3TZMZWUJZZYQ3UGAFHVA5CNFSM5FSQEJ4KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOG76BHWQ.gif" height="1" width="1" alt="" /></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/geany/geany/issues/2920#issuecomment-939267034",
"url": "https://github.com/geany/geany/issues/2920#issuecomment-939267034",
"name": "View Issue"
},
"description": "View this Issue on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>