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
cde16183
Commit
cde16183
authored
1 year ago
by
Deucе
Browse files
Options
Downloads
Patches
Plain Diff
More stuff, really just a checkpoint before I start rendering.
parent
e2bbb4d5
No related branches found
No related tags found
No related merge requests found
Pipeline
#5454
passed
1 year ago
Stage: build
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/newifc/GNUmakefile
+4
-3
4 additions, 3 deletions
src/newifc/GNUmakefile
src/newifc/genapi.c
+19
-5
19 additions, 5 deletions
src/newifc/genapi.c
src/newifc/root_window.c
+50
-19
50 additions, 19 deletions
src/newifc/root_window.c
with
73 additions
and
27 deletions
src/newifc/GNUmakefile
+
4
−
3
View file @
cde16183
CFLAGS
+=
-I
../xpdev
-I
../cutest
-pthread
CFLAGS
+=
-I
../conio
-I
../xpdev
-I
../cutest
-pthread
CFLAGS
+=
-DHAS_STDINT_H
CFLAGS
+=
-DHAS_STDINT_H
CFLAGS
+=
-DHAS_INTTYPES_H
CFLAGS
+=
-DHAS_INTTYPES_H
CFLAGS
+=
-g
-std
=
c11
-Wall
-Wextra
-Wpedantic
CFLAGS
+=
-g
-std
=
c11
-Wall
-Wextra
-Wpedantic
LIBS
+=
-lpthread
LDFLAGS
+=
-L
../conio/clang.freebsd.amd64.lib.portable
-L
../xpdev/clang.freebsd.amd64.lib.portable
LIBS
+=
-lpthread
-lciolib_mt
-lxpdev_mt
-lcursesw
-lm
VPATH
=
../cutest:../xpdev
VPATH
=
../cutest:../xpdev
...
@@ -10,7 +11,7 @@ ifdef TESTS
...
@@ -10,7 +11,7 @@ ifdef TESTS
CFLAGS
+=
-DBUILD_TESTS
CFLAGS
+=
-DBUILD_TESTS
all
:
runtest
all
:
runtest
test
:
alltests.o CuTest.o
threadwrap.o
libnewifc.a
test
:
alltests.o CuTest.o libnewifc.a
cc
${
LDFLAGS
}
-L
.
${
CFLAGS
}
$^
-o
$@
${
LIBS
}
-lnewifc
cc
${
LDFLAGS
}
-L
.
${
CFLAGS
}
$^
-o
$@
${
LIBS
}
-lnewifc
runtest
:
test
runtest
:
test
...
...
This diff is collapsed.
Click to expand it.
src/newifc/genapi.c
+
19
−
5
View file @
cde16183
...
@@ -67,7 +67,6 @@ attributes[] = {
...
@@ -67,7 +67,6 @@ attributes[] = {
{
"child_width"
,
NI_attr_type_uint16_t
,
attr_impl_global
,
1
},
{
"child_width"
,
NI_attr_type_uint16_t
,
attr_impl_global
,
1
},
{
"child_xpos"
,
NI_attr_type_uint16_t
,
attr_impl_global
,
1
},
{
"child_xpos"
,
NI_attr_type_uint16_t
,
attr_impl_global
,
1
},
{
"child_ypos"
,
NI_attr_type_uint16_t
,
attr_impl_global
,
1
},
{
"child_ypos"
,
NI_attr_type_uint16_t
,
attr_impl_global
,
1
},
{
"dirty"
,
NI_attr_type_bool
,
attr_impl_root
,
1
},
{
"fill_character"
,
NI_attr_type_uint32_t
,
attr_impl_global
,
0
},
{
"fill_character"
,
NI_attr_type_uint32_t
,
attr_impl_global
,
0
},
{
"fill_character_colour"
,
NI_attr_type_uint32_t
,
attr_impl_global
,
0
},
{
"fill_character_colour"
,
NI_attr_type_uint32_t
,
attr_impl_global
,
0
},
{
"fill_colour"
,
NI_attr_type_uint32_t
,
attr_impl_global
,
0
},
{
"fill_colour"
,
NI_attr_type_uint32_t
,
attr_impl_global
,
0
},
...
@@ -84,9 +83,6 @@ attributes[] = {
...
@@ -84,9 +83,6 @@ attributes[] = {
{
"min_width"
,
NI_attr_type_uint16_t
,
attr_impl_global
,
1
},
{
"min_width"
,
NI_attr_type_uint16_t
,
attr_impl_global
,
1
},
{
"parent"
,
NI_attr_type_NewIfcObj
,
attr_impl_global
,
1
},
{
"parent"
,
NI_attr_type_NewIfcObj
,
attr_impl_global
,
1
},
{
"root"
,
NI_attr_type_NewIfcObj
,
attr_impl_global
,
1
},
{
"root"
,
NI_attr_type_NewIfcObj
,
attr_impl_global
,
1
},
{
"show_help"
,
NI_attr_type_bool
,
attr_impl_object
,
0
},
{
"show_title"
,
NI_attr_type_bool
,
attr_impl_object
,
0
},
{
"title"
,
NI_attr_type_charptr
,
attr_impl_object
,
0
},
{
"topchild"
,
NI_attr_type_NewIfcObj
,
attr_impl_global
,
1
},
{
"topchild"
,
NI_attr_type_NewIfcObj
,
attr_impl_global
,
1
},
{
"type"
,
NI_attr_type_NewIfc_object
,
attr_impl_global
,
1
},
{
"type"
,
NI_attr_type_NewIfc_object
,
attr_impl_global
,
1
},
{
"width"
,
NI_attr_type_uint16_t
,
attr_impl_global
,
0
},
{
"width"
,
NI_attr_type_uint16_t
,
attr_impl_global
,
0
},
...
@@ -132,6 +128,7 @@ const struct handler_info
...
@@ -132,6 +128,7 @@ const struct handler_info
extra_handlers
[]
=
{
extra_handlers
[]
=
{
{
"on_render"
,
"NI_err (*on_render)(NewIfcObj obj, void *cbdata)"
},
{
"on_render"
,
"NI_err (*on_render)(NewIfcObj obj, void *cbdata)"
},
{
"on_destroy"
,
"NI_err (*on_destroy)(NewIfcObj obj, void *cbdata)"
},
{
"on_destroy"
,
"NI_err (*on_destroy)(NewIfcObj obj, void *cbdata)"
},
{
"on_key"
,
"NI_err (*on_key)(NewIfcObj obj, uint16_t scancode)"
},
};
};
size_t
size_t
...
@@ -319,7 +316,23 @@ main(int argc, char **argv)
...
@@ -319,7 +316,23 @@ main(int argc, char **argv)
}
}
fputs
(
"};
\n\n
"
,
header
);
fputs
(
"};
\n\n
"
,
header
);
fputs
(
"#define NI_TRANSPARENT UINT32_MAX
\n\n
"
,
header
);
fputs
(
"#define NI_TRANSPARENT UINT32_MAX
\n
"
"#define NI_BLACK UINT32_C(0)
\n
"
"#define NI_BLUE UINT32_C(0x0000A8)
\n
"
"#define NI_GREEN UINT32_C(0x00A800)
\n
"
"#define NI_CYAN UINT32_C(0x00A8A8)
\n
"
"#define NI_RED UINT32_C(0xA80000)
\n
"
"#define NI_MAGENTA UINT32_C(0xA800A8)
\n
"
"#define NI_BROWN UINT32_C(0xA85400)
\n
"
"#define NI_LIGHTGRAY UINT32_C(0xA8A8A8)
\n
"
"#define NI_DARKGRAY UINT32_C(0x545454)
\n
"
"#define NI_LIGHTBLUE UINT32_C(0x5454FF)
\n
"
"#define NI_LIGHTGREEN UINT32_C(0x54FF54)
\n
"
"#define NI_LIGHTCYAN UINT32_C(0x54FFFF)
\n
"
"#define NI_LIGHTRED UINT32_C(0xFF5454)
\n
"
"#define NI_LIGHTMAGENTA UINT32_C(0xFF54FF)
\n
"
"#define NI_YELLOW UINT32_C(0xFFFF54)
\n
"
"#define NI_WHITE UINT32_C(0xFFFFFF)
\n\n
"
,
header
);
fputs
(
"NI_err NI_copy(NewIfcObj obj, NewIfcObj *newobj);
\n
"
,
header
);
fputs
(
"NI_err NI_copy(NewIfcObj obj, NewIfcObj *newobj);
\n
"
,
header
);
fputs
(
"NI_err NI_create(enum NewIfc_object obj, NewIfcObj parent, NewIfcObj *newobj);
\n
"
,
header
);
fputs
(
"NI_err NI_create(enum NewIfc_object obj, NewIfcObj parent, NewIfcObj *newobj);
\n
"
,
header
);
...
@@ -485,6 +498,7 @@ main(int argc, char **argv)
...
@@ -485,6 +498,7 @@ main(int argc, char **argv)
" (*newobj)->topchild = NULL;
\n
"
" (*newobj)->topchild = NULL;
\n
"
" (*newobj)->bottomchild = NULL;
\n
"
" (*newobj)->bottomchild = NULL;
\n
"
" (*newobj)->handlers = NULL;
\n
"
" (*newobj)->handlers = NULL;
\n
"
" (*newobj)->handlers_sz = 0;
\n
"
" if (parent) {
\n
"
" if (parent) {
\n
"
" (*newobj)->root = parent->root;
\n
"
" (*newobj)->root = parent->root;
\n
"
" (*newobj)->lowerpeer = parent->topchild;
\n
"
" (*newobj)->lowerpeer = parent->topchild;
\n
"
...
...
This diff is collapsed.
Click to expand it.
src/newifc/root_window.c
+
50
−
19
View file @
cde16183
...
@@ -2,6 +2,8 @@
...
@@ -2,6 +2,8 @@
#include
<stdarg.h>
#include
<stdarg.h>
#include
<stdlib.h>
// malloc()/free()
#include
<stdlib.h>
// malloc()/free()
#define CIOLIB_NO_MACROS
#include
"ciolib.h"
#include
"genwrap.h"
#include
"genwrap.h"
#include
"strwrap.h"
#include
"strwrap.h"
#include
"threadwrap.h"
#include
"threadwrap.h"
...
@@ -19,12 +21,9 @@ static const char default_title[] = "No Title Set";
...
@@ -19,12 +21,9 @@ static const char default_title[] = "No Title Set";
struct
root_window
{
struct
root_window
{
struct
newifc_api
api
;
struct
newifc_api
api
;
char
*
title
;
struct
vmem_cell
*
display
;
size_t
title_sz
;
pthread_mutex_t
mtx
;
pthread_mutex_t
mtx
;
unsigned
locks
;
unsigned
locks
;
unsigned
show_title
:
1
;
unsigned
help
:
1
;
unsigned
dirty
:
1
;
unsigned
dirty
:
1
;
};
};
...
@@ -146,36 +145,68 @@ rw_copy(NewIfcObj old, NewIfcObj *newobj)
...
@@ -146,36 +145,68 @@ rw_copy(NewIfcObj old, NewIfcObj *newobj)
return
NewIfc_error_none
;
return
NewIfc_error_none
;
}
}
static
NI_err
rw_render
(
NewIfcObj
obj
,
uint16_t
xpos
,
uint16_t
ypos
,
uint16_t
width
,
uint16_t
height
)
{
struct
root_window
*
rw
=
(
struct
root_window
*
)
obj
;
size_t
sz
=
rw
->
api
.
width
;
sz
*=
rw
->
api
.
height
;
if
(
rw
->
api
.
fill_colour
!=
NI_TRANSPARENT
||
rw
->
api
.
fill_character_colour
!=
NI_TRANSPARENT
)
{
for
(
size_t
c
=
0
;
c
<
sz
;
c
++
)
{
// TODO: No way to generate legacy attribute from colour.
if
(
rw
->
api
.
fill_colour
!=
NI_TRANSPARENT
)
rw
->
display
[
c
].
bg
=
rw
->
api
.
fill_colour
;
if
(
rw
->
api
.
fill_character_colour
!=
NI_TRANSPARENT
)
{
rw
->
display
[
c
].
fg
=
rw
->
api
.
fill_character_colour
;
rw
->
display
[
c
].
ch
=
rw
->
api
.
fill_character
;
if
(
ciolib_checkfont
(
rw
->
api
.
fill_font
))
rw
->
display
[
c
].
font
=
rw
->
api
.
fill_font
;
}
}
}
}
static
NI_err
static
NI_err
NewIFC_root_window
(
NewIfcObj
*
newobj
)
NewIFC_root_window
(
NewIfcObj
*
newobj
)
{
{
struct
root_window
**
newrw
=
(
struct
root_window
**
)
newobj
;
struct
root_window
**
newrw
=
(
struct
root_window
**
)
newobj
;
*
newrw
=
m
alloc
(
sizeof
(
struct
root_window
));
*
newrw
=
c
alloc
(
1
,
sizeof
(
struct
root_window
));
if
(
*
newrw
==
NULL
)
{
if
(
*
newrw
==
NULL
)
return
NewIfc_error_allocation_failure
;
return
NewIfc_error_allocation_failure
;
}
(
*
newrw
)
->
api
.
get
=
rw_get
;
(
*
newrw
)
->
api
.
get
=
rw_get
;
(
*
newrw
)
->
api
.
set
=
rw_set
;
(
*
newrw
)
->
api
.
set
=
rw_set
;
(
*
newrw
)
->
api
.
copy
=
rw_copy
;
(
*
newrw
)
->
api
.
copy
=
rw_copy
;
(
*
newrw
)
->
api
.
last_error
=
NewIfc_error_none
;
(
*
newrw
)
->
api
.
last_error
=
NewIfc_error_none
;
(
*
newrw
)
->
api
.
width
=
80
;
(
*
newrw
)
->
api
.
height
=
25
;
(
*
newrw
)
->
api
.
child_width
=
80
;
(
*
newrw
)
->
api
.
child_height
=
25
;
(
*
newrw
)
->
api
.
xpos
=
0
;
(
*
newrw
)
->
api
.
ypos
=
0
;
(
*
newrw
)
->
api
.
child_xpos
=
0
;
(
*
newrw
)
->
api
.
child_ypos
=
1
;
(
*
newrw
)
->
api
.
child_ypos
=
1
;
(
*
newrw
)
->
api
.
min_height
=
2
;
(
*
newrw
)
->
api
.
min_width
=
40
;
// TODO: This is only needed by the unit tests...
// TODO: This is only needed by the unit tests...
(
*
newrw
)
->
api
.
root
=
*
newobj
;
(
*
newrw
)
->
api
.
root
=
*
newobj
;
(
*
newrw
)
->
api
.
focus
=
true
;
(
*
newrw
)
->
api
.
focus
=
true
;
(
*
newrw
)
->
locks
=
0
;
(
*
newrw
)
->
mtx
=
pthread_mutex_initializer_np
(
true
);
(
*
newrw
)
->
mtx
=
pthread_mutex_initializer_np
(
true
);
struct
text_info
ti
;
ciolib_gettextinfo
(
&
ti
);
(
*
newrw
)
->
api
.
width
=
ti
.
screenwidth
;
(
*
newrw
)
->
api
.
height
=
ti
.
screenheight
;
(
*
newrw
)
->
api
.
child_width
=
ti
.
screenwidth
;
(
*
newrw
)
->
api
.
child_height
=
ti
.
screenheight
;
(
*
newrw
)
->
api
.
fill_character
=
' '
;
(
*
newrw
)
->
api
.
fill_colour
=
ciolib_bg
;
(
*
newrw
)
->
api
.
fill_character_colour
=
ciolib_fg
;
int
cf
=
ciolib_getfont
(
0
);
if
(
cf
<
0
)
cf
=
0
;
(
*
newrw
)
->
api
.
fill_font
=
cf
;
size_t
cells
=
ti
.
screenwidth
;
cells
*=
ti
.
screenheight
;
(
*
newrw
)
->
display
=
malloc
(
sizeof
(
struct
vmem_cell
)
*
cells
);
if
((
*
newrw
)
->
display
==
NULL
)
{
free
(
*
newrw
);
*
newrw
=
NULL
;
return
NewIfc_error_allocation_failure
;
}
ciolib_vmem_gettext
(
1
,
1
,
(
*
newrw
)
->
api
.
width
,
(
*
newrw
)
->
api
.
height
,
(
*
newrw
)
->
display
);
return
NewIfc_error_none
;
return
NewIfc_error_none
;
}
}
...
@@ -196,8 +227,8 @@ void test_root_window(CuTest *ct)
...
@@ -196,8 +227,8 @@ void test_root_window(CuTest *ct)
CuAssertTrue
(
ct
,
obj
->
last_error
==
NewIfc_error_none
);
CuAssertTrue
(
ct
,
obj
->
last_error
==
NewIfc_error_none
);
CuAssertTrue
(
ct
,
obj
->
width
==
80
);
CuAssertTrue
(
ct
,
obj
->
width
==
80
);
CuAssertTrue
(
ct
,
obj
->
height
==
25
);
CuAssertTrue
(
ct
,
obj
->
height
==
25
);
CuAssertTrue
(
ct
,
obj
->
min_width
==
4
0
);
CuAssertTrue
(
ct
,
obj
->
min_width
==
0
);
CuAssertTrue
(
ct
,
obj
->
min_height
==
2
);
CuAssertTrue
(
ct
,
obj
->
min_height
==
0
);
CuAssertTrue
(
ct
,
obj
->
last_error
==
NewIfc_error_none
);
CuAssertTrue
(
ct
,
obj
->
last_error
==
NewIfc_error_none
);
CuAssertTrue
(
ct
,
obj
->
focus
==
true
);
CuAssertTrue
(
ct
,
obj
->
focus
==
true
);
CuAssertTrue
(
ct
,
obj
->
get
(
obj
,
NewIfc_locked
,
&
b
)
==
NewIfc_error_none
&&
!
b
);
CuAssertTrue
(
ct
,
obj
->
get
(
obj
,
NewIfc_locked
,
&
b
)
==
NewIfc_error_none
&&
!
b
);
...
...
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