mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-03-30 04:03:32 +02:00
Added SearchView - '/', 'n' & 'N'
This commit is contained in:
@@ -277,6 +277,8 @@ const modes = (function () //{{{
|
|||||||
self.addMode("OUTPUT_MULTILINE", true);
|
self.addMode("OUTPUT_MULTILINE", true);
|
||||||
self.addMode("SEARCH_FORWARD", true);
|
self.addMode("SEARCH_FORWARD", true);
|
||||||
self.addMode("SEARCH_BACKWARD", true);
|
self.addMode("SEARCH_BACKWARD", true);
|
||||||
|
self.addMode("SEARCH_VIEW_FORWARD", true);
|
||||||
|
self.addMode("SEARCH_VIEW_BACKWARD", true);
|
||||||
self.addMode("MENU", true); // a popupmenu is active
|
self.addMode("MENU", true); // a popupmenu is active
|
||||||
self.addMode("LINE", true); // linewise visual mode
|
self.addMode("LINE", true); // linewise visual mode
|
||||||
self.addMode("PROMPT", true);
|
self.addMode("PROMPT", true);
|
||||||
|
|||||||
@@ -8,11 +8,20 @@ function Player() // {{{
|
|||||||
////////////////////// PRIVATE SECTION /////////////////////////////////////////
|
////////////////////// PRIVATE SECTION /////////////////////////////////////////
|
||||||
/////////////////////////////////////////////////////////////////////////////{{{
|
/////////////////////////////////////////////////////////////////////////////{{{
|
||||||
|
|
||||||
|
let lastSearchString = "";
|
||||||
|
let lastSearchIndex = 0;
|
||||||
|
let lastSearchView = _SBGetCurrentView();
|
||||||
|
|
||||||
// Get the focus to the visible playlist first
|
// Get the focus to the visible playlist first
|
||||||
//window._SBShowMainLibrary();
|
//window._SBShowMainLibrary();
|
||||||
|
|
||||||
const pageService = Components.classes["@songbirdnest.com/Songbird/MediaPageManager;1"]
|
const pageService = Components.classes["@songbirdnest.com/Songbird/MediaPageManager;1"]
|
||||||
.getService(Components.interfaces.sbIMediaPageManager);
|
.getService(Components.interfaces.sbIMediaPageManager);
|
||||||
|
// Register Callbacks for searching.
|
||||||
|
|
||||||
|
liberator.registerCallback("change", modes.SEARCH_VIEW_FORWARD, function (command) { player.searchView(command);});
|
||||||
|
liberator.registerCallback("submit", modes.SEARCH_VIEW_FORWARD, function (command) { player.searchView(command);});
|
||||||
|
//liberator.registerCallback("cancel", modes.SEARCH_VIEW_FORWARD, function (command) { player.searchView(command);});
|
||||||
|
|
||||||
// interval (milliseconds)
|
// interval (milliseconds)
|
||||||
function seek(interval, direction)
|
function seek(interval, direction)
|
||||||
@@ -143,6 +152,18 @@ function Player() // {{{
|
|||||||
["-"], "Decrease volume by 10%",
|
["-"], "Decrease volume by 10%",
|
||||||
function () { player.decreaseVolume(); });
|
function () { player.decreaseVolume(); });
|
||||||
|
|
||||||
|
mappings.add([modes.PLAYER],
|
||||||
|
["/"], "Search View",
|
||||||
|
function (args) { commandline.open("/", "", modes.SEARCH_VIEW_FORWARD); });
|
||||||
|
|
||||||
|
mappings.add([modes.PLAYER],
|
||||||
|
["n"], "Find Next",
|
||||||
|
function () { player.searchViewAgain(false);});
|
||||||
|
|
||||||
|
mappings.add([modes.PLAYER],
|
||||||
|
["N"], "Find Previous",
|
||||||
|
function () { player.searchViewAgain(true);});
|
||||||
|
|
||||||
////////////////// ///////////////////////////////////////////////////////////}}}
|
////////////////// ///////////////////////////////////////////////////////////}}}
|
||||||
////////////////////// COMMANDS ////////////////////////////////////////////////
|
////////////////////// COMMANDS ////////////////////////////////////////////////
|
||||||
/////////////////////////////////////////////////////////////////////////////{{{
|
/////////////////////////////////////////////////////////////////////////////{{{
|
||||||
@@ -495,21 +516,63 @@ function Player() // {{{
|
|||||||
return tracksList;
|
return tracksList;
|
||||||
},
|
},
|
||||||
|
|
||||||
// TODO: Use this for implementing "/" and "?". -ken
|
searchView: function searchView (args)
|
||||||
searchTracks: function searchTracks(args)
|
|
||||||
{
|
{
|
||||||
let currentView = _SBGetCurrentView();
|
let currentView = _SBGetCurrentView();
|
||||||
let mediaItemList = currentView.mediaList;
|
let mediaItemList = currentView.mediaList;
|
||||||
let search = _getSearchString(currentView);
|
let search = _getSearchString(currentView);
|
||||||
let searchString = "";
|
let searchString = "";
|
||||||
|
let index = 0;
|
||||||
|
|
||||||
if (search != "")
|
if (search != "")
|
||||||
searchString = args + " " + search;
|
searchString = args + " " + search;
|
||||||
else
|
else
|
||||||
searchString = args;
|
searchString = args;
|
||||||
|
|
||||||
let myView = LibraryUtils.createStandardMediaListView(mediaItemList, searchString);
|
lastSearchString = searchString;
|
||||||
focusTrack(myView.getItemByIndex(0));
|
|
||||||
|
let mySearchView = LibraryUtils.createStandardMediaListView(mediaItemList, searchString);
|
||||||
|
|
||||||
|
if (mySearchView.length)
|
||||||
|
{
|
||||||
|
lastSearchView = mySearchView;
|
||||||
|
focusTrack(mySearchView.getItemByIndex(index));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
liberator.echoerr("E486 Pattern not found: "+searchString, commandline.FORCE_SINGLELINE);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
//FIXME: commandline.echo should work --ken
|
||||||
|
searchViewAgain: function searchViewAgain(reverse)
|
||||||
|
{
|
||||||
|
if (reverse)
|
||||||
|
{
|
||||||
|
if (lastSearchIndex == 0)
|
||||||
|
{
|
||||||
|
//commandline.echo("Search hit TOP, continuing at BOTTOM",
|
||||||
|
// commandline.HL_WARNINGMSG, commandline.APPEND_TO_MESSAGES | commandline.FORCE_SINGLELINE);
|
||||||
|
lastSearchIndex = lastSearchView.length - 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
lastSearchIndex = lastSearchIndex - 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (lastSearchIndex == (lastSearchView.length -1))
|
||||||
|
{
|
||||||
|
//commandline.echo("Search hit BOTTOM, continuing at TOP",
|
||||||
|
// commandline.HL_WARNINGMSG, commandline.APPEND_TO_MESSAGES | commandline.FORCE_SINGLELINE);
|
||||||
|
lastSearchIndex = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
lastSearchIndex = lastSearchIndex + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
//FIXME: Implement for "?" --ken
|
||||||
|
commandline.echo("/" + lastSearchString, null, commandline.FORCE_SINGLELINE);
|
||||||
|
focusTrack(lastSearchView.getItemByIndex(lastSearchIndex));
|
||||||
},
|
},
|
||||||
|
|
||||||
getPlaylists: function getPlaylists()
|
getPlaylists: function getPlaylists()
|
||||||
|
|||||||
Reference in New Issue
Block a user