Skip to content

Commit 5c076ec

Browse files
Guerout-ArnaudWSQS
authored andcommitted
Add instructions for wasm build.
PR:ArthurSonzogni/ftxui-starter#3 author: Guerout-Arnaud
1 parent 79bea3b commit 5c076ec

File tree

4 files changed

+40
-5
lines changed

4 files changed

+40
-5
lines changed

CMakeLists.txt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ include(FetchContent)
66
set(FETCHCONTENT_UPDATES_DISCONNECTED TRUE)
77
FetchContent_Declare(ftxui
88
GIT_REPOSITORY https://github.com/ArthurSonzogni/ftxui
9-
GIT_TAG v2.0.0
9+
GIT_TAG v3.0.0
1010
)
1111

1212
FetchContent_GetProperties(ftxui)
@@ -31,4 +31,12 @@ target_link_libraries(ftxui-starter
3131
PRIVATE ftxui::component # Not needed for this example.
3232
)
3333

34-
install(TARGETS ftxui-starter RUNTIME DESTINATION "bin")
34+
if (EMSCRIPTEN)
35+
string(APPEND CMAKE_CXX_FLAGS " -s USE_PTHREADS")
36+
string(APPEND CMAKE_EXE_LINKER_FLAGS " -s ASYNCIFY")
37+
string(APPEND CMAKE_EXE_LINKER_FLAGS " -s PROXY_TO_PTHREAD")
38+
39+
foreach(file "index.html" "run_webassembly.py")
40+
configure_file("src/${file}" ${file})
41+
endforeach(file)
42+
endif()

README.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,18 @@ Minimal starter project using the [FTXUI library](https://github.com/ArthurSonzo
1313
mkdir build
1414
cd build
1515
cmake ..
16-
make -j3
17-
./ftxuistarter
16+
make -j
17+
cd ../target
18+
./ftxui-starter
19+
~~~
20+
21+
## Webassembly build:
22+
~~~bash
23+
mkdir build_emscripten && cd build_emscripten
24+
emcmake cmake ..
25+
make -j
26+
./run_webassembly.py
27+
(visit localhost:8000)
1828
~~~
1929

2030
## Linux snap build:

src/index.html

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,23 @@ <h1>ftxui-starter example </h1>
7676
text-decoration: underline;
7777
}
7878

79+
select {
80+
display:block;
81+
padding: .6em 1.4em .5em .8em;
82+
border-radius: 20px 20px 0px 0px;
83+
font-size: 16px;
84+
font-family: sans-serif;
85+
font-weight: 700;
86+
87+
color: #444;
88+
line-height: 1.3;
89+
background-color:black;
90+
border:0px;
91+
color:white;
92+
transition: color 0.2s linear;
93+
transition: background-color 0.2s linear;
94+
}
95+
7996
#terminal {
8097
padding:10px;
8198
border:none;

src/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ int main(void) {
3333
auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));
3434
Render(screen, document);
3535

36-
std::cout << screen.ToString() << std::endl;
36+
std::cout << screen.ToString() << '\0' << std::endl;
3737

3838
return EXIT_SUCCESS;
3939
}

0 commit comments

Comments
 (0)