Hi,

you can find an improved patch attached to this message.

Regards
  Micha
--- sidebar.c	2008-03-12 19:31:47.000000000 +0100
+++ sidebar.c.patched	2008-03-12 19:31:15.000000000 +0100
@@ -229,9 +229,35 @@
 			tmp->msg_unread = Context->unread;
 			tmp->msgcount = Context->msgcount;
 		}
+		// check whether Maildir is a prefix of the current folder's path
+		short maildir_is_prefix = 0;
+		if ( (strlen(tmp->path) > strlen(Maildir)) &&
+			(strncmp(Maildir, tmp->path, strlen(Maildir)) == 0) )
+			maildir_is_prefix = 1;
+		// calculate depth of current folder and generate its display name with indented spaces
+		int sidebar_folder_depth = 0;
+		char *sidebar_folder_name;
+		sidebar_folder_name = basename(tmp->path);
+		if ( maildir_is_prefix ) {
+			char *tmp_folder_name;
+			int i;
+			tmp_folder_name = tmp->path + strlen(Maildir);
+			for (i = 0; i < strlen(tmp->path) - strlen(Maildir); i++) {
+				if (tmp_folder_name[i] == '/') sidebar_folder_depth++;
+			}
+			if (sidebar_folder_depth > 0) {
+				sidebar_folder_name = malloc(strlen(basename(tmp->path)) + sidebar_folder_depth + 1);
+				for (i=0; i < sidebar_folder_depth; i++)
+					sidebar_folder_name[i]=' ';
+				sidebar_folder_name[i]=0;
+				strncat(sidebar_folder_name, basename(tmp->path), strlen(basename(tmp->path)) + sidebar_folder_depth);
+			}
+		}
                 printw( "%.*s", SidebarWidth - delim_len + 1,
-                        make_sidebar_entry(basename(tmp->path), tmp->msgcount,
+                        make_sidebar_entry(sidebar_folder_name, tmp->msgcount,
                         tmp->msg_unread));
+		if (sidebar_folder_depth > 0)
+			free(sidebar_folder_name);
 		lines++;
 	}
 	SETCOLOR(MT_COLOR_NORMAL);

Reply via email to