Development :
K-Meleon Web Browser Forum
K-Meleon development related discussions.
Close left tabs, close right tabs
Posted by:
mhf
Date: July 21, 2009 11:27AM
One thing I really like(d) in TabMix Plus for FF was the possibility to close tabs on the left etc. from the context menu when right-clicking on a tab - could someone help me to add this ?
Thanks !
Re: Close left tabs, close right tabs
Date: July 21, 2009 05:24PM
You can close any open tab by double left-clicking on it.
Re: Close left tabs, close right tabs
Date: July 21, 2009 05:44PM
@ mhf:
This can be do with a macro, you can begin to make it when you want.
K-Meleon in Spanish
Re: Close left tabs, close right tabs
Posted by:
mhf
Date: July 21, 2009 06:26PM
@Yogi, yes I know that but it's not what I asked about : say you have ten tabs open, you're on the middle tab and you want to close all the tabs on the right (or left)...
Quote
desga2
@ mhf:
This can be do with a macro, you can begin to make it when you want.
What if I buy you a beer ?
Re: Close left tabs, close right tabs
Date: July 22, 2009 08:54PM
Can someone find for me the name of the menu which appears when you right click on a tab. I thought it was "TabButtonPopup". I found that in menus.cfg
# ----- Tabs
%ifplugin tabs
TabButtonPopup{
!New
!CloseTab
!NavTab
-
:T&abs
}
%endif
Either that is the wrong item or my setmenu statements are not valid.
# K-Meleon Macros (http://kmeleon.sourceforge.net/wiki/index.php?id=MacroLanguage)
#
# ---------- EndTabLR.kmm
# ---------- K-Meleon Macro Language Close all tabs to left or right of current ---
#
# Dependencies : main.kmm, tabs plugin active
# Resources : -
# Preferences : -
# Version : 0.2 2009-07-22
# --------------------------------------------------------------------------------
_CloseAllLeft {
alert("close all left", "DEBUG", INFO);
}
_CloseAllRight {
alert("close all right", "DEBUG", INFO);
}
_EndTabLR_ModMenu{
### add another option to menu
setmenu("TabButtonPopup",macro,_("Close All Left"), _CloseAllLeft );
setmenu("TabButtonPopup",macro,_("Close All Right"),_CloseAllRight );
$OnStartup=$OnStartup."_EndTabLR_ModMenu;";
#$OnInit=$OnInit."_EndTabLR_ModMenu;";
$macroModules=$macroModules."EndTabLR;";
Re: Close left tabs, close right tabs
Posted by:
mhf
Date: July 22, 2009 10:02PM
I'm following you JamesD but I don't know enough (anything) about it so can't help
but it's looking good !
Re: Close left tabs, close right tabs
Date: July 22, 2009 10:43PM
Menu is right.
Your bug is in function code:
_EndTabLR_ModMenu{
### add another option to menu
setmenu("TabButtonPopup",macro,_("Close All Left"), _CloseAllLeft );
setmenu("TabButtonPopup",macro,_("Close All Right"),_CloseAllRight );
} <= CLOSE THE FUNCTION !!!
K-Meleon in Spanish
Re: Close left tabs, close right tabs
Date: July 23, 2009 10:35AM
@ desga2
Well, I have egg all over my face again. Thank you for spotting the missing brace.
I guess my next project will be to automate the Error Console to run OnStartup if user pref "k-meleon.errorchecking" is set to true. Then I will have to remember to set the pref when starting a new project.
Re: Close left tabs, close right tabs
Date: July 23, 2009 02:08PM
@ mhf
This is not as automatic as I had hoped. There does not seem to be a variable to inform the MacroLanguage of the index number of the current tab. For now, at least, you must eyeball the tab bar or tab list and enter a number for how many tabs to delete.
EndTabLR.kmm
# K-Meleon Macros (http://kmeleon.sourceforge.net/wiki/index.php?id=MacroLanguage)
#
# ---------- EndTabLR.kmm
# ---------- K-Meleon Macro Language Close all previous or next tabs from current --
#
# Dependencies : main.kmm, tabs plugin active
# Resources : -
# Preferences : -
# Version : 0.4 2009-07-23
# --------------------------------------------------------------------------------
_EndTabLR_CloseLeft {
$_EndTabLR_TabCount = prompt ("How many previous tabs to close?","Enter an integer");
$_EndTabLR_Count=0;
while ($_EndTabLR_Count < $_EndTabLR_TabCount) {
id(ID_TAB_PREV) ;
id(ID_CLOSE_TA ;
$_EndTabLR_Count=$_EndTabLR_Count+1;
}
}
_EndTabLR_CloseRight {
$_EndTabLR_TabCount = prompt ("How many next tabs to close?","Enter an integer");
$_EndTabLR_Count=0;
while ($_EndTabLR_Count < $_EndTabLR_TabCount) {
id(ID_TAB_NEXT) ;
id(ID_CLOSE_TA ;
$_EndTabLR_Count=$_EndTabLR_Count+1;
}
}
_EndTabLR_ModMenu {
## add another option to menu
setmenu ("TabButtonPopup",separator, -1 );
setmenu ("TabButtonPopup",macro, _("Close # Previous Tabs"), "_EndTabLR_CloseLeft" );
setmenu ("TabButtonPopup",macro, _("Close # Next Tabs"), "_EndTabLR_CloseRight" );
}
$OnStartup=$OnStartup."_EndTabLR_ModMenu;";
#$OnInit=$OnInit."_EndTabLR_ModMenu;";
$macroModules=$macroModules."EndTabLR;";
Re: Close left tabs, close right tabs
Posted by:
mhf
Date: July 23, 2009 03:55PM
Thanks JamesD - I'll give it a spin and let you know how it goes.
Re: Close left tabs, close right tabs
Date: July 23, 2009 04:55PM
@ JamesD:
But you know the current $URL and $TITLE, you can compare it with the others to find it.
Start in first tab, compare $URL with tabs and when this is match you have the current tab number and you can close other tabs to left or right without prompt for how much you want to close.
K-Meleon in Spanish
Edited 4 time(s). Last edit at 07/24/2009 06:27AM by desga2.
Re: Close left tabs, close right tabs
Posted by:
mhf
Date: July 23, 2009 05:03PM
The prompt window opens for right-hand tabs but not for left-hand.
Re: Close left tabs, close right tabs
Posted by:
mhf
Date: July 23, 2009 05:06PM
And the context menu has disappeared on the GO button !!!
Re: Close left tabs, close right tabs
Date: July 23, 2009 05:32PM
@ mhf
Fix for context menu on Go button --
Change the # from $OnInit to $OnStartup, save file, and try it.
#$OnStartup=$OnStartup."_EndTabLR_ModMenu;";
$OnInit=$OnInit."_EndTabLR_ModMenu;";
$macroModules=$macroModules."EndTabLR;";
Quote
mhf
The prompt window opens for right-hand tabs but not for left-hand.
I am seeing both. I don't know why you are not.
Wait while I try to implement desga2's suggestion.
Re: Close left tabs, close right tabs
Posted by:
mhf
Date: July 23, 2009 05:43PM
Quote
JamesD
@ mhf
Fix for context menu on Go button --
Change the # from $OnInit to $OnStartup, save file, and try it.
#$OnStartup=$OnStartup."_EndTabLR_ModMenu;";
$OnInit=$OnInit."_EndTabLR_ModMenu;";
$macroModules=$macroModules."EndTabLR;";
Quote
mhf
The prompt window opens for right-hand tabs but not for left-hand.
I am seeing both. I don't know why you are not.
Wait while I try to implement desga2's suggestion.
YES for both - thanks.
Re: Close left tabs, close right tabs
Date: July 23, 2009 05:46PM
Quote
desga2
But you now the current $URL and $Title, you can compare it with the others to find it.
Start in first tab, compare $URL with tabs and when this is match you have the current tab number and you can close other tabs to left or right without prompt for how much you want to close.
How do I determine the first tab? I can compare next with current until I have a match, but then all I will know is how many total tabs. That is already available. I first tried to close each "next" tab thinking that would end at right most tab. Every tab but the current one closed. It made a circle and came back down the left or previous side. Also I think users can clone a tab. I would get an early match then, would I not?
Re: Close left tabs, close right tabs
Date: July 23, 2009 11:25PM
@ mhf
Are you still not seeing a prompt for Previous?
I have had no luck in making macro more automatic. I am seeing prompts for both next and previous. I will post my most recent code.
EndTabLR.kmm
# K-Meleon Macros (http://kmeleon.sourceforge.net/wiki/index.php?id=MacroLanguage)
#
# ---------- EndTabLR.kmm
# ---------- K-Meleon Macro Language Close all previous or next tabs from current --
#
# Dependencies : main.kmm, tabs plugin active
# Resources : -
# Preferences : -
# Version : 0.5 2009-07-23
# --------------------------------------------------------------------------------
_EndTabLR_CloseLeft {
$_EndTabLR_TabCount = prompt ("How many previous tabs to close?","Enter an integer");
$_EndTabLR_Count=0;
while ($_EndTabLR_Count < $_EndTabLR_TabCount) {
id(ID_TAB_PREV) ;
id(ID_CLOSE_TA ;
$_EndTabLR_Count=$_EndTabLR_Count+1;
}
}
_EndTabLR_CloseRight {
$_EndTabLR_TabCount = prompt ("How many next tabs to close?","Enter an integer");
$_EndTabLR_Count=0;
while ($_EndTabLR_Count < $_EndTabLR_TabCount) {
id(ID_TAB_NEXT) ;
id(ID_CLOSE_TA ;
$_EndTabLR_Count=$_EndTabLR_Count+1;
}
}
_EndTabLR_ModMenu {
setmenu ("TabButtonPopup",separator, -1 );
setmenu ("TabButtonPopup",macro, _("Close # Previous Tabs"), "_EndTabLR_CloseLeft" );
setmenu ("TabButtonPopup",macro, _("Close # Next Tabs"), "_EndTabLR_CloseRight" );
}
# - - - - - - - - - - - - - - - - - - - - - - - -
$OnInit=$OnInit."_EndTabLR_ModMenu;";
$macroModules=$macroModules."EndTabLR;";
Re: Close left tabs, close right tabs
Posted by:
mhf
Date: July 24, 2009 11:31AM
@ JamesD - thanks for the new code, everything works fine and I do see both prompt boxes and the context menu is back on the GO button !
Re: Close left tabs, close right tabs
Date: July 24, 2009 12:05PM
@ mhf
That's great. I wish I could get full automation but the critical piece of data, the tab number of the current tab, does not seem to be available to the MacroLanguage.
Re: Close left tabs, close right tabs
Posted by:
mhf
Date: July 24, 2009 02:54PM
@ JamesD - it's OK, it's fine like that although of course fully automatic would be better.
I'd have thought the tab information must be in there somewhere because of the "Close other tabs" command...?
Re: Close left tabs, close right tabs
Date: July 24, 2009 04:01PM
Quote
mhf
I'd have thought the tab information must be in there somewhere because of the "Close other tabs" command...?
There is a specific Command ID to do that.
Quote
http://kmeleon.sourceforge.net/wiki/CommandIDs
ID_CLOSE_ALLOTHERTAB
Only 1.5 and later. Close all other tabs but not current active tab.
@TabList knows the position of the current tab, but it not provided to the MacroLanguage. The "Tabs" item in the menu just above "Close # Previous Tabs" shows a check next to the current tab within the list of tabs. It would be great if we had a Special Variable "$TabIndex" which contained the position of the check. However, we don't. We have only "$TabNumber" which is the total number of tabs in the window.
Re: Close left tabs, close right tabs
Posted by:
mhf
Date: July 24, 2009 04:05PM
OK, I understand better now and thanks again.
Re: Close left tabs, close right tabs
Date: July 24, 2009 11:12PM
i think it's very good cause sometimes you don't want to close all tabs on the left or on the right..so number input can be a good thing. it's like a feature
i've added endtabs to kmext under enhancements next to autotab switcher