[Commands]
1\Command="
copyq:
// ==CopyQ==
// @name Cycle previous and next items
// @version 1.00
// @description Cycles through previous items with Ctrl + Shift + 1 and next items with Ctrl + 1 and then pastes the selected item when the shortcut modifier key is released.
// @namespace https://github.com/XP1/
// @copyright 2024
// @author XP1
// @homepage https://github.com/XP1/
// @license GNU General Public License, Version 3.0; https://www.gnu.org/licenses/gpl-3.0.html
// ==/CopyQ==
/*
* Copyright 2024 XP1
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*jslint devel, long, unordered */
/*global str, settings, focused, queryKeyboardModifiers, select, selectItems, sleep, show, hide, paste */
(function () {
\"use strict\";
const selectedRowOption = \"CycleItems/selectedRow\";
const isWaitingKeyOption = \"CycleItems/isWaitingKey\";
function getSelectedRow() {
return parseInt(str(settings(selectedRowOption)), 10);
}
function isWaitingKey() {
return (str(settings(isWaitingKeyOption)) === \"true\");
}
function previousRow() {
let row = getSelectedRow();
row = (row > 1 ? (row - 1) : 0);
settings(selectedRowOption, row);
selectItems(row);
return row;
}
function nextRow() {
let row = getSelectedRow();
row = (row > 0 ? (row + 1) : 1);
settings(selectedRowOption, row);
selectItems(row);
return row;
}
function waitKey() {
if (isWaitingKey()) {
return;
}
settings(isWaitingKeyOption, true);
// Wait for shortcut modifiers to be released.
while (queryKeyboardModifiers().length > 0) {
sleep(20);
}
const row = getSelectedRow();
if (row >= 0) {
select(row);
hide();
paste();
}
settings(isWaitingKeyOption, false);
}
function initialize(direction) {
if (focused()) {
if (direction === \"previous\") {
previousRow();
} else {
nextRow();
}
} else {
settings(selectedRowOption, -1);
selectItems(0);
show();
}
waitKey();
}
initialize(\"previous\");
}());"
1\GlobalShortcut=ctrl+shift+1
1\Icon=\xf1b8
1\IsGlobalShortcut=true
1\Name=Cycle previous items
1\Shortcut=ctrl+shift+1
2\Command="
copyq:
// ==CopyQ==
// @name Cycle previous and next items
// @version 1.00
// @description Cycles through previous items with Ctrl + Shift + 1 and next items with Ctrl + 1 and then pastes the selected item when the shortcut modifier key is released.
// @namespace https://github.com/XP1/
// @copyright 2024
// @author XP1
// @homepage https://github.com/XP1/
// @license GNU General Public License, Version 3.0; https://www.gnu.org/licenses/gpl-3.0.html
// ==/CopyQ==
/*
* Copyright 2024 XP1
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*jslint devel, long, unordered */
/*global str, settings, focused, queryKeyboardModifiers, select, selectItems, sleep, show, hide, paste */
(function () {
\"use strict\";
const selectedRowOption = \"CycleItems/selectedRow\";
const isWaitingKeyOption = \"CycleItems/isWaitingKey\";
function getSelectedRow() {
return parseInt(str(settings(selectedRowOption)), 10);
}
function isWaitingKey() {
return (str(settings(isWaitingKeyOption)) === \"true\");
}
function previousRow() {
let row = getSelectedRow();
row = (row > 1 ? (row - 1) : 0);
settings(selectedRowOption, row);
selectItems(row);
return row;
}
function nextRow() {
let row = getSelectedRow();
row = (row > 0 ? (row + 1) : 1);
settings(selectedRowOption, row);
selectItems(row);
return row;
}
function waitKey() {
if (isWaitingKey()) {
return;
}
settings(isWaitingKeyOption, true);
// Wait for shortcut modifiers to be released.
while (queryKeyboardModifiers().length > 0) {
sleep(20);
}
const row = getSelectedRow();
if (row >= 0) {
select(row);
hide();
paste();
}
settings(isWaitingKeyOption, false);
}
function initialize(direction) {
if (focused()) {
if (direction === \"previous\") {
previousRow();
} else {
nextRow();
}
} else {
settings(selectedRowOption, -1);
selectItems(0);
show();
}
waitKey();
}
initialize(\"next\");
}());"
2\GlobalShortcut=ctrl+1
2\Icon=\xf1b8
2\IsGlobalShortcut=true
2\Name=Cycle next items
2\Shortcut=ctrl+1
size=2