Type Ahead or LiveFilter for Catalog

Features wanted...
Post Reply
randfee
Posts: 48
Joined: 26 Jul 2018 23:07

Type Ahead or LiveFilter for Catalog

Post by randfee »

Hi,

I keep wondering if there'll be the same type ahead functionality for the catalog frame as for the two panes and the tree. I don't see why this is missing from the catalog. I could really use it there!
If I am mistaken and the feature already exists, please, anyone, let me know how :wink:

regards
randfee

jupe
Posts: 2749
Joined: 20 Oct 2017 21:14
Location: Win10 22H2 120dpi

Re: Type Ahead or LiveFilter for Catalog

Post by jupe »

If you would consider using a script in the meantime while the developer decides on adding your wish: This is far from a perfect solution, and may result in error dialogs sometimes depending on the types of things you keep in your catalog, and some of the items icons may not display, and the categories headings will be visible in the list, and it might goto a exe/lnk file location in the list instead of running it etc, but if you are still interested then here is a quick script that is semi usable for displaying a popup filterable list.

Code: Select all

	$captions = catalogreport("{Caption}", "{Caption}|{Location}");
	$execute  = catalogreport("{Location}", "{Location}");
	$idx = inputselect(,replace($captions, "|:", "||:"),<crlf>, 1+1024+128+64+32, , 500);
	$result = trim(gettoken($execute, $idx, <crlf>), "¶");
	if (regexmatches($result, "¶")) {
		load replace($result, "¶", <crlf>),, 's';
	} elseif (exists($result) == 1) {
		runq $result;
	} elseif ($result UnLike "{Location}") {
		goto $result;
	}
This script has many limitations depending on the type of items you have in Catalog, so if you don't mind seeing the occasional error dialog you could give it a go, it could probably be made to work better with a bit of effort but there are certain limitations because of the information that is available via catalog scripting commands.

klownboy
Posts: 4089
Joined: 28 Feb 2012 19:27

Re: Type Ahead or LiveFilter for Catalog

Post by klownboy »

Hi Jupe, your use of SC catalogreport to come up with a popupmenu of catalog items is a great idea. When I noticed it yesterday I was wondering if there would be a way to eliminate the caption heading since they display with the not-so-nice looking question mark icon. I ended up leaving the "template_category" field blank ("") when using SC catalogreport and then SC formatlist to filter out any blank entries. As far as other entries which might not display an icon properly, I resolved mine by simply adding an icon reference to the category field similar to the way you would for a tab (e.g. Tools|:conf). I also had to clean-up some location field code. I can't say this will work for everyone, but all my catalog items work and have a proper icon. I hope you don't mind me posting the slight modification. Your idea is quite useful - it's like having the your catalog items available on the click of a key or button.

Code: Select all

  $captions=formatlist(catalogreport("","{Caption}|{Location}"), "e", <crlf>);
  $execute=formatlist(catalogreport("","{Location}"), "e", <crlf>);
   $idx = inputselect(,replace($captions, "|:", "||:"),<crlf>, 1+1024+128, , '280', '550', 'Catalog Menu Items');
   $result = trim(gettoken($execute, $idx, <crlf>), "¶");
   if regexmatches($result, "¶") {
      load replace($result, "¶", <crlf>),, 's';
   } elseif (exists($result) == 1) {
      runq $result;
   } elseif $result UnLike "{Location}" {
      goto $result;
   }
Another version that dislays the heading but with no icon which may be better in most cases.

Code: Select all

  $captions = catalogreport("- {Caption} -|:blank","{Caption}|{Location}");
//*** other caption header examples
//  $captions = catalogreport("●  {Caption}  ●|:blank","{Caption}|{Location}");
//  $captions = catalogreport("├- {Caption} -┤|:blank","{Caption}|{Location}");
//  $captions = catalogreport("« {Caption} »|:blank","{Caption}|{Location}");
  $execute=catalogreport("{Caption}","{Location}"), "e", <crlf>);

   $idx = inputselect(,replace($captions, "|:", "||:"),<crlf>, 1+1024+128, , '300', '650', 'Catalog Menu Items');
   $result = trim(gettoken($execute, $idx, <crlf>), "¶");
   if regexmatches($result, "¶") {
      load replace($result, "¶", <crlf>),, 's';
   } elseif (exists($result) == 1) {
      runq $result;
   } elseif $result UnLike "{Location}" {
      goto $result;
   }
