Skip to content

Commit

Permalink
Add instructions for wasm build.
Browse files Browse the repository at this point in the history
PR:ArthurSonzogni/ftxui-starter#3
author: Guerout-Arnaud
  • Loading branch information
Guerout-Arnaud authored and WSQS committed Dec 4, 2024
1 parent 79bea3b commit 5c076ec
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 5 deletions.
12 changes: 10 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ include(FetchContent)
set(FETCHCONTENT_UPDATES_DISCONNECTED TRUE)
FetchContent_Declare(ftxui
GIT_REPOSITORY https://github.com/ArthurSonzogni/ftxui
GIT_TAG v2.0.0
GIT_TAG v3.0.0
)

FetchContent_GetProperties(ftxui)
Expand All @@ -31,4 +31,12 @@ target_link_libraries(ftxui-starter
PRIVATE ftxui::component # Not needed for this example.
)

install(TARGETS ftxui-starter RUNTIME DESTINATION "bin")
if (EMSCRIPTEN)
string(APPEND CMAKE_CXX_FLAGS " -s USE_PTHREADS")
string(APPEND CMAKE_EXE_LINKER_FLAGS " -s ASYNCIFY")
string(APPEND CMAKE_EXE_LINKER_FLAGS " -s PROXY_TO_PTHREAD")

foreach(file "index.html" "run_webassembly.py")
configure_file("src/${file}" ${file})
endforeach(file)
endif()
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,18 @@ Minimal starter project using the [FTXUI library](https://github.com/ArthurSonzo
mkdir build
cd build
cmake ..
make -j3
./ftxuistarter
make -j
cd ../target
./ftxui-starter
~~~

## Webassembly build:
~~~bash
mkdir build_emscripten && cd build_emscripten
emcmake cmake ..
make -j
./run_webassembly.py
(visit localhost:8000)
~~~

## Linux snap build:
Expand Down
17 changes: 17 additions & 0 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,23 @@ <h1>ftxui-starter example </h1>
text-decoration: underline;
}

select {
display:block;
padding: .6em 1.4em .5em .8em;
border-radius: 20px 20px 0px 0px;
font-size: 16px;
font-family: sans-serif;
font-weight: 700;

color: #444;
line-height: 1.3;
background-color:black;
border:0px;
color:white;
transition: color 0.2s linear;
transition: background-color 0.2s linear;
}

#terminal {
padding:10px;
border:none;
Expand Down
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ int main(void) {
auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));
Render(screen, document);

std::cout << screen.ToString() << std::endl;
std::cout << screen.ToString() << '\0' << std::endl;

return EXIT_SUCCESS;
}

0 comments on commit 5c076ec

Please sign in to comment.