Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
openairinterface5G
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Kun
openairinterface5G
Commits
d45551dd
Commit
d45551dd
authored
8 years ago
by
Cédric Roux
Browse files
Options
Downloads
Patches
Plain Diff
deal with scroll in text list
parent
f0d32a86
No related branches found
Branches containing commit
Tags
2016.w50
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
common/utils/T/tracer/view/textlist.c
+61
-3
61 additions, 3 deletions
common/utils/T/tracer/view/textlist.c
with
61 additions
and
3 deletions
common/utils/T/tracer/view/textlist.c
+
61
−
3
View file @
d45551dd
...
...
@@ -17,11 +17,12 @@ struct textlist {
list
*
volatile
to_append
;
};
static
void
_append
(
struct
textlist
*
this
,
char
*
s
)
static
void
_append
(
struct
textlist
*
this
,
char
*
s
,
int
*
deleted
)
{
if
(
this
->
cursize
==
this
->
maxsize
)
{
text_list_del_silent
(
this
->
g
,
this
->
w
,
0
);
this
->
cursize
--
;
(
*
deleted
)
++
;
}
text_list_add_silent
(
this
->
g
,
this
->
w
,
s
,
-
1
,
FOREGROUND_COLOR
);
this
->
cursize
++
;
...
...
@@ -31,18 +32,32 @@ static void *textlist_thread(void *_this)
{
struct
textlist
*
this
=
_this
;
int
dirty
;
int
deleted
;
int
visible_lines
,
start_line
,
number_of_lines
;
while
(
1
)
{
if
(
pthread_mutex_lock
(
&
this
->
lock
))
abort
();
dirty
=
this
->
to_append
==
NULL
?
0
:
1
;
deleted
=
0
;
while
(
this
->
to_append
!=
NULL
)
{
char
*
s
=
this
->
to_append
->
data
;
this
->
to_append
=
list_remove_head
(
this
->
to_append
);
_append
(
this
,
s
);
_append
(
this
,
s
,
&
deleted
);
free
(
s
);
}
if
(
pthread_mutex_unlock
(
&
this
->
lock
))
abort
();
if
(
dirty
)
widget_dirty
(
this
->
g
,
this
->
w
);
if
(
dirty
)
{
text_list_state
(
this
->
g
,
this
->
w
,
&
visible_lines
,
&
start_line
,
&
number_of_lines
);
if
(
this
->
autoscroll
)
start_line
=
number_of_lines
-
visible_lines
;
else
start_line
-=
deleted
;
if
(
start_line
<
0
)
start_line
=
0
;
text_list_set_start_line
(
this
->
g
,
this
->
w
,
start_line
);
/* this call is not necessary, but if things change in text_list... */
widget_dirty
(
this
->
g
,
this
->
w
);
}
sleepms
(
1000
/
this
->
refresh_rate
);
}
...
...
@@ -65,6 +80,45 @@ static void append(view *_this, char *s)
if
(
pthread_mutex_unlock
(
&
this
->
lock
))
abort
();
}
static
void
scroll
(
void
*
private
,
gui
*
g
,
char
*
notification
,
widget
*
w
,
void
*
notification_data
)
{
struct
textlist
*
this
=
private
;
int
visible_lines
;
int
start_line
;
int
number_of_lines
;
int
new_line
;
int
inc
;
text_list_state
(
g
,
w
,
&
visible_lines
,
&
start_line
,
&
number_of_lines
);
inc
=
10
;
if
(
inc
>
visible_lines
-
2
)
inc
=
visible_lines
-
2
;
if
(
inc
<
1
)
inc
=
1
;
if
(
!
strcmp
(
notification
,
"scrollup"
))
inc
=
-
inc
;
new_line
=
start_line
+
inc
;
if
(
new_line
>
number_of_lines
-
visible_lines
)
new_line
=
number_of_lines
-
visible_lines
;
if
(
new_line
<
0
)
new_line
=
0
;
text_list_set_start_line
(
g
,
w
,
new_line
);
if
(
new_line
+
visible_lines
<
number_of_lines
)
this
->
autoscroll
=
0
;
else
this
->
autoscroll
=
1
;
}
static
void
click
(
void
*
private
,
gui
*
g
,
char
*
notification
,
widget
*
w
,
void
*
notification_data
)
{
struct
textlist
*
this
=
private
;
int
*
d
=
notification_data
;
int
button
=
d
[
1
];
if
(
button
==
1
)
this
->
autoscroll
=
1
-
this
->
autoscroll
;
}
view
*
new_textlist
(
int
maxsize
,
float
refresh_rate
,
gui
*
g
,
widget
*
w
)
{
struct
textlist
*
ret
=
calloc
(
1
,
sizeof
(
struct
textlist
));
...
...
@@ -82,6 +136,10 @@ view *new_textlist(int maxsize, float refresh_rate, gui *g, widget *w)
if
(
pthread_mutex_init
(
&
ret
->
lock
,
NULL
))
abort
();
register_notifier
(
g
,
"scrollup"
,
w
,
scroll
,
ret
);
register_notifier
(
g
,
"scrolldown"
,
w
,
scroll
,
ret
);
register_notifier
(
g
,
"click"
,
w
,
click
,
ret
);
new_thread
(
textlist_thread
,
ret
);
return
(
view
*
)
ret
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment