Undo Last Closed history
Posted by: mhf
Date: September 22, 2010 11:40AM

I have the Close Tab button showing which has a small context menu in which there is the option to Undo Last Closed (tab) - I was wondering if it would be possible (and difficult) to add a sort of History to that option which would allow you to choose which previously closed tab you would like to Undo...?

What do you think ? smiling smiley

Re: Undo Last Closed history
Posted by: siria
Date: September 22, 2010 12:47PM

I think there's already a macro which does exactly that grinning smiley
One is called "PriorTabs", but guess there was a second one, just can't remember for sure... if yes, it was in the last months in the extension-forum here.
And if I get that right, Gecko1.9/KM1.6 supports this natively...
http://kmeleon.sourceforge.net/wiki/KMeleon16

Re: Undo Last Closed history
Posted by: mhf
Date: September 22, 2010 03:26PM

Thanks siria - I tried PriorTabs but it messed up my toolbars and menus...!

KM 1.5.4

Re: Undo Last Closed history
Posted by: siria
Date: September 22, 2010 10:28PM

Yikes - why that?? No prob here. Some incompatibility with some other macro perhaps??

What does the error console say? Make sure the KMM button is checked.
In case it's vanished from tools, go to this page:
chrome://console2/content/console2.xul
(I've set it as Home Page since I'm experimenting a lot and occasionally manage to kill the macros.dll, then the error console vanishes from the menu :coolsmiling smiley



Edited 2 time(s). Last edit at 09/22/2010 10:30PM by siria.

Re: Undo Last Closed history
Posted by: mhf
Date: September 23, 2010 09:58AM

Quote
siria
Yikes - why that?? No prob here. Some incompatibility with some other macro perhaps??

What does the error console say? Make sure the KMM button is checked.
In case it's vanished from tools, go to this page:
chrome://console2/content/console2.xul
(I've set it as Home Page since I'm experimenting a lot and occasionally manage to kill the macros.dll, then the error console vanishes from the menu :coolsmiling smiley

Don't know why...grinning smiley

The KMM button IS checked (or was as I've uninstalled PriorTabs).
Menus were shortened, missing items, tool bar buttons missing. I suppose it must be a conflict but with what ?

Re: Undo Last Closed history
Posted by: siria
Date: September 23, 2010 10:33AM

The error console mostly tells which line disables all macros, but only while the error exists. So you must put priortabs.kmm into the macros folder and restart again :cool:

Re: Undo Last Closed history
Posted by: mhf
Date: September 23, 2010 11:18AM

I did that : reinstalled PriorTabs, restarted KM, went to the Error Console and there's nothing in it !

Re: Undo Last Closed history
Posted by: desga2
Date: September 23, 2010 10:31PM

PriorTabs.kmm is a macro in test status, are you sure to read full thread (2 pages) and get it the last code and fixes?

When this macro will be revised, it must be added to MacroLibrary.

@ mhf:
Can you post your PriorTabs.kmm code?

K-Meleon in Spanish

Re: Undo Last Closed history
Posted by: siria
Date: September 23, 2010 11:08PM

Oops... yes you're right, that's not finished yet! Had forgotten that, because it works okay with the changes we did later, it was just never posted as a new complete file yet.

Re: Undo Last Closed history
Posted by: mhf
Date: September 24, 2010 11:58AM

Quote
desga2
PriorTabs.kmm is a macro in test status, are you sure to read full thread (2 pages) and get it the last code and fixes?

When this macro will be revised, it must be added to MacroLibrary.

Yes you are right, I copied the code from this message :

Re: Re-Open Tabs Macro
Posted by: JamesD
Date: June 30, 2009 06:12PM

i.e. on page one.

Looking forward to a final version !

Thanks all, Martin.

Re: Undo Last Closed history
Posted by: jsnj
Date: September 24, 2010 06:39PM

Quote
mhf
Quote
desga2
PriorTabs.kmm is a macro in test status, are you sure to read full thread (2 pages) and get it the last code and fixes?

When this macro will be revised, it must be added to MacroLibrary.

Yes you are right, I copied the code from this message :

Re: Re-Open Tabs Macro
Posted by: JamesD
Date: June 30, 2009 06:12PM

i.e. on page one.

Looking forward to a final version !

Thanks all, Martin.

That version should work. It did for me on KMv1.6 pre beta. It might have been a simple copy & paste error from forums to file. Until JamesD posts the final version, try this one which simply defines $_PriorTabs_ini_Value to avoid the console errors and changes where Prior Tabs is located in menus to under View below Tabs, under Sessions below Undo Last Closed and in the Tab context menu below Tabs. The rest of the code is all JamesD's from the 2009 posting.

*I'd also recommend changing the name to "Closed Tabs" or "Tabs Closed"instead of "Prior Tabs" as Siria suggested to be consistent w/the other Close Tab menu items.



Edited 2 time(s). Last edit at 09/24/2010 07:10PM by jsnj.

Attachments: PriorTabs.kmm (4 KB)  
Re: Undo Last Closed history
Posted by: JamesD
Date: September 24, 2010 08:17PM

I am away from home this week. Maybe I can work on this next week. If anyone else wishes to take over they can. I had never expected in 2009 that this would become a project. It started as a simple code example.

I will check back early next week.

Re: Undo Last Closed history
Posted by: mhf
Date: September 24, 2010 09:43PM

Yup ! Working as you said - thanks a million.

Re: Undo Last Closed history
Posted by: JamesD
Date: September 28, 2010 12:00PM

I will try to finish this macro sometime this week. I do not know why I stopped work in 2009. I did not even remember that PriorTabs was my work until someone pointed it out.

I must merge my work with the new items from jsnj and look at all the recent request/suggestions.

See also: http://kmeleonbrowser.org/forum/read.php?1,94047,110849,page=2#msg-110849

Re: Undo Last Closed history
Posted by: JamesD
Date: September 28, 2010 04:20PM

I have found my copy of PriorTabs, copied the posted code, and downloaded the code that jsnj fixed. I have each running in a different install of KM. Two are 1.6.0a4 and one in 1.5.4. I don't see a problem with the menus nor do I see any items in the error console. I have even commented out jsnj's line of code and I still see no errors. Could I have a problem with my error consoles?

I will have a look at the other menu locations. I am not at all sure about the sessions menu. PriorTabs does not create a session.



Edited 1 time(s). Last edit at 09/28/2010 06:59PM by JamesD.

Re: Undo Last Closed history
Posted by: JamesD
Date: September 28, 2010 07:07PM

I have tried to make the tab title show in the menu and I found a problem. The menu system has a limit on the width of an item. When I appended the title to the URL some, often most, of the title was truncated in the menu.

There is also the problem of the length that an ini file can store. I think that is 255. If I reverse the order of the item stored and both title and URL are long, then part of the URL might get truncated and then the system would not work.

I will try the append of URL to title and see what happens.

Re: Undo Last Closed history
Posted by: JamesD
Date: September 28, 2010 07:32PM

Here is some updated code. http://dl.dropbox.com/u/1522294/PriorTabs.7z

Putting the title before the URL seems to work. There is no check for a combined length exceeding 255. I have kept jsnj's additional menu locations. Thank you, jsnj, for that work

As always, comments and suggestions are welcome.

Please report any kmm items showing in your error console.

Re: Undo Last Closed history
Posted by: mhf
Date: September 29, 2010 11:20AM

Quote
JamesD
Here is some updated code. http://dl.dropbox.com/u/1522294/PriorTabs.7z

Putting the title before the URL seems to work. There is no check for a combined length exceeding 255. I have kept jsnj's additional menu locations. Thank you, jsnj, for that work

As always, comments and suggestions are welcome.

Please report any kmm items showing in your error console.

Thanks JamesD, it's working fine, the titles are showing and there are no errors about kmm in the error console. I'm not sure about the ~~~~ (squiggles) though between the title and the URL, but no big deal.

Re: Undo Last Closed history
Posted by: JamesD
Date: September 29, 2010 12:22PM

Quote
mhf
I'm not sure about the ~~~~ (squiggles) though between the title and the URL, but no big deal.
The title and url are stored as a single string. The '~~' is used to mark the point where the title stops and the url starts. I could use another character. Whatever character is used, it must be one that has little chance of being found in a title.

Re: Undo Last Closed history
Posted by: JamesD
Date: September 29, 2010 03:30PM

Here is what I hope is a final version. http://dl.dropbox.com/u/1522294/PriorTabs.7z

I have added code to handle long title and url lines. If the title plus url is too long then only the url is used. If the url is too long then the user get a warning message and nothing is stored.

I will wait some time for feedback and then see about putting in the MacroLibrary.

Re: Undo Last Closed history
Posted by: mhf
Date: October 01, 2010 09:32PM

Quote
JamesD
I will wait some time for feedback and then see about putting in the MacroLibrary.

Took me a while to get back here. I installed the latest and all went well until I started closing tabs which I usually do with middle-click : bang, KM closed. It didn't crash, no error messages, just disappeared. So I tried again but this time closing tabs with either close tab in the tab context menu or Ctrl+F4 : KM closed.

I uninstalled PriorTabs and no more problems.

Sorry to be a problem :s

Re: Undo Last Closed history
Posted by: JamesD
Date: October 01, 2010 10:17PM

@ mhf

I just tried the middle click method. I had no problems. I also tried Ctrl+F4 and the context menu. I did not have a problem. My normal method to close a tab is the x button on the tab bar. I don't use the x on the tab itself, because that crashes my KM.

I am using KM 1.6.0a4 now but I also have PriorTabs running on 1.5.4. My system is XP-SP3 fully updated.

I am not sure I understand about the other close methods. Did every method cause your KM to close?

Re: Undo Last Closed history
Posted by: siria
Date: October 01, 2010 11:02PM

Uh oh... weird...

Must admit I haven't tried the new macro myself yet, but it's always very difficult to figure out things if everything works fine on the own system.

Uhm, sorry can't resist, have no idea what could be the prob, just a little suggestion for mhf, if you like and have time? smiling smiley

Just for circling the bug a bit - the code below is a copy of the submacro which is executed when closing a tab, except that it has 9 numbered alert boxes inserted, one after each step it does, to easier figure out which of the steps could cause your problem...

-----

_PriorTabs_CreateList_TEST {
alert("","priortest-0");
&_PriorTabs_CheckForLength ;
alert("","priortest-1");
&_PriorTabs_CheckListForDup ;
alert("","priortest-2");
$_PriorTabs_CurrType < 2 ? $_PriorTabs_Count = $_PriorTabs_Count + 1 : 0 ;
if ($_PriorTabs_WasDup == 0) {
alert("","priortest-3");
$_PriorTabs_CurrType == 0 ? iniwrite("List", $_PriorTabs_Count, $TITLE . "~~" . $URL, $_PriorTabs_Path) :0;
alert("","priortest-4");
$_PriorTabs_CurrType == 1 ? iniwrite("List", $_PriorTabs_Count, "~~" . $URL, $_PriorTabs_Path) :0;
alert("","priortest-5");
$_PriorTabs_CurrType == 2 ? alert(_("URL length exceeds storage"). "\n" ._("Unable to store tab"), _("PriorTabs"), EXCLAIM) :0;
}
alert("","priortest-6");
if ($_PriorTabs_WasDup == 1) {
alert("","priortest-7");
&_PriorTabs_ClearListMenu;
}
alert("","priortest-8");
&_PriorTabs_BuildListMenu ;
$_PriorTabs_WasDup = 0 ;
}

---------

If in this line near the end:
#---------------------------------------------
$OnCloseTab=$OnCloseTab."_PriorTabs_CreateList;";


you just insert a "_TEST":
$OnCloseTab=$OnCloseTab."_PriorTabs_CreateList_TEST;";

and add the code block from above at the end of the file, it will flood you with numbered alert boxes for every closed tab :cool:



Edited 1 time(s). Last edit at 10/01/2010 11:03PM by siria.

Re: Undo Last Closed history
Posted by: JamesD
Date: October 02, 2010 12:20AM

@ mhf

One other test you might try would be to change the value to which the length of the title + url is compared. This happens in lines 62 and 65. Change the number from 255 to 250. Maybe the length in your case was 254 and that plus the 'X=' was then greater than what is allowed with iniwrite. Each tab is numbered in the ini file. So if your tab lenght plus the number and equal sign became greater than 255, I think KM might fail.

Desga2 found some problem with this when we were working with Groups2. I will have to do a search and try to find what happened when the 255 limit was exceeded.

Re: Undo Last Closed history
Posted by: mhf
Date: October 02, 2010 12:18PM

@ JamesD and siria - OK I'll have a go this afternoon and try to get back with the results this evening...

Re: Undo Last Closed history
Posted by: JamesD
Date: October 05, 2010 03:32PM

I am looking for some feedback on PriorTabs. I would like to say it is finished and put it into the MacroLibrary. If you have used the latest version of PriorTabs, please report results here.

A problem was reported by mhf. I need to know if that is common or isolated.

PriorTabs can be found here: http://dl.dropbox.com/u/1522294/PriorTabs.7z

Re: Undo Last Closed history
Posted by: mhf
Date: October 05, 2010 05:57PM

Sorry I didn't get back when I said I would - things happen - OK, so I reduced the length from 255 to 250 and the problem goes away. btw I don't have the X showing on tabs.

So thanks JamesD and all - it's working fine here now and is a very useful addon.

Re: Undo Last Closed history
Posted by: JamesD
Date: October 05, 2010 08:54PM

@ mhf

Thanks, I will revise the code to use 250 instead of 255 as the point at which the macro should change methods.

Re: Undo Last Closed history
Posted by: JamesD
Date: October 05, 2010 09:05PM

The revised code for PriorTabs is here: http://dl.dropbox.com/u/1522294/PriorTabs.7z

Re: Undo Last Closed history
Posted by: JamesD
Date: October 06, 2010 12:54PM

PriorTabs is now in the Macro Library. My thanks to everyone who helped.

K-Meleon forum is powered by Phorum.