Thanks again.
Windows 11, 22H2 Build 22621.1555 at 100% 2560x1440

jupe
Posts: 2749
Joined: 20 Oct 2017 21:14
Location: Win10 22H2 120dpi

Re: Type Ahead or LiveFilter for Catalog

Post by jupe »

No I don't mind at all, like I said previously it depends on what things you have in your catalog, what you use as icons etc, (like if you use an .ico file without the path, you would need to add <xyicons> in your catalog entry to get it to display properly etc) I was just providing a basic outline, if anyone was to use this they would probably need to customize it to suit their particular catalog entries, or customize their catalog to suit it, or both actually, but anyway I'm glad you liked it, everyone is free to re-post/modify any of my scripts at any time, I prefer providing proof of concept style scripts instead of perfectly polished full functionality scripts, I hope to encourage others to learn scripting that way, by adapting it themselves.

IMO if catalogreport() could return the catalog ID #s it would be even better because then you could load them with catalogexecute() instead of my hack job of running them, which can cause issues depending on what entry types you have in your catalog, but for the most part it should work ok, and most things could be solved by adapting the catalog entries like you mentioned already, but I didn't want to advertise it as a perfect, works out of the box solution, especially when replying to a new user.

klownboy
Posts: 4089
Joined: 28 Feb 2012 19:27

Re: Type Ahead or LiveFilter for Catalog

Post by klownboy »

jupe wrote:IMO if catalogreport() could return the catalog ID #s it would be even better because then you could load them with catalogexecute() instead of my hack job of running them, which can cause issues depending on what entry types you have in your catalog...
It sounds to me like that would make a good wish. It makes perfect sense to automate the process and obtain the catalog Index in a script. As mentioned in the help file, currently we can only get the index by looking at the properties box. Which doesn't make the SC catalogexecute command very useful at least not to its full potential. So a new variable under template_category called {index} should do it and make similar scripts more reliable.
Windows 11, 22H2 Build 22621.1555 at 100% 2560x1440

randfee
Posts: 48
Joined: 26 Jul 2018 23:07

Re: Type Ahead or LiveFilter for Catalog

Post by randfee »

Hi, this has come up again.
I tried implementing the above solutions a while back but never got it to work. Type ahead (+ livefilter if wanted) is simply so smooth when using it, it's a shame there is none of that in the catalogs.... :wink:

klownboy
Posts: 4089
Joined: 28 Feb 2012 19:27

Re: Type Ahead or LiveFilter for Catalog

Post by klownboy »

With Don's Beta v22.20.0205, we can obtain a catalog index using SC catalogreport. So it's now much simpler to execute a catalog item or to run the catalog as a menu. Here's an example:

Code: Select all

   if !(get("#664")) {#664;} // needed only if your catalog is not shown by default,
   $captions = catalogreport("• {Caption} •|:blank|","{Caption}|{Location}|{Index}");
   $idx = inputselect(,replace($captions, "|", "||"),<crlf>, 1+128+1024+8192, , "250", "650", "Catalog Menu");
   $result = trim(gettoken($captions, $idx, <crlf>), "¶");
   $index = gettoken($result, -1, "|");
   catalogexecute $index;
There are probably other ways of accomplishing this, but it works. Any other ideas for using SC catalogreport and catalogexecute are welcome.

Don, I noticed in testing that these catalog SCs only work if the catalog is on / displayed. Is that by design or not possible otherwise? And, thanks for adding {Index} to SC catalogreport templates.

EDIT 1: It does appear like you can use SC catalogload to load a particular catalog and the above script will work even though "Show Catalog" is not checked.

EDIT 2: Sorry Edit 1 is at least partially hogwash, in further testing it appears you have to "Show" the catalog once to use SC catalogreport in obtaining template information. Once the catalog is "shown" once during a session, you will not need to show the catalog again or use catalogload to allow the use of catalogrerport and use a script similar to the above.
Windows 11, 22H2 Build 22621.1555 at 100% 2560x1440

admin
Site Admin
Posts: 60289
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: Type Ahead or LiveFilter for Catalog

Post by admin »

klownboy wrote: 13 Sep 2021 21:14 Don, I noticed in testing that these catalog SCs only work if the catalog is on / displayed. Is that by design or not possible otherwise? And, thanks for adding {Index} to SC catalogreport templates.
Good point! When the Catalog is not shown on startup then it is not internally processed (to minimize startup time) and SC catalogreport has not much to report. Fixed in next beta.

klownboy
Posts: 4089
Joined: 28 Feb 2012 19:27

Re: Type Ahead or LiveFilter for Catalog

Post by klownboy »

Is that internal processing to the catalog worth changing if it adds to startup time at least for those that don't have the catalog "Shown" as default?
Windows 11, 22H2 Build 22621.1555 at 100% 2560x1440

admin
Site Admin
Posts: 60289
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: Type Ahead or LiveFilter for Catalog

Post by admin »

No worries. I fixed it in a way that only has advantages for everybody. :biggrin: :beer:

klownboy
Posts: 4089
Joined: 28 Feb 2012 19:27

Re: Type Ahead or LiveFilter for Catalog

Post by klownboy »

Thanks Don, there's no need to "show" the Catalog now for SC catalogreport to be fully loaded and functional. :tup: :appl:
Windows 11, 22H2 Build 22621.1555 at 100% 2560x1440

robertryan
Posts: 1
Joined: 27 Sep 2021 21:40

Re: Type Ahead or LiveFilter for Catalog

Post by robertryan »

Your use of SC catalogreport to come up with a popupmenu of catalog items is a great idea.

When I noticed it yesterday I was wondering if there would be a way to eliminate the caption heading since they display with the not-so-nice looking question mark icon.

I ended up leaving the "template_category" field blank ("") when using SC catalogreport and then SC formatlist to filter out any blank entries.

As far as other entries which might not display an icon properly, I resolved mine by simply adding an icon reference to the category field similar to the way you would for a tab (e.g. Tools|:conf).

I also had to clean-up some location field code.

I can't say this will work for everyone, but all my catalog items work and have a proper icon.

I hope you don't mind me posting the slight modification.

Your idea is quite useful - it's like having the your catalog items available on the click of a key or button.

$captions=formatlist(catalogreport("","{Caption}|{Location}"), "e", <crlf>);
$execute=formatlist(catalogreport("","{Location}"), "e", <crlf>);
$idx = inputselect(,replace($captions, "|:", "||:"),<crlf>, 1+1024+128, , '280', '550', 'Catalog Menu Items');
$result = trim(gettoken($execute, $idx, <crlf>), "¶");
if regexmatches($result, "¶") {
load replace($result, "¶", <crlf>),, 's';
} elseif (exists($result) == 1) {
runq $result;
} elseif $result UnLike "{Location}" {
goto $result;
}
Another version that dislays the heading but with no icon which may be better in most cases.
CODE: SELECT ALL

$captions = catalogreport("- {Caption} -|:blank","{Caption}|{Location}");
//*** other caption header examples
// $captions = catalogreport("● {Caption} ●|:blank","{Caption}|{Location}");
// $captions = catalogreport("├- {Caption} -┤|:blank","{Caption}|{Location}");
// $captions = catalogreport("« {Caption} »|:blank","{Caption}|{Location}");
$execute=catalogreport("{Caption}","{Location}"), "e", <crlf>);

$idx = inputselect(,replace($captions, "|:", "||:"),<crlf>, 1+1024+128, , '300', '650', 'Catalog Menu Items');
$result = trim(gettoken($execute, $idx, <crlf>), "¶");
if regexmatches($result, "¶") {
load replace($result, "¶", <crlf>),, 's';
} elseif (exists($result) == 1) {
runq $result;
} elseif $result UnLike "{Location}" {
goto $result;
}

Thanks again.

Post Reply