- Subject: Re: updated ffx -- file dialog
- From: "Klaus Schmid" <klaus.schmid@xxxxxx>
- Date: Thu, 19 Jun 2003 16:07:30 +0200
> To make the recent files capable for multi sessions, it seems there is no
> other
> way to read/write from/on disk at each reference. With a hidden buffer and
> Jed's modified-query function some read's could be avoided. To speed up
> I used get_doc_string_from_file, but in slow environments it probably gets
> annoying or even unusable and this feature has to be turned off.
> Any opinion?
Here my current opinion, yet only as pseudo-code:
common logic
if mode_sync_extra % tries to synchronize most frequently
mode_sync= 1
if mode_sync % tries to synchronize normally
mode_file= 1 % synchronize at minimum (startup, on change,
exit)
file_changed_on_disk ==
file_changed_on_disk_ or file_yet_not_loaded
actions at different places:
at startup
get buffer_file_strings
if buffer_file_strings
if mode_sync
load file
read file_list
merge buffer_file_strings
write buffer
if mode_sync
write file
before file_dialog
read buffer_list
if file_changed_on_disk
load file
read file_list
if buffer_list
merge buffer_list
write buffer
if mode_sync_extra
write file
after file_dialog
if strings_to_save
read buffer_list
merge strings_to_save
if (mode_sync and file_changed_on_disk)
read file_list
merge file_list
write buffer
if mode_sync
write file
on exit
if (mode_file and buffer_list)
if file_changed_on_disk
read buffer_list
load file
read file_list
merge buffer_list
write buffer
if file_changed_on_disk or buffer_modified
write file
This should be self-explanatory, if not please read
this or complain and I will try to explain:
file: file in which file strings are saved
buffer: buffer in which file strings are saved
xxx_list: list of file strings from xxx
load file: load file into buffer (read_file)
read xxx_list: read xxx_list from buffer
merge xxx: merge xxx to current list
write buffer: write current list to buffer
write file: write buffer to file (save_buffer)
To get it work, the merge function must respect
the time-stamps appended on each file string.
The merge function already exists:
define rcl_merge( a1, a2, m) % m: number of chars of each appended
time-stamp
{
variable x, i, a, b, c;
% normal map: 0:L-1-m L-m:L-1
% swapped: 0:m-1 m:L-1
% remove doubles, keep latest
a= [ a1, a2];
a= a[array_sort(a)];
x= Integer_Type[length(a)]; x[*]= 1;
b= a[-1][[:-1-m]];
for (i=2;i<=length(a);i++)
{
c= a[-i][[:-1-m]];
if ( c == b)
x[-i]= 0;
else
b= c;
}
a= a[where(x)];
% sort by time stamp
for (i=0;i<length(a);i++)
a[i]= a[i][[-m:]]+a[i][[:-1-m]];
a= a[array_sort(a)];
for (i=0;i<length(a);i++)
a[i]= a[i][[m:]]+a[i][[:m-1]];
return a;
}
Thanks for looking into this.
Comments, improvements or bugfixes welcome.
-- Klaus
--------------------------
To unsubscribe send email to <jed-users-request@xxxxxxxxxxx> with
the word "unsubscribe" in the message body.
Need help? Email <jed-users-owner@xxxxxxxxxxx>.
[2003 date index]
[2003 thread index]
[Thread Prev] [Thread Next]
[Date Prev] [Date Next]