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.
This commit is contained in:
Miguel de Icaza 2000-05-09 01:18:27 +00:00
parent c4e33ce31a
commit b028900fdd
28 changed files with 705 additions and 324 deletions

View File

@ -170,7 +170,7 @@ dnl
dnl Check availability of some functions
dnl
AC_CHECK_FUNCS(strerror statfs getwd strcasecmp strncasecmp strcoll)
AC_CHECK_FUNCS(strerror statfs getwd strcasecmp strncasecmp strcoll strftime)
AC_CHECK_FUNCS(strdup memmove pwdauth truncate initgroups putenv)
AC_CHECK_FUNCS(memset memcpy tcsetattr tcgetattr cfgetospeed)
AC_CHECK_FUNCS(sigaction sigemptyset sigprocmask sigaddset)

View File

@ -1389,12 +1389,15 @@ Condition syntax: = <sub-cond>
Sub-condition is one of following:
y <pattern> syntax of current file matching pattern?
for edit menu only.
f <pattern> current file matching pattern?
F <pattern> other file matching pattern?
d <pattern> current directory matching pattern?
D <pattern> other directory matching pattern?
t <type> current file of type?
T <type> other file of type?
x <filename> is it executable filename?
! <sub-cond> negate the result of sub-condition
.fi
.PP
@ -1939,10 +1942,39 @@ a simple macro substitution takes place.
.PP
The macros are:
.PP
.I "%i"
.IP
The indent of blank space, equal the cursor column
position. For edit menu only.
.PP
.I "%y"
.IP
The syntax type of current file. For edit menu only.
.PP
.I "%k"
.IP
The block file name.
.PP
.I "%e"
.IP
The error file name.
.PP
.I "%m"
.IP
The current menu name.
.PP
.I "%f"
.IP
The current file name.
.PP
.I "%x"
.IP
The extension of current file name.
.PP
.I "%b"
.IP
The current file name without extension.
.PP
.I "%d"
.IP
The current directory name.

View File

@ -1110,12 +1110,15 @@ Condition syntax:
Sub-condition is one of following:
<tscreen><verb>
y <pattern> syntax of current file matching pattern?
for edit menu only.
f <pattern> current file matching pattern
F <pattern> other file matching pattern
d <pattern> current directory matching pattern
D <pattern> other directory matching pattern
t <type> current file of type
T <type> other file of type
x <filename> is it executable filename
! <sub-cond> negate the result of sub-condition
</verb></tscreen>
@ -1572,8 +1575,23 @@ line input, a simple macro substitution takes place.
The macros are:
<em/"&percnt;i"/ The indent of blank space, equal the cursor column
position. For edit menu only.
<em/"&percnt;y"/ The syntax type of current file. For edit menu only.
<em/"&percnt;k"/ The block file name.
<em/"&percnt;e"/ The error file name.
<em/"&percnt;m"/ The current menu name.
<em/"&percnt;f"/ The current file name.
<em/"&percnt;n"/ Only the current file name without extension.
<em/"&percnt;x"/ The extension of current file name.
<em/"&percnt;d"/ The current directory name.
<em/"&percnt;F"/ The current file in the unselected panel.
@ -1604,6 +1622,7 @@ file.
current directory to the directory specified in front of
it. This is used primarily as an interface to the <lnk name="Virtual
File System" id="Virtual File System">.
Possible to use only in mc.ext .
<tag/"&percnt;view"/ This macro is used to invoke the internal viewer.
This macro can be used alone, or with arguments. If you
@ -1614,6 +1633,7 @@ into ascii mode; <em/hex/ to force the viewer into hex mode;
and underline sequences of nroff; <em/unformatted/ to tell the
viewer to not interpret nroff commands for making the text
bold or underlined.
Possible to use only in mc.ext .
<tag/"&percnt;&percnt;"/ The &percnt; character

View File

@ -51,6 +51,7 @@
KEY_F (6), CK_Move, KEY_F (8), CK_Remove, KEY_F (12), CK_Save_As,
KEY_F (2), CK_Save, XCTRL ('n'), CK_New,
XCTRL ('l'), CK_Refresh, ESC_CHAR, CK_Exit, KEY_F (10), CK_Exit,
KEY_F (11), /* edit user menu */ CK_User_Menu,
KEY_F (19), /*C formatter */ CK_Pipe_Block (0),
XCTRL ('p'), /*spell check */ CK_Pipe_Block (1),
KEY_F (15), CK_Insert_File,
@ -89,6 +90,7 @@
ALT ('w'), CK_XStore,
XCTRL ('l'), CK_Refresh, ESC_CHAR, CK_Exit, KEY_F (10), CK_Exit,
KEY_F (11), /* edit user menu */ CK_User_Menu,
KEY_F (19), /*C formatter */ CK_Pipe_Block (0),
ALT ('$'), /*spell check */ CK_Pipe_Block (1),
KEY_F (15), CK_Insert_File,

View File

@ -1,3 +1,9 @@
2000-05-08 Miguel de Icaza <miguel@helixcode.com>
* gnome-file-property-dialog.c (create_general_properties): Tag
the strftime format for translation to let the localization
efforts to localize the time display.
2000-05-06 Jacob Berkman <jacob@helixcode.com>
* gsession.c (session_set_restart): restart with priority 40 so we show

View File

@ -42,6 +42,7 @@ struct layout_slot {
/* Configuration options for the desktop */
int desktop_use_shaped_icons = TRUE;
int desktop_auto_placement = FALSE;
int desktop_snap_icons = FALSE;
@ -68,6 +69,8 @@ char *desktop_directory;
* array of slots. Each slot is an integer that specifies the number of icons
* that belong to that slot.
*/
static int layout_spacer_width;
static int layout_spacer_height;
static int layout_screen_width;
static int layout_screen_height;
static int layout_cols;
@ -148,6 +151,22 @@ static DesktopIconInfo *desktop_icon_info_new (char *filename, char *url, char *
static GHashTable *icon_hash;
/* Convenience function to figure out the (x, y) position from a slot */
static void
get_pos_from_slot (int u, int v, int *x, int *y)
{
int xx, yy;
xx = (layout_spacer_width / 2) +
(u * (DESKTOP_SNAP_X + layout_spacer_width));
yy = (layout_spacer_height / 2) +
(v * (DESKTOP_SNAP_Y + layout_spacer_height));
*x = CLAMP (xx, 0, layout_screen_width);
*y = CLAMP (yy, 0, layout_screen_height);
}
/* Convenience function to figure out the slot corresponding to an (x, y) position */
static void
@ -155,8 +174,8 @@ get_slot_from_pos (int x, int y, int *u, int *v)
{
int uu, vv;
uu = (x + DESKTOP_SNAP_X / 2) / DESKTOP_SNAP_X;
vv = (y + DESKTOP_SNAP_Y / 2) / DESKTOP_SNAP_Y;
uu = x / (DESKTOP_SNAP_X + layout_spacer_width);
vv = y / (DESKTOP_SNAP_Y + layout_spacer_height);
*u = CLAMP (uu, 0, layout_cols - 1);
*v = CLAMP (vv, 0, layout_rows - 1);
@ -252,6 +271,8 @@ get_icon_auto_pos (int *x, int *y)
int slot1;
int slot;
int sx, sy, ex, ey;
int u, v;
int xx, yy;
#if 0
get_slot_from_pos (*x, *y, &sx, &sy);
@ -305,9 +326,14 @@ get_icon_auto_pos (int *x, int *y)
slot = slot2;
}
#endif
u = slot / layout_rows;
v = slot % layout_rows;
get_pos_from_slot(u, v, &xx, &yy);
*x = xx;
*y = yy;
*x = (slot / layout_rows) * DESKTOP_SNAP_X;
*y = (slot % layout_rows) * DESKTOP_SNAP_Y;
}
/* Snaps the specified position to the icon grid. It looks for the closest free spot on the grid,
@ -321,6 +347,7 @@ get_icon_snap_pos (int *x, int *y)
int u, v;
int val, dist;
int dx, dy;
int ux, vy;
min = l_slots (0, 0).num_icons;
min_x = min_y = 0;
@ -329,21 +356,22 @@ get_icon_snap_pos (int *x, int *y)
for (u = 0; u < layout_cols; u++)
for (v = 0; v < layout_rows; v++) {
val = l_slots (u, v).num_icons;
dx = *x - u * DESKTOP_SNAP_X;
dy = *y - v * DESKTOP_SNAP_Y;
get_pos_from_slot(u, v, &ux, &vy);
dx = *x - ux;
dy = *y - vy;
dist = dx * dx + dy * dy;
if ((val == min && dist < min_dist) || (val < min)) {
min = val;
min_dist = dist;
min_x = u;
min_y = v;
min_x = ux;
min_y = vy;
}
}
*x = min_x * DESKTOP_SNAP_X;
*y = min_y * DESKTOP_SNAP_Y;
*x = min_x;
*y = min_y;
}
/* Removes an icon from the slot it is in, if any */
@ -373,15 +401,16 @@ desktop_icon_info_place (DesktopIconInfo *dii, int xpos, int ypos)
remove_from_slot (dii);
if (xpos < 0)
xpos = 0;
else if (xpos > layout_screen_width)
xpos = layout_screen_width - DESKTOP_SNAP_X;
if (xpos < (layout_spacer_width / 2))
xpos = layout_spacer_width / 2;
else if (xpos > layout_screen_width - (DESKTOP_SNAP_X + (layout_spacer_width / 2)))
xpos = layout_screen_width - (DESKTOP_SNAP_X + (layout_spacer_width / 2));
if (ypos < (layout_spacer_height / 2))
ypos = layout_spacer_height / 2;
else if (ypos > layout_screen_height - (DESKTOP_SNAP_Y + (layout_spacer_height / 2)))
ypos = layout_screen_height - (DESKTOP_SNAP_Y + (layout_spacer_height / 2));
if (ypos < 0)
ypos = 0;
else if (ypos > layout_screen_height)
ypos = layout_screen_height - DESKTOP_SNAP_Y;
/* Increase the number of icons in the corresponding slot */
@ -507,6 +536,64 @@ typedef struct {
char *caption;
} file_and_url_t;
/* get_drop_grid generates a compact organization for icons that are dragged out
* of applications on to the desktop.
*/
GSList *
get_drop_grid (gint xpos, gint ypos, gint need_position_list_length, GSList *grid_list)
{
gint i = 1;
gint my_bool = 0;
gint j;
gint k;
gint new_xpos;
gint new_ypos;
/* Determine size of a square grid in which to put the dropped icons */
while (!my_bool) {
if (need_position_list_length <= i * i)
my_bool = 1;
else
i++;
}
/* Make sure no icons are off the side of the screen */
if ((xpos + (i * DESKTOP_SNAP_X) + ((i - 1) * layout_spacer_width) +
(layout_spacer_width / 2)) > layout_screen_width) {
xpos = layout_screen_width - (layout_spacer_width / 2) -
(i * DESKTOP_SNAP_X) - ((i - 1) * layout_spacer_width);
}
if ((ypos + (i * DESKTOP_SNAP_Y) + ((i - 1) * layout_spacer_height) +
(layout_spacer_height / 2)) > layout_screen_height) {
ypos = layout_screen_height - (layout_spacer_height / 2) -
(i * DESKTOP_SNAP_Y) - ((i - 1) * layout_spacer_height);
}
if (xpos < layout_spacer_width / 2) {
xpos = layout_spacer_width / 2;
}
if (ypos < layout_spacer_height / 2) {
ypos = layout_spacer_height / 2;
}
/* Now write the (x, y) coordinates of the dropped icons */
for (j = 0; j < i; j++) {
for (k = 0; k < i; k++) {
new_xpos = xpos + k * (DESKTOP_SNAP_X + layout_spacer_width);
new_ypos = ypos + j * (DESKTOP_SNAP_Y + layout_spacer_height);
if (desktop_snap_icons) {
get_icon_snap_pos (&new_xpos, &new_ypos);
}
grid_list = g_slist_append (grid_list, (void *) new_xpos); grid_list = g_slist_append (grid_list, (void *) new_ypos);
}
}
return grid_list;
}
/* Reloads the desktop icons efficiently. If there are "new" files for which no
* icons have been created, then icons for them will be created started at the
* specified position if user_pos is TRUE. If it is FALSE, the icons will be
@ -518,13 +605,16 @@ desktop_reload_icons (int user_pos, int xpos, int ypos)
struct dirent *dirent;
DIR *dir;
char *full_name;
int have_pos, x, y, size;
/* int have_pos, x, y, size; */
int x, y, size;
DesktopIconInfo *dii;
GSList *need_position_list, *sl;
GSList *need_position_list, *sl, *drop_grid_list, *drop_gl_copy;
GList *all_icons, *l;
char *desktop_url, *caption;
const char *mime;
int orig_xpos, orig_ypos;
guint need_position_list_length;
file_and_url_t *fau;
dir = mc_opendir (desktop_directory);
if (!dir) {
@ -538,9 +628,9 @@ desktop_reload_icons (int user_pos, int xpos, int ypos)
gnome_metadata_lock ();
/* Read the directory. For each file for which we do have an existing
* icon, do nothing. Otherwise, if the file has its metadata for icon
* position set, create an icon for it. Otherwise, store it in a list
* of new icons for which positioning is pending.
* icon, do nothing. Otherwise, store it in a list
* of new icons for which positioning is pending. If we have metadata for
* the file but no icon, delete the metadata and treat the file as new.
*/
need_position_list = NULL;
@ -583,7 +673,6 @@ desktop_reload_icons (int user_pos, int xpos, int ypos)
}
full_name = g_concat_dir_and_file (desktop_directory, dirent->d_name);
have_pos = gmeta_get_icon_pos (full_name, &x, &y);
if (gnome_metadata_get (full_name, "desktop-url", &size, &desktop_url) != 0)
desktop_url = NULL;
@ -591,23 +680,16 @@ desktop_reload_icons (int user_pos, int xpos, int ypos)
caption = NULL;
gnome_metadata_get (full_name, "icon-caption", &size, &caption);
if (have_pos) {
dii = desktop_icon_info_new (dirent->d_name, desktop_url, caption, x, y);
gtk_widget_show (dii->dicon);
} else {
file_and_url_t *fau;
fau = g_new0 (file_and_url_t, 1);
fau->filename = g_strdup (dirent->d_name);
fau = g_new0 (file_and_url_t, 1);
fau->filename = g_strdup (dirent->d_name);
if (desktop_url)
fau->url = g_strdup (desktop_url);
if (desktop_url)
fau->url = g_strdup (desktop_url);
if (caption)
fau->caption = g_strdup (caption);
if (caption)
fau->caption = g_strdup (caption);
need_position_list = g_slist_prepend (need_position_list, fau);
}
need_position_list = g_slist_prepend (need_position_list, fau);
g_free (full_name);
@ -643,6 +725,15 @@ desktop_reload_icons (int user_pos, int xpos, int ypos)
need_position_list = g_slist_reverse (need_position_list);
need_position_list_length = g_slist_length (need_position_list);
/* Get a position list for the dragged icons, to nicely place multiple icon drops */
if (user_pos && (need_position_list_length != 0)) {
drop_grid_list = NULL;
drop_grid_list = get_drop_grid (xpos, ypos, need_position_list_length, drop_grid_list);
drop_gl_copy = drop_grid_list;
}
orig_xpos = orig_ypos = 0;
for (sl = need_position_list; sl; sl = sl->next) {
@ -650,19 +741,16 @@ desktop_reload_icons (int user_pos, int xpos, int ypos)
fau = sl->data;
if (user_pos && sl == need_position_list) {
/* If we are on the first icon, place it "by hand".
* Else, use automatic placement based on the position
* of the first icon of the series.
*/
if (user_pos) {
if (desktop_auto_placement) {
xpos = ypos = 0;
get_icon_auto_pos (&xpos, &ypos);
} else if (desktop_snap_icons)
get_icon_snap_pos (&xpos, &ypos);
orig_xpos = xpos;
orig_ypos = ypos;
} else { /* Place the icons according to the position list obtained above */
xpos = (int) drop_gl_copy->data;
drop_gl_copy = drop_gl_copy->next;
ypos = (int) drop_gl_copy->data;
drop_gl_copy = drop_gl_copy->next;
}
} else {
xpos = orig_xpos;
ypos = orig_ypos;
@ -721,7 +809,12 @@ desktop_reload_icons (int user_pos, int xpos, int ypos)
g_free (fau);
}
if ((need_position_list_length != 0) && user_pos) {
g_slist_free (drop_grid_list);
}
g_slist_free (need_position_list);
gnome_metadata_unlock ();
}
@ -2002,26 +2095,31 @@ static void
drop_desktop_icons (GdkDragContext *context, GtkSelectionData *data, int x, int y)
{
DesktopIconInfo *source_dii, *dii;
int dx, dy;
int dx, dy, sl_x, sl_y, sl_max_x, sl_max_y, sl_min_x, sl_min_y;
int i;
GList *l;
GSList *sel_icons, *sl;
GSList *sel_icons, *sl, *sl2, *sl2_p;
/* Find the icon that the user is dragging */
source_dii = find_icon_by_drag_context (context);
if (!source_dii) {
g_warning ("Eeeeek, could not find the icon that started the drag!");
return;
}
x -= dnd_press_x;
y -= dnd_press_y;
/* Compute the distance to move icons */
if (desktop_snap_icons)
get_icon_snap_pos (&x, &y);
dx = x - source_dii->x - dnd_press_x;
dy = y - source_dii->y - dnd_press_y;
dx = x - source_dii->x;
dy = y - source_dii->y;
/* Build a list of selected icons */
@ -2038,12 +2136,66 @@ drop_desktop_icons (GdkDragContext *context, GtkSelectionData *data, int x, int
* icons in the proper place.
*/
if (!desktop_auto_placement)
if (!desktop_auto_placement) {
sl2 = NULL;
sl2_p = NULL;
for (sl = sel_icons; sl; sl = sl->next) {
dii = sl->data;
sl2 = g_slist_prepend (sl2, (void *) (dii->x + dx));
sl2 = g_slist_prepend (sl2, (void *) (dii->y + dy));
}
sl_max_x = 0;
sl_max_y = 0;
sl_min_x = INT_MAX;
sl_min_y = INT_MAX;
sl2_p = sl2;
/* For multiple icon drags, get the min/max x and y coordinates */
for (sl = sel_icons; sl; sl = sl->next) {
sl_y = (int) sl2_p->data;
sl2_p = sl2_p->next;
sl_x = (int) sl2_p->data;
sl2_p = sl2_p->next;
if (sl_x > sl_max_x) {
sl_max_x = sl_x;
}
if (sl_x < sl_min_x) {
sl_min_x = sl_x;
}
if (sl_y > sl_max_y) {
sl_max_y = sl_y;
}
if (sl_x < sl_min_y) {
sl_min_y = sl_y;
}
}
g_slist_free (sl2);
/* Make sure that no icons are placed off the screen, and keep their relative positions */
if (sl_max_x > layout_screen_width - (DESKTOP_SNAP_X + layout_spacer_width / 2)) {
dx -= (sl_max_x - (layout_screen_width -
(DESKTOP_SNAP_X + layout_spacer_width / 2)));
}
if (sl_max_y > layout_screen_height - (DESKTOP_SNAP_Y + layout_spacer_height / 2)) {
dy -= (sl_max_y - (layout_screen_height -
(DESKTOP_SNAP_Y + layout_spacer_width / 2)));
}
if (sl_min_x < layout_spacer_width / 2) {
dx += (layout_spacer_width / 2 - sl_min_x);
}
if (sl_min_y < layout_spacer_height / 2) {
dy += (layout_spacer_height / 2 - sl_min_y);
}
/* Place the icons */
for (sl = sel_icons; sl; sl = sl->next) {
dii = sl->data;
desktop_icon_info_place (dii, dii->x + dx, dii->y + dy);
}
}
/* Clean up */
g_slist_free (sel_icons);
@ -2202,8 +2354,14 @@ create_layout_info (void)
{
layout_screen_width = gdk_screen_width ();
layout_screen_height = gdk_screen_height ();
layout_cols = (layout_screen_width + DESKTOP_SNAP_X - 1) / DESKTOP_SNAP_X;
layout_rows = (layout_screen_height + DESKTOP_SNAP_Y - 1) / DESKTOP_SNAP_Y;
layout_cols = layout_screen_width / DESKTOP_SNAP_X;
layout_rows = layout_screen_height / DESKTOP_SNAP_Y;
/* Adjust icon size to spread the icons evenly across the screen */
layout_spacer_width = (layout_screen_width / layout_cols) - DESKTOP_SNAP_X;
layout_spacer_height = (layout_screen_height / layout_rows) - DESKTOP_SNAP_Y;
layout_slots = g_new0 (struct layout_slot, layout_cols * layout_rows);
}
@ -2745,7 +2903,7 @@ desktop_popup (GdkEventButton *event)
static void
draw_rubberband (int x, int y)
{
int x1, y1, x2, y2;
int x1, y1, x2, y2;
if (click_start_x < x) {
x1 = click_start_x;

View File

@ -278,7 +278,7 @@ create_general_properties (GnomeFilePropertyDialog *fp_dlg)
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 0, 1);
time = localtime (&(fp_dlg->st.st_ctime));
strftime (buf, MC_MAXPATHLEN, "%a, %b %d %Y, %I:%M:%S %p", time);
strftime (buf, MC_MAXPATHLEN, _("%a, %b %d %Y, %I:%M:%S %p"), time);
label = gtk_label_new (buf);
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_table_attach_defaults (GTK_TABLE (table), label, 1, 2, 0, 1);
@ -287,7 +287,7 @@ create_general_properties (GnomeFilePropertyDialog *fp_dlg)
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 1, 2);
time = localtime (&(fp_dlg->st.st_mtime));
strftime (buf, MC_MAXPATHLEN, "%a, %b %d %Y, %I:%M:%S %p", time);
strftime (buf, MC_MAXPATHLEN, _("%a, %b %d %Y, %I:%M:%S %p"), time);
label = gtk_label_new (buf);
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_table_attach_defaults (GTK_TABLE (table), label, 1, 2, 1, 2);
@ -296,7 +296,7 @@ create_general_properties (GnomeFilePropertyDialog *fp_dlg)
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 2, 3);
time = localtime (&(fp_dlg->st.st_atime));
strftime (buf, MC_MAXPATHLEN, "%a, %b %d %Y, %I:%M:%S %p", time);
strftime (buf, MC_MAXPATHLEN, _("%a, %b %d %Y, %I:%M:%S %p"), time);
label = gtk_label_new (buf);
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_table_attach_defaults (GTK_TABLE (table), label, 1, 2, 2, 3);

View File

@ -38,6 +38,10 @@
#include "mad.h"
#endif
#include <../src/dialog.h> /* MSG_ERROR */
extern char *edit_one_file;
/*
*
* here's a quick sketch of the layout: (don't run this through indent.)
@ -2562,6 +2566,14 @@ int edit_execute_cmd (WEdit * edit, int command, int char_for_insertion)
case CK_Match_Bracket:
edit_goto_matching_bracket (edit);
break;
case CK_User_Menu:
if (edit_one_file) {
message (1, MSG_ERROR, _("User menu avalaible only in mcedit invoked from mc"));
break;
}
else
user_menu (edit);
break;
#ifdef MIDNIGHT
case CK_Sort:
edit_sort_cmd (edit);
@ -2714,3 +2726,61 @@ void edit_execute_macro (WEdit * edit, struct macro macro[], int n)
edit_update_screen (edit);
}
/* User edit menu, like user menu (F2) but only in editor. */
void user_menu (WEdit *edit)
{
FILE *fd;
int nomark;
struct stat status;
long start_mark, end_mark;
char *block_file = catstrs (home_dir, BLOCK_FILE, 0);
char *error_file = catstrs (home_dir, ERROR_FILE, 0);
int rc = 0;
nomark = eval_marks (edit, &start_mark, &end_mark);
if (! nomark) /* remember marked or not */
edit_save_block (edit, block_file = catstrs (home_dir, BLOCK_FILE, 0),
start_mark, end_mark);
/* run shell scripts from menu */
user_menu_cmd (edit);
if (stat (error_file, &status) == 0) {
if (!status.st_size) { /* no error messages */
if (stat (block_file, &status) == 0)
if (!status.st_size)
return; /* no block messages */
if (! nomark) /* i.e. we have marked block */
rc = edit_block_delete_cmd(edit);
if (!rc) {
edit_cursor_to_bol (edit);
edit_insert_file (edit, block_file);
edit_cursor_to_eol (edit);
if (fd = fopen (block_file, "w")) fclose(fd);
}
} else { /* it is error */
edit_cursor_to_bol (edit);
edit_insert_file (edit, error_file);
if (fd = fopen (error_file, "w")) fclose(fd);
if (fd = fopen (block_file, "w")) fclose(fd);
}
} else {
edit_error_dialog (_(""),
get_sys_error (catstrs (_ ("Error trying to stat file:"),
error_file, 0)));
return;
}
edit_refresh_cmd (edit);
edit->force |= REDRAW_COMPLETELY;
return;
}
void edit_init_file()
{
FILE *f;
if (f = fopen (catstrs (home_dir, ERROR_FILE, 0), "w")) fclose(f);
if (f = fopen (catstrs (home_dir, BLOCK_FILE, 0), "w")) fclose(f);
if (f = fopen (catstrs (home_dir, TEMP_FILE, 0) , "w")) fclose(f);
return;
}

View File

@ -174,15 +174,6 @@
#define SEARCH_DIALOG_OPTION_BACKWARDS 8
#define SEARCH_DIALOG_OPTION_BOOKMARK 16
#define SYNTAX_FILE "/.cedit/Syntax"
#define CLIP_FILE "/.cedit/cooledit.clip"
#define MACRO_FILE "/.cedit/cooledit.macros"
#define BLOCK_FILE "/.cedit/cooledit.block"
#define ERROR_FILE "/.cedit/cooledit.error"
#define TEMP_FILE "/.cedit/cooledit.temp"
#define SCRIPT_FILE "/.cedit/cooledit.script"
#define EDIT_DIR "/.cedit"
#define EDIT_KEY_EMULATION_NORMAL 0
#define EDIT_KEY_EMULATION_EMACS 1
@ -225,10 +216,7 @@
#define EDIT_TOP_EXTREME option_edit_top_extreme
#define EDIT_BOTTOM_EXTREME option_edit_bottom_extreme
#define MAX_MACRO_LENGTH 1024
/*there are a maximum of ... */
#define MAXBUFF 1024
/*... edit buffers, each of which is ... */
#define EDIT_BUF_SIZE 0x10000
/* ...bytes in size. */
@ -265,26 +253,11 @@
#define TAB_SIZE option_tab_spacing
#define HALF_TAB_SIZE ((int) option_tab_spacing / 2)
struct macro {
short command;
short ch;
};
struct selection {
unsigned char * text;
int len;
};
struct syntax_rule {
unsigned short keyword;
unsigned char end;
unsigned char context;
unsigned char _context;
#define RULE_ON_LEFT_BORDER 1
#define RULE_ON_RIGHT_BORDER 2
unsigned char border;
};
#define MAX_WORDS_PER_CONTEXT 1024
#define MAX_CONTEXTS 128
@ -318,118 +291,7 @@ struct context_rule {
struct key_word **keyword;
};
struct _syntax_marker {
long offset;
struct syntax_rule rule;
struct _syntax_marker *next;
};
struct _book_mark {
int line; /* line number */
// #define BOOK_MARK_COLOR ((0 << 8) | 26) /* black on white */
#define BOOK_MARK_COLOR ((25 << 8) | 5)
#define BOOK_MARK_FOUND_COLOR ((26 << 8) | 4)
int c; /* colour */
struct _book_mark *next;
struct _book_mark *prev;
};
struct editor_widget {
#ifdef MIDNIGHT
Widget widget;
#elif defined(GTK)
GtkEdit *widget;
#else
struct cool_widget *widget;
#endif
#define from_here num_widget_lines
int num_widget_lines;
int num_widget_columns;
#ifdef MIDNIGHT
int have_frame;
#else
int stopped;
#endif
char *filename; /* Name of the file */
char *dir; /* current directory */
/* dynamic buffers and cursor position for editor: */
long curs1; /*position of the cursor from the beginning of the file. */
long curs2; /*position from the end of the file */
unsigned char *buffers1[MAXBUFF + 1]; /*all data up to curs1 */
unsigned char *buffers2[MAXBUFF + 1]; /*all data from end of file down to curs2 */
/* search variables */
long search_start; /* First character to start searching from */
int found_len; /* Length of found string or 0 if none was found */
long found_start; /* the found word from a search - start position */
/* display information */
long last_byte; /* Last byte of file */
long start_display; /* First char displayed */
long start_col; /* First displayed column, negative */
long max_column; /* The maximum cursor position ever reached used to calc hori scroll bar */
long curs_row; /*row position of cursor on the screen */
long curs_col; /*column position on screen */
int force; /* how much of the screen do we redraw? */
unsigned char overwrite;
unsigned char modified; /*has the file been changed?: 1 if char inserted or
deleted at all since last load or save */
unsigned char screen_modified; /* has the file been changed since the last screen draw? */
#if defined(MIDNIGHT) || defined(GTK)
int delete_file; /* has the file been created in edit_load_file? Delete
it at end of editing when it hasn't been modified
or saved */
#endif
unsigned char highlight;
long prev_col; /*recent column position of the cursor - used when moving
up or down past lines that are shorter than the current line */
long curs_line; /*line number of the cursor. */
long start_line; /*line nummber of the top of the page */
/* file info */
long total_lines; /*total lines in the file */
long mark1; /*position of highlight start */
long mark2; /*position of highlight end */
int column1; /*position of column highlight start */
int column2; /*position of column highlight end */
long bracket; /*position of a matching bracket */
/* cache speedup for line lookups */
#define N_LINE_CACHES 32
int caches_valid;
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;
unsigned long stack_size;
unsigned long stack_size_mask;
unsigned long stack_bottom;
struct stat stat;
/* syntax higlighting */
struct _syntax_marker *syntax_marker;
struct context_rule **rules;
long last_get_rule;
struct syntax_rule rule;
char *syntax_type; /* description of syntax highlighting type being used */
int explicit_syntax; /* have we forced the syntax hi. type in spite of the filename? */
int to_here; /* dummy marker */
/* macro stuff */
int macro_i; /* -1 if not recording index to macro[] otherwise */
struct macro macro[MAX_MACRO_LENGTH];
};
typedef struct editor_widget WEdit;
#include "edit-widget.h"
#ifndef MIDNIGHT
@ -590,6 +452,8 @@ void book_mark_flush (WEdit * edit, int c);
void book_mark_inc (WEdit * edit, int line);
void book_mark_dec (WEdit * edit, int line);
void user_menu (WEdit *edit);
#ifdef MIDNIGHT

View File

@ -1122,6 +1122,7 @@ void edit_delete_column_of_text (WEdit * edit)
}
}
/* if success return 0 */
int edit_block_delete (WEdit * edit)
{
long count;
@ -2864,47 +2865,90 @@ void edit_block_process_cmd (WEdit * edit, const char *shell_cmd, int block)
{
long start_mark, end_mark;
struct stat s;
char *f = NULL, *b = NULL;
char buf[BUFSIZ];
FILE *script_home = NULL;
FILE *script_src = NULL;
FILE *block_file = NULL;
if (block) {
char *o = catstrs (mc_home, shell_cmd, 0); /* original source script */
char *h = catstrs (home_dir, EDIT_DIR, shell_cmd, 0); /* home script */
char *b = catstrs (home_dir, BLOCK_FILE, 0); /* block file */
char *e = catstrs (home_dir, ERROR_FILE, 0); /* error file */
if (! (script_home = fopen (h, "r"))) {
if (! (script_home = fopen (h, "w"))) {
edit_error_dialog (_(""),
get_sys_error (catstrs (_ ("Error create script:"), h, 0)));
return;
} else {
if (! (script_src = fopen (o, "r"))) {
fclose (script_home); unlink (h);
edit_error_dialog (_(""),
get_sys_error (catstrs (_ ("Error read script:"), o, 0)));
return;
} else {
while (fgets(buf, sizeof(buf), script_src))
fprintf(script_home, "%s",buf);
if (fclose(script_home)) {
edit_error_dialog (_(""),
get_sys_error (catstrs (_ ("Error close script:"), h, 0)));
return;
} else {
chmod (h, 0700);
edit_error_dialog (_(""),
get_sys_error (catstrs (_ ("Script created:"), h, 0)));
}
}
}
}
if (block) { /* for marked block run indent formatter */
if (eval_marks (edit, &start_mark, &end_mark)) {
edit_error_dialog (_(" Process block "),
edit_error_dialog (_("Process block"),
/* Not essential to translate */
_(" You must first highlight a block of text. "));
return;
}
edit_save_block (edit, b = catstrs (home_dir, BLOCK_FILE, 0), start_mark, end_mark);
my_system (0, shell, catstrs (home_dir, shell_cmd, 0));
edit_refresh_cmd (edit);
} else {
my_system (0, shell, shell_cmd);
edit_refresh_cmd (edit);
edit_save_block (edit, b, start_mark, end_mark);
/* run your script */
my_system (EXECUTE_AS_SHELL, shell,
catstrs (home_dir, EDIT_DIR, shell_cmd, " ",
edit->filename, " ", home_dir, BLOCK_FILE, " ",
home_dir, ERROR_FILE, 0));
edit_refresh_cmd (edit);
} else { /* for missing marked block run ... */
my_system (0, shell, catstrs (EDIT_DIR, shell_cmd));
edit_refresh_cmd (edit);
}
edit->force |= REDRAW_COMPLETELY;
f = catstrs (home_dir, ERROR_FILE, 0);
/* insert result block */
if (block) {
if (stat (f, &s) == 0) {
if (stat (e, &s) == 0) {
if (!s.st_size) { /* no error messages */
if (edit_block_delete_cmd (edit))
return;
edit_insert_file (edit, b);
if (block_file = fopen (b, "w")) fclose(block_file);
return;
} else {
edit_insert_file (edit, f);
edit_insert_file (edit, e);
if (block_file = fopen (b, "w")) fclose(block_file);
return;
}
} else {
/* Not essential to translate */
edit_error_dialog (_(" Process block "),
edit_error_dialog (_(""),
/* Not essential to translate */
get_sys_error (_(" Error trying to stat file ")));
get_sys_error (catstrs (_ ("Error trying to stat file:"), e, 0)));
edit->force |= REDRAW_COMPLETELY;
if (block_file = fopen (b, "w")) fclose(block_file);
return;
}
}
return;
}
#endif

View File

@ -92,6 +92,7 @@
#define CK_Terminal 422
#define CK_Terminal_App 423
#define CK_User_Menu 425
/* application control */
#define CK_Save_Desktop 451
#define CK_New_Window 452

View File

@ -42,14 +42,25 @@ void status_string (WEdit * edit, char *s, int w, int fill, int font_width)
#endif
char t[160]; /* 160 just to be sure */
/* The field lengths just prevents the status line from shortening to much */
sprintf (t, "[%c%c%c%c] %2ld:%3ld+%2ld=%3ld/%3ld - *%-4ld/%4ldb=%3d",
edit->mark1 != edit->mark2 ? ( column_highlighting ? 'C' : 'B') : '-',
edit->modified ? 'M' : '-', edit->macro_i < 0 ? '-' : 'R',
edit->overwrite == 0 ? '-' : 'O',
edit->curs_col / font_width, edit->start_line + 1, edit->curs_row,
edit->curs_line + 1, edit->total_lines + 1, edit->curs1,
edit->last_byte, edit->curs1 < edit->last_byte
? edit_get_byte (edit, edit->curs1) : -1);
sprintf (t,"[%c%c%c%c] %2ld L:[%3ld+%2ld %3ld/%3ld] *(%-4ld/%4ldb)= %c %d %xH",
edit->mark1 != edit->mark2 ? ( column_highlighting ? 'C' : 'B') : '-',
edit->modified ? 'M' : '-',
edit->macro_i < 0 ? '-' : 'R',
edit->overwrite == 0 ? '-' : 'O',
edit->curs_col / font_width,
edit->start_line + 1,
edit->curs_row,
edit->curs_line + 1,
edit->total_lines + 1,
edit->curs1,
edit->last_byte,
edit->curs1 < edit->last_byte ? edit_get_byte (edit, edit->curs1) : '?',
edit->curs1 < edit->last_byte ? edit_get_byte (edit, edit->curs1) : -1,
edit->curs1 < edit->last_byte ? edit_get_byte (edit, edit->curs1) : -1
);
#ifdef MIDNIGHT
sprintf (s, "%.*s", w + 1, t);
i = strlen (s);

View File

@ -22,6 +22,7 @@
#include <config.h>
#include "edit.h"
#include "../src/user.h"
#include "editcmddef.h"
@ -118,6 +119,9 @@ void menu_lit_cmd (void) { menu_key (XCTRL ('q')); }
void menu_format_paragraph (void) { menu_cmd (CK_Paragraph_Format); }
void edit_options_dialog (void);
void menu_options (void) { edit_options_dialog (); }
void menu_user_menu_cmd (void) { menu_key (KEY_F (11)); }
void edit_user_menu_cmd (void) { menu_edit_cmd (1); }
static menu_entry FileMenu[] =
{
@ -129,6 +133,9 @@ static menu_entry FileMenu[] =
{' ', "", ' ', 0},
{' ', N_("&Insert file... F15"), 'I', menu_insert_file_cmd},
{' ', N_("copy to &File... C-f"), 'F', menu_cut_cmd},
{' ', "", ' ', 0},
{' ', N_("&User menu... F11"), 'U', menu_user_menu_cmd},
/* {' ', N_("Menu edi&Tor edit "), 'T', edit_user_menu_cmd}, */
{' ', "", ' ', 0},
{' ', N_("a&Bout... "), 'B', edit_about_cmd},
{' ', "", ' ', 0},
@ -145,6 +152,9 @@ static menu_entry FileMenuEmacs[] =
{' ', "", ' ', 0},
{' ', N_("&Insert file... F15"), 'I', menu_insert_file_cmd},
{' ', N_("copy to &File... "), 'F', menu_cut_cmd},
{' ', "", ' ', 0},
{' ', N_("&User menu... F11"), 'U', menu_user_menu_cmd},
/* {' ', N_("Menu edi&Tor edit "), 'T', edit_user_menu_cmd}, */
{' ', "", ' ', 0},
{' ', N_("a&Bout... "), 'B', edit_about_cmd},
{' ', "", ' ', 0},
@ -218,7 +228,7 @@ static menu_entry CmdMenu[] =
{' ', N_("format p&Aragraph M-p"), 'A', menu_format_paragraph},
{' ', N_("'ispell' s&Pell check C-p"), 'P', menu_ispell_cmd},
{' ', N_("sor&T... M-t"), 'T', menu_sort_cmd},
{' ', N_("'indent' &C Formatter F19"), 'C', menu_c_form_cmd},
{' ', N_("E&xternal Formatter F19"), 'C', menu_c_form_cmd},
{' ', N_("&Mail... "), 'M', menu_mail_cmd}
};
@ -241,7 +251,7 @@ static menu_entry CmdMenuEmacs[] =
{' ', N_("format p&Aragraph M-p"), 'a', menu_format_paragraph},
{' ', N_("'ispell' s&Pell check M-$"), 'P', menu_ispell_cmd},
{' ', N_("sor&T... M-t"), 'T', menu_sort_cmd},
{' ', N_("'indent' &C Formatter F19"), 'C', menu_c_form_cmd}
{' ', N_("E&xternal Formatter F19"), 'C', menu_c_form_cmd}
};
extern void menu_save_mode_cmd (void);

View File

@ -374,9 +374,12 @@ static void translate_rule_to_color (WEdit * edit, struct syntax_rule rule, int
*fg = k->fg;
}
extern int use_colors;
void edit_get_syntax_color (WEdit * edit, long byte_index, int *fg, int *bg)
{
if (edit->rules && byte_index < edit->last_byte && option_syntax_highlighting) {
if (edit->rules && byte_index < edit->last_byte &&
option_syntax_highlighting && use_colors) {
translate_rule_to_color (edit, edit_get_rule (edit, byte_index), fg, bg);
} else {
#ifdef MIDNIGHT
@ -1501,11 +1504,6 @@ void edit_load_syntax (WEdit * edit, char **names, char *type)
edit_free_syntax_rules (edit);
#ifdef MIDNIGHT
if (!SLtt_Use_Ansi_Colors || !use_colors)
return;
#endif
if (edit) {
if (!edit->filename)
return;

View File

@ -14,7 +14,7 @@ INSTALL_DATA = @INSTALL_DATA@
LIBFILES_IN = mc.ext.in mc-gnome.ext.in
LIBFILES_OUT = mc.ext mc-gnome.ext mc.csh mc.sh
LIBFILES_CONST = mc.hint mc.hint.es mc.hint.cs mc.hint.ru mc.lib mc.menu
LIBFILES_CONST = mc.hint mc.hint.es mc.hint.cs mc.hint.ru mc.lib mc.menu cedit.menu edit.indent.rc
SUPPBIN_IN = mc.csh.in mc.sh.in
SUPPBIN_OUT = mc.csh mc.sh
DESKTOP_FILES = startup.links README.desktop

View File

@ -335,3 +335,8 @@ C Convert gz<->bz2, tar.gz<->tar.bz2 & tgz->tar.bz2
fi
shift
done
+ x /usr/bin/open | x /usr/local/bin/open & x /bin/sh
o Open next a free console
open -s -- sh

View File

@ -1,3 +1,46 @@
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-04-17 Andrew V. Samoilov <sav@bcs.zp.ua>
* widget.c: (history_put): profile is free()d if chmod failed,

View File

@ -79,9 +79,6 @@
#include "profile.h"
#define MIDNIGHT
#ifdef USE_INTERNAL_EDIT
extern int edit (const char *file, int line);
#endif
#include "../vfs/vfs.h"
#define WANT_WIDGETS
#include "main.h" /* global variables, global functions */
@ -655,34 +652,36 @@ void ext_cmd (void)
flush_extension_file ();
}
void menu_edit_cmd (void)
/* where = 0 - do edit a file menu for mc */
/* where = 1 - do edit a file menu for cool edit */
void menu_edit_cmd (int where)
{
char *buffer;
char *menufile;
int dir = 0;
dir = query_dialog (
_("Menu file edit"),
_(" Which menu file will you edit? "),
_(" Menu edit "),
_(" Which menu file will you edit ? "),
0, geteuid() ? 2 : 3,
_("&Local"), _("&Home"), _("&System Wide")
);
menufile = concat_dir_and_file(mc_home, MC_GLOBAL_MENU);
menufile = concat_dir_and_file (mc_home, where ? CEDIT_GLOBAL_MENU : MC_GLOBAL_MENU);
switch (dir){
switch (dir) {
case 0:
buffer = g_strdup (MC_LOCAL_MENU);
buffer = g_strdup (where ? CEDIT_LOCAL_MENU : MC_LOCAL_MENU);
check_for_default (menufile, buffer);
break;
case 1:
buffer = concat_dir_and_file (home_dir, MC_HOME_MENU);
buffer = concat_dir_and_file (home_dir, where ? CEDIT_HOME_MENU : MC_HOME_MENU);
check_for_default (menufile, buffer);
break;
case 2:
buffer = concat_dir_and_file (mc_home, MC_GLOBAL_MENU);
buffer = concat_dir_and_file (mc_home, where ? CEDIT_GLOBAL_MENU : MC_GLOBAL_MENU);
break;
default:
@ -1222,43 +1221,55 @@ void mkdir_panel_cmd (void)
}
/* partly taken from dcgettect.c, returns "" for C locale */
static const char *
guess_message_value (void)
/* value should be gfreed by calling function */
char *guess_message_value (unsigned want_info)
{
const char *retval;
/* The highest priority value is the `LANGUAGE' environment
variable. This is a GNU extension. */
retval = getenv ("LANGUAGE");
if (retval != NULL && retval[0] != '\0')
return retval;
/* Setting of LC_ALL overwrites all other. */
retval = getenv ("LC_ALL");
if (retval != NULL && retval[0] != '\0')
return retval;
/* Next comes the name of the desired category. */
retval = getenv ("LC_MESSAGE");
if (retval != NULL && retval[0] != '\0')
return retval;
const char *var[] = {
/* The highest priority value is the `LANGUAGE' environment
variable. This is a GNU extension. */
"LANGUAGE",
/* Setting of LC_ALL overwrites all other. */
"LC_ALL",
/* Next comes the name of the desired category. */
"LC_MESSAGE",
/* Last possibility is the LANG environment variable. */
"LANG",
/* NULL exit loops */
NULL
};
/* Last possibility is the LANG environment variable. */
retval = getenv ("LANG");
if (retval != NULL && retval[0] != '\0')
return retval;
gchar *retval;
unsigned i = 0;
char *locale = NULL;
/* We use C as the default domain. POSIX says this is implementation
defined. */
return "";
while (var[i] != NULL) {
locale = getenv (var[i]);
if (locale != NULL && locale[0] != '\0')
break;
i++;
}
if (var[i] == NULL)
locale = "";
if (want_info == 0)
retval = g_strdup (locale);
else
if (var[i] == NULL)
retval = g_strdup (_("Using default locale"));
else
retval = g_strdup_printf (_("Using locale \"%s\" (from environment variable %s)"), locale, var[i]);
return retval;
}
/* Returns a random hint */
char *get_random_hint (void)
{
char *data, *result, *eol;
char *hintfile_base, *hintfile;
const char *lang;
char *lang;
int len;
int start;
@ -1283,7 +1294,7 @@ char *get_random_hint (void)
#endif
hintfile_base = concat_dir_and_file (mc_home, MC_HINT);
lang = guess_message_value ();
lang = guess_message_value (0);
hintfile = g_strdup_printf ("%s.%s", hintfile_base, lang);
data = load_file (hintfile);
@ -1298,6 +1309,7 @@ char *get_random_hint (void)
data = load_file (hintfile_base);
}
g_free (lang);
g_free (hintfile_base);
if (!data)
return 0;
@ -1557,7 +1569,7 @@ info_cmd (void)
void
quick_view_cmd (void)
{
if (get_panel_widget (MENU_PANEL_IDX) == cpanel)
if ((WPanel *) get_panel_widget (MENU_PANEL_IDX) == cpanel)
change_panel ();
set_display_type (MENU_PANEL_IDX, view_quick);
}

View File

@ -8,7 +8,7 @@ void help_cmd (void);
void dirsizes_cmd (void);
int view_file_at_line (char *filename, int plain_view, int internal,
int start_line);
int view_file (char *filename, int normal, int internal);
int view_file (char *filename, int normal, int internal);
void view_cmd (WPanel *panel);
void view_file_cmd (WPanel *panel);
void view_simple_cmd (WPanel *panel);
@ -35,7 +35,7 @@ void do_re_sort (WPanel *panel);
void quick_view_cmd (void);
void tree_view_cmd (void);
void ext_cmd (void);
void menu_edit_cmd (void);
void menu_edit_cmd (int select);
void quick_chdir_cmd (void);
void compare_dirs_cmd (void);
void history_cmd (void);
@ -59,6 +59,8 @@ void quick_cd_cmd (void);
void save_setup_cmd (void);
char *get_random_hint (void);
void source_routing (void);
void user_file_menu_cmd (void);
char *guess_message_value (unsigned want_info);
/* Display mode code */
void info_cmd (void);
@ -71,4 +73,10 @@ void info_cmd_no_menu (void);
void quick_view_cmd (void);
void toggle_listing_cmd (void);
void configure_panel_listing (WPanel *p, int view_type, int use_msformat, char *user, char *status);
#ifdef USE_INTERNAL_EDIT
extern int edit (const char *file, int line);
extern int edit_run;
#endif
#endif /* __CMD_H */

View File

@ -18,7 +18,7 @@ static const char * const features [] = {
N_(" with X11 support to read modifiers"),
#endif
#endif
".\n",
"\n",
#ifdef USE_VFS
N_("Virtual File System: tarfs, extfs"),
@ -38,7 +38,7 @@ static const char * const features [] = {
#ifdef USE_EXT2FSLIB
N_(", undelfs"),
#endif
".\n",
"\n",
#endif
#ifdef USE_INTERNAL_EDIT

View File

@ -1287,7 +1287,7 @@ static menu_entry RightMenu [] = {
};
static menu_entry FileMenu [] = {
{ ' ', N_("&User menu F2"), 'U', user_menu_cmd },
{ ' ', N_("&User menu F2"), 'U', user_file_menu_cmd },
{ ' ', N_("&View F3"), 'V', view_cmd },
{ ' ', N_("Vie&w file... "), 'W', view_file_cmd },
{ ' ', N_("&Filtered view M-!"), 'F', filtered_view_cmd },
@ -1345,8 +1345,10 @@ static menu_entry CmdMenu [] = {
#ifdef VERSION_4
{ ' ', N_("&Listing format edit"), 'L', listmode_cmd},
#endif
{ ' ', "", ' ', 0 },
{ ' ', N_("&Extension file edit"), 'E', ext_cmd },
{ ' ', N_("&Menu file edit"), 'M', menu_edit_cmd }
{ ' ', N_("&Menu file edit"), 'M', menu_edit_cmd },
{' ', N_("Menu edi&Tor edit"), 'T', edit_user_menu_cmd}
};
/* Must keep in sync with the constants in menu_cmd */
@ -1719,7 +1721,7 @@ static void
init_labels (Widget *paneletc)
{
define_label (midnight_dlg, paneletc, 1, _("Help"), help_cmd);
define_label (midnight_dlg, paneletc, 2, _("Menu"), user_menu_cmd);
define_label (midnight_dlg, paneletc, 2, _("Menu"), user_file_menu_cmd);
define_label (midnight_dlg, paneletc, 9, _("PullDn"), menu_cmd);
define_label (midnight_dlg, paneletc, 10, _("Quit"), (voidfn) quit_cmd);
}
@ -2196,7 +2198,6 @@ prepend_cwd_on_local (char *filename)
}
#ifdef USE_INTERNAL_EDIT
void edit (const char *file_name, int startline);
static int
mc_maybe_editor_or_viewer (void)
@ -2275,17 +2276,24 @@ do_nc (void)
static void
version (int verbose)
{
char *str;
fprintf (stderr, "The Midnight Commander %s\n", VERSION);
if (!verbose)
return;
#ifndef HAVE_X
fprintf (stderr,
_("with mouse support on xterm%s.\n"),
status_mouse_support ? _(" and the Linux console") : "");
fprintf (stderr, status_mouse_support ?
_("with mouse support on xterm and the Linux console.\n") :
_("with mouse support on xterm.\n"));
#endif /* HAVE_X */
for (verbose = 0; features [verbose]; verbose++)
fprintf (stderr, _(features [verbose]));
str = guess_message_value (1);
fprintf (stderr, "%s\n", str);
g_free (str);
if (print_last_wd)
write (stdout_fd, ".", 1);
}
@ -2524,7 +2532,8 @@ print_mc_usage (void)
#endif
N_("-v, --view fname Start up into the viewer mode.\n"
"-V, --version Report version and configuration options.\n"
"-x, --xterm Force xterm mouse support and screen save/restore.\n"),
"-x, --xterm Force xterm mouse support and screen save/restore.\n"
"+number number it is the start line number of file for `mcedit'.\n"),
#ifdef HAVE_SUBSHELL_SUPPORT
N_("-X, --dbgsubshell [DEVEL-ONLY: Debug the subshell].\n"),
#endif
@ -3004,9 +3013,10 @@ main (int argc, char *argv [])
/* mc_home was computed by OS_Setup */
home_dir = mc_home;
}
vfs_init ();
edit_init_file();
#ifdef HAVE_X
/* NOTE: This call has to be before any our argument handling :) */

View File

@ -46,6 +46,7 @@ extern int auto_save_setup;
extern int use_internal_view;
extern int use_internal_edit;
#ifdef USE_INTERNAL_EDIT
extern int edit (const char *file, int line);
extern int option_word_wrap_line_length;
extern int edit_key_emulation;
extern int option_tab_spacing;
@ -162,6 +163,8 @@ void load_hint (void);
void print_vfs_message(char *msg, ...);
void edit_user_menu_cmd (void);
extern char *prompt;
extern char *mc_home;

View File

@ -1238,12 +1238,15 @@ Condition syntax: = <sub-cond>
Sub-condition is one of following:
y <pattern> syntax of current file matching pattern?
for edit menu only.
f <pattern> current file matching pattern?
F <pattern> other file matching pattern?
d <pattern> current directory matching pattern?
D <pattern> other directory matching pattern?
t <type> current file of type?
T <type> other file of type?
x <filename> is it executable filename?
! <sub-cond> negate the result of sub-condition
Pattern is a normal shell pattern or a regular expression,
@ -1701,8 +1704,23 @@ line input, a simple macro substitution takes place.
The macros are:
"%i" The indent of blank space, equal the cursor column
position. For edit menu only.
"%y" The syntax type of current file. For edit menu only.
"%k" The block file name.
"%e" The error file name.
"%m" The current menu name.
"%f" The current file name.
"%n" Only the current file name without extension.
"%x" The extension of current file name.
"%d" The current directory name.
"%F" The current file in the unselected panel.
@ -2158,17 +2176,14 @@ press Ctrl-A and then the assigned key. The macro is also
executed if you press Meta, Ctrl, or Esc and the assigned
key, provided that the key is not used for any other
function. Once defined, the macro commands go into the
file cedit/cooledit.macros in your home directory. You can
file ~/.cedit/cooledit.macros in your home directory. You can
delete a macro by deleting the appropriate line in this
file.
F19 will format C code when it is highlighted. For this to
work, make an executable file called cedit/edit.indent.rc
in your home directory containing the following:
#!/bin/sh
/usr/bin/indent -kr -pcs ~/cedit/cooledit.block >& /dev/null
cat /dev/null > ~/cedit/cooledit.error
F19 will format text (C , C++ code or another) when it is
block highlighted. For this to work, first time, will create
executable file called ~/.cedit/edit.indent.rc in your
home directory. To edit this script if needed.
You can use scanf search and replace to search and replace
a C format string. First take a look at the sscanf and
@ -2429,7 +2444,7 @@ For example, to recover deleted files on the second
partition of the first scsi disk on Linux, you would use
the following path name:
/#undel:/dev/sda2
/#undel:sda2
It may take a while for the undelfs to load the required
information before you start browsing files there.

View File

@ -2385,6 +2385,8 @@ panel_key (WPanel *panel, int key)
return 0;
}
void user_file_menu_cmd (void) { user_menu_cmd (NULL); }
static int
panel_callback (Dlg_head *h, WPanel *panel, int msg, int par)
{
@ -2392,7 +2394,7 @@ panel_callback (Dlg_head *h, WPanel *panel, int msg, int par)
case WIDGET_INIT:
#ifdef HAVE_X
define_label (h, (Widget *)panel, 1, _("Help"), help_cmd);
define_label (h, (Widget *)panel, 2, _("Menu"), user_menu_cmd);
define_label (h, (Widget *)panel, 2, _("Menu"), user_file_menu_cmd);
define_label (h, (Widget *)panel, 3, _("View"), view_panel_cmd);
define_label (h, (Widget *)panel, 4, _("Edit"), edit_panel_cmd);
define_label (h, (Widget *)panel, 5, _("Copy"), copy_cmd);
@ -2422,7 +2424,7 @@ panel_callback (Dlg_head *h, WPanel *panel, int msg, int par)
focus_select_item (panel);
#ifndef HAVE_X
define_label (h, (Widget *)panel, 1, _("Help"), help_cmd);
define_label (h, (Widget *)panel, 2, _("Menu"), user_menu_cmd);
define_label (h, (Widget *)panel, 2, _("Menu"), user_file_menu_cmd);
define_label (h, (Widget *)panel, 3, _("View"), view_panel_cmd);
define_label (h, (Widget *)panel, 4, _("Edit"), edit_panel_cmd);
define_label (h, (Widget *)panel, 5, _("Copy"), copy_cmd);

View File

@ -31,6 +31,7 @@
#include "dir.h"
#include "panel.h"
#include "main.h"
#include "subshell.h" /* for subshell_pty */
#include "user.h"
#include "layout.h"
#include "setup.h"
@ -50,6 +51,8 @@
static int debug_flag = 0;
static int debug_error = 0;
static WEdit *s_editwidget;
static char *menu;
/* Formats defined:
%% The % character
@ -203,9 +206,27 @@ char *expand_format (char c, int quote)
case 'f':
case 'p': return (*quote_func) (fname, 0);
case 'b': return strip_ext((*quote_func) (fname, 0));
case 'x': return (*quote_func) (extension(fname), 0);
case 'd': return (*quote_func) (panel->cwd, 0);
case 's': if (!panel->marked)
return (*quote_func) (fname, 0);
case 'i': /* indent equal number cursor position in line */
if (s_editwidget)
return g_strnfill (s_editwidget->curs_col, ' ');
break;
case 'y': /* syntax type */
if (s_editwidget)
return g_strdup (s_editwidget->syntax_type);
break;
case 'e':
/* error file name */
return (*quote_func) (g_strconcat (home_dir, ERROR_FILE, NULL), 0);
case 'k':
/* block file name */
return (*quote_func) (g_strconcat (home_dir, BLOCK_FILE, NULL), 0);
case 'm':
/* menu file name */
return (*quote_func) (menu, 0);
/* Fall through */
@ -259,7 +280,8 @@ static char *extract_arg (char *p, char *arg)
{
while (*p && (*p == ' ' || *p == '\t' || *p == '\n'))
p++;
while (*p && *p != ' ' && *p != '\t' && *p != '\n')
/* support quote space .mnu */
while (*p && (*p != ' ' || *(p-1) == '\\') && *p != '\t' && *p != '\n')
*arg++ = *p++;
*arg = 0;
if (!*p || *p == '\n')
@ -323,7 +345,8 @@ static char *test_condition (char *p, int *condition)
/* Handle one condition */
for (;*p != '\n' && *p != '&' && *p != '|'; p++){
if (*p == ' ' || *p == '\t')
/* support quote space .mnu */
if ((*p == ' ' && *(p-1) != '\\') || *p == '\t')
continue;
if (*p >= 'a')
panel = cpanel;
@ -341,10 +364,17 @@ static char *test_condition (char *p, int *condition)
*condition = ! *condition;
p--;
break;
case 'f':
case 'f': /* file name pattern */
p = extract_arg (p, arg);
*condition = panel && regexp_match (arg, panel->dir.list [panel->selected].fname, match_file);
break;
case 'y': /* syntax pattern */
if (s_editwidget) {
p = extract_arg (p, arg);
*condition = panel &&
regexp_match (arg, s_editwidget->syntax_type, match_normal);
}
break;
case 'd':
p = extract_arg (p, arg);
*condition = panel && regexp_match (arg, panel->cwd, match_file);
@ -353,6 +383,17 @@ static char *test_condition (char *p, int *condition)
p = extract_arg (p, arg);
*condition = panel && test_type (panel, arg);
break;
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;
}
default:
debug_error = 1;
break;
@ -424,8 +465,9 @@ static char *test_line (char *p, int *result)
/* Init debugger */
debug_out (NULL, NULL, 0);
/* Repeat till end of line */
while (*p && *p != '\n'){
while (*p == ' ' || *p == '\t')
while (*p && *p != '\n') {
/* support quote space .mnu */
while ((*p == ' ' && *(p-1) != '\\' ) || *p == '\t')
p++;
if (!*p || *p == '\n')
break;
@ -434,7 +476,8 @@ static char *test_line (char *p, int *result)
debug_flag = 1;
p++;
}
while (*p == ' ' || *p == '\t')
/* support quote space .mnu */
while ((*p == ' ' && *(p-1) != '\\' ) || *p == '\t')
p++;
if (!*p || *p == '\n')
break;
@ -482,7 +525,7 @@ execute_menu_command (char *commands)
int cmd_file_fd;
int expand_prefix_found = 0;
char *parameter = 0;
int do_quote;
int do_quote = 0;
char prompt [80];
int col;
char *file_name;
@ -608,14 +651,19 @@ menu_file_own(char* path)
return 0;
}
void user_menu_cmd (void)
/*
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)
{
char *menu, *p;
char *p;
char *data, **entries;
int max_cols, menu_lines, menu_limit;
int col, i, accept_entry = 1;
int selected, old_patterns;
Listbox *listbox;
s_editwidget = edit_widget;
if (!vfs_current_is_local ()){
message (1, _(" Oops... "),
@ -623,13 +671,15 @@ void user_menu_cmd (void)
return;
}
menu = g_strdup (MC_LOCAL_MENU);
menu = g_strdup (edit_widget ? CEDIT_LOCAL_MENU : MC_LOCAL_MENU);
if (!exist_file (menu) || !menu_file_own (menu)){
g_free (menu);
menu = concat_dir_and_file (home_dir, MC_HOME_MENU);
menu = concat_dir_and_file \
(home_dir, edit_widget ? CEDIT_HOME_MENU : MC_HOME_MENU);
if (!exist_file (menu)){
g_free (menu);
menu = concat_dir_and_file (mc_home, MC_GLOBAL_MENU);
menu = concat_dir_and_file \
(mc_home, edit_widget ? CEDIT_GLOBAL_MENU : MC_GLOBAL_MENU);
}
}
@ -722,7 +772,6 @@ void user_menu_cmd (void)
easy_patterns = old_patterns;
return;
}
g_free (menu);
max_cols = min (max (max_cols, col), MAX_ENTRY_LEN);
@ -745,6 +794,7 @@ void user_menu_cmd (void)
easy_patterns = old_patterns;
do_refresh ();
g_free (menu);
g_free (entries);
g_free (data);
}

View File

@ -1,7 +1,14 @@
#ifndef __USER_H
#define __USER_H
void user_menu_cmd (void);
#ifndef MIDNIGHT
#include "panel.h"
#define MIDNIGHT
#include "../gtkedit/edit-widget.h"
#undef MIDNIGHT
void user_menu_cmd (WEdit *edit_widget);
#endif
char *expand_format (char, int);
int check_format_view (const char *);
int check_format_var (const char *, char **);
@ -9,15 +16,21 @@ int check_format_cd (const char *);
char *check_patterns (char*);
#ifdef OS2_NT
# define MC_LOCAL_MENU "mc.mnu"
# define MC_GLOBAL_MENU "mc.mnu"
# define MC_HOME_MENU "mc.mnu"
# define MC_HINT "mc.hnt"
# define CEDIT_LOCAL_MENU "cedit.mnu"
# define CEDIT_GLOBAL_MENU "cedit.mnu"
# define CEDIT_HOME_MENU "cedit.mnu"
# define MC_LOCAL_MENU "mc.mnu"
# define MC_GLOBAL_MENU "mc.mnu"
# define MC_HOME_MENU "mc.mnu"
# define MC_HINT "mc.hnt"
#else
# define MC_GLOBAL_MENU "mc.menu"
# define MC_LOCAL_MENU ".mc.menu"
# define MC_HOME_MENU ".mc/menu"
# define MC_HINT "mc.hint"
# define CEDIT_GLOBAL_MENU "cedit.menu"
# define CEDIT_LOCAL_MENU ".cedit.menu"
# define CEDIT_HOME_MENU ".cedit/menu"
# define MC_GLOBAL_MENU "mc.menu"
# define MC_LOCAL_MENU ".mc.menu"
# define MC_HOME_MENU ".mc/menu"
# define MC_HINT "mc.hint"
#endif
#endif

View File

@ -1,3 +1,7 @@
2000-05-08 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
vfs/extfs/uha.in: add HSC type archives
2000-05-01 Pavel Machek <pavel@bug.ucw.cz>
* direntry.c (vfs_s_inode_from_path): fix for stating / directory

View File

@ -1,7 +1,7 @@
#!/bin/sh
#
# It is the uhafs Valery Kornienkov vlk@st.simbirsk.su 2:5051/30@fidonet
# ver ? :)
# ver 0.1 Thu Apr 6 12:05:08 2000
HA=ha # for HA 0.999 Copyright (c) 1995 Harri Hirvola
# Source: ftp://sunsite.unc.edu/pub/Linux/compress/ha0999p-linux.tar.gz
@ -12,7 +12,7 @@ mchafs_list ()
{ date="JanFebMarAprMayJunJulAugSepOctNovDec" }
/^===========/ {next}
{
if ($5="%" && $8~/DIR|ASC|CPY/) {
if ($5="%" && $8~/DIR|ASC|HSC|CPY/) {
split($6, a, "-")
split($7, t, ":")
filename=$1