Re: [Anjuta-list] My Idea about Indentation
- From: Nathan H?sken <anjuta lonely-star org>
- To: anjuta-list lists sourceforge net
- Subject: Re: [Anjuta-list] My Idea about Indentation
- Date: Sat, 22 Jul 2006 12:04:24 +0200
Hello,
I am currently trying to implement in the language-support-cpp-jave
plugin. But as far as I can see, the "on_editor_char_inserted_cpp"
function is currently never called, correct? I do now know what to
change so that it is called and can not test my code.
I am also not sure how to set the indentation. I thought, I could just
delete all whitespaces at the begining of the line and then insert the
correct number of whitspaces for indentation. I have not found a
function do delete in the editor, is there a way?
Regards,
Nathan
Quoting Naba Kumar <naba kumar gmail com>:
Hi Nathan,
Thanks for the interesting approach to solving the indentation
problem. However, apart from Johannes's suggestion, the changes should
be in language-support-cpp-java plugin and not in editor plugin. We
will be removing indentation and autocompletion code from the editor
and define them in language-support plugin.
I will see how your changes fit there (the plugin itself is under
development).
Thanks.
Regards,
-Naba
On 7/20/06, Nathan H?sken <anjuta lonely-star org> wrote:
Hello together,
Since I was not really happy about the indetation in anjuta I got the
Idea of using the astyle code for indentation in anjuta.
This works for me, but I am not sure if anyone would be interested in
this. I will just tell you what I did and you can decide if the
project would benefit from this.
I added the files ASBeautifier.cpp, ASResource.cpp, astlye.h and
compiler_defines.h to the editor plugin and rewrote the following
function in aneditor-indent.cxx:
----------------------------------------
#include "astyle.h"
using namespace astyle;
void AnEditor::AutomaticIndentation(char ch) {
static ASBeautifier beautifier;
//The line number correspondening to the beautifier
static int beauty_line=-1;
//Get the current and check if it is lower than the last
beautified line
int curLine = GetCurrentLineNumber();
if(curLine<=beauty_line)
{
//OK, we need to restart from the begining
beauty_line=-1;
}
//If the beauty line is -1, we need to initilize the Beautifier
if(beauty_line==-1)
{
int indentSize = SendEditor(SCI_GETINDENT);
beautifier.setSpaceIndentation(indentSize);
beautifier.init();
beautifier.setSpaceIndentation(indentSize);
}
SString tmp_line;
string line;
//Get the beautifier to the state correspondening to the
previous line
while(beauty_line<curLine-1)
{
beauty_line++;
GetLine(tmp_line,beauty_line);
line=tmp_line.c_str();
beautifier.beautify(line);
}
//OK, make a copy of the beautifier to beautify the current line
ASBeautifier tmp_beautifier(beautifier);
GetLine(tmp_line,curLine);
line=tmp_line.c_str();
if(line.length()==0)
{
//Set the line to something so that the characters
is set to correct
position on an empty line
line="a";
}
line=tmp_beautifier.beautify(line);
//Find the indentation number and set it
int intendation=0;
while(line[intendation]==' ')
{
intendation++;
}
SetLineIndentation(curLine,intendation);
}
----------------------------------------
Greetings,
Nathan
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Anjuta-list mailing list
Anjuta-list lists sourceforge net
https://lists.sourceforge.net/lists/listinfo/anjuta-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]