-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature Request] Include Tree Style Tab structure when using "Copy to Clipboard". #185
Comments
I wrote a function that will format a string in the way I specified above: const kCOPY_TO_CLIPBOARD_TST_START = "%TST(";
const kCOPY_TO_CLIPBOARD_TST_SEPARATOR = ",";
const kCOPY_TO_CLIPBOARD_TST_END = ")%";
function formatTSTInfo(aFormat, ancestorCount) {
if ((!ancestorCount && ancestorCount !== 0) || ancestorCount < 0 || !aFormat || aFormat.indexOf(kCOPY_TO_CLIPBOARD_TST_START) < 0)
return aFormat;
let formatted = "";
while (true) {
// Find next TST Entry:
let startIndex = aFormat.indexOf(kCOPY_TO_CLIPBOARD_TST_START);
let endIndex = aFormat.indexOf(kCOPY_TO_CLIPBOARD_TST_END);
if (startIndex < 0 || endIndex < 0) {
// No more TST Entries:
formatted += aFormat;
break;
}
// Find TST Separator:
let separatorIndex = aFormat.indexOf(kCOPY_TO_CLIPBOARD_TST_SEPARATOR);
if (separatorIndex > endIndex) {
// Separator is after end -> ignore it.
separatorIndex = -1;
}
// Find TST Arguments:
let arg1 = aFormat.substring(startIndex + kCOPY_TO_CLIPBOARD_TST_START.length, separatorIndex < 0 ? endIndex : separatorIndex);
let arg2 = null;
if (separatorIndex >= 0) {
arg2 = aFormat.substring(separatorIndex + 1, endIndex);
}
// Create TST Structure representation:
let tstInfo = "";
for (let i = 0; i < ancestorCount; i++) {
if (i + 1 === ancestorCount && arg2) {
tstInfo += arg2;
} else {
tstInfo += arg1;
}
}
// Move Parse location to after TST Entry:
formatted += aFormat.substr(0, startIndex) + tstInfo;
aFormat = aFormat.substr(endIndex + kCOPY_TO_CLIPBOARD_TST_END.length)
}
return formatted;
} You should probably apply this function before you do anything else to the format string since you don't want it to do anything if a tab should have the wrong title or something. Also you check that the string has both |
Thanks to nice suggestion! Finally I've implemented similar placeholder based on your idea. You need to update the format you added like following:
The
|
Note that this feature depends on TST 2.4.8 (not released yet) and later, because this uses the new property |
@piroor Great! Looking forward to having this available! |
Thanks, I realized that I forgot to think about partially selected tree nodes. By 9cdf2e1 now partial tree items are indented correctly. |
@piroor Thanks! |
Description
Currently I use a separate program to export my Tree Style Tab structure to text documents. I posted the code I use on TST Issue 1678. Anyways I think it would also be useful to include TST structure when copying tabs to the clipboard using this extension.
Example Solution
I think that tree structure should be presented as the number of TST ancestor tabs a tab has. An indent text could then be inserted before the text that many times. To allow for customization I think you should add a new placeholder for formatting. For example:
%TST(parameter1, parameter2)%
parameter1
: indent text.parameter2
: last indent text. (Optional, same asparameter1
if not specified.)Some "Copy to Clipboard" alternatives that could be used:
Example results for solution
[TST] Title and URI:
[TST] HTML Link:
Add-ons for Firefox
|---All Tabs Helper – Add-ons for Firefox
|---User Info for Piro (piro_or) :: Add-ons for Firefox
| |---Tree Style Tab – Add-ons for Firefox
| | |---GitHub - piroor/treestyletab: Tree Style Tab, Show tabs like a tree.
| | | |---Issues · piroor/treestyletab · GitHub
| | | |---Pull Requests · piroor/treestyletab · GitHub
| | | |---Commits · piroor/treestyletab · GitHub
| | | |---TST-MiddleClick – Add-ons for Firefox
| | | |---Tree Style Tab Mouse Wheel – Add-ons for Firefox
| | | | |---Reviews for Tree Style Tab Mouse Wheel – Add-ons for Firefox
| | | |---Tree Style Tab Open in Private – Add-ons for Firefox
| | | |---Tree Style Tab Closed Tabs – Add-ons for Firefox
| | | | |---Reviews for Tree Style Tab Closed Tabs – Add-ons for Firefox
| | |---Reviews for Tree Style Tab – Add-ons for Firefox
| |---Multiple Tab Handler – Add-ons for Firefox
| | |---GitHub - piroor/multipletab: Multiple Tab Handler, Provides feature to close multiple tabs.
| | | |---Issues · piroor/multipletab · GitHub
| | | |---Pull Requests · piroor/multipletab · GitHub
| | | |---Commits · piroor/multipletab · GitHub
|---Tab Session Manager – Add-ons for Firefox
Firefox Nightly News – Let's improve quality, build after build!
|---These Weeks in Firefox: Issue 29 – Firefox Nightly News
| |---Using the new theming API in Firefox – Mozilla Hacks – the Web developer blog
| |---Roadmap Review: Sync and Storage
To illustrate how I think ancestor counting should be done I made another example for the copied text but this time with only the last 10 of the tabs above selected:
[TST] HTML Link:
Multiple Tab Handler – Add-ons for Firefox
|---GitHub - piroor/multipletab: Multiple Tab Handler, Provides feature to close multiple tabs.
| |---Issues · piroor/multipletab · GitHub
| |---Pull Requests · piroor/multipletab · GitHub
| |---Commits · piroor/multipletab · GitHub
Tab Session Manager – Add-ons for Firefox
Firefox Nightly News – Let's improve quality, build after build!
|---These Weeks in Firefox: Issue 29 – Firefox Nightly News
| |---Using the new theming API in Firefox – Mozilla Hacks – the Web developer blog
| |---Roadmap Review: Sync and Storage
Notice how relationships to tabs that weren't copied is ignored.
For example "Tab Session Manager – Add-ons for Firefox" is shown without parent tabs even though it actually has one.
The text was updated successfully, but these errors were encountered: