[ScintillaNET] Re: Smart Indent

  • From: Greg Dietsche <greg@xxxxxxxxx>
  • To: scintillanet@xxxxxxxxxxxxx
  • Date: Thu, 24 Jun 2004 17:15:51 -0500

I was taking a look at the smart indentation support, and i thought i'd add my 2 cents...

I think the IndentLine function should be declared public. Then, add few documentation comments to it to show how to use it in a charadded event handler. The reason being is that other people can use that function to do lots of things. For example, I used the posted version in my project to indent c source code in a (even) smarter manner (lol) ;)

(I've shortened the code by quite a bit, but here is the essence of what i have it doing):

           if(ch == '\n')
           {//Indentation Support

//C Brace Indentation Support: auto indent after opening brace
if(scintilla.CharAt(scintilla.LineEndPosition(curLine - 1) - 1)=='{')
previousIndent+=scintilla.TabWidth;


IndentLine(curLine, previousIndent);
}
else
if(ch=='}')
{ //C Brace Indent Support: auto indent / reposition for closing brace
int match = BraceMatch(scintilla.CurrentPos - 1);


if(match!=-1)
{
previousIndent = scintilla.GetLineIndentation(scintilla.LineFromPosition(match));
IndentLine(curLine, previousIndent);
}
}


Regards,
/*Greg Dietsche*/**     http://www.gregd.org/ <http://www.gregd.org>
*GForce Programming:*   http://calc.gregd.org
*Detached Solutions:*      http://www.detachedsolutions.com

**



gserack wrote:

Uh, that didn't quite come out right :)

Hang on... The code you sent me has :

#region Not-so-smart indenting support

that line at the top...

:? Ah well. It's already in the code in svn, so when I post the build you can get it.

If you are desperate for the code, you can get the latest version of all the source from svn.scide.net either by using wget:

wget -m http://svn.scide.net/

or the subversion client:

svn co http://svn.scide.net/

That being said, I'm not making any guarantees as to it being perfectly ready yet, as I'm doing some code shuffling/refactoring, and I'm pretty sure that I've yet-again changed the names of the namespaces. (sorry)... I had to clean up some stupidity along the way.

G
-----Original Message-----
From: scintillanet-bounce@xxxxxxxxxxxxx on behalf of 
mike.griffin@xxxxxxxxxxxxxxxxxxxxxxxx
Sent: Thu 6/24/2004 8:24 AM
To: scintillanet@xxxxxxxxxxxxx
Subject: [ScintillaNET] Re: Smart Indent

What do you mean "If nobody came forward with anything better"? he he, I'm
crushed ...




--


Regards,
/*Greg Dietsche*/**     http://www.gregd.org/ <http://www.gregd.org>
*GForce Programming:*   http://calc.gregd.org
*Detached Solutions:*      http://www.detachedsolutions.com

**

Other related posts: