Discussion:
Switching to last edited document when opening project
Andrius
2013-09-22 15:29:50 UTC
Permalink
Here is the patch that would provide saving of more information about state of the opened documents, and after re-opening of the project, it would configure all documents to the previous state and switch to the last edited tab.
Changes are following:
project->files stringlist is changed to array list, which would include, together with uri also cursor position, textview offset and whether document is current or not.
Then, during project load, the textview is scrolled to the last position and cursor is placed to last known position, so one can continue editing from where he left. This is done for all documents in project.
Large number of files needed modification, mostly because modifications of doc_new_from_uri() and file_doc_from_uri(), which now has variables for cursor offset and textview alignment method.
I would be glad to receive feedback regarding this patch, if it is acceptable, and if the speed of opening of the first document is good enough...
Theoretically, first document loading speed might be improved even more, with some further modifications to doc_new_from_uri() and file_doc_from_uri() to pass higher event priority for last edited document to the callbacks that does document loading and configuration.
Andrius
________________________________
Sent: Tuesday, September 3, 2013 4:01 PM
Subject: Re: Switching to last edited document when opening project
I would vote to make it always enabled, because perceived loading speed doesnt mater much for me, anyway I need to scroll to document manually. Would it be OK first to make it not selectable for testing and evaluation, and if there will be complains, I can always add project setting at the later time?
Andrius
________________________________
Sent: Monday, September 2, 2013 11:22 PM
Subject: Re: Switching to last edited document when opening project
Hi,
right now when opening project, bluefish activates document in the notepad somewhat randomly, depending on processor and file system speed. Sometimes it activates tab #1, but most often  #5 or even #7. Would it be there interest to add code to activate the last edited document, maybe even to scroll to the same part of document that was edited last? In this case after closing project and re-opening one would be able to continue from where he left.
Andrius
The current code is optimized to show the first document that has
finished loading, in the meanwhile all other documents continue to
load. The perceived loading speed for a project is very high this
way. This obviously only makes sense if project loading is slow
because either there are many many files, or because the connection
to the server with the files is slow.
I agree that for local small projects the loading speed doesn't
matter at all, so retaining the last opened document and line number
would be a nice feature indeed. Perhaps a project setting "load
optimize for speed / load with restored current document and line
numbers " is a good thing? Or should we enable it always?
Olivier
--
Bluefish website http://bluefish.openoffice.nl/
Blog http://oli4444.wordpress.com/
Olivier Sessink
2013-09-22 19:08:31 UTC
Permalink
Post by Andrius
Here is the patch that would provide saving of more information about
state of the opened documents, and after re-opening of the project, it
would configure all documents to the previous state and switch to the
last edited tab.
project->files stringlist is changed to array list, which would
include, together with uri also cursor position, textview offset and
whether document is current or not.
Then, during project load, the textview is scrolled to the last
position and cursor is placed to last known position, so one can
continue editing from where he left. This is done for all documents in
project.
Large number of files needed modification, mostly because
modifications of doc_new_from_uri() and file_doc_from_uri(), which now
has variables for cursor offset and textview alignment method.
I would be glad to receive feedback regarding this patch, if it is
acceptable, and if the speed of opening of the first document is good
enough...
Theoretically, first document loading speed might be improved even
more, with some further modifications to doc_new_from_uri() and
file_doc_from_uri() to pass higher event priority for last edited
document to the callbacks that does document loading and configuration.
Andrius
excellent job!

from reading the patch I have no comments at all.

one question that you might want to test: if you load 20 documents, make
sure that only the active document is syntax-scanned. Syntax scanning
takes a lot of CPU. For example if you load 20 documents, and first
document 1 is active and later on you switch to document 15 because that
was the active document when the project was saved, you might scan them
both.

Olivier
--
Bluefish website http://bluefish.openoffice.nl/
Blog http://oli4444.wordpress.com/
Andrius
2013-09-23 13:15:03 UTC
Permalink
I think I took care regarding scanning since I disabled notebook signals during documents loading. In the log file I am seeing only one line like
scanning run 1 (19 ms): 0, 0, 0, 19; from 0-11211......
when loading project, so I assume only one documents was scanned. When I switch to another tab, then I get scanning run #2 and so on.

Andrius
________________________________
Sent: Sunday, September 22, 2013 10:08 PM
Subject: Re: Switching to last edited document when opening project
Here is the patch that would provide saving of more information about state of the opened documents, and after re-opening of the project, it would configure all documents to the previous state and switch to the last edited tab.
Post by Andrius
project->files stringlist is changed to array list, which would include, together with uri also cursor position, textview offset and whether document is current or not.
Then, during project load, the textview is scrolled to the last position and cursor is placed to last known position, so one can continue editing from where he left. This is done for all documents in project.
Large number of files needed modification, mostly because modifications of doc_new_from_uri() and file_doc_from_uri(), which now has variables for cursor offset and textview alignment method.
I would be glad to receive feedback regarding this patch, if it is acceptable, and if the speed of opening of the first document is good enough...
Theoretically, first document loading speed might be improved even more, with some further modifications to doc_new_from_uri() and file_doc_from_uri() to pass higher event priority for last edited document to the callbacks that does document loading and configuration.
Andrius
excellent job!
from reading the patch I have no comments at all.
one question that you might want to test: if you load 20 documents,
make sure that only the active document is syntax-scanned. Syntax
scanning takes a lot of CPU. For example if you load 20 documents,
and first document 1 is active and later on you switch to document
15 because that was the active document when the project was saved,
you might scan them both.
Olivier
--
Bluefish website http://bluefish.openoffice.nl/
Blog http://oli4444.wordpress.com/
Olivier Sessink
2013-09-23 19:17:23 UTC
Permalink
Post by Andrius
I think I took care regarding scanning since I disabled notebook signals
during documents loading. In the log file I am seeing only one line like
scanning run 1 (19 ms): 0, 0, 0, 19; from 0-11211......
when loading project, so I assume only one documents was scanned. When I
switch to another tab, then I get scanning run #2 and so on.
Andrius
sounds good to me. perhaps we can align this a little more with some
other bluefish code (previously this was done by setting
delay_activate=TRUE in doc_new), but we can look at that later (if
required at all). So feel free to commit!

Olivier
--
Bluefish website http://bluefish.openoffice.nl/
Blog http://oli4444.wordpress.com/
Andrius
2013-09-24 11:33:59 UTC
Permalink
I just committed patch. I did some speed improvements by setting different load priorities for current document and the rest. In my opinion, loading speed now shuld be the same as before.
Andrius
________________________________
Sent: Monday, September 23, 2013 10:17 PM
Subject: Re: Switching to last edited document when opening project
Post by Andrius
I think I took care regarding scanning since I disabled notebook signals
during documents loading. In the log file I am seeing only one line like
scanning run 1 (19 ms): 0, 0, 0, 19; from 0-11211......
when loading project, so I assume only one documents was scanned. When I
switch to another tab, then I get scanning run #2 and so on.
Andrius
sounds good to me. perhaps we can align this a little more with some
other bluefish code (previously this was done by setting
delay_activate=TRUE in doc_new), but we can look at that later (if
required at all). So feel free to commit!
Olivier
--
Bluefish website http://bluefish.openoffice.nl/
Blog http://oli4444.wordpress.com/
--
To unsubscribe from this list: send the line "unsubscribe bluefish-dev" in
Bluefish web site: http://bluefish.openoffice.nl/
Olivier Sessink
2013-09-24 14:37:12 UTC
Permalink
Post by Andrius
I just committed patch. I did some speed improvements by setting
different load priorities for current document and the rest. In my
opinion, loading speed now shuld be the same as before.
Andrius
what happens if you just set delay_activation to FALSE for the document
that should be focused? (in the call to doc_new_from_uri() from
project_open_from_file())

