diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index 3936f14..0000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,49 +0,0 @@ -# Copyright (c) 2018 Calvin Rose -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to -# deal in the Software without restriction, including without limitation the -# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -# sell copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -# IN THE SOFTWARE. - -cmake_minimum_required(VERSION 3.7) -project(janetui) - -# Set Some Variables -set(TARGET_NAME ${PROJECT_NAME}) -set(CMAKE_C_STANDARD 99) -set(CMAKE_C_FLAGS "${CMAKE_C_CFLAGS} -fPIC") - -# Set configurations -SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g") -SET(CMAKE_C_FLAGS_RELEASE "-O2") -SET(CMAKE_C_FLAGS_DEBUG "-O0 -g") - -set(SOURCES -main.c -) - -# Get the header ui.h -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/libui) - -# Build libui as static library -set(BUILD_SHARED_LIBS OFF CACHE BOOL "") -add_subdirectory(libui) -set(_COMMON_CFLAGS "") -set(_COMMON_LDFLAGS "") - -# Build our library -add_library(${TARGET_NAME} MODULE ${SOURCES}) -target_link_libraries(${TARGET_NAME} libui glib-2.0 gtk-3 gdk-3) diff --git a/doc-me-this.janet b/doc-me-this.janet new file mode 100644 index 0000000..ff74f79 --- /dev/null +++ b/doc-me-this.janet @@ -0,0 +1,21 @@ +#!/usr/bin/env janet +(import janetui :as ui) + +(defn main [& args] + (let [w (ui/window "doc-me-this" 500 250 true) + outerbox (ui/vertical-box) + entrybox (ui/search-entry ) + biglabel (ui/multiline-entry)] + (ui/entry/on-changed entrybox |(let [entry (ui/entry/text entrybox) + doctext (let [buffer (buffer/new 4096)] + (with-dyns [*out* buffer] + (when (> (length entry) 0) + (doc* entry) + (doc* (symbol entry)))) + (string buffer))] + (ui/multiline-entry/text biglabel doctext))) + (ui/box/append outerbox entrybox) + (ui/box/append outerbox biglabel true) + (ui/window/set-child w outerbox) + (ui/show w)) + (ui/main)) \ No newline at end of file diff --git a/main.c b/main.c index 83f5d17..f3fb08c 100644 --- a/main.c +++ b/main.c @@ -20,7 +20,7 @@ * IN THE SOFTWARE. */ -#include +#include #include #include diff --git a/project.janet b/project.janet index e85ec80..094172f 100644 --- a/project.janet +++ b/project.janet @@ -4,13 +4,43 @@ :url "https://github.com/janet-lang/janetui" :repo "https://github.com/janet-lang/janetui.git") -(rule "build/janetui.so" ["CMakeLists.txt"] - (do - (os/mkdir "build") - (os/cd "build") - (os/execute ["cmake" ".."] :p) - (assert +# build with --workers=1 + +(def o (os/which)) + +(defn buildwithcmake [] + (do + (os/cd "libui") + ## need to make this error more verbose + (assert + (and (zero? - (os/execute ["make"] :p))))) + (os/execute ["cmake" "-B" "build" "-DBUILD_SHARED_LIBS=OFF"] :p)) + (zero? + (os/execute ["cmake" "--build" "build"] :p))) "! use jpm build --workers=1 !") + (os/cd ".."))) + +(rule "libui/build/out/libui.a" ["libui"] (buildwithcmake)) + +(add-dep "build" "libui/build/out/libui.a") + +(declare-native + :name "janetui" + :source ["main.c"] + :cflags [;default-cflags ;(case o + :macos '["-Ilibui" "-Ilibui/darwin"] + :windows '["-Ilibui" "-Ilibui/windows" ] + #default + '["-Ilibui" "-Ilibui/unix"])] + :lflags [;default-lflags ;(case o + :linux '[ "libui/build/out/libui.a" "-lglib-2.0" "-lgtk-3" "-lgdk-3"] + #default + '[ "libui/build/out/libui.a" "-lglib-2.0" "-lgtk-3" "-lgdk-3"])]) -(add-dep "build" "build/janetui.so") +(comment +(declare-executable + :name "doc-me-this" + :entry "doc-me-this.janet" + :install false + :deps [(native-module :static)]) +) \ No newline at end of file diff --git a/test.janet b/test.janet index ac11bea..5f872dc 100755 --- a/test.janet +++ b/test.janet @@ -1,6 +1,6 @@ #!/usr/bin/env janet -(import build/libjanetui :as ui) +(import ./build/janetui :as ui) (def menu (ui/menu "File"))