Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Synchronet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
Main
Synchronet
Commits
c5624ae3
Commit
c5624ae3
authored
20 years ago
by
deuce
Browse files
Options
Downloads
Patches
Plain Diff
Use the new mouse API (Origin of the console window is 1,1 now, not 0,0)
parent
f53b220e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/uifc/GNUmakefile
+1
-0
1 addition, 0 deletions
src/uifc/GNUmakefile
src/uifc/uifc32.c
+65
-81
65 additions, 81 deletions
src/uifc/uifc32.c
with
66 additions
and
81 deletions
src/uifc/GNUmakefile
+
1
−
0
View file @
c5624ae3
...
...
@@ -2,6 +2,7 @@ XPDEV := ../xpdev/
UIFC_SRC
:=
./
NEED_UIFC
:=
1
USE_UIFC32
:=
1
NEED_THREADS
:=
1
include
$(XPDEV)Common.gmake
include
$(UIFC_SRC)Common.gmake
...
...
This diff is collapsed.
Click to expand it.
src/uifc/uifc32.c
+
65
−
81
View file @
c5624ae3
...
...
@@ -110,6 +110,18 @@ static void reset_dynamic(void) {
/* Returns 0 on success. */
/****************************************************************************/
void
uifc_mouse_enable
(
void
)
{
ciomouse_setevents
(
1
<<
CIOLIB_BUTTON_1_CLICK
|
1
<<
CIOLIB_BUTTON_3_CLICK
);
showmouse
();
}
void
uifc_mouse_disable
(
void
)
{
ciomouse_setevents
(
0
);
hidemouse
();
}
int
kbwait
(
void
)
{
int
timeout
=
0
;
while
(
timeout
++<
50
)
{
...
...
@@ -165,16 +177,6 @@ int uifcini32(uifcapi_t* uifcapi)
ESCDELAY
=
api
->
esc_delay
;
#endif
#ifdef PDCURSES
/*
* "ALL DESCRIPTIONS ARE GUESSES. I DON'T KNOW ANYONE WHO KNOWS EXACTLY WHAT THESE FUNCTIONS DO!"
*
* if(mouse_set(BUTTON1_CLICKED|BUTTON3_CLICKED)==0)
* api->mode|=UIFC_MOUSE;
* else
* mouse_set(0);
*/
#endif
if
(
api
->
scrn_len
!=
0
)
{
switch
(
api
->
scrn_len
)
{
#ifdef C80X14
...
...
@@ -296,37 +298,11 @@ int uifcini32(uifcapi_t* uifcapi)
return
(
0
);
}
static
int
uifc_getmouse
(
struct
cio_mouse_event
*
mevent
)
{
mevent
->
x
=
0
;
mevent
->
y
=
0
;
mevent
->
button
=
0
;
if
(
api
->
mode
&
UIFC_MOUSE
)
{
getmouse
(
mevent
);
if
(
mevent
->
button
==
2
)
return
(
ESC
);
if
(
mevent
->
y
==
api
->
buttony
)
{
if
(
mevent
->
x
>=
api
->
exitstart
&&
mevent
->
x
<=
api
->
exitend
&&
mevent
->
button
==
1
)
{
return
(
ESC
);
}
if
(
mevent
->
x
>=
api
->
helpstart
&&
mevent
->
x
<=
api
->
helpend
&&
mevent
->
button
==
1
)
{
return
(
CIO_KEY_F
(
1
));
}
}
return
(
0
);
}
return
(
-
1
);
}
void
uifcbail
(
void
)
{
_setcursortype
(
_NORMALCURSOR
);
textattr
(
LIGHTGRAY
);
hidemous
e
();
uifc_mouse_disabl
e
();
clrscr
();
#ifdef __unix__
if
(
cio_api
.
mode
==
CIOLIB_MODE_CURSES
)
{
...
...
@@ -421,7 +397,7 @@ int ulist(int mode, int left, int top, int width, int *cur, int *bar
uint
s_right
=
SCRN_RIGHT
;
uint
s_bottom
=
api
->
scrn_len
-
3
;
uint
title_len
;
struct
cio_
mouse_event
mevnt
;
struct
mouse_event
mevnt
;
char
*
title
;
int
a
,
b
,
c
,
longopt
;
...
...
@@ -431,7 +407,7 @@ int ulist(int mode, int left, int top, int width, int *cur, int *bar
return
(
-
1
);
}
strcpy
(
title
,
initial_title
);
hidemous
e
();
uifc_mouse_disabl
e
();
title_len
=
strlen
(
title
);
...
...
@@ -762,7 +738,7 @@ int ulist(int mode, int left, int top, int width, int *cur, int *bar
if
(
mode
&
WIN_IMM
)
return
(
-
2
);
showmous
e
();
uifc_mouse_enabl
e
();
while
(
1
)
{
#if 0 /* debug */
...
...
@@ -777,24 +753,26 @@ int ulist(int mode, int left, int top, int width, int *cur, int *bar
if
(
i
==
BS
)
i
=
ESC
;
if
(
i
==
CIO_KEY_MOUSE
)
{
if
((
i
=
uifc_getmouse
(
&
mevnt
))
==
0
)
{
if
((
i
=
getmouse
(
&
mevnt
))
==
0
)
{
if
(
mevnt
.
event
==
CIOLIB_BUTTON_3_CLICK
)
i
=
ESC
;
/* Clicked in menu */
if
(
mevnt
.
x
>=
s_left
+
left
+
2
&&
mevnt
.
x
<=
s_left
+
left
+
width
&&
mevnt
.
y
>=
s_top
+
top
+
2
&&
mevnt
.
y
<=
(
s_top
+
top
+
height
)
-
3
&&
mevnt
.
button
==
1
)
{
if
(
mevnt
.
start
x
>=
s_left
+
left
+
3
&&
mevnt
.
start
x
<=
s_left
+
left
+
width
+
1
&&
mevnt
.
start
y
>=
s_top
+
top
+
3
&&
mevnt
.
start
y
<=
(
s_top
+
top
+
height
)
-
2
&&
mevnt
.
event
==
CIOLIB_BUTTON_1_CLICK
)
{
(
*
cur
)
=
(
mevnt
.
y
)
-
(
s_top
+
top
+
2
);
(
*
cur
)
=
(
mevnt
.
start
y
)
-
(
s_top
+
top
+
3
);
if
(
bar
)
(
*
bar
)
=
(
*
cur
);
y
=
top
+
3
+
((
mevnt
.
y
)
-
(
s_top
+
top
+
2
));
y
=
top
+
3
+
((
mevnt
.
start
y
)
-
(
s_top
+
top
+
3
));
if
(
!
opts
)
continue
;
if
(
mode
&
WIN_ACT
)
{
hidemous
e
();
uifc_mouse_disabl
e
();
if
((
win
=
(
char
*
)
MALLOC
((
width
+
3
)
*
(
height
+
2
)
*
2
))
==
NULL
)
{
cprintf
(
"UIFC line %d: error allocating %u bytes."
,
__LINE__
,(
width
+
3
)
*
(
height
+
2
)
*
2
);
...
...
@@ -811,14 +789,14 @@ int ulist(int mode, int left, int top, int width, int *cur, int *bar
puttext
(
s_left
+
left
,
s_top
+
top
,
s_left
+
left
+
width
-
1
,
s_top
+
top
+
height
-
1
,
win
);
free
(
win
);
showmous
e
();
uifc_mouse_enabl
e
();
}
else
if
(
mode
&
WIN_SAV
)
{
hidemous
e
();
uifc_mouse_disabl
e
();
puttext
(
sav
[
api
->
savnum
].
left
,
sav
[
api
->
savnum
].
top
,
sav
[
api
->
savnum
].
right
,
sav
[
api
->
savnum
].
bot
,
sav
[
api
->
savnum
].
buf
);
showmous
e
();
uifc_mouse_enabl
e
();
free
(
sav
[
api
->
savnum
].
buf
);
api
->
savdepth
--
;
}
...
...
@@ -827,9 +805,9 @@ int ulist(int mode, int left, int top, int width, int *cur, int *bar
return
(
*
cur
);
}
/* Clicked Scroll Up */
if
(
mevnt
.
x
==
s_left
+
left
&&
mevnt
.
y
==
s_top
+
top
+
2
&&
mevnt
.
button
==
1
)
{
if
(
mevnt
.
start
x
==
s_left
+
left
+
1
&&
mevnt
.
start
y
==
s_top
+
top
+
3
&&
mevnt
.
event
==
CIOLIB_BUTTON_1_CLICK
)
{
if
(
!
opts
)
continue
;
*
cur
-=
(
height
-
5
);
...
...
@@ -857,9 +835,9 @@ int ulist(int mode, int left, int top, int width, int *cur, int *bar
continue
;
}
/* Clicked Scroll Down */
if
(
mevnt
.
x
==
s_left
+
left
&&
mevnt
.
y
==
(
s_top
+
top
+
height
)
-
3
&&
mevnt
.
button
==
1
)
{
if
(
mevnt
.
start
x
==
s_left
+
left
+
1
&&
mevnt
.
start
y
==
(
s_top
+
top
+
height
)
-
2
&&
mevnt
.
event
==
CIOLIB_BUTTON_1_CLICK
)
{
if
(
!
opts
)
continue
;
*
cur
+=
(
height
-
5
);
...
...
@@ -1544,7 +1522,7 @@ int ugetstr(int left, int top, int width, char *outstr, int max, long mode, int
int
i
,
j
,
k
,
f
=
0
;
/* i=offset, j=length */
BOOL
gotdecimal
=
FALSE
;
int
soffset
=
0
;
struct
cio_
mouse_event
mevnt
;
struct
mouse_event
mevnt
;
if
((
str
=
(
uchar
*
)
malloc
(
max
+
1
))
==
NULL
)
{
cprintf
(
"UIFC line %d: error allocating %u bytes
\r\n
"
...
...
@@ -1579,11 +1557,13 @@ int ugetstr(int left, int top, int width, char *outstr, int max, long mode, int
#endif
f
=
inkey
();
if
(
f
==
CIO_KEY_MOUSE
)
{
if
((
f
=
uifc_getmouse
(
&
mevnt
))
==
0
)
{
if
(
mevnt
.
x
>=
left
-
1
&&
mevnt
.
x
<=
left
+
width
-
1
&&
mevnt
.
button
==
1
)
{
i
=
mevnt
.
x
-
left
+
soffset
+
1
;
if
((
f
=
getmouse
(
&
mevnt
))
==
0
)
{
if
(
mevnt
.
event
==
CIOLIB_BUTTON_3_CLICK
)
f
=
ESC
;
if
(
mevnt
.
startx
>=
left
&&
mevnt
.
startx
<=
left
+
width
&&
mevnt
.
event
==
CIOLIB_BUTTON_1_CLICK
)
{
i
=
mevnt
.
startx
-
left
+
soffset
;
if
(
i
>
j
)
i
=
j
;
}
...
...
@@ -1619,11 +1599,13 @@ int ugetstr(int left, int top, int width, char *outstr, int max, long mode, int
ch
=
f
;
f
=
0
;
if
(
ch
==
CIO_KEY_MOUSE
)
{
if
((
ch
=
uifc_getmouse
(
&
mevnt
))
==
0
)
{
if
(
mevnt
.
x
>=
left
-
1
&&
mevnt
.
x
<=
left
+
width
-
1
&&
mevnt
.
button
==
1
)
{
i
=
mevnt
.
x
-
left
+
soffset
+
1
;
if
((
ch
=
getmouse
(
&
mevnt
))
==
0
)
{
if
(
mevnt
.
event
==
CIOLIB_BUTTON_3_CLICK
)
ch
=
ESC
;
if
(
mevnt
.
startx
>=
left
&&
mevnt
.
startx
<=
left
+
width
&&
mevnt
.
event
==
CIOLIB_BUTTON_1_CLICK
)
{
i
=
mevnt
.
startx
-
left
+
soffset
;
if
(
i
>
j
)
i
=
j
;
}
...
...
@@ -2002,7 +1984,7 @@ void showbuf(int mode, int left, int top, int width, int height, char *title, ch
int
pad
=
1
;
int
is_redraw
=
0
;
uint
title_len
=
0
;
struct
cio_
mouse_event
mevnt
;
struct
mouse_event
mevnt
;
_setcursortype
(
_NOCURSOR
);
...
...
@@ -2180,24 +2162,26 @@ void showbuf(int mode, int left, int top, int width, int height, char *title, ch
j
=
inkey
();
if
(
j
==
CIO_KEY_MOUSE
)
{
/* Ignores return value to avoid hitting help/exit hotspots */
if
(
uifc_getmouse
(
&
mevnt
)
>=
0
)
{
if
(
getmouse
(
&
mevnt
)
>=
0
)
{
if
(
mevnt
.
event
==
CIOLIB_BUTTON_3_CLICK
)
j
=
ESC
;
/* Clicked Scroll Up */
if
(
mevnt
.
x
>=
left
+
pad
-
1
&&
mevnt
.
x
<=
left
+
pad
+
width
-
4
&&
mevnt
.
y
>=
top
+
pad
&&
mevnt
.
y
<=
top
+
pad
+
(
height
/
2
)
-
3
&&
mevnt
.
button
==
1
)
{
if
(
mevnt
.
start
x
>=
left
+
pad
&&
mevnt
.
start
x
<=
left
+
pad
+
width
-
3
&&
mevnt
.
start
y
>=
top
+
pad
+
1
&&
mevnt
.
start
y
<=
top
+
pad
+
(
height
/
2
)
-
2
&&
mevnt
.
event
==
CIOLIB_BUTTON_1_CLICK
)
{
p
=
p
-
((
width
-
4
)
*
2
*
(
height
-
5
));
if
(
p
<
textbuf
)
p
=
textbuf
;
continue
;
}
/* Clicked Scroll Down */
if
(
mevnt
.
x
>=
left
+
pad
-
1
&&
mevnt
.
x
<=
left
+
pad
+
width
-
1
&&
mevnt
.
y
<=
top
+
pad
+
height
-
3
&&
mevnt
.
y
>=
top
+
pad
+
height
-
(
height
/
2
+
1
)
-
3
&&
mevnt
.
button
==
1
)
{
if
(
mevnt
.
start
x
>=
left
+
pad
&&
mevnt
.
start
x
<=
left
+
pad
+
width
&&
mevnt
.
start
y
<=
top
+
pad
+
height
-
2
&&
mevnt
.
start
y
>=
top
+
pad
+
height
-
(
height
/
2
+
1
)
-
2
&&
mevnt
.
event
==
CIOLIB_BUTTON_1_CLICK
)
{
p
=
p
+
(
width
-
4
)
*
2
*
(
height
-
5
);
if
(
p
>
textbuf
+
(
lines
-
height
+
1
)
*
(
width
-
4
)
*
2
)
p
=
textbuf
+
(
lines
-
height
+
1
)
*
(
width
-
4
)
*
2
;
...
...
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