Olivier
--
Bluefish website http://bluefish.openoffice.nl/
Blog http://oli4444.wordpress.com/
Andrius
2013-09-24 15:34:33 UTC
Permalink
This would activate document that is in the load process and finishes loading. This will not the the document that is launched with delay_activation=FALSE, since this condition just sets bfwin->focus_next_new_doc = TRUE; which is not related to any particular document. Load callbacks is checking this condition, and activates first document that is successfully loaded.
This logic was used earlier, and resulted in random tab activated - on my system it was #5 usually, but for other projects it was #2 or #7, depending which file was first loaded with when bfwin->focus_next_new_doc = TRUE was set.
Andrius
________________________________
Sent: Tuesday, September 24, 2013 5:37 PM
Subject: Re: Switching to last edited document when opening project
I just committed patch. I did some speed improvements by setting different load priorities for current document and the rest. In my opinion, loading speed now shuld be the same as before.
Post by Andrius
Andrius
what happens if you just set delay_activation to FALSE for the
document that should be focused? (in the call to doc_new_from_uri()
from project_open_from_file())
Olivier
--
Bluefish website http://bluefish.openoffice.nl/ Blog http://oli4444.wordpress.com/
Olivier Sessink
2013-09-24 20:15:42 UTC
Permalink
hmm I just found an issue that we have to fix:

if somebody has a project with URL's in there, the project file contains
lines like:

files: sftp://olivier-9tyh7LrZqWhIKVk4D9YtbGZHpeb/A1Y/@public.gmane.org/home/olivier/tmp/jk_lib.c
files: sftp://olivier-9tyh7LrZqWhIKVk4D9YtbGZHpeb/A1Y/@public.gmane.org/home/olivier/tmp/mypython.py

this doesn't work with the new code, because the string is handled as an
array, so it is split up into

sftp

and

//olivier-9tyh7LrZqWhIKVk4D9YtbGZHpeb/A1Y/@public.gmane.org/home/olivier/tmp/jk_lib.c

both of them obviously not valid. So we'll have to add some code to make
bluefish backwards compatible with old project files.

what we could do is do the conversion in rcfile.c. load "files:" into a
temporary list, and load "files2:" in Tproject->files.

if we have any entries in the temporary list, and Tproject->files is
NULL, we convert the temporary list to an arraylist --> conversion done!
Does that sound like a good idea?

Olivier
--
Bluefish website http://bluefish.openoffice.nl/
Blog http://oli4444.wordpress.com/
Andrius
2013-09-25 04:20:47 UTC
Permalink
Oops,
Windows users will have problem too, since files entries in old format looks like this:
Y:\\Data\\Bluefish\\bluefish-2.2.4\\src\\bluefish.c
I think, for new projects there should be no problems since machinery in stringlist.c (string_to_array() and array_to_string() ) would take care of this by escaping : with \: .
There is common feature for both sftp:// and windows - the array would have just two elements, while new format file will have four. So, probably, if array has just two elements we can rejoin them in project.c using g_strjoin() ?
Andrius
________________________________
Sent: Tuesday, September 24, 2013 11:15 PM
Subject: Re: Switching to last edited document when opening project
if somebody has a project with URL's in there, the project file contains
this doesn't work with the new code, because the string is handled as an
array, so it is split up into
sftp
and
both of them obviously not valid. So we'll have to add some code to make
bluefish backwards compatible with old project files.
what we could do is do the conversion in rcfile.c. load "files:" into a
temporary list, and load "files2:" in Tproject->files.
if we have any entries in the temporary list, and Tproject->files is
NULL, we convert the temporary list to an arraylist --> conversion done!
Does that sound like a good idea?
Olivier
--
Bluefish website http://bluefish.openoffice.nl/
Blog http://oli4444.wordpress.com/
--
To unsubscribe from this list: send the line "unsubscribe bluefish-dev" in
Bluefish web site: http://bluefish.openoffice.nl/
Olivier Sessink
2013-09-25 20:20:14 UTC
Permalink
Post by Andrius
Oops,
Y:\\Data\\Bluefish\\bluefish-2.2.4\\src\\bluefish.c
I think, for new projects there should be no problems since machinery
in stringlist.c (string_to_array() and array_to_string() ) would take
care of this by escaping : with \: .
There is common feature for both sftp:// and windows - the array would
have just two elements, while new format file will have four. So,
probably, if array has just two elements we can rejoin them in
project.c using g_strjoin() ?
I guess that was a good solution too, but since there is quite a bit of
migration code in rcfile.c already I think it is best done there. I just
committed a patch to convert from old to new style project files.

Only project files from the last few days svn are not handled correctly ;-)

Olivier

Continue reading on narkive:
Loading...