mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 12:32:40 +03:00
bring editor up to date with cooledit-3.9.0 - see ChangeLog for details
This commit is contained in:
parent
d97c87e5c8
commit
bb36519e9f
@ -20,10 +20,11 @@ AR = @AR@
|
||||
|
||||
EDITSRC = edit.c editcmd.c editdraw.c gtkedit.c gtkeditkey.c \
|
||||
propfont.c syntax.c wordproc.c edit.h editcmddef.h global.h gtkedit.h \
|
||||
libgettext.h lkeysym.h editmenu.c editoptions.c mousemark.h editwidget.c
|
||||
libgettext.h lkeysym.h editmenu.c editoptions.c mousemark.h \
|
||||
editwidget.c bookmark.c
|
||||
|
||||
EDITOBJS = edit.o editcmd.o editdraw.o gtkedit.o gtkeditkey.o \
|
||||
propfont.o syntax.o wordproc.o
|
||||
propfont.o syntax.o wordproc.o bookmark.o
|
||||
|
||||
DIST = Makefile.in $(EDITSRC)
|
||||
|
||||
|
217
gtkedit/bookmark.c
Normal file
217
gtkedit/bookmark.c
Normal file
@ -0,0 +1,217 @@
|
||||
/* editor book mark handling
|
||||
|
||||
Copyright (C) 1996, 1997 the Free Software Foundation
|
||||
|
||||
Authors: 1996, 1997 Paul Sheer
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
02111-1307, USA.
|
||||
*/
|
||||
|
||||
|
||||
#include <config.h>
|
||||
#include "edit.h"
|
||||
|
||||
/* note, if there is more than one bookmark on a line, then they are
|
||||
appended after each other and the last one is always the one found
|
||||
by book_mark_found() i.e. last in is the one seen */
|
||||
|
||||
static inline struct _book_mark *double_marks (WEdit * edit, struct _book_mark *p)
|
||||
{
|
||||
if (p->next)
|
||||
while (p->next->line == p->line)
|
||||
p = p->next;
|
||||
return p;
|
||||
}
|
||||
|
||||
/* returns the first bookmark on or before this line */
|
||||
struct _book_mark *book_mark_find (WEdit * edit, int line)
|
||||
{
|
||||
struct _book_mark *p;
|
||||
if (!edit->book_mark) {
|
||||
/* must have an imaginary top bookmark at line -1 to make things less complicated */
|
||||
edit->book_mark = malloc (sizeof (struct _book_mark));
|
||||
memset (edit->book_mark, 0, sizeof (struct _book_mark));
|
||||
edit->book_mark->line = -1;
|
||||
return edit->book_mark;
|
||||
}
|
||||
for (p = edit->book_mark; p; p = p->next) {
|
||||
if (p->line > line)
|
||||
break; /* gone past it going downward */
|
||||
if (p->line <= line) {
|
||||
if (p->next) {
|
||||
if (p->next->line > line) {
|
||||
edit->book_mark = p;
|
||||
return double_marks (edit, p);
|
||||
}
|
||||
} else {
|
||||
edit->book_mark = p;
|
||||
return double_marks (edit, p);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (p = edit->book_mark; p; p = p->prev) {
|
||||
if (p->next)
|
||||
if (p->next->line <= line)
|
||||
break; /* gone past it going upward */
|
||||
if (p->line <= line) {
|
||||
if (p->next) {
|
||||
if (p->next->line > line) {
|
||||
edit->book_mark = p;
|
||||
return double_marks (edit, p);
|
||||
}
|
||||
} else {
|
||||
edit->book_mark = p;
|
||||
return double_marks (edit, p);
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0; /* can't get here */
|
||||
}
|
||||
|
||||
/* returns true if a bookmark exists at this line of colour c */
|
||||
int book_mark_query_color (WEdit * edit, int line, int c)
|
||||
{
|
||||
struct _book_mark *p;
|
||||
if (!edit->book_mark)
|
||||
return 0;
|
||||
for (p = book_mark_find (edit, line); p; p = p->prev) {
|
||||
if (p->line != line)
|
||||
return 0;
|
||||
if (p->c == c)
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* returns the number of bookmarks at this line and a list of their colours in c
|
||||
up to a maximum of 8 colours */
|
||||
int book_mark_query_all (WEdit * edit, int line, int *c)
|
||||
{
|
||||
int i;
|
||||
struct _book_mark *p;
|
||||
if (!edit->book_mark)
|
||||
return 0;
|
||||
for (i = 0, p = book_mark_find (edit, line); p && i < 8; p = p->prev, i++) {
|
||||
if (p->line != line)
|
||||
return i;
|
||||
c[i] = p->c;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
/* insert a bookmark at this line */
|
||||
void book_mark_insert (WEdit * edit, int line, int c)
|
||||
{
|
||||
struct _book_mark *p, *q;
|
||||
p = book_mark_find (edit, line);
|
||||
#if 0
|
||||
if (p->line == line) { /* already exists, so just change the colour */
|
||||
if (p->c != c) {
|
||||
edit->force |= REDRAW_LINE;
|
||||
p->c = c;
|
||||
}
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
edit->force |= REDRAW_LINE;
|
||||
/* create list entry */
|
||||
q = malloc (sizeof (struct _book_mark));
|
||||
memset (q, 0, sizeof (struct _book_mark));
|
||||
q->line = line;
|
||||
q->c = c;
|
||||
q->next = p->next;
|
||||
/* insert into list */
|
||||
q->prev = p;
|
||||
if (p->next)
|
||||
p->next->prev = q;
|
||||
p->next = q;
|
||||
}
|
||||
|
||||
/* remove a bookmark if there is one at this line matching this colour - c of -1 clear all */
|
||||
void book_mark_clear (WEdit * edit, int line, int c)
|
||||
{
|
||||
struct _book_mark *p, *q;
|
||||
if (!edit->book_mark)
|
||||
return;
|
||||
for (p = book_mark_find (edit, line); p; p = q) {
|
||||
q = p->prev;
|
||||
if (p->line == line && (p->c == c || c == -1)) {
|
||||
edit->force |= REDRAW_LINE;
|
||||
edit->book_mark = p->prev;
|
||||
p->prev->next = p->next;
|
||||
if (p->next)
|
||||
p->next->prev = p->prev;
|
||||
memset (p, 0, sizeof (struct _book_mark));
|
||||
free (p);
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* if there is only our dummy book mark left, clear it for speed */
|
||||
if (edit->book_mark->line == -1 && !edit->book_mark->next) {
|
||||
free (edit->book_mark);
|
||||
edit->book_mark = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* clear all bookmarks matching this colour, if c is -1 clears all */
|
||||
void book_mark_flush (WEdit * edit, int c)
|
||||
{
|
||||
struct _book_mark *p, *q;
|
||||
if (!edit->book_mark)
|
||||
return;
|
||||
edit->force |= REDRAW_PAGE;
|
||||
while (edit->book_mark->prev)
|
||||
edit->book_mark = edit->book_mark->prev;
|
||||
for (q = edit->book_mark->next; q; q = p) {
|
||||
p = q->next;
|
||||
if (q->c == c || c == -1) {
|
||||
q->prev->next = q->next;
|
||||
if (p)
|
||||
p->prev = q->prev;
|
||||
memset (q, 0, sizeof (struct _book_mark));
|
||||
free (q);
|
||||
}
|
||||
}
|
||||
if (!edit->book_mark->next) {
|
||||
free (edit->book_mark);
|
||||
edit->book_mark = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* shift down bookmarks after this line */
|
||||
void book_mark_inc (WEdit * edit, int line)
|
||||
{
|
||||
if (edit->book_mark) {
|
||||
struct _book_mark *p;
|
||||
p = book_mark_find (edit, line);
|
||||
for (p = p->next; p; p = p->next)
|
||||
p->line++;
|
||||
}
|
||||
}
|
||||
|
||||
/* shift up bookmarks after this line */
|
||||
void book_mark_dec (WEdit * edit, int line)
|
||||
{
|
||||
if (edit->book_mark) {
|
||||
struct _book_mark *p;
|
||||
p = book_mark_find (edit, line);
|
||||
for (p = p->next; p; p = p->next)
|
||||
p->line--;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -16,15 +16,17 @@
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
02111-1307, USA.
|
||||
*/
|
||||
|
||||
#define _EDIT_C THIS_IS
|
||||
|
||||
#include <config.h>
|
||||
#if defined(NEEDS_IO_H)
|
||||
# include <io.h>
|
||||
# include <fcntl.h>
|
||||
#endif
|
||||
#include <fcntl.h>
|
||||
#ifdef NEEDS_CR_LF_TRANSLATION
|
||||
# define CR_LF_TRANSLATION
|
||||
#endif
|
||||
@ -255,10 +257,10 @@ int edit_load_file (WEdit * edit, const char *filename, const char *text, unsign
|
||||
|
||||
/* Lastbyte calculation in TEXT mode FRANCO */
|
||||
#if defined CR_LF_TRANSLATION
|
||||
if(file && (!text)){
|
||||
if(file && (!text)) {
|
||||
real_size=0;
|
||||
tmp_buf[sizeof (tmp_buf)-1]=0;
|
||||
while((bytes_read = read(file,tmp_buf,1024)) > 0){
|
||||
tmp_buf[sizeof (tmp_buf) - 1] = 0;
|
||||
while ((bytes_read = read (file, tmp_buf, 1024)) > 0) {
|
||||
real_size += bytes_read;
|
||||
}
|
||||
s.st_size = real_size;
|
||||
@ -362,6 +364,7 @@ int edit_clean (WEdit * edit)
|
||||
if (edit) {
|
||||
int j = 0;
|
||||
edit_free_syntax_rules (edit);
|
||||
book_mark_flush (edit, -1);
|
||||
for (; j <= MAXBUFF; j++) {
|
||||
if (edit->buffers1[j] != NULL)
|
||||
free (edit->buffers1[j]);
|
||||
@ -602,6 +605,8 @@ void edit_insert (WEdit * edit, int c)
|
||||
}
|
||||
/* now we must update some info on the file and check if a redraw is required */
|
||||
if (c == '\n') {
|
||||
if (edit->book_mark)
|
||||
book_mark_inc (edit, edit->curs_line);
|
||||
edit->curs_line++;
|
||||
edit->total_lines++;
|
||||
edit->force |= REDRAW_LINE_ABOVE | REDRAW_AFTER_CURSOR;
|
||||
@ -643,6 +648,8 @@ void edit_insert_ahead (WEdit * edit, int c)
|
||||
edit->start_line++;
|
||||
}
|
||||
if (c == '\n') {
|
||||
if (edit->book_mark)
|
||||
book_mark_inc (edit, edit->curs_line);
|
||||
edit->total_lines++;
|
||||
edit->force |= REDRAW_AFTER_CURSOR;
|
||||
}
|
||||
@ -682,6 +689,8 @@ int edit_delete (WEdit * edit)
|
||||
edit->curs2--;
|
||||
|
||||
if (p == '\n') {
|
||||
if (edit->book_mark)
|
||||
book_mark_dec (edit, edit->curs_line);
|
||||
edit->total_lines--;
|
||||
edit->force |= REDRAW_AFTER_CURSOR;
|
||||
}
|
||||
@ -716,6 +725,8 @@ int edit_backspace (WEdit * edit)
|
||||
edit->curs1--;
|
||||
|
||||
if (p == '\n') {
|
||||
if (edit->book_mark)
|
||||
book_mark_dec (edit, edit->curs_line);
|
||||
edit->curs_line--;
|
||||
edit->total_lines--;
|
||||
edit->force |= REDRAW_AFTER_CURSOR;
|
||||
@ -1169,6 +1180,10 @@ long edit_find_line (WEdit * edit, int line)
|
||||
edit->line_offsets[2] = edit_bol (edit, edit->last_byte);
|
||||
edit->caches_valid = 1;
|
||||
}
|
||||
if (line >= edit->total_lines)
|
||||
return edit->line_offsets[2];
|
||||
if (line <= 0)
|
||||
return 0;
|
||||
/* find the closest known point */
|
||||
for (i = 0; i < N_LINE_CACHES; i++) {
|
||||
int n;
|
||||
@ -2122,6 +2137,43 @@ int edit_execute_cmd (WEdit * edit, int command, int char_for_insertion)
|
||||
edit_mark_cmd (edit, 1);
|
||||
break;
|
||||
|
||||
case CK_Toggle_Bookmark:
|
||||
if (book_mark_query_color (edit, edit->curs_line, BOOK_MARK_COLOR))
|
||||
book_mark_clear (edit, edit->curs_line, BOOK_MARK_COLOR);
|
||||
else
|
||||
book_mark_insert (edit, edit->curs_line, BOOK_MARK_COLOR);
|
||||
break;
|
||||
case CK_Flush_Bookmarks:
|
||||
book_mark_flush (edit, BOOK_MARK_COLOR);
|
||||
edit->force |= REDRAW_PAGE;
|
||||
break;
|
||||
case CK_Next_Bookmark:
|
||||
if (edit->book_mark) {
|
||||
struct _book_mark *p;
|
||||
p = (struct _book_mark *) book_mark_find (edit, edit->curs_line);
|
||||
if (p->next) {
|
||||
p = p->next;
|
||||
if (p->line >= edit->start_line + edit->num_widget_lines || p->line < edit->start_line)
|
||||
edit_move_display (edit, p->line - edit->num_widget_lines / 2);
|
||||
edit_move_to_line (edit, p->line);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CK_Prev_Bookmark:
|
||||
if (edit->book_mark) {
|
||||
struct _book_mark *p;
|
||||
p = (struct _book_mark *) book_mark_find (edit, edit->curs_line);
|
||||
while (p->line == edit->curs_line)
|
||||
if (p->prev)
|
||||
p = p->prev;
|
||||
if (p->line >= 0) {
|
||||
if (p->line >= edit->start_line + edit->num_widget_lines || p->line < edit->start_line)
|
||||
edit_move_display (edit, p->line - edit->num_widget_lines / 2);
|
||||
edit_move_to_line (edit, p->line);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case CK_Beginning_Of_Text:
|
||||
case CK_Beginning_Of_Text_Highlight:
|
||||
edit_move_to_top (edit);
|
||||
@ -2241,6 +2293,7 @@ int edit_execute_cmd (WEdit * edit, int command, int char_for_insertion)
|
||||
#ifndef MIDNIGHT
|
||||
case CK_Sort:
|
||||
case CK_Mail:
|
||||
case CK_Find_File:
|
||||
#endif
|
||||
case CK_Complete:
|
||||
case CK_Cancel:
|
||||
@ -2250,6 +2303,16 @@ int edit_execute_cmd (WEdit * edit, int command, int char_for_insertion)
|
||||
case CK_Save_And_Quit:
|
||||
case CK_Check_Save_And_Quit:
|
||||
case CK_Run_Another:
|
||||
case CK_Debug_Start:
|
||||
case CK_Debug_Stop:
|
||||
case CK_Debug_Toggle_Break:
|
||||
case CK_Debug_Clear:
|
||||
case CK_Debug_Next:
|
||||
case CK_Debug_Step:
|
||||
case CK_Debug_Back_Trace:
|
||||
case CK_Debug_Continue:
|
||||
case CK_Debug_Enter_Command:
|
||||
case CK_Debug_Until_Curser:
|
||||
result = 0;
|
||||
break;
|
||||
case CK_Menu:
|
||||
|
@ -16,7 +16,9 @@
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __EDIT_H
|
||||
#define __EDIT_H
|
||||
@ -79,7 +81,11 @@
|
||||
# endif
|
||||
# endif
|
||||
|
||||
#ifdef GTK
|
||||
# include <regex.h>
|
||||
#else
|
||||
# include "regex.h"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@ -110,6 +116,7 @@
|
||||
#else
|
||||
|
||||
# include "src/main.h" /* for char *shell */
|
||||
# include "src/mad.h"
|
||||
# include "src/dlg.h"
|
||||
# include "src/widget.h"
|
||||
# include "src/color.h"
|
||||
@ -166,7 +173,7 @@
|
||||
#define SEARCH_DIALOG_OPTION_NO_CASE 4
|
||||
#define SEARCH_DIALOG_OPTION_BACKWARDS 8
|
||||
|
||||
#define SYNTAX_FILE "/.cedit/syntax"
|
||||
#define SYNTAX_FILE "/.cedit/Syntax"
|
||||
#define CLIP_FILE "/.cedit/cooledit.clip"
|
||||
#define MACRO_FILE "/.cedit/cooledit.macros"
|
||||
#define BLOCK_FILE "/.cedit/cooledit.block"
|
||||
@ -281,7 +288,7 @@ struct key_word {
|
||||
char last;
|
||||
char *whole_word_chars_left;
|
||||
char *whole_word_chars_right;
|
||||
#define NO_COLOR ((unsigned long) -1);
|
||||
#define NO_COLOR 0xFFFFFFFF
|
||||
int line_start;
|
||||
int bg;
|
||||
int fg;
|
||||
@ -313,6 +320,14 @@ struct _syntax_marker {
|
||||
struct _syntax_marker *next;
|
||||
};
|
||||
|
||||
struct _book_mark {
|
||||
int line; /* line number */
|
||||
#define BOOK_MARK_COLOR ((5 << 8) + 26) /* cyan on white */
|
||||
int c; /* colour */
|
||||
struct _book_mark *next;
|
||||
struct _book_mark *prev;
|
||||
};
|
||||
|
||||
struct editor_widget {
|
||||
#ifdef MIDNIGHT
|
||||
Widget widget;
|
||||
@ -381,6 +396,8 @@ struct editor_widget {
|
||||
int line_numbers[N_LINE_CACHES];
|
||||
long line_offsets[N_LINE_CACHES];
|
||||
|
||||
struct _book_mark *book_mark;
|
||||
|
||||
/* undo stack and pointers */
|
||||
unsigned long stack_pointer;
|
||||
long *undo_stack;
|
||||
@ -420,7 +437,7 @@ void edit_change_directory (void);
|
||||
int edit_man_page_cmd (WEdit * edit);
|
||||
void edit_search_replace_dialog (Window parent, int x, int y, char **search_text, char **replace_text, char **arg_order, char *heading, int option);
|
||||
void edit_search_dialog (WEdit * edit, char **search_text);
|
||||
long edit_find (long search_start, unsigned char *expr, int *len, long last_byte, int (*get_byte) (void *, long), void *data);
|
||||
long edit_find (long search_start, unsigned char *expr, int *len, long last_byte, int (*get_byte) (void *, long), void *data, void *d);
|
||||
void edit_set_foreground_colors (unsigned long normal, unsigned long bold, unsigned long italic);
|
||||
void edit_set_background_colors (unsigned long normal, unsigned long abnormal, unsigned long marked, unsigned long marked_abnormal, unsigned long highlighted);
|
||||
void edit_set_cursor_color (unsigned long c);
|
||||
@ -557,6 +574,16 @@ void edit_free_syntax_rules (WEdit * edit);
|
||||
void edit_get_syntax_color (WEdit * edit, long byte_index, int *fg, int *bg);
|
||||
|
||||
|
||||
void book_mark_insert (WEdit * edit, int line, int c);
|
||||
int book_mark_query_color (WEdit * edit, int line, int c);
|
||||
int book_mark_query_all (WEdit * edit, int line, int *c);
|
||||
struct _book_mark *book_mark_find (WEdit * edit, int line);
|
||||
void book_mark_clear (WEdit * edit, int line, int c);
|
||||
void book_mark_flush (WEdit * edit, int c);
|
||||
void book_mark_inc (WEdit * edit, int line);
|
||||
void book_mark_dec (WEdit * edit, int line);
|
||||
|
||||
|
||||
#ifdef MIDNIGHT
|
||||
|
||||
/* put OS2/NT/WIN95 defines here */
|
||||
|
@ -16,7 +16,9 @@
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* #define PIPE_BLOCKS_SO_READ_BYTE_BY_BYTE */
|
||||
|
||||
@ -54,7 +56,7 @@ int edit_confirm_save = 1;
|
||||
int edit_confirm_save = 0;
|
||||
#endif
|
||||
|
||||
#define NUM_REPL_ARGS 16
|
||||
#define NUM_REPL_ARGS 64
|
||||
#define MAX_REPL_LEN 1024
|
||||
|
||||
#if defined(MIDNIGHT) || defined(GTK)
|
||||
@ -807,7 +809,7 @@ int edit_new_cmd (WEdit * edit)
|
||||
{
|
||||
edit->force |= REDRAW_COMPLETELY;
|
||||
if (edit->modified)
|
||||
if (edit_query_dialog2 (_(" Warning "), _(" Current text was modified without a file save. \n Continue discards these changes. "), _("Continue"), _("Cancel")))
|
||||
if (edit_query_dialog2 (_ (" Warning "), _ (" Current text was modified without a file save. \n Continue discards these changes. "), _ ("Continue"), _ ("Cancel")))
|
||||
return 0;
|
||||
edit->modified = 0;
|
||||
return edit_renew (edit); /* if this gives an error, something has really screwed up */
|
||||
@ -826,7 +828,7 @@ int edit_load_file_from_filename (WEdit *edit, char *exp)
|
||||
return 0;
|
||||
} else {
|
||||
/* Heads the 'Load' file dialog box */
|
||||
edit_error_dialog (_(" Load "), get_sys_error (_(" Error trying to open file for reading ")));
|
||||
edit_error_dialog (_ (" Load "), get_sys_error (_ (" Error trying to open file for reading ")));
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@ -837,10 +839,10 @@ int edit_load_cmd (WEdit * edit)
|
||||
edit->force |= REDRAW_COMPLETELY;
|
||||
|
||||
if (edit->modified)
|
||||
if (edit_query_dialog2 (_(" Warning "), _(" Current text was modified without a file save. \n Continue discards these changes. "), _("Continue"), _("Cancel")))
|
||||
if (edit_query_dialog2 (_ (" Warning "), _ (" Current text was modified without a file save. \n Continue discards these changes. "), _ ("Continue"), _ ("Cancel")))
|
||||
return 0;
|
||||
|
||||
exp = edit_get_load_file (edit->dir, edit->filename, _(" Load "));
|
||||
exp = edit_get_load_file (edit->dir, edit->filename, _ (" Load "));
|
||||
|
||||
if (exp) {
|
||||
if (*exp)
|
||||
@ -984,7 +986,7 @@ void edit_block_move_cmd (WEdit * edit)
|
||||
return;
|
||||
|
||||
if ((end_mark - start_mark) > option_max_undo / 2)
|
||||
if (edit_query_dialog2 (_(" Warning "), _(" Block is large, you may not be able to undo this action. "), _("Continue"), _("Cancel")))
|
||||
if (edit_query_dialog2 (_ (" Warning "), _ (" Block is large, you may not be able to undo this action. "), _ ("Continue"), _ ("Cancel")))
|
||||
return;
|
||||
|
||||
edit_push_markers (edit);
|
||||
@ -1081,7 +1083,7 @@ int edit_block_delete (WEdit * edit)
|
||||
edit_mark_cmd (edit, 0);
|
||||
if ((end_mark - start_mark) > option_max_undo / 2)
|
||||
/* Warning message with a query to continue or cancel the operation */
|
||||
if (edit_query_dialog2 (_(" Warning "), _(" Block is large, you may not be able to undo this action. "), _(" Continue "), _(" Cancel ")))
|
||||
if (edit_query_dialog2 (_ (" Warning "), _ (" Block is large, you may not be able to undo this action. "), _ (" Continue "), _ (" Cancel ")))
|
||||
return 1;
|
||||
edit_push_markers (edit);
|
||||
edit_cursor_move (edit, start_mark - edit->curs1);
|
||||
@ -1315,7 +1317,6 @@ void edit_search_dialog (WEdit * edit, char **search_text)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#else
|
||||
|
||||
#define B_ENTER 0
|
||||
@ -1355,13 +1356,15 @@ void edit_search_replace_dialog (Window parent, int x, int y, char **search_text
|
||||
(CDrawText ("replace.t2", win, xh, yh, _(" Enter replace text : ")))->hotkey = 'n';
|
||||
CGetHintPos (0, &yh);
|
||||
(CDrawTextInput ("replace.rinp", win, xh, yh, 10, AUTO_HEIGHT, 256, *replace_text))->hotkey = 'n';
|
||||
CSetToolHint ("replace.t2", _("You can enter regexp substrings with %s (not \\1, \\2 like sed) then use \"Enter...order\""));
|
||||
CSetToolHint ("replace.rinp", _("You can enter regexp substrings with %s (not \\1, \\2 like sed) then use \"Enter...order\""));
|
||||
CGetHintPos (0, &yh);
|
||||
(CDrawText ("replace.t3", win, xh, yh, _(" Enter argument order : ")))->hotkey = 'o';
|
||||
(CDrawText ("replace.t3", win, xh, yh, _(" Enter argument (or substring) order : ")))->hotkey = 'o';
|
||||
CGetHintPos (0, &yh);
|
||||
(CDrawTextInput ("replace.ainp", win, xh, yh, 10, AUTO_HEIGHT, 256, *arg_order))->hotkey = 'o';
|
||||
/* Tool hint */
|
||||
CSetToolHint ("replace.ainp", _("Enter the order of replacement of your scanf format specifiers"));
|
||||
CSetToolHint ("replace.t3", _("Enter the order of replacement of your scanf format specifiers"));
|
||||
CSetToolHint ("replace.ainp", _("Enter the order of replacement of your scanf format specifiers or regexp substrings"));
|
||||
CSetToolHint ("replace.t3", _("Enter the order of replacement of your scanf format specifiers or regexp substrings"));
|
||||
}
|
||||
CGetHintPos (0, &yh);
|
||||
ys = yh;
|
||||
@ -1609,14 +1612,20 @@ long sargs[NUM_REPL_ARGS][256 / sizeof (long)];
|
||||
sargs[argord[8]], sargs[argord[9]], sargs[argord[10]], sargs[argord[11]], \
|
||||
sargs[argord[12]], sargs[argord[13]], sargs[argord[14]], sargs[argord[15]]
|
||||
|
||||
|
||||
/* This function is a modification of mc-3.2.10/src/view.c:regexp_view_search() */
|
||||
/* returns -3 on error in pattern, -1 on not found, found_len = 0 if either */
|
||||
int string_regexp_search (char *pattern, char *string, int len, int match_type, int match_bol, int icase, int *found_len)
|
||||
int string_regexp_search (char *pattern, char *string, int len, int match_type, int match_bol, int icase, int *found_len, void *d)
|
||||
{
|
||||
static regex_t r;
|
||||
regmatch_t pmatch[1];
|
||||
static char *old_pattern = NULL;
|
||||
static int old_type, old_icase;
|
||||
regmatch_t *pmatch;
|
||||
static regmatch_t s[1];
|
||||
|
||||
pmatch = (regmatch_t *) d;
|
||||
if (!pmatch)
|
||||
pmatch = s;
|
||||
|
||||
if (!old_pattern || strcmp (old_pattern, pattern) || old_type != match_type || old_icase != icase) {
|
||||
if (old_pattern) {
|
||||
@ -1632,7 +1641,7 @@ int string_regexp_search (char *pattern, char *string, int len, int match_type,
|
||||
old_type = match_type;
|
||||
old_icase = icase;
|
||||
}
|
||||
if (regexec (&r, string, 1, pmatch, ((match_bol || match_type != match_normal) ? 0 : REG_NOTBOL)) != 0) {
|
||||
if (regexec (&r, string, d ? NUM_REPL_ARGS : 1, pmatch, ((match_bol || match_type != match_normal) ? 0 : REG_NOTBOL)) != 0) {
|
||||
*found_len = 0;
|
||||
return -1;
|
||||
}
|
||||
@ -1643,7 +1652,7 @@ int string_regexp_search (char *pattern, char *string, int len, int match_type,
|
||||
/* thanks to Liviu Daia <daia@stoilow.imar.ro> for getting this
|
||||
(and the above) routines to work properly - paul */
|
||||
|
||||
long edit_find_string (long start, unsigned char *exp, int *len, long last_byte, int (*get_byte) (void *, long), void *data, int once_only)
|
||||
long edit_find_string (long start, unsigned char *exp, int *len, long last_byte, int (*get_byte) (void *, long), void *data, int once_only, void *d)
|
||||
{
|
||||
long p, q = 0;
|
||||
long l = strlen ((char *) exp), f = 0;
|
||||
@ -1734,7 +1743,7 @@ long edit_find_string (long start, unsigned char *exp, int *len, long last_byte,
|
||||
|
||||
buf = mbuf;
|
||||
while (q) {
|
||||
found_start = string_regexp_search ((char *) exp, (char *) buf, q, match_normal, match_bol, !replace_case, len);
|
||||
found_start = string_regexp_search ((char *) exp, (char *) buf, q, match_normal, match_bol, !replace_case, len, d);
|
||||
|
||||
if (found_start <= -2) { /* regcomp/regexec error */
|
||||
*len = 0;
|
||||
@ -1800,13 +1809,13 @@ long edit_find_string (long start, unsigned char *exp, int *len, long last_byte,
|
||||
}
|
||||
|
||||
|
||||
long edit_find_forwards (long search_start, unsigned char *exp, int *len, long last_byte, int (*get_byte) (void *, long), void *data, int once_only)
|
||||
long edit_find_forwards (long search_start, unsigned char *exp, int *len, long last_byte, int (*get_byte) (void *, long), void *data, int once_only, void *d)
|
||||
{ /*front end to find_string to check for
|
||||
whole words */
|
||||
long p;
|
||||
p = search_start;
|
||||
|
||||
while ((p = edit_find_string (p, exp, len, last_byte, get_byte, data, once_only)) >= 0) {
|
||||
while ((p = edit_find_string (p, exp, len, last_byte, get_byte, data, once_only, d)) >= 0) {
|
||||
if (replace_whole) {
|
||||
/*If the bordering chars are not in option_whole_chars_search then word is whole */
|
||||
if (!strcasechr (option_whole_chars_search, (*get_byte) (data, p - 1))
|
||||
@ -1823,18 +1832,18 @@ long edit_find_forwards (long search_start, unsigned char *exp, int *len, long l
|
||||
return p;
|
||||
}
|
||||
|
||||
long edit_find (long search_start, unsigned char *exp, int *len, long last_byte, int (*get_byte) (void *, long), void *data)
|
||||
long edit_find (long search_start, unsigned char *exp, int *len, long last_byte, int (*get_byte) (void *, long), void *data, void *d)
|
||||
{
|
||||
long p;
|
||||
if (replace_backwards) {
|
||||
while (search_start >= 0) {
|
||||
p = edit_find_forwards (search_start, exp, len, last_byte, get_byte, data, 1);
|
||||
p = edit_find_forwards (search_start, exp, len, last_byte, get_byte, data, 1, d);
|
||||
if (p == search_start)
|
||||
return p;
|
||||
search_start--;
|
||||
}
|
||||
} else {
|
||||
return edit_find_forwards (search_start, exp, len, last_byte, get_byte, data, 0);
|
||||
return edit_find_forwards (search_start, exp, len, last_byte, get_byte, data, 0, d);
|
||||
}
|
||||
return -2;
|
||||
}
|
||||
@ -1948,6 +1957,7 @@ static void regexp_error (WEdit *edit)
|
||||
/* call with edit = 0 before shutdown to close memory leaks */
|
||||
void edit_replace_cmd (WEdit * edit, int again)
|
||||
{
|
||||
static regmatch_t pmatch[NUM_REPL_ARGS];
|
||||
static char *old1 = NULL;
|
||||
static char *old2 = NULL;
|
||||
static char *old3 = NULL;
|
||||
@ -1976,7 +1986,6 @@ void edit_replace_cmd (WEdit * edit, int again)
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
last_search = edit->last_byte;
|
||||
|
||||
edit->force |= REDRAW_COMPLETELY;
|
||||
@ -2045,7 +2054,7 @@ void edit_replace_cmd (WEdit * edit, int again)
|
||||
int len = 0;
|
||||
long new_start;
|
||||
new_start = edit_find (edit->search_start, (unsigned char *) exp1, &len, last_search,
|
||||
(int (*) (void *, long)) edit_get_byte, (void *) edit);
|
||||
(int (*)(void *, long)) edit_get_byte, (void *) edit, pmatch);
|
||||
if (new_start == -3) {
|
||||
regexp_error (edit);
|
||||
break;
|
||||
@ -2095,8 +2104,20 @@ void edit_replace_cmd (WEdit * edit, int again)
|
||||
}
|
||||
}
|
||||
if (replace_yes) { /* delete then insert new */
|
||||
if (replace_scanf) {
|
||||
if (replace_scanf || replace_regexp) {
|
||||
char repl_str[MAX_REPL_LEN + 2];
|
||||
if (replace_regexp) { /* we need to fill in sargs just like with scanf */
|
||||
int k, j;
|
||||
for (k = 1; k < NUM_REPL_ARGS && pmatch[k].rm_eo >= 0; k++) {
|
||||
unsigned char *t;
|
||||
t = (unsigned char *) &sargs[k - 1][0];
|
||||
for (j = 0; j < pmatch[k].rm_eo - pmatch[k].rm_so && j < 255; j++, t++)
|
||||
*t = (unsigned char) edit_get_byte (edit, edit->search_start - pmatch[0].rm_so + pmatch[k].rm_so + j);
|
||||
*t = '\0';
|
||||
}
|
||||
for (; k <= NUM_REPL_ARGS; k++)
|
||||
sargs[k - 1][0] = 0;
|
||||
}
|
||||
if (sprintf_p (repl_str, exp2, PRINTF_ARGS) >= 0) {
|
||||
times_replaced++;
|
||||
while (i--)
|
||||
@ -2104,9 +2125,9 @@ void edit_replace_cmd (WEdit * edit, int again)
|
||||
while (repl_str[++i])
|
||||
edit_insert (edit, repl_str[i]);
|
||||
} else {
|
||||
edit_error_dialog (_(" Replace "),
|
||||
edit_error_dialog (_ (" Replace "),
|
||||
/* "Invalid regexp string or scanf string" */
|
||||
_(" Error in replacement format string. "));
|
||||
_ (" Error in replacement format string. "));
|
||||
replace_continue = 0;
|
||||
}
|
||||
} else {
|
||||
@ -2134,10 +2155,10 @@ void edit_replace_cmd (WEdit * edit, int again)
|
||||
edit->force |= REDRAW_PAGE;
|
||||
edit_render_keypress (edit);
|
||||
if (times_replaced) {
|
||||
sprintf (fin_string, _(" %ld replacements made. "), times_replaced);
|
||||
edit_message_dialog (_(" Replace "), fin_string);
|
||||
sprintf (fin_string, _ (" %ld replacements made. "), times_replaced);
|
||||
edit_message_dialog (_ (" Replace "), fin_string);
|
||||
} else
|
||||
edit_message_dialog (_(" Replace "), _(" Search string not found. "));
|
||||
edit_message_dialog (_ (" Replace "), _ (" Search string not found. "));
|
||||
replace_continue = 0;
|
||||
}
|
||||
} while (replace_continue);
|
||||
@ -2189,7 +2210,7 @@ void edit_search_cmd (WEdit * edit, int again)
|
||||
edit->search_start++;
|
||||
|
||||
edit->search_start = edit_find (edit->search_start, (unsigned char *) exp, &len, edit->last_byte,
|
||||
(int (*)(void *, long)) edit_get_byte, (void *) edit);
|
||||
(int (*)(void *, long)) edit_get_byte, (void *) edit, 0);
|
||||
|
||||
if (edit->search_start >= 0) {
|
||||
edit->found_start = edit->search_start;
|
||||
|
@ -47,7 +47,7 @@
|
||||
#define CK_Remove 204
|
||||
#define CK_Unmark 206
|
||||
#define CK_Save_Block 207
|
||||
#define CK_Column_Mark 208
|
||||
#define CK_Column_Mark 208
|
||||
|
||||
/* search and replace */
|
||||
#define CK_Find 301
|
||||
@ -55,6 +55,18 @@
|
||||
#define CK_Replace 303
|
||||
#define CK_Replace_Again 304
|
||||
|
||||
/* debugger commands */
|
||||
#define CK_Debug_Start 350
|
||||
#define CK_Debug_Stop 351
|
||||
#define CK_Debug_Toggle_Break 352
|
||||
#define CK_Debug_Clear 353
|
||||
#define CK_Debug_Next 354
|
||||
#define CK_Debug_Step 355
|
||||
#define CK_Debug_Back_Trace 356
|
||||
#define CK_Debug_Continue 357
|
||||
#define CK_Debug_Enter_Command 358
|
||||
#define CK_Debug_Until_Curser 359
|
||||
|
||||
/* misc */
|
||||
#define CK_Insert_File 401
|
||||
#define CK_Exit 402
|
||||
@ -72,6 +84,9 @@
|
||||
#define CK_Cancel 414
|
||||
#define CK_Complete 415
|
||||
#define CK_Paragraph_Format 416
|
||||
#define CK_Util 417
|
||||
#define CK_Type_Load_Python 418
|
||||
#define CK_Find_File 419
|
||||
|
||||
/* application control */
|
||||
#define CK_Save_Desktop 451
|
||||
@ -81,13 +96,19 @@
|
||||
#define CK_Save_And_Quit 455
|
||||
#define CK_Run_Another 456
|
||||
#define CK_Check_Save_And_Quit 457
|
||||
#define CK_Maximise 458
|
||||
#define CK_Maximize 458
|
||||
|
||||
/* macro */
|
||||
#define CK_Begin_Record_Macro 501
|
||||
#define CK_End_Record_Macro 502
|
||||
#define CK_Delete_Macro 503
|
||||
|
||||
/* book mark */
|
||||
#define CK_Toggle_Bookmark 550
|
||||
#define CK_Flush_Bookmarks 551
|
||||
#define CK_Next_Bookmark 552
|
||||
#define CK_Prev_Bookmark 553
|
||||
|
||||
/* highlight commands */
|
||||
#define CK_Page_Up_Highlight 604
|
||||
#define CK_Page_Down_Highlight 605
|
||||
@ -108,8 +129,8 @@
|
||||
#define CK_Paragraph_Up_Highlight 620
|
||||
#define CK_Paragraph_Down_Highlight 621
|
||||
|
||||
/* X clipboard operations */
|
||||
|
||||
/* X clipboard operations */
|
||||
#define CK_XStore 701
|
||||
#define CK_XCut 702
|
||||
#define CK_XPaste 703
|
||||
|
@ -16,7 +16,9 @@
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include "edit.h"
|
||||
@ -103,12 +105,10 @@ void rerender_text (CWidget * wdt);
|
||||
|
||||
#ifdef GTK
|
||||
|
||||
void edit_status (WEdit * edit)
|
||||
void edit_status (WEdit *edit)
|
||||
{
|
||||
GtkEntry *entry;
|
||||
GtkWidget *widget;
|
||||
int w, i, t;
|
||||
char id[33];
|
||||
char s[160];
|
||||
w = edit->num_widget_columns - 1;
|
||||
if (w > 150)
|
||||
@ -119,7 +119,7 @@ void edit_status (WEdit * edit)
|
||||
if (w > 1) {
|
||||
i = w > 24 ? 18 : w - 6;
|
||||
i = i < 13 ? 13 : i;
|
||||
sprintf (s, "%s", name_trunc (edit->filename ? edit->filename : "", i));
|
||||
sprintf (s, "%s", (char *) name_trunc (edit->filename ? edit->filename : "", i));
|
||||
i = strlen (s);
|
||||
s[i] = ' ';
|
||||
s[i + 1] = ' ';
|
||||
@ -291,11 +291,6 @@ void edit_set_cursor_color (unsigned long c)
|
||||
|
||||
#else
|
||||
|
||||
#define BOLD_COLOR MARKED_COLOR
|
||||
#define UNDERLINE_COLOR VIEW_UNDERLINED_COLOR
|
||||
#define MARK_COLOR SELECTED_COLOR
|
||||
#define DEF_COLOR NORMAL_COLOR
|
||||
|
||||
static void set_color (int font)
|
||||
{
|
||||
attrset (font);
|
||||
@ -309,7 +304,7 @@ static void print_to_widget (WEdit * edit, long row, int start_col, float start_
|
||||
int x1 = start_col + EDIT_TEXT_HORIZONTAL_OFFSET;
|
||||
int y = row + EDIT_TEXT_VERTICAL_OFFSET;
|
||||
|
||||
set_color (DEF_COLOR);
|
||||
set_color (EDITOR_NORMAL_COLOR);
|
||||
edit_move (x1, y);
|
||||
hline (' ', end_col + 1 - EDIT_TEXT_HORIZONTAL_OFFSET - x1);
|
||||
|
||||
@ -329,15 +324,15 @@ static void print_to_widget (WEdit * edit, long row, int start_col, float start_
|
||||
if (style & MOD_ABNORMAL)
|
||||
textchar = '.';
|
||||
if (style & MOD_HIGHLIGHTED) {
|
||||
set_color (BOLD_COLOR);
|
||||
set_color (EDITOR_BOLD_COLOR);
|
||||
} else if (style & MOD_MARKED) {
|
||||
set_color (MARK_COLOR);
|
||||
set_color (EDITOR_MARKED_COLOR);
|
||||
}
|
||||
if (style & MOD_UNDERLINED) {
|
||||
set_color (UNDERLINE_COLOR);
|
||||
set_color (EDITOR_UNDERLINED_COLOR);
|
||||
}
|
||||
if (style & MOD_BOLD) {
|
||||
set_color (BOLD_COLOR);
|
||||
set_color (EDITOR_BOLD_COLOR);
|
||||
}
|
||||
addch (textchar);
|
||||
p++;
|
||||
@ -354,7 +349,12 @@ static void edit_draw_this_line (WEdit * edit, long b, long row, long start_col,
|
||||
int col, start_col_real;
|
||||
unsigned int c;
|
||||
int fg, bg;
|
||||
int i;
|
||||
int i, book_mark = -1;
|
||||
|
||||
#if 0
|
||||
if (!book_mark_query (edit, edit->start_line + row, &book_mark))
|
||||
book_mark = -1;
|
||||
#endif
|
||||
|
||||
edit_get_syntax_color (edit, b - 1, &fg, &bg);
|
||||
q = edit_move_forward3 (edit, b, start_col - edit->start_col, 0);
|
||||
@ -384,9 +384,13 @@ static void edit_draw_this_line (WEdit * edit, long b, long row, long start_col,
|
||||
if (q >= edit->found_start && q < edit->found_start + edit->found_len)
|
||||
*p |= MOD_HIGHLIGHTED * 256;
|
||||
c = edit_get_byte (edit, q);
|
||||
edit_get_syntax_color (edit, q, &fg, &bg);
|
||||
/* we don't use bg for mc - fg contains both */
|
||||
*p |= fg << 16;
|
||||
if (book_mark == -1) {
|
||||
edit_get_syntax_color (edit, q, &fg, &bg);
|
||||
*p |= fg << 16;
|
||||
} else {
|
||||
*p |= book_mark << 16;
|
||||
}
|
||||
q++;
|
||||
switch (c) {
|
||||
case '\n':
|
||||
@ -470,6 +474,7 @@ void render_edit_text (WEdit * edit, long start_row, long start_column, long end
|
||||
#ifndef MIDNIGHT
|
||||
static unsigned long prev_win = 0;
|
||||
#endif
|
||||
|
||||
int force = edit->force;
|
||||
long b;
|
||||
|
||||
@ -585,6 +590,7 @@ void render_edit_text (WEdit * edit, long start_row, long start_column, long end
|
||||
#endif
|
||||
#endif
|
||||
exit_render:
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
@ -16,8 +16,9 @@
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include "edit.h"
|
||||
@ -389,37 +390,42 @@ void CDrawEditMenuButtons (const char *ident, Window parent, Window focus_return
|
||||
CDrawMenuButton (catstrs (ident, ".filemenu", 0), parent, focus_return, x, y, AUTO_WIDTH, AUTO_HEIGHT, 8,
|
||||
/* The following are menu options. Do not change the key bindings (eg. C-o) and preserve '\t' */
|
||||
_(" File "),
|
||||
_("Open...\tC-o"), '~', menu_cmd, CK_Load,
|
||||
_("New\tC-n"), '~', menu_cmd, CK_New,
|
||||
"", ' ', 0, 0,
|
||||
_("Save\tF2"), '~', menu_cmd, CK_Save,
|
||||
_("Save as...\tF12"), '~', menu_cmd, CK_Save_As,
|
||||
"", ' ', 0, 0,
|
||||
_("Insert file...\tF15"), '~', menu_cmd, CK_Insert_File,
|
||||
_("Copy to file...\tC-f"), '~', menu_cmd, CK_Save_Block
|
||||
_("Open...\tC-o"), '~', menu_cmd, (unsigned long) CK_Load,
|
||||
_("New\tC-n"), '~', menu_cmd, (unsigned long) CK_New,
|
||||
"", ' ', (void *) 0, 0L,
|
||||
_("Save\tF2"), '~', menu_cmd, (unsigned long) CK_Save,
|
||||
_("Save as...\tF12"), '~', menu_cmd, (unsigned long) CK_Save_As,
|
||||
"", ' ', (void *) 0, 0L,
|
||||
_("Insert file...\tF15"), '~', menu_cmd, (unsigned long) CK_Insert_File,
|
||||
_("Copy to file...\tC-f"), '~', menu_cmd, (unsigned long) CK_Save_Block
|
||||
);
|
||||
/* Tool hint */
|
||||
CSetToolHint (catstrs (ident, ".filemenu", 0), _("Disk operations"));
|
||||
|
||||
CGetHintPos (&x, &d);
|
||||
|
||||
CDrawMenuButton (catstrs (ident, ".editmenu", 0), parent, focus_return, x, y, AUTO_WIDTH, AUTO_HEIGHT, 15,
|
||||
CDrawMenuButton (catstrs (ident, ".editmenu", 0), parent, focus_return, x, y, AUTO_WIDTH, AUTO_HEIGHT, 20,
|
||||
_(" Edit "),
|
||||
_("Toggle mark\tF3"), '~', menu_cmd, CK_Mark,
|
||||
_("Toggle mark columns\tC-b"), '~', menu_cmd, CK_Column_Mark,
|
||||
"", ' ', 0, 0,
|
||||
_("Toggle insert/overwrite\tIns"), '~', menu_cmd, CK_Toggle_Insert,
|
||||
"", ' ', 0, 0,
|
||||
_("Copy block to cursor\tF5"), '~', menu_cmd, CK_Copy,
|
||||
_("Move block to cursor\tF6"), '~', menu_cmd, CK_Move,
|
||||
_("Delete block\tF8/C-Del"), '~', menu_cmd, CK_Remove,
|
||||
"", ' ', 0, 0,
|
||||
_("Copy block to clipbrd\tC-Ins"), '~', menu_cmd, CK_XStore,
|
||||
_("Cut block to clipbrd\tS-Del"), '~', menu_cmd, CK_XCut,
|
||||
_("Paste block from clipbrd\tS-Ins"), '~', menu_cmd, CK_XPaste,
|
||||
_("Selection history\tM-Ins"), '~', menu_cmd, CK_Selection_History,
|
||||
"", ' ', 0, 0,
|
||||
_("Undo\tC-BackSpace"), '~', menu_cmd, CK_Undo
|
||||
_("Toggle mark\tF3"), '~', menu_cmd, (unsigned long) CK_Mark,
|
||||
_("Toggle mark columns\tC-b"), '~', menu_cmd, (unsigned long) CK_Column_Mark,
|
||||
"", ' ', (void *) 0, 0L,
|
||||
_("Toggle book mark\tC-M-Ins"), '~', menu_cmd, (unsigned long) CK_Toggle_Bookmark,
|
||||
_("Previous book mark\tC-M-Up"), '~', menu_cmd, (unsigned long) CK_Prev_Bookmark,
|
||||
_("Next book mark\tC-M-Down"), '~', menu_cmd, (unsigned long) CK_Next_Bookmark,
|
||||
_("Flush book marks"), '~', menu_cmd, (unsigned long) CK_Flush_Bookmarks,
|
||||
"", ' ', (void *) 0, 0L,
|
||||
_("Toggle insert/overwrite\tIns"), '~', menu_cmd, (unsigned long) CK_Toggle_Insert,
|
||||
"", ' ', (void *) 0, 0L,
|
||||
_("Copy block to cursor\tF5"), '~', menu_cmd, (unsigned long) CK_Copy,
|
||||
_("Move block to cursor\tF6"), '~', menu_cmd, (unsigned long) CK_Move,
|
||||
_("Delete block\tF8/C-Del"), '~', menu_cmd, (unsigned long) CK_Remove,
|
||||
"", ' ', (void *) 0, 0L,
|
||||
_("Copy block to clipbrd\tC-Ins"), '~', menu_cmd, (unsigned long) CK_XStore,
|
||||
_("Cut block to clipbrd\tS-Del"), '~', menu_cmd, (unsigned long) CK_XCut,
|
||||
_("Paste block from clipbrd\tS-Ins"), '~', menu_cmd, (unsigned long) CK_XPaste,
|
||||
_("Selection history\tM-Ins"), '~', menu_cmd, (unsigned long) CK_Selection_History,
|
||||
"", ' ', (void *) 0, 0L,
|
||||
_("Undo\tC-BackSpace"), '~', menu_cmd, (unsigned long) CK_Undo
|
||||
);
|
||||
/* Tool hint */
|
||||
CSetToolHint (catstrs (ident, ".editmenu", 0), _("Manipulating blocks of text"));
|
||||
@ -428,10 +434,10 @@ void CDrawEditMenuButtons (const char *ident, Window parent, Window focus_return
|
||||
|
||||
CDrawMenuButton (catstrs (ident, ".searchmenu", 0), parent, focus_return, x, y, AUTO_WIDTH, AUTO_HEIGHT, 4,
|
||||
_(" Srch/Replce "),
|
||||
_("Search...\tF7"), '~', menu_cmd, CK_Find,
|
||||
_("Search again\tF17"), '~', menu_cmd, CK_Find_Again,
|
||||
_("Replace...\tF4"), '~', menu_cmd, CK_Replace,
|
||||
_("Replace again\tF14"), '~', menu_cmd, CK_Replace_Again
|
||||
_("Search...\tF7"), '~', menu_cmd, (unsigned long) CK_Find,
|
||||
_("Search again\tF17"), '~', menu_cmd, (unsigned long) CK_Find_Again,
|
||||
_("Replace...\tF4"), '~', menu_cmd, (unsigned long) CK_Replace,
|
||||
_("Replace again\tF14"), '~', menu_cmd, (unsigned long) CK_Replace_Again
|
||||
);
|
||||
/* Tool hint */
|
||||
CSetToolHint (catstrs (ident, ".searchmenu", 0), _("Search for and replace text"));
|
||||
@ -440,17 +446,17 @@ void CDrawEditMenuButtons (const char *ident, Window parent, Window focus_return
|
||||
|
||||
CDrawMenuButton (catstrs (ident, ".commandmenu", 0), parent, focus_return, x, y, AUTO_WIDTH, AUTO_HEIGHT, 11,
|
||||
_(" Command "),
|
||||
_("Goto line...\tM-l"), '~', menu_cmd, CK_Goto,
|
||||
"", ' ', 0, 0,
|
||||
_("Start record macro\tC-r"), '~', menu_cmd, CK_Begin_Record_Macro,
|
||||
_("Finish record macro...\tC-r"), '~', menu_cmd, CK_End_Record_Macro,
|
||||
_("Execute macro...\tC-a, KEY"), '~', menu_ctrl_key, XK_a,
|
||||
_("Delete macro...\t"), '~', menu_cmd, CK_Delete_Macro,
|
||||
"", ' ', 0, 0,
|
||||
_("Insert date/time\tC-d"), '~', menu_cmd, CK_Date,
|
||||
_("Format paragraph\tM-p"), '~', menu_cmd, CK_Paragraph_Format,
|
||||
"", ' ', 0, 0,
|
||||
_("Refresh display\tC-l"), '~', menu_cmd, CK_Refresh
|
||||
_("Goto line...\tM-l"), '~', menu_cmd, (unsigned long) CK_Goto,
|
||||
"", ' ', (void *) 0, 0L,
|
||||
_("Start record macro\tC-r"), '~', menu_cmd, (unsigned long) CK_Begin_Record_Macro,
|
||||
_("Finish record macro...\tC-r"), '~', menu_cmd, (unsigned long) CK_End_Record_Macro,
|
||||
_("Execute macro...\tC-a, KEY"), '~', menu_ctrl_key, (unsigned long) XK_a,
|
||||
_("Delete macro...\t"), '~', menu_cmd, (unsigned long) CK_Delete_Macro,
|
||||
"", ' ', (void *) 0, 0L,
|
||||
_("Insert date/time\tC-d"), '~', menu_cmd, (unsigned long) CK_Date,
|
||||
_("Format paragraph\tM-p"), '~', menu_cmd, (unsigned long) CK_Paragraph_Format,
|
||||
"", ' ', (void *) 0, 0L,
|
||||
_("Refresh display\tC-l"), '~', menu_cmd, (unsigned long) CK_Refresh
|
||||
);
|
||||
/* Tool hint */
|
||||
CSetToolHint (catstrs (ident, ".commandmenu", 0), _("Macros and internal commands"));
|
||||
|
@ -16,7 +16,9 @@
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include "edit.h"
|
||||
|
@ -16,7 +16,9 @@
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
02111-1307, USA.
|
||||
*/
|
||||
|
||||
|
||||
#include <config.h>
|
||||
|
@ -13,7 +13,9 @@
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include "edit.h"
|
||||
@ -57,6 +59,7 @@ void set_style_color (
|
||||
{
|
||||
int fgp, bgp;
|
||||
fgp = (s & 0xFF000000UL) >> 24;
|
||||
/* NO_COLOR would give fgp == 255 */
|
||||
if (fgp < 255)
|
||||
*fg = color_palette (fgp);
|
||||
else
|
||||
@ -277,23 +280,41 @@ static inline cache_type get_style (WEdit * edit, long q, int c, long m1, long m
|
||||
return s | ((fg & 0xFF) << 24) | ((bg & 0xFF) << 16);
|
||||
}
|
||||
|
||||
void convert_text (WEdit * edit, long q, cache_type *p, int x, int x_max)
|
||||
void convert_text (WEdit * edit, long q, cache_type * p, int x, int x_max, int row)
|
||||
{
|
||||
int c;
|
||||
cache_type s;
|
||||
long m1, m2;
|
||||
unsigned char *r, text[4];
|
||||
int book_mark_colors[10], book_mark, book_mark_cycle = 0, the_end = 0;
|
||||
|
||||
eval_marks (edit, &m1, &m2);
|
||||
|
||||
book_mark = book_mark_query_all (edit, edit->start_line + row, book_mark_colors);
|
||||
|
||||
for (;;) {
|
||||
c = edit_get_byte (edit, q);
|
||||
*p = get_style (edit, q, c, m1, m2, x);
|
||||
if (!the_end)
|
||||
*p = get_style (edit, q, c, m1, m2, x);
|
||||
if (book_mark) {
|
||||
if (the_end)
|
||||
*p = 0;
|
||||
*p = (*p & 0x0000FFFF) | (book_mark_colors[book_mark_cycle++ % book_mark] << 16);
|
||||
}
|
||||
switch (c) {
|
||||
case '\n':
|
||||
*p++ |= ' ';
|
||||
*p = 0;
|
||||
if (x > edit->max_column)
|
||||
edit->max_column = x;
|
||||
return;
|
||||
if (book_mark) { /* bookmarks must show right across the screen */
|
||||
the_end = 1;
|
||||
c = ' ';
|
||||
q--;
|
||||
goto the_default;
|
||||
} else {
|
||||
*p++ |= ' ';
|
||||
*p = 0;
|
||||
if (x > edit->max_column)
|
||||
edit->max_column = x;
|
||||
return;
|
||||
}
|
||||
case '\t':
|
||||
if (fixed_font) {
|
||||
int t;
|
||||
@ -301,6 +322,10 @@ void convert_text (WEdit * edit, long q, cache_type *p, int x, int x_max)
|
||||
t = min (t, x_max);
|
||||
s = *p;
|
||||
while (x < t) {
|
||||
#if 0
|
||||
if (book_mark)
|
||||
*p = (*p & 0x0000FFFF) | (book_mark_colors[book_mark_cycle++ % book_mark] << 16);
|
||||
#endif
|
||||
x += per_char[' '];
|
||||
*p++ = s | ' ';
|
||||
}
|
||||
@ -310,6 +335,7 @@ void convert_text (WEdit * edit, long q, cache_type *p, int x, int x_max)
|
||||
}
|
||||
break;
|
||||
default:
|
||||
the_default:
|
||||
x += convert_to_long_printable (c, text);
|
||||
r = text;
|
||||
s = *p;
|
||||
@ -557,7 +583,7 @@ cache_type mode_spacing = 0;
|
||||
#define NOT_VALID (-2000000000)
|
||||
|
||||
void edit_draw_proportional (void *data,
|
||||
void (*converttext) (void *, long, cache_type *, int, int),
|
||||
void (*converttext) (void *, long, cache_type *, int, int, int),
|
||||
int calctextpos (void *, long, long *, int),
|
||||
int scroll_right,
|
||||
Window win,
|
||||
@ -594,7 +620,7 @@ void edit_draw_proportional (void *data,
|
||||
/* q contains the offset in the edit buffer */
|
||||
|
||||
/* translate this line into printable characters with a style (=color) high byte */
|
||||
(*converttext) (data, q, line, x0, x_max - scroll_right - EDIT_TEXT_HORIZONTAL_OFFSET);
|
||||
(*converttext) (data, q, line, x0, x_max - scroll_right - EDIT_TEXT_HORIZONTAL_OFFSET, row);
|
||||
|
||||
/* adjust for the horizontal scroll and border */
|
||||
x0 += scroll_right + EDIT_TEXT_HORIZONTAL_OFFSET;
|
||||
@ -693,7 +719,7 @@ void edit_draw_this_line_proportional (WEdit * edit, long b, int row, int start_
|
||||
edit_get_syntax_color (edit, b - 1, &fg, &bg);
|
||||
|
||||
edit_draw_proportional (edit,
|
||||
(void (*) (void *, long, cache_type *, int, int)) convert_text,
|
||||
(void (*) (void *, long, cache_type *, int, int, int)) convert_text,
|
||||
(int (*) (void *, long, long *, int)) calc_text_pos,
|
||||
edit->start_col, CWindowOf (edit->widget),
|
||||
end_column, b, row, row * FONT_PIX_PER_LINE + EDIT_TEXT_VERTICAL_OFFSET,
|
||||
@ -799,7 +825,7 @@ int calc_text_len2 (CWidget *w, long b, long upto)
|
||||
int highlight_this_line;
|
||||
|
||||
/* this is for the text widget (i.e. nroff formatting) */
|
||||
void convert_text2 (CWidget * w, long q, cache_type *line, int x, int x_max)
|
||||
void convert_text2 (CWidget * w, long q, cache_type *line, int x, int x_max, int row)
|
||||
{
|
||||
int c = 0, d;
|
||||
cache_type s, *p;
|
||||
|
2052
gtkedit/syntax.c
2052
gtkedit/syntax.c
File diff suppressed because it is too large
Load Diff
@ -14,7 +14,8 @@
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
@ -13,7 +13,8 @@
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef _X_DND_H
|
||||
@ -23,7 +24,10 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* you can set this to either 2 (which support 0 and 1 as well) or 3 */
|
||||
#define XDND_VERSION 2
|
||||
/* #define XDND_VERSION 3 */
|
||||
|
||||
|
||||
/* XdndEnter */
|
||||
#define XDND_THREE 3
|
||||
|
Loading…
Reference in New Issue
Block a user