GithubHelp home page GithubHelp logo

newlisp-gtk-demos's Introduction

newLISP GTK Demos

Minimal examples of GTK applications written completely in newLISP.

Inspired by a Common Lisp project, Gtk-Demos.

Build library documentation

$ ./doc/build
$ xdg-open ./doc/index.html

Run demos as scripts

$ chmod +x ./src/demo[1-4].nl
$ ./src/demo4.nl

Build standalone executables

$ ./bin/build
$ ./bin/demo4

Project Structure

.
├── bin
│   └── build         # Build demos as standalone executables
├── doc
│   └── build         # Build library documentation
├── lib
│   ├── gtk.nl        # GTK FFI
│   ├── roman.nl      # Roman numeral representation from integer
│   ├── spell-int.nl  # Spell out integer in English
│   └── ui.nl         # Stateful wrapper around GTK
├── README.md
└── src
    ├── demo1.nl      # Four buttons demo
    ├── demo2.nl      # Numerals demo
    ├── demo3.nl      # Dates demo
    └── demo4.nl      # Menu demo

Dependencies

Project Notes

The GTK3 shared library path is assumed to be: /usr/lib/libgtk-3.so.0
If this is not the case for your system, modify lib/gtk.nl accordingly.

Tested on newLISP v.10.7.5 64-bit on Linux, with UTF-8 & libffi support enabled.

newLISP Setup Notes

The following AUR package is recommended for Arch Linux users.

Below is an example of how you could achieve syntax highlighting and REPL integration with Neovim.

Install vim-plug:

$ curl -fLo ~/.local/share/nvim/site/autoload/plug.vim --create-dirs \
    https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim

Modify the init file (~/.config/nvim/init.vim):

" Specify a directory for plugins
call plug#begin('~/.local/share/nvim/plugged')

" Neovim terminal wrapper
Plug 'kassio/neoterm'

" Precision editing for S-expressions
Plug 'guns/vim-sexp'

" newLISP syntax highlighting
Plug 'joefromct/vim-newlisp.vim'

" Initialize plugin system
call plug#end()

" Map space as leader
let mapleader = "\<Space>"

" Autoscrolling terminal
let g:neoterm_autoscroll = '1'

" Enable vim-sexp
let g:sexp_filetypes = 'newlisp'

" Detect filetype & syntax
autocmd BufNewFile,BufRead *.nl set filetype=newlisp
autocmd FileType newlisp setlocal commentstring=;\ %s

" Send all newLISP forms wrapped in [cmd] tags
" Modified version of TREPLSendSelection
" https://github.com/kassio/neoterm/blob/b4156bd3208c1b96efe53b5407ecda0cf5b5d0f8/autoload/neoterm/repl.vim#L45-L55
function! NlSendSel()
  let [l:lnum1, l:col1] = getpos("'<")[1:2]
  let [l:lnum2, l:col2] = getpos("'>")[1:2]
  if &selection ==# 'exclusive'
    let l:col2 -= 1
  endif
  let l:lines = getline(l:lnum1, l:lnum2)
  let l:lines[-1] = l:lines[-1][:l:col2 - 1]
  let l:lines[0] = l:lines[0][l:col1 - 1:]
  call g:neoterm.repl.exec(["[cmd]"] + l:lines + ["[/cmd]"])
endfunction

command! -range NlSendSel
 \ call NlSendSel()

" Send current top-level compound form to REPL
" space + F
autocmd FileType newlisp nmap <Leader>F v<Plug>(sexp_outer_top_list):NlSendSel<CR>``

" Send current compound form to REPL
" space + f
autocmd FileType newlisp nmap <Leader>f v<Plug>(sexp_outer_list):NlSendSel<CR>``

" Send current element to REPL
" space + e
autocmd FileType newlisp nmap <Leader>e v<Plug>(sexp_inner_element):NlSendSel<CR>``

" Clear REPL
" space + l
autocmd FileType newlisp nmap <Leader>l :Tclear<CR>

" Open REPL
function! Newlisp()
  :vsplit new
  :T newlisp
  :set syntax=newlisp
  :wincmd h
  :TREPLSet 1
endfunction

command! -range Newlisp
 \ call Newlisp()

Start Neovim, run :PlugInstall.
Open a newLISP file and :Newlisp should open a REPL.

newlisp-gtk-demos's People

Contributors

paullucas avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.