-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a --linker-flags argument (#221)
Co-authored-by: XiaoBaiYun <[email protected]>
- Loading branch information
1 parent
405cb8c
commit 097dee7
Showing
6 changed files
with
119 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# To run this program, you need linux: | ||
# | ||
# $ ./jou --linker-flags "-lX11" examples/x11_window.jou | ||
# | ||
|
||
declare usleep(x: int) -> int | ||
|
||
struct Display: | ||
_dummy: int | ||
struct XGCValues: | ||
_dummy: int | ||
struct GC: | ||
_dummy: int | ||
|
||
declare XOpenDisplay(name: byte*) -> Display* | ||
declare XCreateSimpleWindow( | ||
display: Display*, | ||
parent: long, | ||
x: int, | ||
y: int, | ||
width: int, | ||
height: int, | ||
border_width: int, | ||
border: long, | ||
background: long, | ||
) -> long | ||
declare XCreateGC(display: Display*, drawable: long, valuemask: long, values: XGCValues*) -> GC* | ||
declare XSetForeground(display: Display*, gc: GC*, foreground: long) -> int | ||
declare XSelectInput(display: Display*, window: long, event_mask: long) -> int | ||
declare XMapRaised(display: Display*, window: long) -> int | ||
declare XDrawImageString( | ||
display: Display*, | ||
drawable: long, | ||
gc: GC*, | ||
x: int, | ||
y: int, | ||
string: byte*, | ||
length: int, | ||
) -> int | ||
declare XDefaultRootWindow(display: Display*) -> long | ||
declare XStoreName(display: Display*, window: long, name: byte*) -> int | ||
declare XFlush(display: Display*) -> int | ||
|
||
def main() -> int: | ||
display = XOpenDisplay("") | ||
window = XCreateSimpleWindow(display, XDefaultRootWindow(display), 200, 200, 200, 200, 5, 0, 0xff00ffL) | ||
XStoreName(display, window, "Hello pink world") | ||
|
||
gc = XCreateGC(display, window, 0, NULL) | ||
XSetForeground(display, gc, 0xffffffL) | ||
|
||
XSelectInput(display, window, 32768) | ||
XMapRaised(display, window) | ||
|
||
while True: | ||
usleep(100) | ||
XDrawImageString(display, window, gc, 50, 50, "hello", 5) | ||
XFlush(display) # This makes the program die when closed. Don't know why :) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters