1998-02-27 07:54:42 +03:00
|
|
|
/* User Menu implementation
|
|
|
|
Copyright (C) 1994 Miguel de Icaza, Janne Kukonlehto
|
|
|
|
|
|
|
|
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
|
2000-08-23 02:50:00 +04:00
|
|
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
1998-02-27 07:54:42 +03:00
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <errno.h>
|
1998-04-24 05:08:06 +04:00
|
|
|
#include <fcntl.h>
|
2001-09-03 09:07:40 +04:00
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
#include "global.h"
|
2001-09-03 09:07:40 +04:00
|
|
|
#include "tty.h"
|
1998-02-27 07:54:42 +03:00
|
|
|
#include "dialog.h"
|
|
|
|
#include "color.h"
|
|
|
|
#include "dir.h"
|
|
|
|
#include "panel.h"
|
|
|
|
#include "main.h"
|
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add macro %k it is block file name
Add macro %e it is error file name
Add macro %i it is cursor column indent of spaces, only for edit
Add macro %y, it is syntax of current file in editor, only for edit
Add condition y , it is syntax pattern of current file in edit
Add macro %x it is extension of current file
Add macro %m it is current menu filename
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editcmd.c: Modify External Formatter (was C indent formatter) .
Autocreate a scripts in home, from templates /usr/lib/mc/edit.indent.rc,
edit.ispell.rc, etc. Remove leading and trailing spaces into _(""),
(the message of David H. Martin <dmartina@usa.net>)
2000-05-05 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add condition (x filename) into mc.menu .
for "Open next a free console" and like.
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
src/user.c: fix segfault in chunk_alloc of glibc, when into condition
of .mnu we have quoted space. (~.mc/menu: + f \.\ test$).
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/edit.c:
Add ability user edit menus: system: /usr/lib/mc/cedit.menu,
* gtkedit/editmenu.c: home: ~/.cedit.menu, local: .cedit.menu
Marked block is access now from an user edit menu
Access ~/.cedit/cooledit.block for insert to cursor place from
user edit menu.
Created system cedit.menu
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editdraw.c:
Improved a status string of cool editor for best understand,
and to add char,hex view.
2000-05-04 Richard Hestilow <hestgray@ionet.net>
* gnome/gdesktop.c: Fixes snap to grid.
2000-05-09 05:18:27 +04:00
|
|
|
#include "subshell.h" /* for subshell_pty */
|
1998-02-27 07:54:42 +03:00
|
|
|
#include "user.h"
|
|
|
|
#include "layout.h"
|
1998-11-18 05:31:23 +03:00
|
|
|
#include "setup.h"
|
1998-02-27 07:54:42 +03:00
|
|
|
#include "../vfs/vfs.h"
|
|
|
|
|
|
|
|
/* For the simple listbox manager */
|
|
|
|
#include "dlg.h"
|
|
|
|
#include "widget.h"
|
|
|
|
#include "wtools.h"
|
|
|
|
|
|
|
|
#include "view.h" /* for default_* externs */
|
|
|
|
|
|
|
|
/* "$Id$" */
|
|
|
|
|
1999-11-01 23:49:03 +03:00
|
|
|
#define MAX_ENTRIES 16
|
1998-02-27 07:54:42 +03:00
|
|
|
#define MAX_ENTRY_LEN 60
|
|
|
|
|
|
|
|
static int debug_flag = 0;
|
|
|
|
static int debug_error = 0;
|
2000-05-25 20:21:42 +04:00
|
|
|
static char *menu = NULL;
|
1998-02-27 07:54:42 +03:00
|
|
|
|
|
|
|
/* Formats defined:
|
|
|
|
%% The % character
|
|
|
|
%f The current file (if non-local vfs, file will be copied locally and
|
|
|
|
%f will be full path to it).
|
|
|
|
%p The current file
|
|
|
|
%d The current working directory
|
|
|
|
%s "Selected files"; the tagged files if any, otherwise the current file
|
|
|
|
%t Tagged files
|
|
|
|
%u Tagged files (and they are untagged on return from expand_format)
|
2001-07-20 01:25:40 +04:00
|
|
|
%view Runs the commands and pipes standard output to the view command.
|
|
|
|
If %view is immediately followed by '{', recognize keywords
|
|
|
|
ascii, hex, nroff and unform
|
1998-02-27 07:54:42 +03:00
|
|
|
|
|
|
|
If the format letter is in uppercase, it refers to the other panel.
|
|
|
|
|
|
|
|
With a number followed the % character you can turn quoting on (default)
|
|
|
|
and off. For example:
|
|
|
|
%f quote expanded macro
|
|
|
|
%1f ditto
|
|
|
|
%0f don't quote expanded macro
|
|
|
|
|
|
|
|
expand_format returns a memory block that must be free()d.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Returns how many characters we should advance if %view was found */
|
1999-10-19 08:21:26 +04:00
|
|
|
int check_format_view (const char *p)
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
1999-10-19 08:21:26 +04:00
|
|
|
const char *q = p;
|
2001-07-20 01:25:40 +04:00
|
|
|
if (!strncmp (p, "view", 4)) {
|
1998-02-27 07:54:42 +03:00
|
|
|
q += 4;
|
|
|
|
if (*q == '{'){
|
2001-07-20 01:25:40 +04:00
|
|
|
for (q++;*q && *q != '}';q++) {
|
|
|
|
if (!strncmp (q, "ascii", 5)) {
|
1998-02-27 07:54:42 +03:00
|
|
|
default_hex_mode = 0;
|
|
|
|
q += 4;
|
2001-07-20 01:25:40 +04:00
|
|
|
} else if (!strncmp (q, "hex", 3)) {
|
1998-02-27 07:54:42 +03:00
|
|
|
default_hex_mode = 1;
|
|
|
|
q += 2;
|
2001-07-20 01:25:40 +04:00
|
|
|
} else if (!strncmp (q, "nroff", 5)) {
|
1998-02-27 07:54:42 +03:00
|
|
|
default_nroff_flag = 1;
|
|
|
|
q += 4;
|
2001-07-20 01:25:40 +04:00
|
|
|
} else if (!strncmp (q, "unform", 6)) {
|
1998-02-27 07:54:42 +03:00
|
|
|
default_nroff_flag = 0;
|
2001-07-20 01:25:40 +04:00
|
|
|
q += 5;
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (*q == '}')
|
|
|
|
q++;
|
|
|
|
}
|
|
|
|
return q - p;
|
1999-10-19 08:21:26 +04:00
|
|
|
}
|
|
|
|
return 0;
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
|
1999-10-19 08:21:26 +04:00
|
|
|
int check_format_cd (const char *p)
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
1999-10-19 08:21:26 +04:00
|
|
|
return (strncmp (p, "cd", 2)) ? 0 : 3;
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Check if p has a "^var\{var-name\}" */
|
|
|
|
/* Returns the number of skipped characters (zero on not found) */
|
|
|
|
/* V will be set to the expanded variable name */
|
1999-10-19 08:21:26 +04:00
|
|
|
int check_format_var (const char *p, char **v)
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
1999-10-19 08:21:26 +04:00
|
|
|
const char *q = p;
|
1998-02-27 07:54:42 +03:00
|
|
|
char *var_name;
|
|
|
|
char *value;
|
1999-10-19 08:21:26 +04:00
|
|
|
const char *dots = 0;
|
1998-02-27 07:54:42 +03:00
|
|
|
|
|
|
|
*v = 0;
|
|
|
|
if (!strncmp (p, "var{", 4)){
|
|
|
|
for (q += 4; *q && *q != '}'; q++){
|
|
|
|
if (*q == ':')
|
|
|
|
dots = q+1;
|
|
|
|
}
|
|
|
|
if (!*q)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (!dots || dots == q+5){
|
|
|
|
message (1,
|
2000-05-25 20:21:42 +04:00
|
|
|
_(" Format error on file Extensions File "),
|
2001-06-14 02:12:04 +04:00
|
|
|
!dots ? _(" The %%var macro has no default ")
|
|
|
|
: _(" The %%var macro has no variable "));
|
1998-02-27 07:54:42 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Copy the variable name */
|
Glibing..... (2)
Wed Jan 27 03:17:44 1999 Timur Bakeyev <mc@bat.ru>
* Converted memory managment to Glib. Now we use g_new()/g_malloc()/
g_strdup()/g_free() routings. Also, copy_strings() replaced by
g_strconcat(), strcasecmp() -> g_strcasecmp(),and sprintf() by
g_snprintf().
* Some sequences of malloc()/sprintf() changed to g_strdup_printf().
* mad.[ch]: Modified, to work with new GLib's memory managment. Fixed
a missing #undef for tempnam, which caused dead loop. Add several new
functions to emulate GLib memory managment.
*main.c, mad.[ch]: Add a new switch "-M", which allows to redirect MAD
messages to the file.
* util.[ch], utilunix.c: Modified, deleted our variants of strcasecmp()
and strdup() - we have g_ equivalences. Remove get_full_name() - it is
similar to concat_dir_and_file(). Some other tricks with g_* functions.
* global.h: Modified, extended. Now it is main memory mangment include -
i.e. all inclusions of <stdlib.h>, <malloc.h>, <glib.h>, "fs.h", "mem.h",
"util.h" and "mad.h" done there. This elimanates problem with proper or-
der of #include's.
* All around the source - changed order of #include's, most of them gone
to global.h (see above), minor changes, like "0" -> NULL in string func-
tions.
1999-01-27 04:08:30 +03:00
|
|
|
var_name = g_malloc (dots - p);
|
1998-02-27 07:54:42 +03:00
|
|
|
strncpy (var_name, p+4, dots-2 - (p+3));
|
|
|
|
var_name [dots-2 - (p+3)] = 0;
|
|
|
|
|
|
|
|
value = getenv (var_name);
|
1999-11-01 23:49:03 +03:00
|
|
|
g_free (var_name);
|
1998-02-27 07:54:42 +03:00
|
|
|
if (value){
|
Glibing..... (2)
Wed Jan 27 03:17:44 1999 Timur Bakeyev <mc@bat.ru>
* Converted memory managment to Glib. Now we use g_new()/g_malloc()/
g_strdup()/g_free() routings. Also, copy_strings() replaced by
g_strconcat(), strcasecmp() -> g_strcasecmp(),and sprintf() by
g_snprintf().
* Some sequences of malloc()/sprintf() changed to g_strdup_printf().
* mad.[ch]: Modified, to work with new GLib's memory managment. Fixed
a missing #undef for tempnam, which caused dead loop. Add several new
functions to emulate GLib memory managment.
*main.c, mad.[ch]: Add a new switch "-M", which allows to redirect MAD
messages to the file.
* util.[ch], utilunix.c: Modified, deleted our variants of strcasecmp()
and strdup() - we have g_ equivalences. Remove get_full_name() - it is
similar to concat_dir_and_file(). Some other tricks with g_* functions.
* global.h: Modified, extended. Now it is main memory mangment include -
i.e. all inclusions of <stdlib.h>, <malloc.h>, <glib.h>, "fs.h", "mem.h",
"util.h" and "mad.h" done there. This elimanates problem with proper or-
der of #include's.
* All around the source - changed order of #include's, most of them gone
to global.h (see above), minor changes, like "0" -> NULL in string func-
tions.
1999-01-27 04:08:30 +03:00
|
|
|
*v = g_strdup (value);
|
1998-02-27 07:54:42 +03:00
|
|
|
return q-p;
|
|
|
|
}
|
Glibing..... (2)
Wed Jan 27 03:17:44 1999 Timur Bakeyev <mc@bat.ru>
* Converted memory managment to Glib. Now we use g_new()/g_malloc()/
g_strdup()/g_free() routings. Also, copy_strings() replaced by
g_strconcat(), strcasecmp() -> g_strcasecmp(),and sprintf() by
g_snprintf().
* Some sequences of malloc()/sprintf() changed to g_strdup_printf().
* mad.[ch]: Modified, to work with new GLib's memory managment. Fixed
a missing #undef for tempnam, which caused dead loop. Add several new
functions to emulate GLib memory managment.
*main.c, mad.[ch]: Add a new switch "-M", which allows to redirect MAD
messages to the file.
* util.[ch], utilunix.c: Modified, deleted our variants of strcasecmp()
and strdup() - we have g_ equivalences. Remove get_full_name() - it is
similar to concat_dir_and_file(). Some other tricks with g_* functions.
* global.h: Modified, extended. Now it is main memory mangment include -
i.e. all inclusions of <stdlib.h>, <malloc.h>, <glib.h>, "fs.h", "mem.h",
"util.h" and "mad.h" done there. This elimanates problem with proper or-
der of #include's.
* All around the source - changed order of #include's, most of them gone
to global.h (see above), minor changes, like "0" -> NULL in string func-
tions.
1999-01-27 04:08:30 +03:00
|
|
|
var_name = g_malloc (q - dots + 1);
|
1998-02-27 07:54:42 +03:00
|
|
|
strncpy (var_name, dots, q - dots + 1);
|
|
|
|
var_name [q-dots] = 0;
|
|
|
|
*v = var_name;
|
|
|
|
return q-p;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* strip file's extension */
|
1998-12-03 00:27:27 +03:00
|
|
|
static char *
|
|
|
|
strip_ext(char *ss)
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
|
|
|
register char *s = ss;
|
|
|
|
char *e = NULL;
|
|
|
|
while(*s) {
|
|
|
|
if(*s == '.') e = s;
|
|
|
|
if(*s == PATH_SEP && e) e=NULL; /* '.' in *directory* name */
|
|
|
|
s++;
|
|
|
|
}
|
|
|
|
if(e) *e = 0;
|
|
|
|
return ss;
|
|
|
|
}
|
|
|
|
|
2002-08-24 21:25:27 +04:00
|
|
|
char *
|
|
|
|
expand_format (WEdit * edit_widget, char c, int quote)
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
|
|
|
WPanel *panel;
|
2002-08-24 21:25:27 +04:00
|
|
|
char *(*quote_func) (const char *, int);
|
1999-11-01 23:49:03 +03:00
|
|
|
char *fname;
|
1998-02-27 07:54:42 +03:00
|
|
|
|
|
|
|
if (c == '%')
|
Glibing..... (2)
Wed Jan 27 03:17:44 1999 Timur Bakeyev <mc@bat.ru>
* Converted memory managment to Glib. Now we use g_new()/g_malloc()/
g_strdup()/g_free() routings. Also, copy_strings() replaced by
g_strconcat(), strcasecmp() -> g_strcasecmp(),and sprintf() by
g_snprintf().
* Some sequences of malloc()/sprintf() changed to g_strdup_printf().
* mad.[ch]: Modified, to work with new GLib's memory managment. Fixed
a missing #undef for tempnam, which caused dead loop. Add several new
functions to emulate GLib memory managment.
*main.c, mad.[ch]: Add a new switch "-M", which allows to redirect MAD
messages to the file.
* util.[ch], utilunix.c: Modified, deleted our variants of strcasecmp()
and strdup() - we have g_ equivalences. Remove get_full_name() - it is
similar to concat_dir_and_file(). Some other tricks with g_* functions.
* global.h: Modified, extended. Now it is main memory mangment include -
i.e. all inclusions of <stdlib.h>, <malloc.h>, <glib.h>, "fs.h", "mem.h",
"util.h" and "mad.h" done there. This elimanates problem with proper or-
der of #include's.
* All around the source - changed order of #include's, most of them gone
to global.h (see above), minor changes, like "0" -> NULL in string func-
tions.
1999-01-27 04:08:30 +03:00
|
|
|
return g_strdup ("%");
|
2002-08-24 21:25:27 +04:00
|
|
|
|
|
|
|
if (islower ((unsigned) c))
|
1998-02-27 07:54:42 +03:00
|
|
|
panel = cpanel;
|
|
|
|
else {
|
1999-11-01 23:49:03 +03:00
|
|
|
if (get_other_type () != view_listing)
|
Glibing..... (2)
Wed Jan 27 03:17:44 1999 Timur Bakeyev <mc@bat.ru>
* Converted memory managment to Glib. Now we use g_new()/g_malloc()/
g_strdup()/g_free() routings. Also, copy_strings() replaced by
g_strconcat(), strcasecmp() -> g_strcasecmp(),and sprintf() by
g_snprintf().
* Some sequences of malloc()/sprintf() changed to g_strdup_printf().
* mad.[ch]: Modified, to work with new GLib's memory managment. Fixed
a missing #undef for tempnam, which caused dead loop. Add several new
functions to emulate GLib memory managment.
*main.c, mad.[ch]: Add a new switch "-M", which allows to redirect MAD
messages to the file.
* util.[ch], utilunix.c: Modified, deleted our variants of strcasecmp()
and strdup() - we have g_ equivalences. Remove get_full_name() - it is
similar to concat_dir_and_file(). Some other tricks with g_* functions.
* global.h: Modified, extended. Now it is main memory mangment include -
i.e. all inclusions of <stdlib.h>, <malloc.h>, <glib.h>, "fs.h", "mem.h",
"util.h" and "mad.h" done there. This elimanates problem with proper or-
der of #include's.
* All around the source - changed order of #include's, most of them gone
to global.h (see above), minor changes, like "0" -> NULL in string func-
tions.
1999-01-27 04:08:30 +03:00
|
|
|
return g_strdup ("");
|
1999-11-01 23:49:03 +03:00
|
|
|
panel = other_panel;
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
if (!panel)
|
|
|
|
panel = cpanel;
|
|
|
|
|
1999-11-01 23:49:03 +03:00
|
|
|
if (quote)
|
|
|
|
quote_func = name_quote;
|
|
|
|
else
|
|
|
|
quote_func = fake_name_quote;
|
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
c = tolower (c);
|
2002-08-24 21:25:27 +04:00
|
|
|
fname = panel->dir.list[panel->selected].fname;
|
|
|
|
|
|
|
|
switch (c) {
|
|
|
|
case 'f':
|
|
|
|
case 'p':
|
|
|
|
return (*quote_func) (fname, 0);
|
|
|
|
case 'x':
|
|
|
|
return (*quote_func) (extension (fname), 0);
|
|
|
|
case 'd':
|
|
|
|
return (*quote_func) (panel->cwd, 0);
|
|
|
|
case 'i': /* indent equal number cursor position in line */
|
|
|
|
if (edit_widget)
|
|
|
|
return g_strnfill (edit_widget->curs_col, ' ');
|
2002-06-13 15:22:04 +04:00
|
|
|
break;
|
2002-08-24 21:25:27 +04:00
|
|
|
case 'y': /* syntax type */
|
|
|
|
if (edit_widget && edit_widget->syntax_type)
|
|
|
|
return g_strdup (edit_widget->syntax_type);
|
|
|
|
break;
|
|
|
|
case 'k': /* block file name */
|
|
|
|
case 'b': /* block file name / strip extension */ {
|
|
|
|
if (edit_widget) {
|
|
|
|
char *file = g_strconcat (home_dir, BLOCK_FILE, NULL);
|
|
|
|
fname = (*quote_func) (file, 0);
|
|
|
|
g_free (file);
|
|
|
|
return fname;
|
|
|
|
} else if (c == 'b') {
|
|
|
|
return strip_ext ((*quote_func) (fname, 0));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 'n': /* strip extension in editor */
|
2001-07-24 02:50:54 +04:00
|
|
|
if (edit_widget)
|
2002-08-24 21:25:27 +04:00
|
|
|
return strip_ext ((*quote_func) (fname, 0));
|
2001-07-24 02:50:54 +04:00
|
|
|
break;
|
2002-08-24 21:25:27 +04:00
|
|
|
case 'm': /* menu file name */
|
2000-05-25 20:21:42 +04:00
|
|
|
if (menu)
|
|
|
|
return (*quote_func) (menu, 0);
|
|
|
|
break;
|
2002-08-24 21:25:27 +04:00
|
|
|
case 's':
|
|
|
|
if (!panel->marked)
|
|
|
|
return (*quote_func) (fname, 0);
|
1998-02-27 07:54:42 +03:00
|
|
|
|
|
|
|
/* Fall through */
|
|
|
|
|
|
|
|
case 't':
|
|
|
|
case 'u':
|
2002-08-24 21:25:27 +04:00
|
|
|
{
|
|
|
|
int length = 2, i;
|
|
|
|
char *block, *tmp;
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2002-08-24 21:25:27 +04:00
|
|
|
for (i = 0; i < panel->count; i++)
|
|
|
|
if (panel->dir.list[i].f.marked)
|
|
|
|
length += strlen (panel->dir.list[i].fname) + 1; /* for space */
|
|
|
|
|
|
|
|
block = g_malloc (length * 2 + 1);
|
|
|
|
*block = 0;
|
|
|
|
for (i = 0; i < panel->count; i++)
|
|
|
|
if (panel->dir.list[i].f.marked) {
|
|
|
|
strcat (block, tmp =
|
|
|
|
(*quote_func) (panel->dir.list[i].fname, 0));
|
|
|
|
g_free (tmp);
|
|
|
|
strcat (block, " ");
|
|
|
|
if (c == 'u')
|
|
|
|
do_file_mark (panel, i, 0);
|
|
|
|
}
|
|
|
|
return block;
|
|
|
|
} /* sub case block */
|
|
|
|
} /* switch */
|
Glibing..... (2)
Wed Jan 27 03:17:44 1999 Timur Bakeyev <mc@bat.ru>
* Converted memory managment to Glib. Now we use g_new()/g_malloc()/
g_strdup()/g_free() routings. Also, copy_strings() replaced by
g_strconcat(), strcasecmp() -> g_strcasecmp(),and sprintf() by
g_snprintf().
* Some sequences of malloc()/sprintf() changed to g_strdup_printf().
* mad.[ch]: Modified, to work with new GLib's memory managment. Fixed
a missing #undef for tempnam, which caused dead loop. Add several new
functions to emulate GLib memory managment.
*main.c, mad.[ch]: Add a new switch "-M", which allows to redirect MAD
messages to the file.
* util.[ch], utilunix.c: Modified, deleted our variants of strcasecmp()
and strdup() - we have g_ equivalences. Remove get_full_name() - it is
similar to concat_dir_and_file(). Some other tricks with g_* functions.
* global.h: Modified, extended. Now it is main memory mangment include -
i.e. all inclusions of <stdlib.h>, <malloc.h>, <glib.h>, "fs.h", "mem.h",
"util.h" and "mad.h" done there. This elimanates problem with proper or-
der of #include's.
* All around the source - changed order of #include's, most of them gone
to global.h (see above), minor changes, like "0" -> NULL in string func-
tions.
1999-01-27 04:08:30 +03:00
|
|
|
return g_strdup ("");
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
|
1999-09-20 03:09:07 +04:00
|
|
|
/* Checks for shell patterns definition */
|
1998-02-27 07:54:42 +03:00
|
|
|
char *check_patterns (char *p)
|
|
|
|
{
|
1999-09-20 03:09:07 +04:00
|
|
|
static const char def_name [] = "shell_patterns=";
|
1998-02-27 07:54:42 +03:00
|
|
|
int value;
|
|
|
|
|
1999-09-20 03:09:07 +04:00
|
|
|
if (strncmp (p, def_name, sizeof (def_name) - 1) == 0){
|
|
|
|
p += sizeof (def_name) - 1;
|
1998-02-27 07:54:42 +03:00
|
|
|
value = *p++ - '0';
|
|
|
|
if (value == 0 || value == 1)
|
|
|
|
easy_patterns = value;
|
|
|
|
else
|
1999-09-20 03:09:07 +04:00
|
|
|
message (1, MSG_ERROR, _(" Invalid shell pattern definition \"%c\". "), value + '0');
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
while (*p == '\n' || *p == '\t' || *p == ' ') p++;
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Copies a whitespace separated argument from p to arg. Returns the
|
|
|
|
point after argument. */
|
|
|
|
static char *extract_arg (char *p, char *arg)
|
|
|
|
{
|
|
|
|
while (*p && (*p == ' ' || *p == '\t' || *p == '\n'))
|
|
|
|
p++;
|
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add macro %k it is block file name
Add macro %e it is error file name
Add macro %i it is cursor column indent of spaces, only for edit
Add macro %y, it is syntax of current file in editor, only for edit
Add condition y , it is syntax pattern of current file in edit
Add macro %x it is extension of current file
Add macro %m it is current menu filename
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editcmd.c: Modify External Formatter (was C indent formatter) .
Autocreate a scripts in home, from templates /usr/lib/mc/edit.indent.rc,
edit.ispell.rc, etc. Remove leading and trailing spaces into _(""),
(the message of David H. Martin <dmartina@usa.net>)
2000-05-05 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add condition (x filename) into mc.menu .
for "Open next a free console" and like.
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
src/user.c: fix segfault in chunk_alloc of glibc, when into condition
of .mnu we have quoted space. (~.mc/menu: + f \.\ test$).
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/edit.c:
Add ability user edit menus: system: /usr/lib/mc/cedit.menu,
* gtkedit/editmenu.c: home: ~/.cedit.menu, local: .cedit.menu
Marked block is access now from an user edit menu
Access ~/.cedit/cooledit.block for insert to cursor place from
user edit menu.
Created system cedit.menu
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editdraw.c:
Improved a status string of cool editor for best understand,
and to add char,hex view.
2000-05-04 Richard Hestilow <hestgray@ionet.net>
* gnome/gdesktop.c: Fixes snap to grid.
2000-05-09 05:18:27 +04:00
|
|
|
/* support quote space .mnu */
|
|
|
|
while (*p && (*p != ' ' || *(p-1) == '\\') && *p != '\t' && *p != '\n')
|
1998-02-27 07:54:42 +03:00
|
|
|
*arg++ = *p++;
|
|
|
|
*arg = 0;
|
|
|
|
if (!*p || *p == '\n')
|
|
|
|
p --;
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Tests whether the selected file in the panel is of any of the types
|
|
|
|
specified in argument. */
|
|
|
|
static int test_type (WPanel *panel, char *arg)
|
|
|
|
{
|
|
|
|
int result = 0; /* False by default */
|
|
|
|
int st_mode = panel->dir.list [panel->selected].buf.st_mode;
|
|
|
|
|
|
|
|
for (;*arg != 0; arg++){
|
|
|
|
switch (*arg){
|
|
|
|
case 'n': /* Not a directory */
|
|
|
|
result |= !S_ISDIR (st_mode);
|
|
|
|
break;
|
|
|
|
case 'r': /* Regular file */
|
|
|
|
result |= S_ISREG (st_mode);
|
|
|
|
break;
|
|
|
|
case 'd': /* Directory */
|
|
|
|
result |= S_ISDIR (st_mode);
|
|
|
|
break;
|
|
|
|
case 'l': /* Link */
|
|
|
|
result |= S_ISLNK (st_mode);
|
|
|
|
break;
|
|
|
|
case 'c': /* Character special */
|
|
|
|
result |= S_ISCHR (st_mode);
|
|
|
|
break;
|
|
|
|
case 'b': /* Block special */
|
|
|
|
result |= S_ISBLK (st_mode);
|
|
|
|
break;
|
|
|
|
case 'f': /* Fifo (named pipe) */
|
|
|
|
result |= S_ISFIFO (st_mode);
|
|
|
|
break;
|
|
|
|
case 's': /* Socket */
|
|
|
|
result |= S_ISSOCK (st_mode);
|
|
|
|
break;
|
|
|
|
case 'x': /* Executable */
|
|
|
|
result |= (st_mode & 0111) ? 1 : 0;
|
|
|
|
break;
|
|
|
|
case 't':
|
|
|
|
result |= panel->marked ? 1 : 0;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
debug_error = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Calculates the truth value of the next condition starting from
|
|
|
|
p. Returns the point after condition. */
|
2001-07-24 02:50:54 +04:00
|
|
|
static char *test_condition (WEdit *edit_widget, char *p, int *condition)
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
|
|
|
WPanel *panel;
|
|
|
|
char arg [256];
|
|
|
|
|
|
|
|
/* Handle one condition */
|
|
|
|
for (;*p != '\n' && *p != '&' && *p != '|'; p++){
|
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add macro %k it is block file name
Add macro %e it is error file name
Add macro %i it is cursor column indent of spaces, only for edit
Add macro %y, it is syntax of current file in editor, only for edit
Add condition y , it is syntax pattern of current file in edit
Add macro %x it is extension of current file
Add macro %m it is current menu filename
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editcmd.c: Modify External Formatter (was C indent formatter) .
Autocreate a scripts in home, from templates /usr/lib/mc/edit.indent.rc,
edit.ispell.rc, etc. Remove leading and trailing spaces into _(""),
(the message of David H. Martin <dmartina@usa.net>)
2000-05-05 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add condition (x filename) into mc.menu .
for "Open next a free console" and like.
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
src/user.c: fix segfault in chunk_alloc of glibc, when into condition
of .mnu we have quoted space. (~.mc/menu: + f \.\ test$).
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/edit.c:
Add ability user edit menus: system: /usr/lib/mc/cedit.menu,
* gtkedit/editmenu.c: home: ~/.cedit.menu, local: .cedit.menu
Marked block is access now from an user edit menu
Access ~/.cedit/cooledit.block for insert to cursor place from
user edit menu.
Created system cedit.menu
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editdraw.c:
Improved a status string of cool editor for best understand,
and to add char,hex view.
2000-05-04 Richard Hestilow <hestgray@ionet.net>
* gnome/gdesktop.c: Fixes snap to grid.
2000-05-09 05:18:27 +04:00
|
|
|
/* support quote space .mnu */
|
|
|
|
if ((*p == ' ' && *(p-1) != '\\') || *p == '\t')
|
1998-02-27 07:54:42 +03:00
|
|
|
continue;
|
|
|
|
if (*p >= 'a')
|
|
|
|
panel = cpanel;
|
|
|
|
else {
|
|
|
|
if (get_other_type () == view_listing)
|
|
|
|
panel = other_panel;
|
|
|
|
else
|
|
|
|
panel = NULL;
|
|
|
|
}
|
|
|
|
*p |= 0x20;
|
|
|
|
|
|
|
|
switch (*p++){
|
|
|
|
case '!':
|
2001-07-24 02:50:54 +04:00
|
|
|
p = test_condition (edit_widget, p, condition);
|
1998-02-27 07:54:42 +03:00
|
|
|
*condition = ! *condition;
|
|
|
|
p--;
|
|
|
|
break;
|
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add macro %k it is block file name
Add macro %e it is error file name
Add macro %i it is cursor column indent of spaces, only for edit
Add macro %y, it is syntax of current file in editor, only for edit
Add condition y , it is syntax pattern of current file in edit
Add macro %x it is extension of current file
Add macro %m it is current menu filename
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editcmd.c: Modify External Formatter (was C indent formatter) .
Autocreate a scripts in home, from templates /usr/lib/mc/edit.indent.rc,
edit.ispell.rc, etc. Remove leading and trailing spaces into _(""),
(the message of David H. Martin <dmartina@usa.net>)
2000-05-05 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add condition (x filename) into mc.menu .
for "Open next a free console" and like.
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
src/user.c: fix segfault in chunk_alloc of glibc, when into condition
of .mnu we have quoted space. (~.mc/menu: + f \.\ test$).
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/edit.c:
Add ability user edit menus: system: /usr/lib/mc/cedit.menu,
* gtkedit/editmenu.c: home: ~/.cedit.menu, local: .cedit.menu
Marked block is access now from an user edit menu
Access ~/.cedit/cooledit.block for insert to cursor place from
user edit menu.
Created system cedit.menu
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editdraw.c:
Improved a status string of cool editor for best understand,
and to add char,hex view.
2000-05-04 Richard Hestilow <hestgray@ionet.net>
* gnome/gdesktop.c: Fixes snap to grid.
2000-05-09 05:18:27 +04:00
|
|
|
case 'f': /* file name pattern */
|
1998-02-27 07:54:42 +03:00
|
|
|
p = extract_arg (p, arg);
|
|
|
|
*condition = panel && regexp_match (arg, panel->dir.list [panel->selected].fname, match_file);
|
|
|
|
break;
|
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add macro %k it is block file name
Add macro %e it is error file name
Add macro %i it is cursor column indent of spaces, only for edit
Add macro %y, it is syntax of current file in editor, only for edit
Add condition y , it is syntax pattern of current file in edit
Add macro %x it is extension of current file
Add macro %m it is current menu filename
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editcmd.c: Modify External Formatter (was C indent formatter) .
Autocreate a scripts in home, from templates /usr/lib/mc/edit.indent.rc,
edit.ispell.rc, etc. Remove leading and trailing spaces into _(""),
(the message of David H. Martin <dmartina@usa.net>)
2000-05-05 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add condition (x filename) into mc.menu .
for "Open next a free console" and like.
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
src/user.c: fix segfault in chunk_alloc of glibc, when into condition
of .mnu we have quoted space. (~.mc/menu: + f \.\ test$).
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/edit.c:
Add ability user edit menus: system: /usr/lib/mc/cedit.menu,
* gtkedit/editmenu.c: home: ~/.cedit.menu, local: .cedit.menu
Marked block is access now from an user edit menu
Access ~/.cedit/cooledit.block for insert to cursor place from
user edit menu.
Created system cedit.menu
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editdraw.c:
Improved a status string of cool editor for best understand,
and to add char,hex view.
2000-05-04 Richard Hestilow <hestgray@ionet.net>
* gnome/gdesktop.c: Fixes snap to grid.
2000-05-09 05:18:27 +04:00
|
|
|
case 'y': /* syntax pattern */
|
2001-07-24 02:50:54 +04:00
|
|
|
if (edit_widget && edit_widget->syntax_type) {
|
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add macro %k it is block file name
Add macro %e it is error file name
Add macro %i it is cursor column indent of spaces, only for edit
Add macro %y, it is syntax of current file in editor, only for edit
Add condition y , it is syntax pattern of current file in edit
Add macro %x it is extension of current file
Add macro %m it is current menu filename
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editcmd.c: Modify External Formatter (was C indent formatter) .
Autocreate a scripts in home, from templates /usr/lib/mc/edit.indent.rc,
edit.ispell.rc, etc. Remove leading and trailing spaces into _(""),
(the message of David H. Martin <dmartina@usa.net>)
2000-05-05 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add condition (x filename) into mc.menu .
for "Open next a free console" and like.
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
src/user.c: fix segfault in chunk_alloc of glibc, when into condition
of .mnu we have quoted space. (~.mc/menu: + f \.\ test$).
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/edit.c:
Add ability user edit menus: system: /usr/lib/mc/cedit.menu,
* gtkedit/editmenu.c: home: ~/.cedit.menu, local: .cedit.menu
Marked block is access now from an user edit menu
Access ~/.cedit/cooledit.block for insert to cursor place from
user edit menu.
Created system cedit.menu
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editdraw.c:
Improved a status string of cool editor for best understand,
and to add char,hex view.
2000-05-04 Richard Hestilow <hestgray@ionet.net>
* gnome/gdesktop.c: Fixes snap to grid.
2000-05-09 05:18:27 +04:00
|
|
|
p = extract_arg (p, arg);
|
|
|
|
*condition = panel &&
|
2001-07-24 02:50:54 +04:00
|
|
|
regexp_match (arg, edit_widget->syntax_type, match_normal);
|
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add macro %k it is block file name
Add macro %e it is error file name
Add macro %i it is cursor column indent of spaces, only for edit
Add macro %y, it is syntax of current file in editor, only for edit
Add condition y , it is syntax pattern of current file in edit
Add macro %x it is extension of current file
Add macro %m it is current menu filename
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editcmd.c: Modify External Formatter (was C indent formatter) .
Autocreate a scripts in home, from templates /usr/lib/mc/edit.indent.rc,
edit.ispell.rc, etc. Remove leading and trailing spaces into _(""),
(the message of David H. Martin <dmartina@usa.net>)
2000-05-05 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add condition (x filename) into mc.menu .
for "Open next a free console" and like.
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
src/user.c: fix segfault in chunk_alloc of glibc, when into condition
of .mnu we have quoted space. (~.mc/menu: + f \.\ test$).
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/edit.c:
Add ability user edit menus: system: /usr/lib/mc/cedit.menu,
* gtkedit/editmenu.c: home: ~/.cedit.menu, local: .cedit.menu
Marked block is access now from an user edit menu
Access ~/.cedit/cooledit.block for insert to cursor place from
user edit menu.
Created system cedit.menu
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editdraw.c:
Improved a status string of cool editor for best understand,
and to add char,hex view.
2000-05-04 Richard Hestilow <hestgray@ionet.net>
* gnome/gdesktop.c: Fixes snap to grid.
2000-05-09 05:18:27 +04:00
|
|
|
}
|
|
|
|
break;
|
1998-02-27 07:54:42 +03:00
|
|
|
case 'd':
|
|
|
|
p = extract_arg (p, arg);
|
|
|
|
*condition = panel && regexp_match (arg, panel->cwd, match_file);
|
|
|
|
break;
|
|
|
|
case 't':
|
|
|
|
p = extract_arg (p, arg);
|
|
|
|
*condition = panel && test_type (panel, arg);
|
|
|
|
break;
|
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add macro %k it is block file name
Add macro %e it is error file name
Add macro %i it is cursor column indent of spaces, only for edit
Add macro %y, it is syntax of current file in editor, only for edit
Add condition y , it is syntax pattern of current file in edit
Add macro %x it is extension of current file
Add macro %m it is current menu filename
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editcmd.c: Modify External Formatter (was C indent formatter) .
Autocreate a scripts in home, from templates /usr/lib/mc/edit.indent.rc,
edit.ispell.rc, etc. Remove leading and trailing spaces into _(""),
(the message of David H. Martin <dmartina@usa.net>)
2000-05-05 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add condition (x filename) into mc.menu .
for "Open next a free console" and like.
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
src/user.c: fix segfault in chunk_alloc of glibc, when into condition
of .mnu we have quoted space. (~.mc/menu: + f \.\ test$).
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/edit.c:
Add ability user edit menus: system: /usr/lib/mc/cedit.menu,
* gtkedit/editmenu.c: home: ~/.cedit.menu, local: .cedit.menu
Marked block is access now from an user edit menu
Access ~/.cedit/cooledit.block for insert to cursor place from
user edit menu.
Created system cedit.menu
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editdraw.c:
Improved a status string of cool editor for best understand,
and to add char,hex view.
2000-05-04 Richard Hestilow <hestgray@ionet.net>
* gnome/gdesktop.c: Fixes snap to grid.
2000-05-09 05:18:27 +04:00
|
|
|
case 'x': /* executable */
|
|
|
|
{
|
|
|
|
struct stat status;
|
|
|
|
|
|
|
|
p = extract_arg (p, arg);
|
|
|
|
if (stat (arg, &status) == 0)
|
|
|
|
*condition = is_exe (status.st_mode);
|
|
|
|
else
|
|
|
|
*condition = 0;
|
|
|
|
break;
|
|
|
|
}
|
1998-02-27 07:54:42 +03:00
|
|
|
default:
|
|
|
|
debug_error = 1;
|
|
|
|
break;
|
|
|
|
} /* switch */
|
|
|
|
|
|
|
|
} /* while */
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* General purpose condition debug output handler */
|
1998-12-03 00:27:27 +03:00
|
|
|
static void
|
|
|
|
debug_out (char *start, char *end, int cond)
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
|
|
|
static char msg [256];
|
|
|
|
int len;
|
|
|
|
|
|
|
|
if (start == NULL && end == NULL){
|
|
|
|
if (cond == 0){
|
|
|
|
/* Init */
|
|
|
|
msg [0] = 0;
|
|
|
|
} else {
|
|
|
|
/* Show output */
|
|
|
|
if (!debug_flag)
|
|
|
|
return;
|
|
|
|
len = strlen (msg);
|
|
|
|
if (len)
|
|
|
|
msg [len - 1] = 0;
|
2002-09-01 12:10:11 +04:00
|
|
|
message (0, _(" Debug "), "%s", msg);
|
1998-02-27 07:54:42 +03:00
|
|
|
debug_flag = 0;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* Save debug info for later output */
|
|
|
|
if (!debug_flag)
|
|
|
|
return;
|
|
|
|
/* Save the result of the condition */
|
|
|
|
if (debug_error){
|
1998-03-25 08:16:00 +03:00
|
|
|
strcat (msg, _(" ERROR: "));
|
1998-02-27 07:54:42 +03:00
|
|
|
debug_error = 0;
|
|
|
|
}
|
|
|
|
else if (cond)
|
1998-03-25 08:16:00 +03:00
|
|
|
strcat (msg, _(" True: "));
|
1998-02-27 07:54:42 +03:00
|
|
|
else
|
1998-03-25 08:16:00 +03:00
|
|
|
strcat (msg, _(" False: "));
|
1998-02-27 07:54:42 +03:00
|
|
|
/* Copy condition statement */
|
|
|
|
len = strlen (msg);
|
|
|
|
if (end == NULL){
|
|
|
|
/* Copy one character */
|
|
|
|
msg [len] = *start;
|
|
|
|
msg [len + 1] = 0;
|
|
|
|
} else {
|
|
|
|
/* Copy many characters */
|
|
|
|
while (start < end){
|
|
|
|
msg [len++] = *start++;
|
|
|
|
}
|
|
|
|
msg [len] = 0;
|
|
|
|
}
|
|
|
|
strcat (msg, " \n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Calculates the truth value of one lineful of conditions. Returns
|
|
|
|
the point just before the end of line. */
|
2001-07-24 02:50:54 +04:00
|
|
|
static char *test_line (WEdit *edit_widget, char *p, int *result)
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
|
|
|
int condition;
|
|
|
|
char operator;
|
|
|
|
char *debug_start, *debug_end;
|
|
|
|
|
|
|
|
/* Init debugger */
|
|
|
|
debug_out (NULL, NULL, 0);
|
|
|
|
/* Repeat till end of line */
|
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add macro %k it is block file name
Add macro %e it is error file name
Add macro %i it is cursor column indent of spaces, only for edit
Add macro %y, it is syntax of current file in editor, only for edit
Add condition y , it is syntax pattern of current file in edit
Add macro %x it is extension of current file
Add macro %m it is current menu filename
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editcmd.c: Modify External Formatter (was C indent formatter) .
Autocreate a scripts in home, from templates /usr/lib/mc/edit.indent.rc,
edit.ispell.rc, etc. Remove leading and trailing spaces into _(""),
(the message of David H. Martin <dmartina@usa.net>)
2000-05-05 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add condition (x filename) into mc.menu .
for "Open next a free console" and like.
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
src/user.c: fix segfault in chunk_alloc of glibc, when into condition
of .mnu we have quoted space. (~.mc/menu: + f \.\ test$).
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/edit.c:
Add ability user edit menus: system: /usr/lib/mc/cedit.menu,
* gtkedit/editmenu.c: home: ~/.cedit.menu, local: .cedit.menu
Marked block is access now from an user edit menu
Access ~/.cedit/cooledit.block for insert to cursor place from
user edit menu.
Created system cedit.menu
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editdraw.c:
Improved a status string of cool editor for best understand,
and to add char,hex view.
2000-05-04 Richard Hestilow <hestgray@ionet.net>
* gnome/gdesktop.c: Fixes snap to grid.
2000-05-09 05:18:27 +04:00
|
|
|
while (*p && *p != '\n') {
|
|
|
|
/* support quote space .mnu */
|
|
|
|
while ((*p == ' ' && *(p-1) != '\\' ) || *p == '\t')
|
1998-02-27 07:54:42 +03:00
|
|
|
p++;
|
|
|
|
if (!*p || *p == '\n')
|
|
|
|
break;
|
|
|
|
operator = *p++;
|
|
|
|
if (*p == '?'){
|
|
|
|
debug_flag = 1;
|
|
|
|
p++;
|
|
|
|
}
|
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add macro %k it is block file name
Add macro %e it is error file name
Add macro %i it is cursor column indent of spaces, only for edit
Add macro %y, it is syntax of current file in editor, only for edit
Add condition y , it is syntax pattern of current file in edit
Add macro %x it is extension of current file
Add macro %m it is current menu filename
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editcmd.c: Modify External Formatter (was C indent formatter) .
Autocreate a scripts in home, from templates /usr/lib/mc/edit.indent.rc,
edit.ispell.rc, etc. Remove leading and trailing spaces into _(""),
(the message of David H. Martin <dmartina@usa.net>)
2000-05-05 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add condition (x filename) into mc.menu .
for "Open next a free console" and like.
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
src/user.c: fix segfault in chunk_alloc of glibc, when into condition
of .mnu we have quoted space. (~.mc/menu: + f \.\ test$).
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/edit.c:
Add ability user edit menus: system: /usr/lib/mc/cedit.menu,
* gtkedit/editmenu.c: home: ~/.cedit.menu, local: .cedit.menu
Marked block is access now from an user edit menu
Access ~/.cedit/cooledit.block for insert to cursor place from
user edit menu.
Created system cedit.menu
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editdraw.c:
Improved a status string of cool editor for best understand,
and to add char,hex view.
2000-05-04 Richard Hestilow <hestgray@ionet.net>
* gnome/gdesktop.c: Fixes snap to grid.
2000-05-09 05:18:27 +04:00
|
|
|
/* support quote space .mnu */
|
|
|
|
while ((*p == ' ' && *(p-1) != '\\' ) || *p == '\t')
|
1998-02-27 07:54:42 +03:00
|
|
|
p++;
|
|
|
|
if (!*p || *p == '\n')
|
|
|
|
break;
|
|
|
|
condition = 1; /* True by default */
|
|
|
|
|
|
|
|
debug_start = p;
|
2001-07-24 02:50:54 +04:00
|
|
|
p = test_condition (edit_widget, p, &condition);
|
1998-02-27 07:54:42 +03:00
|
|
|
debug_end = p;
|
|
|
|
/* Add one debug statement */
|
|
|
|
debug_out (debug_start, debug_end, condition);
|
|
|
|
|
|
|
|
switch (operator){
|
|
|
|
case '+':
|
|
|
|
case '=':
|
|
|
|
/* Assignment */
|
|
|
|
*result = condition;
|
|
|
|
break;
|
|
|
|
case '&': /* Logical and */
|
|
|
|
*result &= condition;
|
|
|
|
break;
|
|
|
|
case '|': /* Logical or */
|
|
|
|
*result |= condition;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
debug_error = 1;
|
|
|
|
break;
|
|
|
|
} /* switch */
|
|
|
|
/* Add one debug statement */
|
|
|
|
debug_out (&operator, NULL, *result);
|
|
|
|
|
|
|
|
} /* while (*p != '\n') */
|
|
|
|
/* Report debug message */
|
|
|
|
debug_out (NULL, NULL, 1);
|
|
|
|
|
|
|
|
if (!*p || *p == '\n')
|
|
|
|
p --;
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* FIXME: recode this routine on version 3.0, it could be cleaner */
|
1998-12-03 00:27:27 +03:00
|
|
|
static void
|
2001-07-24 02:50:54 +04:00
|
|
|
execute_menu_command (WEdit *edit_widget, char *commands)
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
|
|
|
FILE *cmd_file;
|
1998-04-24 05:08:06 +04:00
|
|
|
int cmd_file_fd;
|
1998-02-27 07:54:42 +03:00
|
|
|
int expand_prefix_found = 0;
|
1999-11-01 23:49:03 +03:00
|
|
|
char *parameter = 0;
|
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add macro %k it is block file name
Add macro %e it is error file name
Add macro %i it is cursor column indent of spaces, only for edit
Add macro %y, it is syntax of current file in editor, only for edit
Add condition y , it is syntax pattern of current file in edit
Add macro %x it is extension of current file
Add macro %m it is current menu filename
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editcmd.c: Modify External Formatter (was C indent formatter) .
Autocreate a scripts in home, from templates /usr/lib/mc/edit.indent.rc,
edit.ispell.rc, etc. Remove leading and trailing spaces into _(""),
(the message of David H. Martin <dmartina@usa.net>)
2000-05-05 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add condition (x filename) into mc.menu .
for "Open next a free console" and like.
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
src/user.c: fix segfault in chunk_alloc of glibc, when into condition
of .mnu we have quoted space. (~.mc/menu: + f \.\ test$).
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/edit.c:
Add ability user edit menus: system: /usr/lib/mc/cedit.menu,
* gtkedit/editmenu.c: home: ~/.cedit.menu, local: .cedit.menu
Marked block is access now from an user edit menu
Access ~/.cedit/cooledit.block for insert to cursor place from
user edit menu.
Created system cedit.menu
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editdraw.c:
Improved a status string of cool editor for best understand,
and to add char,hex view.
2000-05-04 Richard Hestilow <hestgray@ionet.net>
* gnome/gdesktop.c: Fixes snap to grid.
2000-05-09 05:18:27 +04:00
|
|
|
int do_quote = 0;
|
1999-11-01 23:49:03 +03:00
|
|
|
char prompt [80];
|
1998-02-27 07:54:42 +03:00
|
|
|
int col;
|
1999-04-22 08:36:11 +04:00
|
|
|
char *file_name;
|
|
|
|
#ifdef OS2_NT
|
|
|
|
char *p;
|
|
|
|
#endif
|
1999-11-01 23:49:03 +03:00
|
|
|
/* Skip menu entry title line */
|
|
|
|
commands = strchr (commands, '\n');
|
|
|
|
if (!commands){
|
|
|
|
return;
|
|
|
|
}
|
1999-04-22 08:36:11 +04:00
|
|
|
|
2001-05-21 20:21:07 +04:00
|
|
|
cmd_file_fd = mc_mkstemps(&file_name, "mcusr", SCRIPT_SUFFIX);
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2001-05-21 20:21:07 +04:00
|
|
|
if (cmd_file_fd == -1){
|
2001-08-14 04:55:34 +04:00
|
|
|
message (1, MSG_ERROR, _(" Cannot create temporary command file \n %s "),
|
1998-02-27 07:54:42 +03:00
|
|
|
unix_error_string (errno));
|
|
|
|
return;
|
|
|
|
}
|
1998-04-24 05:08:06 +04:00
|
|
|
cmd_file = fdopen (cmd_file_fd, "w");
|
1998-02-27 07:54:42 +03:00
|
|
|
commands++;
|
|
|
|
|
|
|
|
for (col = 0; *commands; commands++){
|
1999-11-01 23:49:03 +03:00
|
|
|
if (col == 0) {
|
|
|
|
if (*commands != ' ' && *commands != '\t')
|
|
|
|
break;
|
1998-02-27 07:54:42 +03:00
|
|
|
while (*commands == ' ' || *commands == '\t')
|
|
|
|
commands++;
|
1999-11-01 23:49:03 +03:00
|
|
|
}
|
1998-02-27 07:54:42 +03:00
|
|
|
col++;
|
|
|
|
if (*commands == '\n')
|
|
|
|
col = 0;
|
1999-11-01 23:49:03 +03:00
|
|
|
if (parameter){
|
1998-02-27 07:54:42 +03:00
|
|
|
if (*commands == '}'){
|
|
|
|
char *tmp;
|
1999-11-01 23:49:03 +03:00
|
|
|
*parameter = 0;
|
1998-03-25 08:16:00 +03:00
|
|
|
parameter = input_dialog (_(" Parameter "), prompt, "");
|
1998-02-27 07:54:42 +03:00
|
|
|
if (!parameter || !*parameter){
|
|
|
|
/* User canceled */
|
|
|
|
fclose (cmd_file);
|
|
|
|
unlink (file_name);
|
2001-05-22 11:10:43 +04:00
|
|
|
g_free (file_name);
|
1998-02-27 07:54:42 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (do_quote) {
|
|
|
|
fputs (tmp = name_quote (parameter, 0), cmd_file);
|
Glibing..... (2)
Wed Jan 27 03:17:44 1999 Timur Bakeyev <mc@bat.ru>
* Converted memory managment to Glib. Now we use g_new()/g_malloc()/
g_strdup()/g_free() routings. Also, copy_strings() replaced by
g_strconcat(), strcasecmp() -> g_strcasecmp(),and sprintf() by
g_snprintf().
* Some sequences of malloc()/sprintf() changed to g_strdup_printf().
* mad.[ch]: Modified, to work with new GLib's memory managment. Fixed
a missing #undef for tempnam, which caused dead loop. Add several new
functions to emulate GLib memory managment.
*main.c, mad.[ch]: Add a new switch "-M", which allows to redirect MAD
messages to the file.
* util.[ch], utilunix.c: Modified, deleted our variants of strcasecmp()
and strdup() - we have g_ equivalences. Remove get_full_name() - it is
similar to concat_dir_and_file(). Some other tricks with g_* functions.
* global.h: Modified, extended. Now it is main memory mangment include -
i.e. all inclusions of <stdlib.h>, <malloc.h>, <glib.h>, "fs.h", "mem.h",
"util.h" and "mad.h" done there. This elimanates problem with proper or-
der of #include's.
* All around the source - changed order of #include's, most of them gone
to global.h (see above), minor changes, like "0" -> NULL in string func-
tions.
1999-01-27 04:08:30 +03:00
|
|
|
g_free (tmp);
|
1998-02-27 07:54:42 +03:00
|
|
|
} else
|
|
|
|
fputs (parameter, cmd_file);
|
Glibing..... (2)
Wed Jan 27 03:17:44 1999 Timur Bakeyev <mc@bat.ru>
* Converted memory managment to Glib. Now we use g_new()/g_malloc()/
g_strdup()/g_free() routings. Also, copy_strings() replaced by
g_strconcat(), strcasecmp() -> g_strcasecmp(),and sprintf() by
g_snprintf().
* Some sequences of malloc()/sprintf() changed to g_strdup_printf().
* mad.[ch]: Modified, to work with new GLib's memory managment. Fixed
a missing #undef for tempnam, which caused dead loop. Add several new
functions to emulate GLib memory managment.
*main.c, mad.[ch]: Add a new switch "-M", which allows to redirect MAD
messages to the file.
* util.[ch], utilunix.c: Modified, deleted our variants of strcasecmp()
and strdup() - we have g_ equivalences. Remove get_full_name() - it is
similar to concat_dir_and_file(). Some other tricks with g_* functions.
* global.h: Modified, extended. Now it is main memory mangment include -
i.e. all inclusions of <stdlib.h>, <malloc.h>, <glib.h>, "fs.h", "mem.h",
"util.h" and "mad.h" done there. This elimanates problem with proper or-
der of #include's.
* All around the source - changed order of #include's, most of them gone
to global.h (see above), minor changes, like "0" -> NULL in string func-
tions.
1999-01-27 04:08:30 +03:00
|
|
|
g_free (parameter);
|
1999-11-01 23:49:03 +03:00
|
|
|
parameter = 0;
|
1998-02-27 07:54:42 +03:00
|
|
|
} else {
|
1999-11-01 23:49:03 +03:00
|
|
|
if (parameter < &prompt [sizeof (prompt) - 1]) {
|
|
|
|
*parameter++ = *commands;
|
|
|
|
}
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
} else if (expand_prefix_found){
|
|
|
|
expand_prefix_found = 0;
|
2002-08-16 18:56:13 +04:00
|
|
|
if (isdigit ((unsigned)*commands)) {
|
1998-02-27 07:54:42 +03:00
|
|
|
do_quote = atoi (commands);
|
2002-08-16 18:56:13 +04:00
|
|
|
while (isdigit ((unsigned)*commands))
|
1999-11-01 23:49:03 +03:00
|
|
|
commands++;
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
if (*commands == '{')
|
1999-11-01 23:49:03 +03:00
|
|
|
parameter = prompt;
|
1998-02-27 07:54:42 +03:00
|
|
|
else{
|
2001-07-24 02:50:54 +04:00
|
|
|
char *text = expand_format (edit_widget, *commands, do_quote);
|
1998-02-27 07:54:42 +03:00
|
|
|
fputs (text, cmd_file);
|
Glibing..... (2)
Wed Jan 27 03:17:44 1999 Timur Bakeyev <mc@bat.ru>
* Converted memory managment to Glib. Now we use g_new()/g_malloc()/
g_strdup()/g_free() routings. Also, copy_strings() replaced by
g_strconcat(), strcasecmp() -> g_strcasecmp(),and sprintf() by
g_snprintf().
* Some sequences of malloc()/sprintf() changed to g_strdup_printf().
* mad.[ch]: Modified, to work with new GLib's memory managment. Fixed
a missing #undef for tempnam, which caused dead loop. Add several new
functions to emulate GLib memory managment.
*main.c, mad.[ch]: Add a new switch "-M", which allows to redirect MAD
messages to the file.
* util.[ch], utilunix.c: Modified, deleted our variants of strcasecmp()
and strdup() - we have g_ equivalences. Remove get_full_name() - it is
similar to concat_dir_and_file(). Some other tricks with g_* functions.
* global.h: Modified, extended. Now it is main memory mangment include -
i.e. all inclusions of <stdlib.h>, <malloc.h>, <glib.h>, "fs.h", "mem.h",
"util.h" and "mad.h" done there. This elimanates problem with proper or-
der of #include's.
* All around the source - changed order of #include's, most of them gone
to global.h (see above), minor changes, like "0" -> NULL in string func-
tions.
1999-01-27 04:08:30 +03:00
|
|
|
g_free (text);
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (*commands == '%') {
|
|
|
|
do_quote = 1; /* Default: Quote expanded macro */
|
|
|
|
expand_prefix_found = 1;
|
|
|
|
} else
|
|
|
|
fputc (*commands, cmd_file);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fclose (cmd_file);
|
|
|
|
chmod (file_name, S_IRWXU);
|
|
|
|
execute (file_name);
|
|
|
|
unlink (file_name);
|
2001-05-22 11:10:43 +04:00
|
|
|
g_free (file_name);
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Check owner of the menu file. Using menu file is allowed, if
|
|
|
|
** owner of the menu is root or the actual user. In either case
|
|
|
|
** file should not be group and word-writable.
|
|
|
|
**
|
|
|
|
** Q. Should we apply this routine to system and home menu (and .ext files)?
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
menu_file_own(char* path)
|
|
|
|
{
|
1999-11-01 23:49:03 +03:00
|
|
|
struct stat st;
|
1998-02-27 07:54:42 +03:00
|
|
|
|
1999-11-01 23:49:03 +03:00
|
|
|
if (stat (path, &st) == 0
|
|
|
|
&& (!st.st_uid || (st.st_uid == geteuid ()))
|
|
|
|
&& ((st.st_mode & (S_IWGRP | S_IWOTH)) == 0)
|
|
|
|
) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
if (verbose)
|
|
|
|
{
|
|
|
|
message (0, _(" Warning -- ignoring file "),
|
|
|
|
_("File %s is not owned by root or you or is world writable.\n"
|
|
|
|
"Using it may compromise your security"),
|
|
|
|
path
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return 0;
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
|
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add macro %k it is block file name
Add macro %e it is error file name
Add macro %i it is cursor column indent of spaces, only for edit
Add macro %y, it is syntax of current file in editor, only for edit
Add condition y , it is syntax pattern of current file in edit
Add macro %x it is extension of current file
Add macro %m it is current menu filename
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editcmd.c: Modify External Formatter (was C indent formatter) .
Autocreate a scripts in home, from templates /usr/lib/mc/edit.indent.rc,
edit.ispell.rc, etc. Remove leading and trailing spaces into _(""),
(the message of David H. Martin <dmartina@usa.net>)
2000-05-05 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add condition (x filename) into mc.menu .
for "Open next a free console" and like.
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
src/user.c: fix segfault in chunk_alloc of glibc, when into condition
of .mnu we have quoted space. (~.mc/menu: + f \.\ test$).
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/edit.c:
Add ability user edit menus: system: /usr/lib/mc/cedit.menu,
* gtkedit/editmenu.c: home: ~/.cedit.menu, local: .cedit.menu
Marked block is access now from an user edit menu
Access ~/.cedit/cooledit.block for insert to cursor place from
user edit menu.
Created system cedit.menu
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editdraw.c:
Improved a status string of cool editor for best understand,
and to add char,hex view.
2000-05-04 Richard Hestilow <hestgray@ionet.net>
* gnome/gdesktop.c: Fixes snap to grid.
2000-05-09 05:18:27 +04:00
|
|
|
/*
|
|
|
|
if edit_widget = pointer then it is file menu from cool edit
|
|
|
|
if edit_widget = NULL then routine is invoke from file menu of mc.
|
|
|
|
*/
|
|
|
|
void user_menu_cmd (WEdit *edit_widget)
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add macro %k it is block file name
Add macro %e it is error file name
Add macro %i it is cursor column indent of spaces, only for edit
Add macro %y, it is syntax of current file in editor, only for edit
Add condition y , it is syntax pattern of current file in edit
Add macro %x it is extension of current file
Add macro %m it is current menu filename
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editcmd.c: Modify External Formatter (was C indent formatter) .
Autocreate a scripts in home, from templates /usr/lib/mc/edit.indent.rc,
edit.ispell.rc, etc. Remove leading and trailing spaces into _(""),
(the message of David H. Martin <dmartina@usa.net>)
2000-05-05 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add condition (x filename) into mc.menu .
for "Open next a free console" and like.
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
src/user.c: fix segfault in chunk_alloc of glibc, when into condition
of .mnu we have quoted space. (~.mc/menu: + f \.\ test$).
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/edit.c:
Add ability user edit menus: system: /usr/lib/mc/cedit.menu,
* gtkedit/editmenu.c: home: ~/.cedit.menu, local: .cedit.menu
Marked block is access now from an user edit menu
Access ~/.cedit/cooledit.block for insert to cursor place from
user edit menu.
Created system cedit.menu
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editdraw.c:
Improved a status string of cool editor for best understand,
and to add char,hex view.
2000-05-04 Richard Hestilow <hestgray@ionet.net>
* gnome/gdesktop.c: Fixes snap to grid.
2000-05-09 05:18:27 +04:00
|
|
|
char *p;
|
1999-11-01 23:49:03 +03:00
|
|
|
char *data, **entries;
|
|
|
|
int max_cols, menu_lines, menu_limit;
|
1998-02-27 07:54:42 +03:00
|
|
|
int col, i, accept_entry = 1;
|
|
|
|
int selected, old_patterns;
|
|
|
|
Listbox *listbox;
|
|
|
|
|
|
|
|
if (!vfs_current_is_local ()){
|
1998-03-25 08:16:00 +03:00
|
|
|
message (1, _(" Oops... "),
|
|
|
|
_(" I can't run programs while logged on a non local directory "));
|
1998-02-27 07:54:42 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add macro %k it is block file name
Add macro %e it is error file name
Add macro %i it is cursor column indent of spaces, only for edit
Add macro %y, it is syntax of current file in editor, only for edit
Add condition y , it is syntax pattern of current file in edit
Add macro %x it is extension of current file
Add macro %m it is current menu filename
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editcmd.c: Modify External Formatter (was C indent formatter) .
Autocreate a scripts in home, from templates /usr/lib/mc/edit.indent.rc,
edit.ispell.rc, etc. Remove leading and trailing spaces into _(""),
(the message of David H. Martin <dmartina@usa.net>)
2000-05-05 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add condition (x filename) into mc.menu .
for "Open next a free console" and like.
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
src/user.c: fix segfault in chunk_alloc of glibc, when into condition
of .mnu we have quoted space. (~.mc/menu: + f \.\ test$).
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/edit.c:
Add ability user edit menus: system: /usr/lib/mc/cedit.menu,
* gtkedit/editmenu.c: home: ~/.cedit.menu, local: .cedit.menu
Marked block is access now from an user edit menu
Access ~/.cedit/cooledit.block for insert to cursor place from
user edit menu.
Created system cedit.menu
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editdraw.c:
Improved a status string of cool editor for best understand,
and to add char,hex view.
2000-05-04 Richard Hestilow <hestgray@ionet.net>
* gnome/gdesktop.c: Fixes snap to grid.
2000-05-09 05:18:27 +04:00
|
|
|
menu = g_strdup (edit_widget ? CEDIT_LOCAL_MENU : MC_LOCAL_MENU);
|
1998-02-27 07:54:42 +03:00
|
|
|
if (!exist_file (menu) || !menu_file_own (menu)){
|
Glibing..... (2)
Wed Jan 27 03:17:44 1999 Timur Bakeyev <mc@bat.ru>
* Converted memory managment to Glib. Now we use g_new()/g_malloc()/
g_strdup()/g_free() routings. Also, copy_strings() replaced by
g_strconcat(), strcasecmp() -> g_strcasecmp(),and sprintf() by
g_snprintf().
* Some sequences of malloc()/sprintf() changed to g_strdup_printf().
* mad.[ch]: Modified, to work with new GLib's memory managment. Fixed
a missing #undef for tempnam, which caused dead loop. Add several new
functions to emulate GLib memory managment.
*main.c, mad.[ch]: Add a new switch "-M", which allows to redirect MAD
messages to the file.
* util.[ch], utilunix.c: Modified, deleted our variants of strcasecmp()
and strdup() - we have g_ equivalences. Remove get_full_name() - it is
similar to concat_dir_and_file(). Some other tricks with g_* functions.
* global.h: Modified, extended. Now it is main memory mangment include -
i.e. all inclusions of <stdlib.h>, <malloc.h>, <glib.h>, "fs.h", "mem.h",
"util.h" and "mad.h" done there. This elimanates problem with proper or-
der of #include's.
* All around the source - changed order of #include's, most of them gone
to global.h (see above), minor changes, like "0" -> NULL in string func-
tions.
1999-01-27 04:08:30 +03:00
|
|
|
g_free (menu);
|
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add macro %k it is block file name
Add macro %e it is error file name
Add macro %i it is cursor column indent of spaces, only for edit
Add macro %y, it is syntax of current file in editor, only for edit
Add condition y , it is syntax pattern of current file in edit
Add macro %x it is extension of current file
Add macro %m it is current menu filename
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editcmd.c: Modify External Formatter (was C indent formatter) .
Autocreate a scripts in home, from templates /usr/lib/mc/edit.indent.rc,
edit.ispell.rc, etc. Remove leading and trailing spaces into _(""),
(the message of David H. Martin <dmartina@usa.net>)
2000-05-05 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add condition (x filename) into mc.menu .
for "Open next a free console" and like.
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
src/user.c: fix segfault in chunk_alloc of glibc, when into condition
of .mnu we have quoted space. (~.mc/menu: + f \.\ test$).
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/edit.c:
Add ability user edit menus: system: /usr/lib/mc/cedit.menu,
* gtkedit/editmenu.c: home: ~/.cedit.menu, local: .cedit.menu
Marked block is access now from an user edit menu
Access ~/.cedit/cooledit.block for insert to cursor place from
user edit menu.
Created system cedit.menu
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editdraw.c:
Improved a status string of cool editor for best understand,
and to add char,hex view.
2000-05-04 Richard Hestilow <hestgray@ionet.net>
* gnome/gdesktop.c: Fixes snap to grid.
2000-05-09 05:18:27 +04:00
|
|
|
menu = concat_dir_and_file \
|
|
|
|
(home_dir, edit_widget ? CEDIT_HOME_MENU : MC_HOME_MENU);
|
1998-02-27 07:54:42 +03:00
|
|
|
if (!exist_file (menu)){
|
Glibing..... (2)
Wed Jan 27 03:17:44 1999 Timur Bakeyev <mc@bat.ru>
* Converted memory managment to Glib. Now we use g_new()/g_malloc()/
g_strdup()/g_free() routings. Also, copy_strings() replaced by
g_strconcat(), strcasecmp() -> g_strcasecmp(),and sprintf() by
g_snprintf().
* Some sequences of malloc()/sprintf() changed to g_strdup_printf().
* mad.[ch]: Modified, to work with new GLib's memory managment. Fixed
a missing #undef for tempnam, which caused dead loop. Add several new
functions to emulate GLib memory managment.
*main.c, mad.[ch]: Add a new switch "-M", which allows to redirect MAD
messages to the file.
* util.[ch], utilunix.c: Modified, deleted our variants of strcasecmp()
and strdup() - we have g_ equivalences. Remove get_full_name() - it is
similar to concat_dir_and_file(). Some other tricks with g_* functions.
* global.h: Modified, extended. Now it is main memory mangment include -
i.e. all inclusions of <stdlib.h>, <malloc.h>, <glib.h>, "fs.h", "mem.h",
"util.h" and "mad.h" done there. This elimanates problem with proper or-
der of #include's.
* All around the source - changed order of #include's, most of them gone
to global.h (see above), minor changes, like "0" -> NULL in string func-
tions.
1999-01-27 04:08:30 +03:00
|
|
|
g_free (menu);
|
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add macro %k it is block file name
Add macro %e it is error file name
Add macro %i it is cursor column indent of spaces, only for edit
Add macro %y, it is syntax of current file in editor, only for edit
Add condition y , it is syntax pattern of current file in edit
Add macro %x it is extension of current file
Add macro %m it is current menu filename
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editcmd.c: Modify External Formatter (was C indent formatter) .
Autocreate a scripts in home, from templates /usr/lib/mc/edit.indent.rc,
edit.ispell.rc, etc. Remove leading and trailing spaces into _(""),
(the message of David H. Martin <dmartina@usa.net>)
2000-05-05 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add condition (x filename) into mc.menu .
for "Open next a free console" and like.
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
src/user.c: fix segfault in chunk_alloc of glibc, when into condition
of .mnu we have quoted space. (~.mc/menu: + f \.\ test$).
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/edit.c:
Add ability user edit menus: system: /usr/lib/mc/cedit.menu,
* gtkedit/editmenu.c: home: ~/.cedit.menu, local: .cedit.menu
Marked block is access now from an user edit menu
Access ~/.cedit/cooledit.block for insert to cursor place from
user edit menu.
Created system cedit.menu
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editdraw.c:
Improved a status string of cool editor for best understand,
and to add char,hex view.
2000-05-04 Richard Hestilow <hestgray@ionet.net>
* gnome/gdesktop.c: Fixes snap to grid.
2000-05-09 05:18:27 +04:00
|
|
|
menu = concat_dir_and_file \
|
|
|
|
(mc_home, edit_widget ? CEDIT_GLOBAL_MENU : MC_GLOBAL_MENU);
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((data = load_file (menu)) == NULL){
|
2001-08-14 04:55:34 +04:00
|
|
|
message (1, MSG_ERROR, _(" Cannot open file %s \n %s "),
|
1998-02-27 07:54:42 +03:00
|
|
|
menu, unix_error_string (errno));
|
Glibing..... (2)
Wed Jan 27 03:17:44 1999 Timur Bakeyev <mc@bat.ru>
* Converted memory managment to Glib. Now we use g_new()/g_malloc()/
g_strdup()/g_free() routings. Also, copy_strings() replaced by
g_strconcat(), strcasecmp() -> g_strcasecmp(),and sprintf() by
g_snprintf().
* Some sequences of malloc()/sprintf() changed to g_strdup_printf().
* mad.[ch]: Modified, to work with new GLib's memory managment. Fixed
a missing #undef for tempnam, which caused dead loop. Add several new
functions to emulate GLib memory managment.
*main.c, mad.[ch]: Add a new switch "-M", which allows to redirect MAD
messages to the file.
* util.[ch], utilunix.c: Modified, deleted our variants of strcasecmp()
and strdup() - we have g_ equivalences. Remove get_full_name() - it is
similar to concat_dir_and_file(). Some other tricks with g_* functions.
* global.h: Modified, extended. Now it is main memory mangment include -
i.e. all inclusions of <stdlib.h>, <malloc.h>, <glib.h>, "fs.h", "mem.h",
"util.h" and "mad.h" done there. This elimanates problem with proper or-
der of #include's.
* All around the source - changed order of #include's, most of them gone
to global.h (see above), minor changes, like "0" -> NULL in string func-
tions.
1999-01-27 04:08:30 +03:00
|
|
|
g_free (menu);
|
2000-05-25 20:21:42 +04:00
|
|
|
menu = NULL;
|
1998-02-27 07:54:42 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
max_cols = 0;
|
|
|
|
selected = 0;
|
1999-11-01 23:49:03 +03:00
|
|
|
menu_limit = 0;
|
|
|
|
entries = 0;
|
1998-02-27 07:54:42 +03:00
|
|
|
|
|
|
|
/* Parse the menu file */
|
|
|
|
old_patterns = easy_patterns;
|
|
|
|
p = check_patterns (data);
|
|
|
|
for (menu_lines = col = 0; *p; p++){
|
1999-11-01 23:49:03 +03:00
|
|
|
if (menu_lines >= menu_limit){
|
|
|
|
char ** new_entries;
|
|
|
|
|
|
|
|
menu_limit += MAX_ENTRIES;
|
|
|
|
new_entries = g_realloc (entries, sizeof (new_entries[0]) * menu_limit);
|
|
|
|
|
|
|
|
if (new_entries == 0)
|
|
|
|
break;
|
|
|
|
|
|
|
|
entries = new_entries;
|
|
|
|
new_entries += menu_limit;
|
|
|
|
while (--new_entries >= &entries[menu_lines])
|
|
|
|
*new_entries = 0;
|
|
|
|
}
|
1998-02-27 07:54:42 +03:00
|
|
|
if (col == 0 && !entries [menu_lines]){
|
|
|
|
if (*p == '#'){
|
|
|
|
/* A commented menu entry */
|
|
|
|
accept_entry = 1;
|
|
|
|
} else if (*p == '+'){
|
|
|
|
if (*(p+1) == '='){
|
|
|
|
/* Combined adding and default */
|
2001-07-24 02:50:54 +04:00
|
|
|
p = test_line (edit_widget, p, &accept_entry);
|
1998-02-27 07:54:42 +03:00
|
|
|
if (selected == 0 && accept_entry)
|
|
|
|
selected = menu_lines;
|
|
|
|
} else {
|
|
|
|
/* A condition for adding the entry */
|
2001-07-24 02:50:54 +04:00
|
|
|
p = test_line (edit_widget, p, &accept_entry);
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
} else if (*p == '='){
|
|
|
|
if (*(p+1) == '+'){
|
|
|
|
/* Combined adding and default */
|
2001-07-24 02:50:54 +04:00
|
|
|
p = test_line (edit_widget, p, &accept_entry);
|
1998-02-27 07:54:42 +03:00
|
|
|
if (selected == 0 && accept_entry)
|
|
|
|
selected = menu_lines;
|
|
|
|
} else {
|
|
|
|
/* A condition for making the entry default */
|
|
|
|
i = 1;
|
2001-07-24 02:50:54 +04:00
|
|
|
p = test_line (edit_widget, p, &i);
|
1998-02-27 07:54:42 +03:00
|
|
|
if (selected == 0 && i)
|
|
|
|
selected = menu_lines;
|
|
|
|
}
|
|
|
|
}
|
1999-06-19 02:25:24 +04:00
|
|
|
else if (*p != ' ' && *p != '\t' && is_printable (*p)) {
|
1998-02-27 07:54:42 +03:00
|
|
|
/* A menu entry title line */
|
|
|
|
if (accept_entry)
|
|
|
|
entries [menu_lines] = p;
|
|
|
|
else
|
|
|
|
accept_entry = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (*p == '\n'){
|
|
|
|
if (entries [menu_lines]){
|
|
|
|
menu_lines++;
|
|
|
|
accept_entry = 1;
|
|
|
|
}
|
|
|
|
max_cols = max (max_cols, col);
|
|
|
|
col = 0;
|
1999-11-01 23:49:03 +03:00
|
|
|
} else {
|
|
|
|
if (*p == '\t')
|
|
|
|
*p = ' ';
|
|
|
|
col++;
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
}
|
2000-05-25 20:21:42 +04:00
|
|
|
|
1999-06-19 02:25:24 +04:00
|
|
|
if (menu_lines == 0) {
|
2000-05-25 20:21:42 +04:00
|
|
|
message (1, MSG_ERROR, _(" No appropriative entries found in %s "), menu);
|
|
|
|
} else {
|
1998-02-27 07:54:42 +03:00
|
|
|
|
1999-06-19 02:25:24 +04:00
|
|
|
max_cols = min (max (max_cols, col), MAX_ENTRY_LEN);
|
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
/* Create listbox */
|
1998-05-08 06:25:00 +04:00
|
|
|
listbox = create_listbox_window (max_cols+2, menu_lines, _(" User menu "),
|
1998-02-27 07:54:42 +03:00
|
|
|
"[Menu File Edit]");
|
|
|
|
/* insert all the items found */
|
1999-11-01 23:49:03 +03:00
|
|
|
for (i = 0; i < menu_lines; i++) {
|
|
|
|
p = entries [i];
|
|
|
|
LISTBOX_APPEND_TEXT (listbox, (unsigned char) p[0],
|
|
|
|
extract_line (p, p + MAX_ENTRY_LEN), p
|
|
|
|
);
|
|
|
|
}
|
1998-02-27 07:54:42 +03:00
|
|
|
/* Select the default entry */
|
|
|
|
listbox_select_by_number (listbox->list, selected);
|
|
|
|
|
|
|
|
selected = run_listbox (listbox);
|
|
|
|
if (selected >= 0)
|
2001-07-24 02:50:54 +04:00
|
|
|
execute_menu_command (edit_widget, entries [selected]);
|
1998-02-27 07:54:42 +03:00
|
|
|
|
|
|
|
do_refresh ();
|
2000-05-25 20:21:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
easy_patterns = old_patterns;
|
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add macro %k it is block file name
Add macro %e it is error file name
Add macro %i it is cursor column indent of spaces, only for edit
Add macro %y, it is syntax of current file in editor, only for edit
Add condition y , it is syntax pattern of current file in edit
Add macro %x it is extension of current file
Add macro %m it is current menu filename
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editcmd.c: Modify External Formatter (was C indent formatter) .
Autocreate a scripts in home, from templates /usr/lib/mc/edit.indent.rc,
edit.ispell.rc, etc. Remove leading and trailing spaces into _(""),
(the message of David H. Martin <dmartina@usa.net>)
2000-05-05 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add condition (x filename) into mc.menu .
for "Open next a free console" and like.
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
src/user.c: fix segfault in chunk_alloc of glibc, when into condition
of .mnu we have quoted space. (~.mc/menu: + f \.\ test$).
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/edit.c:
Add ability user edit menus: system: /usr/lib/mc/cedit.menu,
* gtkedit/editmenu.c: home: ~/.cedit.menu, local: .cedit.menu
Marked block is access now from an user edit menu
Access ~/.cedit/cooledit.block for insert to cursor place from
user edit menu.
Created system cedit.menu
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editdraw.c:
Improved a status string of cool editor for best understand,
and to add char,hex view.
2000-05-04 Richard Hestilow <hestgray@ionet.net>
* gnome/gdesktop.c: Fixes snap to grid.
2000-05-09 05:18:27 +04:00
|
|
|
g_free (menu);
|
2000-05-25 20:21:42 +04:00
|
|
|
menu = NULL;
|
|
|
|
if (entries)
|
|
|
|
g_free (entries);
|
Glibing..... (2)
Wed Jan 27 03:17:44 1999 Timur Bakeyev <mc@bat.ru>
* Converted memory managment to Glib. Now we use g_new()/g_malloc()/
g_strdup()/g_free() routings. Also, copy_strings() replaced by
g_strconcat(), strcasecmp() -> g_strcasecmp(),and sprintf() by
g_snprintf().
* Some sequences of malloc()/sprintf() changed to g_strdup_printf().
* mad.[ch]: Modified, to work with new GLib's memory managment. Fixed
a missing #undef for tempnam, which caused dead loop. Add several new
functions to emulate GLib memory managment.
*main.c, mad.[ch]: Add a new switch "-M", which allows to redirect MAD
messages to the file.
* util.[ch], utilunix.c: Modified, deleted our variants of strcasecmp()
and strdup() - we have g_ equivalences. Remove get_full_name() - it is
similar to concat_dir_and_file(). Some other tricks with g_* functions.
* global.h: Modified, extended. Now it is main memory mangment include -
i.e. all inclusions of <stdlib.h>, <malloc.h>, <glib.h>, "fs.h", "mem.h",
"util.h" and "mad.h" done there. This elimanates problem with proper or-
der of #include's.
* All around the source - changed order of #include's, most of them gone
to global.h (see above), minor changes, like "0" -> NULL in string func-
tions.
1999-01-27 04:08:30 +03:00
|
|
|
g_free (data);
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
2001-11-15 02:20:37 +03:00
|
|
|
|