Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Cameron Cawley
Browse
Commits
6864b4e4
Commit
6864b4e4
authored
27 years ago
by
Andrew Hodgkinson
Browse files
Options
Download
Email Patches
Plain Diff
A bit more tidying up
parent
f3e8124f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
151 additions
and
76 deletions
+151
-76
c/Hotlist
c/Hotlist
+151
-76
No files found.
c/Hotlist
View file @
6864b4e4
...
...
@@ -79,8 +79,6 @@ static unsigned int hotlist_bbar_size = 0; /* Height in OS units
static
unsigned
int
alter_new
;
/* Remembers if the edit dialogue is Alter or New; see */
/* HOTLIST_MENUSECTION_NEW and HOTLIST_MENUSECTION_ALTER */
static
unsigned
int
item_number
;
/* Current item being considered for drawing */
static
hotlist_item
*
hotlist_save_item
=
NULL
;
/* Item whose URL is being saved */
static
int
hotlist_ram_transfer_sent
;
/* Number of bytes which have already been sent by ram transfer */
static
int
hotlist_save_type
=
HL_SAVE_NONE
;
/* Variety of save currently in progress */
...
...
@@ -167,11 +165,10 @@ static _kernel_oserror * hotlist_draw (hotlist_item * list, u
static
_kernel_oserror
*
hotlist_draw_r
(
hotlist_item
*
list
,
unsigned
int
first_item
,
unsigned
int
last_item
,
int
*
curr_item
,
unsigned
int
indent
,
unsigned
int
item_height
,
unsigned
int
item_dir_width
,
unsigned
int
item_url_width
);
static
unsigned
int
hotlist_contents_selected
(
hotlist_item
*
item
);
static
unsigned
int
hotlist_no_contents_selected
(
hotlist_item
*
item
);
// Need renaming to hotlist_get_max_width_r and hotlist_redraw_now_r
static
void
_hotlist_get_max_width
(
hotlist_item
*
list
,
unsigned
int
indent
);
static
void
_hotlist_redraw_now
(
hotlist_item
*
list
);
static
void
hotlist_redraw_now
(
void
);
static
unsigned
int
hotlist_get_max_width
(
hotlist_item
*
list
);
static
_kernel_oserror
*
hotlist_get_max_width_r
(
hotlist_item
*
list
,
unsigned
int
indent
,
int
*
max_width
,
unsigned
int
item_height
,
unsigned
int
item_dir_width
,
unsigned
int
item_url_width
);
static
void
hotlist_redraw_now
(
void
);
static
void
hotlist_redraw_now_r
(
hotlist_item
*
list
,
int
*
curr_item
);
static
void
hotlist_get_shape
(
unsigned
int
*
xmin
,
unsigned
int
*
xmax
,
hotlist_item
*
item
);
static
void
hotlist_directory_open_close
(
hotlist_item
*
item
,
unsigned
int
itemno
);
static
void
hotlist_redraw_items
(
unsigned
int
firstitem
,
unsigned
int
lastitem
);
...
...
@@ -983,7 +980,7 @@ static _kernel_oserror * hotlist_get_entry_sizes(unsigned int * item_height, uns
/* Set the URL width to the value found above and add 8 to */
/* all of them for aesthetics. */
if
(
item_url_width
)
*
item_url_width
=
width
+
8
;
/* +8 for aesthetics */
if
(
item_url_width
)
*
item_url_width
=
width
+
8
;
if
(
item_dir_width
)
*
item_dir_width
+=
8
;
if
(
item_height
)
*
item_height
+=
8
;
...
...
@@ -1650,106 +1647,183 @@ static _kernel_oserror * hotlist_draw_r(hotlist_item *list, unsigned int first_i
}
/*************************************************/
/* _hotlist_get_max_width */
/* hotlist_get_max_width_r */
/* */
/* Recursive back-end to hotlist_get_max_width. */
/* */
/* Parameters: Pointer to a hotlist_item struct */
/* to start at; */
/* */
/* This function does all the work for */
/* hotlist_get_max_width */
/* An indent in OS units, as for */
/* redrawing the hotlist; */
/* */
/* Pointer to an int, in which the */
/* width of the widest item so far */
/* is accumulated; */
/* */
/* Height of a hotlist item in OS */
/* units; */
/* */
/* Width of a hotlist directory */
/* sprite in OS units; */
/* */
/* Width of a hotlist URL sprite in */
/* OS units. */
/* */
/* Assumes: The pointer to the int may *not* */
/* be NULL. */
/*************************************************/
static
void
_hotlist_get_max_width
(
hotlist_item
*
list
,
unsigned
int
indent
)
static
_kernel_oserror
*
hotlist_get_max_width_r
(
hotlist_item
*
list
,
unsigned
int
indent
,
int
*
max_width
,
unsigned
int
item_height
,
unsigned
int
item_dir_width
,
unsigned
int
item_url_width
)
{
unsigned
int
item_height
,
item_dir_width
,
item_url_width
;
unsigned
int
tem
p
_width
;
int
text_width
;
_kernel_oserror
*
e
;
unsigned
int
i
tem_width
;
int
text_width
;
hotlist_get_entry_sizes
(
&
item_height
,
&
item_dir_width
,
&
item_url_width
);
while
(
list
)
while
(
list
)
{
switch
(
list
->
type
)
/* Get width of the icon */
switch
(
list
->
type
)
{
case
hl_directory
:
temp_width
=
item_dir_width
;
break
;
case
hl_directory
:
item_width
=
item_dir_width
;
break
;
case
hl_url
:
item_width
=
item_url_width
;
break
;
default:
item_width
=
0
;
break
;
}
case
hl_url
:
temp_width
=
item_url_width
;
break
;
/* Work out width of the text */
default:
temp_width
=
0
;
break
;
}
if
(
list
->
type
==
hl_url
&&
hl_show_urls
)
e
=
utils_text_width
(
list
->
data
.
url
,
&
text_width
,
0
);
else
e
=
utils_text_width
(
list
->
name
,
&
text_width
,
0
)
;
if
(
e
)
return
e
;
if
(
list
->
type
==
hl_url
&&
hl_show_urls
)
utils_text_width
(
list
->
data
.
url
,
&
text_width
,
0
);
else
utils_text_width
(
list
->
name
,
&
text_width
,
0
);
/* Account for the indent and spacers (aesthetics) */
tem
p
_width
+=
indent
+
2
+
text_width
+
12
;
i
tem_width
+=
indent
+
2
+
text_width
+
12
;
if
(
temp_width
>
item_number
)
item_number
=
temp_width
;
/* If this is wider than so far recorded, store the new value */
if
(
item_width
>
*
max_width
)
*
max_width
=
item_width
;
/* Recursive call for open directories */
if
(
list
->
type
==
hl_directory
&&
list
->
flags
&
HOTLIST_D_IS_OPEN
)
{
_hotlist_get_max_width
(
list
->
data
.
directory_content
,
indent
+
item_dir_width
);
RetError
(
hotlist_get_max_width_r
(
list
->
data
.
directory_content
,
indent
+
item_dir_width
,
max_width
,
item_height
,
item_dir_width
,
item_url_width
));
}
/* Move on down the list */
list
=
list
->
next
;
item_number
++
;
}
return
NULL
;
}
/*************************************************/
/* hotlist_get_max_width() */
/* */
/* This function returns the maximum width of */
/* of the displayed hotlist entries
*/
/* of the displayed hotlist entries
.
*/
/* */
/* Parameters: Pointer to a hotlist_item struct */
/* to start at. This is assumed to */
/* be at zero indent from the left */
/* hand side. */
/* */
/* Returns: Of all visible entries, the width */
/* of the widest, in OS units. */
/*************************************************/
static
unsigned
int
hotlist_get_max_width
(
hotlist_item
*
list
)
static
unsigned
int
hotlist_get_max_width
(
hotlist_item
*
list
)
{
item_number
=
0
;
_hotlist_get_max_width
(
list
,
0
);
return
item_number
;
unsigned
int
item_height
,
item_dir_width
,
item_url_width
;
int
widest
=
0
;
/* Find basic item size information */
if
(
hotlist_get_entry_sizes
(
&
item_height
,
&
item_dir_width
,
&
item_url_width
))
return
0
;
/* Scan the directory and all open directories with in it for */
/* the widest item */
if
(
hotlist_get_max_width_r
(
list
,
0
,
&
widest
,
item_height
,
item_dir_width
,
item_url_width
))
return
0
;
/* Return the result */
return
widest
;
}
/*************************************************/
/* _hotlist_redraw_now() */
/* */
/* This function does the work for */
/* hotlist_redraw_now() */
/* */
/* This function redraws all visible items with */
/* the HOTLIST_G_REDRAW_NOW bit set. */
/*************************************************/
static
void
_
hotlist_redraw_now
(
hotlist_item
*
list
)
static
void
hotlist_redraw_now
(
void
)
{
while
(
list
)
int
curr_item
=
0
;
hotlist_redraw_now_r
(
hotlist_root
->
data
.
directory_content
,
&
curr_item
);
}
/*************************************************/
/* hotlist_redraw_now_r() */
/* */
/* Recursive back-end to hotlist_redraw_now. */
/* */
/* Parameters: Pointer to a hotlist_item struct */
/* to start on; */
/* */
/* Pointer to an int, in which the */
/* current item number being redrawn */
/* is accumulated. */
/* */
/* Assumes: The pointer to the int may *not* */
/* be NULL. */
/*************************************************/
static
void
hotlist_redraw_now_r
(
hotlist_item
*
list
,
int
*
curr_item
)
{
while
(
list
)
{
if
(
list
->
flags
&
HOTLIST_G_REDRAW_NOW
)
{
hotlist_redraw_items
(
item_number
,
item_number
);
/* Redraw just the one item */
hotlist_redraw_items
(
*
curr_item
,
*
curr_item
);
/* Clear the flag */
list
->
flags
&=
~
HOTLIST_G_REDRAW_NOW
;
}
item_number
++
;
*
curr_item
+=
1
;
if
(
list
->
type
==
hl_directory
&&
list
->
flags
&
HOTLIST_D_IS_OPEN
)
{
_hotlist_redraw_now
(
list
->
data
.
directory_content
);
/* Recursive call for open directories */
hotlist_redraw_now_r
(
list
->
data
.
directory_content
,
curr_item
);
}
list
=
list
->
next
;
}
}
/*************************************************/
/* hotlist_redraw_now() */
/* */
/* This function redraws all visible items with */
/* the HOTLIST_G_REDRAW_NOW bit set */
/*************************************************/
static
void
hotlist_redraw_now
(
void
)
{
item_number
=
0
;
_hotlist_redraw_now
(
hotlist_root
->
data
.
directory_content
);
}
/*************************************************/
/* hotlist_add() */
/* */
...
...
@@ -2432,10 +2506,6 @@ static _kernel_oserror * hotlist_save_entries(FILE * fileptr, hotlist_item * lis
int
written
;
_kernel_oserror
*
e
;
/* Write the entry header */
//HotlistWrite(fprintf(fileptr, "<ul>\n"));
/* Follow the directory list */
while
(
list
)
...
...
@@ -2461,9 +2531,17 @@ static _kernel_oserror * hotlist_save_entries(FILE * fileptr, hotlist_item * lis
{
HotlistWrite
(
fprintf
(
fileptr
,
"<h4>%s</h4>
\n
"
,
list
->
name
));
/* Recursive call for the directory contents */
/* Recursive call for the directory contents. First, */
/* write the entry header. */
HotlistWrite
(
fprintf
(
fileptr
,
"<ul>
\n
"
));
/* Do the contents */
RetError
(
hotlist_save_entries
(
fileptr
,
list
->
data
.
directory_content
,
type
));
/* Write the entry footer */
HotlistWrite
(
fprintf
(
fileptr
,
"</ul>
\n
"
));
}
}
...
...
@@ -2475,10 +2553,6 @@ static _kernel_oserror * hotlist_save_entries(FILE * fileptr, hotlist_item * lis
list
=
list
->
next
;
}
/* Write the entry footer */
//HotlistWrite(fprintf(fileptr, "</ul>\n"));
return
NULL
;
}
...
...
@@ -2488,13 +2562,14 @@ static _kernel_oserror * hotlist_save_entries(FILE * fileptr, hotlist_item * lis
/* This function saves the hotlist as an HTML */
/* file. */
/* */
/* Parameters: Pointer to the filename to
load
*/
/* (null terminated)
.
*/
/* Parameters: Pointer to the filename to
save
*/
/*
to
(null terminated)
;
*/
/* */
/* 0
-
save all of hotlist
*/
/*
1 -
only
sav
e select
ion
portions */
/* 0
to
save all of hotlist
, 1 to
*/
/*
save
only
th
e select
ed
portions
.
*/
/*************************************************/
_kernel_oserror
*
hotlist_save_hotlist
(
char
*
filename
,
int
type
)
_kernel_oserror
*
hotlist_save_hotlist
(
char
*
filename
,
int
type
)
{
FILE
*
fileptr
;
_kernel_oserror
*
e
;
...
...
@@ -2546,10 +2621,10 @@ _kernel_oserror * hotlist_save_hotlist(char *filename, int type)
/* hotlist_save() */
/* */
/* Veneer onto hotlist_save_hotlist - saves all */
/* of the hotlist, created to preserve API
*/
/* of the hotlist, created to preserve API
.
*/
/* */
/* Parameters: Pointer to the filename to
load
*/
/* (null terminated).
*/
/* Parameters: Pointer to the filename to
save
*/
/*
under
(null terminated). */
/*************************************************/
_kernel_oserror
*
hotlist_save
(
char
*
filename
)
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment