Commit da5f481e authored by Naba Kumar's avatar Naba Kumar

Updated.

	* po/POTFILES.in: Updated.

	* NEWS: Updated.

	Patch from Jean-Noel Guiheneuf  <jnoel@saudionline.com.sa>
	* src/aneditor.cxx, src/goto_line.c, src/main_menubar_def.h,
	src/mainmenu_callbacks.c, src/mainmenu_callbacks.h:
	Uncomment (Box & Stream), Select the current function,
	authorize the "Quit" button of the GotoLine window
parent dfd54b00
2003-05-06 Naba Kumar <naba@gnome.org>
* src/aneditor.cxx, src/goto_line.c, src/main_menubar_def.h,
src/mainmenu_callbacks.c, src/mainmenu_callbacks.h:
Uncomment (Box & Stream), Select the current function,
authorize the "Quit" button of the GotoLine window
2003-05-05 Naba Kumar <naba@gnome.org>
* src/watch_gui.h: CVS added new file.
......
Anjuta 1.2.0-beta ( February 2003) -- Naba Kumar
Anjuta 1.2.0-beta (05 May 2003) -- Naba Kumar
New: Ported to GNOME2
New: Preferences management.
New: Ported to GNOME2:
New: New Preferences management.
New: Tools management.
New:
Updated: Scintilla 1.50
New: Watch and Backtrace moved to messages pane.
New: GNOMEVFS based file browser.
New: Pango fonts in editor (Anti-Aliased fonts).
New: Project configuration for GUI editor and version.
New: Advance search and replace (ported from 1.0.x branch).
Updated: Scintilla 1.51+ (cvs)
Updated: Session management. It now saves tree states.
Bug fix: Many
Anjuta 1.0.1: (xth June 2002) -- Naba Kumar
......
......@@ -175,6 +175,7 @@ src/watch.c
src/watch_cbs.c
src/watch_cbs.h
src/watch_gui.c
src/watch_gui.h
src/watch.h
src/widget-registry.c
src/widget-registry.h
......
......@@ -263,6 +263,7 @@ protected:
bool StartAutoComplete();
bool StartAutoCompleteWord(int autoShowCount);
bool StartBlockComment();
bool CanBeCommented(bool box_stream);
bool StartBoxComment();
bool StartStreamComment();
......@@ -1339,6 +1340,155 @@ bool AnEditor::StartBlockComment() {
return true;
}
// Return true if the selected zone can be commented
// Return false if it cannot be commented or has been uncommented
// BOX_COMMENT : box_stream = true STREAM_COMMENT : box_stream = false
// Uncomment if the selected zone or the cursor is inside the comment
//
bool AnEditor::CanBeCommented(bool box_stream) {
SString fileNameForExtension = ExtensionFileName();
SString language = props->GetNewExpand("lexer.", fileNameForExtension.c_str());
SString start_base("comment.box.start.");
SString middle_base("comment.box.middle.");
SString end_base("comment.box.end.");
SString white_space(" ");
start_base += language;
middle_base += language;
end_base += language;
SString start_comment = props->Get(start_base.c_str());
SString middle_cmt = props->Get(middle_base.c_str());
SString end_comment = props->Get(end_base.c_str());
start_comment += white_space;
middle_cmt += white_space;
white_space += end_comment;
end_comment = white_space;
size_t start_comment_length = start_comment.length();
size_t end_comment_length = end_comment.length();
size_t middle_cmt_length = middle_cmt.length();
SString start_base_stream ("comment.stream.start.");
start_base_stream += language;
SString end_base_stream ("comment.stream.end.");
end_base_stream += language;
SString end_comment_stream = props->Get(end_base_stream.c_str());
SString white_space_stream(" ");
//SString end_white_space_stream(" ");
SString start_comment_stream = props->Get(start_base_stream.c_str());
start_comment_stream += white_space_stream;
size_t start_comment_stream_length = start_comment_stream.length();
white_space_stream +=end_comment_stream;
end_comment_stream = white_space_stream ;
size_t end_comment_stream_length = end_comment_stream.length();
char linebuf[1000];
size_t selectionStart = SendEditor(SCI_GETSELECTIONSTART);
size_t selectionEnd = SendEditor(SCI_GETSELECTIONEND);
int line = SendEditor(SCI_LINEFROMPOSITION, selectionStart);
bool start1 = false, start2 = false;
bool end1 = false, end2 = false;
int lineEnd1;
if (box_stream)
lineEnd1 = selectionStart + start_comment_length;
else
lineEnd1 = selectionStart + start_comment_stream_length +1;
int lineStart1;
size_t start_cmt, end_cmt;
int index;
// Find Backward StartComment
while (line >= 0 && start1 == false && end1 == false)
{
lineStart1 = SendEditor(SCI_POSITIONFROMLINE, line);
GetRange(wEditor, lineStart1, lineEnd1, linebuf);
for (index = lineEnd1-lineStart1; index >= 0; index--)
{
if (end1= ((end_comment_length > 1 && !memcmp(linebuf+index,
end_comment.c_str(), end_comment_length ))
|| (end_comment_stream_length > 0 && !memcmp(linebuf+index,
end_comment_stream.c_str(), end_comment_stream_length))))
break;
if (start1=((start_comment_length > 1 && !memcmp(linebuf+index,
start_comment.c_str(), start_comment_length))
|| (start_comment_stream_length > 0 && !memcmp(linebuf+index,
start_comment_stream.c_str(), start_comment_stream_length))))
break;
}
line --;
lineEnd1= SendEditor(SCI_GETLINEENDPOSITION, line);
}
start_cmt = index + lineStart1;
line = SendEditor(SCI_LINEFROMPOSITION, selectionEnd);
if (box_stream)
lineStart1 = selectionEnd - start_comment_length;
else
lineStart1 = selectionEnd - start_comment_stream_length;
int last_line = SendEditor(SCI_GETLINECOUNT);
// Find Forward EndComment
while (line <= last_line && start2 == false && end2 == false)
{
lineEnd1= SendEditor(SCI_GETLINEENDPOSITION, line);
GetRange(wEditor, lineStart1, lineEnd1, linebuf);
for (index = 0; index <= (lineEnd1-lineStart1); index++)
{
if (start2= ((start_comment_length > 1 && !memcmp(linebuf+index,
start_comment.c_str(), start_comment_length))
|| (start_comment_stream_length > 0 && !memcmp(linebuf+index,
start_comment_stream.c_str(), start_comment_stream_length))))
break;
if (end2= ((end_comment_length > 1 && !memcmp(linebuf+index,
end_comment.c_str(), end_comment_length ))
|| (end_comment_stream_length > 0 && !memcmp(linebuf+index,
end_comment_stream.c_str(), end_comment_stream_length))))
break;
}
line ++;
end_cmt = lineStart1 + index;
lineStart1 = SendEditor(SCI_POSITIONFROMLINE, line);
}
// Uncomment
if(start1 || end2)
{
if (start1 && end2)
{
SendEditor(SCI_BEGINUNDOACTION);
if (box_stream) // Box
{
SendEditor(SCI_SETSEL, start_cmt, start_cmt +
start_comment_length);
end_cmt -= start_comment_length;
}
else // Stream
{
SendEditor(SCI_SETSEL, start_cmt, start_cmt +
start_comment_stream_length);
end_cmt -= start_comment_stream_length;
}
SendEditorString(SCI_REPLACESEL, 0, "");
line = SendEditor(SCI_LINEFROMPOSITION, start_cmt) + 1;
last_line = SendEditor(SCI_LINEFROMPOSITION, end_cmt) ;
for (int i = line; i < last_line; i++)
{
int s = SendEditor(SCI_POSITIONFROMLINE, i);
int e = SendEditor(SCI_GETLINEENDPOSITION, i);
GetRange(wEditor, s, e, linebuf);
if (!memcmp(linebuf, middle_cmt.c_str(), middle_cmt_length))
{
SendEditor(SCI_SETSEL, s, s + middle_cmt_length);
SendEditorString(SCI_REPLACESEL, 0, "");
end_cmt -= middle_cmt_length;
}
}
if (box_stream) // Box
SendEditor(SCI_SETSEL, end_cmt, end_cmt + end_comment_length);
else // Stream
SendEditor(SCI_SETSEL, end_cmt, end_cmt + end_comment_stream_length);
SendEditorString(SCI_REPLACESEL, 0, "");
SendEditor(SCI_ENDUNDOACTION);
}
return false;
}
return true;
}
bool AnEditor::StartBoxComment() {
SString fileNameForExtension = ExtensionFileName();
SString language = props->GetNewExpand("lexer.", fileNameForExtension.c_str());
......@@ -1386,34 +1536,38 @@ bool AnEditor::StartBoxComment() {
// get rid of CRLF problems
selectionEnd = SendEditor(SCI_GETLINEENDPOSITION, selEndLine);
}
SendEditor(SCI_BEGINUNDOACTION);
// first commented line (start_comment)
int lineStart = SendEditor(SCI_POSITIONFROMLINE, selStartLine);
SendEditorString(SCI_INSERTTEXT, lineStart, start_comment.c_str());
selectionStart += start_comment_length;
// lines between first and last commented lines (middle_comment)
for (size_t i = selStartLine + 1; i <= selEndLine; i++) {
lineStart = SendEditor(SCI_POSITIONFROMLINE, i);
SendEditorString(SCI_INSERTTEXT, lineStart, middle_comment.c_str());
selectionEnd += middle_comment_length;
}
// last commented line (end_comment)
int lineEnd = SendEditor(SCI_GETLINEENDPOSITION, selEndLine);
if (lines > 0) {
SendEditorString(SCI_INSERTTEXT, lineEnd, "\n");
SendEditorString(SCI_INSERTTEXT, lineEnd + 1, (end_comment.c_str() + 1));
} else {
SendEditorString(SCI_INSERTTEXT, lineEnd, end_comment.c_str());
}
selectionEnd += (start_comment_length);
if (move_caret) {
// moving caret to the beginning of selected block
SendEditor(SCI_GOTOPOS, selectionEnd);
SendEditor(SCI_SETCURRENTPOS, selectionStart);
} else {
SendEditor(SCI_SETSEL, selectionStart, selectionEnd);
// Comment , Uncomment or Do Nothing
if (CanBeCommented(true))
{
SendEditor(SCI_BEGINUNDOACTION);
// first commented line (start_comment)
int lineStart = SendEditor(SCI_POSITIONFROMLINE, selStartLine);
SendEditorString(SCI_INSERTTEXT, lineStart, start_comment.c_str());
selectionStart += start_comment_length;
// lines between first and last commented lines (middle_comment)
for (size_t i = selStartLine + 1; i <= selEndLine; i++) {
lineStart = SendEditor(SCI_POSITIONFROMLINE, i);
SendEditorString(SCI_INSERTTEXT, lineStart, middle_comment.c_str());
selectionEnd += middle_comment_length;
}
// last commented line (end_comment)
int lineEnd = SendEditor(SCI_GETLINEENDPOSITION, selEndLine);
if (lines > 0) {
SendEditorString(SCI_INSERTTEXT, lineEnd, "\n");
SendEditorString(SCI_INSERTTEXT, lineEnd + 1, (end_comment.c_str() + 1));
} else {
SendEditorString(SCI_INSERTTEXT, lineEnd, end_comment.c_str());
}
selectionEnd += (start_comment_length);
if (move_caret) {
// moving caret to the beginning of selected block
SendEditor(SCI_GOTOPOS, selectionEnd);
SendEditor(SCI_SETCURRENTPOS, selectionStart);
} else {
SendEditor(SCI_SETSEL, selectionStart, selectionEnd);
}
SendEditor(SCI_ENDUNDOACTION);
}
SendEditor(SCI_ENDUNDOACTION);
return true;
}
......@@ -1423,6 +1577,7 @@ bool AnEditor::StartStreamComment() {
SString start_base("comment.stream.start.");
SString end_base("comment.stream.end.");
SString white_space(" ");
//SString end_white_space(" ");
start_base += language;
end_base += language;
SString start_comment = props->Get(start_base.c_str());
......@@ -1477,19 +1632,23 @@ bool AnEditor::StartStreamComment() {
selectionStart -= start_counter;
selectionEnd += (end_counter + 1);
}
SendEditor(SCI_BEGINUNDOACTION);
SendEditorString(SCI_INSERTTEXT, selectionStart, start_comment.c_str());
selectionEnd += start_comment_length;
selectionStart += start_comment_length;
SendEditorString(SCI_INSERTTEXT, selectionEnd, end_comment.c_str());
if (move_caret) {
// moving caret to the beginning of selected block
SendEditor(SCI_GOTOPOS, selectionEnd);
SendEditor(SCI_SETCURRENTPOS, selectionStart);
} else {
SendEditor(SCI_SETSEL, selectionStart, selectionEnd);
// Comment , Uncomment or Do Nothing
if (CanBeCommented(false))
{
SendEditor(SCI_BEGINUNDOACTION);
SendEditorString(SCI_INSERTTEXT, selectionStart, start_comment.c_str());
selectionEnd += start_comment_length;
selectionStart += start_comment_length;
SendEditorString(SCI_INSERTTEXT, selectionEnd, end_comment.c_str());
if (move_caret) {
// moving caret to the beginning of selected block
SendEditor(SCI_GOTOPOS, selectionEnd);
SendEditor(SCI_SETCURRENTPOS, selectionStart);
} else {
SendEditor(SCI_SETSEL, selectionStart, selectionEnd);
}
SendEditor(SCI_ENDUNDOACTION);
}
SendEditor(SCI_ENDUNDOACTION);
return true;
}
......
......@@ -92,7 +92,8 @@ gotoline_init (GotoLine * obj)
GtkWidget *frame;
GtkWidget *numberentry;
GtkWidget *combo_entry;
GtkWidget *vbox;
assert (obj != NULL);
gtk_window_set_position (GTK_WINDOW (obj), GTK_WIN_POS_CENTER);
......@@ -106,10 +107,14 @@ gotoline_init (GotoLine * obj)
gtk_widget_show (frame);
gtk_box_pack_start (GTK_BOX (dialog_vbox), frame, FALSE, FALSE, 0);
vbox = gtk_vbox_new (FALSE, 0);
gtk_widget_show (vbox);
gtk_container_add (GTK_CONTAINER (frame), vbox);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 10);
numberentry = gtk_entry_new ();
gtk_widget_show (numberentry);
gtk_container_add (GTK_CONTAINER (frame), numberentry);
gtk_container_set_border_width (GTK_CONTAINER (numberentry), 10);
gtk_container_add (GTK_CONTAINER (vbox), numberentry);
gtk_dialog_add_button (GTK_DIALOG (obj), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
gtk_dialog_add_button (GTK_DIALOG (obj), GTK_STOCK_OK, GTK_RESPONSE_OK);
......@@ -144,4 +149,6 @@ on_go_to_line_response (GtkDialog* dialog, gint response, gpointer user_data)
if (te)
text_editor_goto_line (te, num, TRUE);
}
else
gtk_widget_hide (GTK_WIDGET(dialog));
}
......@@ -198,7 +198,7 @@ static GnomeUIInfo transform1_submenu_uiinfo[NUM_TRANSFORM_SUBMENUS+1] = {
GNOMEUIINFO_END
};
#define NUM_SELECT_SUBMENUS 3
#define NUM_SELECT_SUBMENUS 4
static GnomeUIInfo select1_submenu_uiinfo[NUM_SELECT_SUBMENUS+1] = {
{/*0*/
GNOME_APP_UI_ITEM, N_("_Select All"),
......@@ -218,7 +218,13 @@ static GnomeUIInfo select1_submenu_uiinfo[NUM_SELECT_SUBMENUS+1] = {
on_editor_command_activate, (gpointer) ANE_SELECTBLOCK, NULL,
GNOME_APP_PIXMAP_NONE, NULL,
GDK_B, GDK_MOD1_MASK, NULL},
GNOMEUIINFO_END/*3*/
{/*3*/
GNOME_APP_UI_ITEM, N_("Current Function"),
N_("Select the current function"),
on_editor_select_function , NULL, NULL,
GNOME_APP_PIXMAP_NONE, NULL,
0, 0, NULL},
GNOMEUIINFO_END/*4*/
};
#define NUM_INSERTTEXT_SUBMENUS 7
......@@ -388,14 +394,14 @@ static GnomeUIInfo comment_submenu_uiinfo[NUM_COMMENT_SUBMENUS+1] = {
GNOME_APP_PIXMAP_NONE, NULL,
0, 0, NULL},
{/*1*/
GNOME_APP_UI_ITEM, N_("Box Comment"),
N_("Box comment the selected text"),
GNOME_APP_UI_ITEM, N_("Box Comment/Uncomment"),
N_("Box comment/uncomment the selected text"),
on_comment_box, NULL, NULL,
GNOME_APP_PIXMAP_NONE, NULL,
0, 0, NULL},
{/*2*/
GNOME_APP_UI_ITEM, N_("Stream Comment"),
N_("Stream comment the selected text"),
GNOME_APP_UI_ITEM, N_("Stream Comment/Uncomment"),
N_("Stream comment/uncomment the selected text"),
on_comment_stream, NULL, NULL,
GNOME_APP_PIXMAP_NONE, NULL,
0, 0, NULL},
......
......@@ -62,6 +62,8 @@
#include "memory.h"
#include "fileselection.h"
#include "anjuta-tools.h"
#include "search-replace.h"
#include "anjuta_info.h"
void on_toolbar_find_clicked (GtkButton * button, gpointer user_data);
......@@ -328,6 +330,16 @@ on_editor_command_activate (GtkMenuItem * menuitem, gpointer user_data)
aneditor_command (te->editor_id, (gint) user_data, 0, 0);
}
void
on_editor_select_function (GtkMenuItem * menuitem, gpointer user_data)
{
TextEditor *te;
te = anjuta_get_current_text_editor ();
if (te == NULL)
return;
function_select(te);
}
void
on_transform_eolchars1_activate (GtkMenuItem * menuitem, gpointer user_data)
{
......
......@@ -40,6 +40,7 @@ void on_exit1_activate (GtkMenuItem * menuitem, gpointer user_data);
/*****************************************************************************/
void on_editor_command_activate (GtkMenuItem * menuitem, gpointer user_data);
void on_editor_select_function (GtkMenuItem * menuitem, gpointer user_data);
void on_transform_eolchars1_activate (GtkMenuItem * menuitem,
gpointer user_data);
void on_find1_activate (GtkMenuItem * menuitem, gpointer user_data);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment