public inbox for cygwin-apps@cygwin.com
 help / color / mirror / Atom feed
* [PATCH] setup.exe case-insensitive package sorting
@ 2012-09-13  4:46 Warren Young
  2012-09-19 16:21 ` Christopher Faylor
  0 siblings, 1 reply; 2+ messages in thread
From: Warren Young @ 2012-09-13  4:46 UTC (permalink / raw)
  To: Cygwin Apps List

[-- Attachment #1: Type: text/plain, Size: 1931 bytes --]

This patch is incomplete, but I've been fighting this for four hours 
now.  I'm tired, hungry, and frustrated, so in case I don't get back to 
finishing this, I decided to just post what I have so far.

The point of the patch is to get the Select Packages screen's package 
lists to sort case-insensitively.

(This saga began after I spent far too long looking for the R package 
down in the bottom third of the Interpreters category.)

The patch works for the flat views only.  I have yet to figure out how 
to do the same for the Category tree view, since that is treated as a 
completely separate exception case in the code.

(Any setup.exe hackers want to opine on whether it's reasonable for it 
to have required 3 hours of spelunking through the package DB reader, 
the INI file parser, and the dialog chaining system to find out where to 
even begin attempting the patch?  Did I make par?  Was there a map to 
this twisty maze of global variables that I missed?)

When I dove in, I expected to find setup.exe sorting its package list 
ASCIIbetically somewhere, making this an easy fix, but no.  In fact, it 
doesn't sort the package list internally at all.  You can find std::map 
overridden with casecompare_lt_op sorting in a few places, but I've 
proven to myself that the solution doesn't lie down this alley.

Proof: Open setup.ini in a text editor, and move the R package down to 
the bottom of the file.  Run setup.exe in "install from local disk" mode 
so it doesn't blow away your changes with a copy from the Internet, get 
to the Select Packages screen, and open the Interpreters category.  R is 
now at the bottom of the category, instead of at the top.  Ergo, 
setup.exe is getting its package sort order from the ini file, not doing 
any sorting internally.  Not in a way that affects this screen, anyway.

I expect fixing upset would have been easier in the end, but I didn't 
want to be yelled at.  (SHTDI!)

[-- Attachment #2: setup-pkg-sort.patch --]
[-- Type: text/x-patch, Size: 2554 bytes --]

Index: ChangeLog
===================================================================
RCS file: /cvs/cygwin-apps/setup/ChangeLog,v
retrieving revision 2.780
diff -u -p -r2.780 ChangeLog
--- ChangeLog	4 Sep 2012 13:55:16 -0000	2.780
+++ ChangeLog	13 Sep 2012 04:32:13 -0000
@@ -1,3 +1,13 @@
+2012-09-12  Warren Young  <warren@etr-usa.com>
+
+	Sorting "select packages" UI lists case-insensitively now,
+	instead of taking setup.ini order, which is ASCIIbetical.
+	This doesn't fix the category (tree) view, only the flat list
+	views.
+	* PickCategoryLine.{cc,h}: Added sort() method
+	* PickView.cc: Calling new PickCategoryLine::sort() each time
+	  something changes in the package list, just before UI repaint.
+
 2012-09-04  Yaakov Selkowitz  <yselkowitz@users.sourceforge.net>
 
 	Fix build with mingw-w64 headers.
Index: PickCategoryLine.cc
===================================================================
RCS file: /cvs/cygwin-apps/setup/PickCategoryLine.cc,v
retrieving revision 2.12
diff -u -p -r2.12 PickCategoryLine.cc
--- PickCategoryLine.cc	23 Jul 2010 10:21:54 -0000	2.12
+++ PickCategoryLine.cc	13 Sep 2012 04:32:13 -0000
@@ -17,6 +17,8 @@
 #include "package_db.h"
 #include "PickView.h"
 
+#include <algorithm>
+
 void
 PickCategoryLine::empty (void)
 {
@@ -147,3 +149,14 @@ PickCategoryLine::set_action (packagemet
   theView.GetParent ()->ClearBusy ();
   return accum_diff;
 }
+
+static bool is_lt_icase(const PickLine* a, const PickLine* b)
+{
+  return casecompare(a->key, b->key) < 0;
+}
+
+void
+PickCategoryLine::sort ()
+{
+  std::sort (bucket.begin (), bucket.end (), is_lt_icase);
+}
Index: PickCategoryLine.h
===================================================================
RCS file: /cvs/cygwin-apps/setup/PickCategoryLine.h,v
retrieving revision 2.8
diff -u -p -r2.8 PickCategoryLine.h
--- PickCategoryLine.h	21 May 2005 23:04:02 -0000	2.8
+++ PickCategoryLine.h	13 Sep 2012 04:32:13 -0000
@@ -73,6 +73,7 @@ public:
   }
   void empty ();
   virtual int set_action (packagemeta::_actions);
+  void sort ();
 private:
   packagemeta::_actions
   current_default;
Index: PickView.cc
===================================================================
RCS file: /cvs/cygwin-apps/setup/PickView.cc,v
retrieving revision 2.42
diff -u -p -r2.42 PickView.cc
--- PickView.cc	19 Feb 2012 13:57:02 -0000	2.42
+++ PickView.cc	13 Sep 2012 04:32:13 -0000
@@ -207,6 +207,8 @@ PickView::setViewMode (views mode)
         }
     }
 
+	contents.sort();
+
   RECT r = GetClientRect ();
   SCROLLINFO si;
   memset (&si, 0, sizeof (si));

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] setup.exe case-insensitive package sorting
  2012-09-13  4:46 [PATCH] setup.exe case-insensitive package sorting Warren Young
@ 2012-09-19 16:21 ` Christopher Faylor
  0 siblings, 0 replies; 2+ messages in thread
From: Christopher Faylor @ 2012-09-19 16:21 UTC (permalink / raw)
  To: Cygwin Apps List, Warren Young

On Wed, Sep 12, 2012 at 10:46:02PM -0600, Warren Young wrote:
>This patch is incomplete, but I've been fighting this for four hours 
>now.  I'm tired, hungry, and frustrated, so in case I don't get back to 
>finishing this, I decided to just post what I have so far.
>
>The point of the patch is to get the Select Packages screen's package 
>lists to sort case-insensitively.
>
>(This saga began after I spent far too long looking for the R package 
>down in the bottom third of the Interpreters category.)
>
>The patch works for the flat views only.  I have yet to figure out how 
>to do the same for the Category tree view, since that is treated as a 
>completely separate exception case in the code.
>
>(Any setup.exe hackers want to opine on whether it's reasonable for it 
>to have required 3 hours of spelunking through the package DB reader, 
>the INI file parser, and the dialog chaining system to find out where to 
>even begin attempting the patch?  Did I make par?  Was there a map to 
>this twisty maze of global variables that I missed?)

You want us to weigh in on your being tired and frustrated and unable
to figure out source code?  I'm going to carefully lay down that loaded
weapon.

I modified "upset" to do case insensitive sorting of packages.  This seems
preferable to adding YA level of complexity to setup.

cgf

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-09-19 16:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-13  4:46 [PATCH] setup.exe case-insensitive package sorting Warren Young
2012-09-19 16:21 ` Christopher Faylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).