aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authors-ol <s-ol@users.noreply.github.com>2019-11-19 21:24:49 +0000
committers-ol <s-ol@users.noreply.github.com>2019-11-19 21:24:49 +0000
commit9e6414f9a10e32759ee1ecfaffbc8d8f7bc9fc13 (patch)
tree92e4c221aac288353e76c0f48b5c4a46f898056c
parentadd keyboard capturing to input (diff)
downloadwatch-cad-9e6414f9a10e32759ee1ecfaffbc8d8f7bc9fc13.tar.gz
watch-cad-9e6414f9a10e32759ee1ecfaffbc8d8f7bc9fc13.zip
add EX mode, script name display
-rw-r--r--font/FantasqueSansMono-Regular.ttfbin0 -> 168008 bytes
-rw-r--r--font/LICENSE.txt93
-rw-r--r--font/README.md125
-rw-r--r--init.moon7
-rw-r--r--session.moon48
5 files changed, 266 insertions, 7 deletions
diff --git a/font/FantasqueSansMono-Regular.ttf b/font/FantasqueSansMono-Regular.ttf
new file mode 100644
index 0000000..fa6be4d
--- /dev/null
+++ b/font/FantasqueSansMono-Regular.ttf
Binary files differ
diff --git a/font/LICENSE.txt b/font/LICENSE.txt
new file mode 100644
index 0000000..af9106f
--- /dev/null
+++ b/font/LICENSE.txt
@@ -0,0 +1,93 @@
+Copyright (c) 2013-2017, Jany Belluz (jany.belluz@hotmail.fr)
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+This license is copied below, and is also available with a FAQ at:
+http://scripts.sil.org/OFL
+
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded,
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
diff --git a/font/README.md b/font/README.md
new file mode 100644
index 0000000..2dae439
--- /dev/null
+++ b/font/README.md
@@ -0,0 +1,125 @@
+Fantasque Sans Mono
+===================
+
+A programming font, designed with functionality in mind, and with some
+wibbly-wobbly handwriting-like fuzziness that makes it unassumingly cool.
+[Download](https://github.com/belluzj/fantasque-sans/releases/latest) or
+see [installation instructions](#installation).
+
+
+![](Specimen/urxvt13.png)
+
+Previously known as *Cosmic Sans Neue Mono*. It
+appeared that [similar names were already in use for other
+fonts](https://github.com/belluzj/cosmic-sans-neue/issues/16), and that
+people tended to extend their instinctive hatred of Comic Sans to this very
+font of mine (which of course can only be *loved*). Why the previous name?
+Here is my original explanation:
+
+> The name comes from my realization that at some point it looked like the
+> mutant child of Comic Sans and Helvetica Neue. Hopefully it is not the
+> case any more.
+
+Inspirational sources include Inconsolata and Monaco. I have also been using
+Consolas a lot in my programming life, so it may have some points in common.
+
+![](Specimen/kdevelop11.png)
+![](Specimen/sublime11.png)
+
+Weights, variants and glyph coverage
+------------------------------------
+
+The font includes a bold version, with the same metrics as the regular one.
+Both versions include the same ranges of characters : latin letters, some
+accented glyphs (quite a lot), some greek letters, some arrows.
+
+Please note that I have not tested all of the glyphs I have drawn (some letters
+have those two layers of crazy accents that I have never witnessed before), so
+it might look bad in some cases. Please report these problems: see next section.
+
+It also features a good italic version, which I designed in a fashion similar
+to Consolas' italic version, with new glyph designs, not just an added slant.
+
+![](Specimen/vim21.png)
+
+Stylistic set(s)
+----------------
+
+### `ss01`: nondescript `k`
+
+No ~~distractive~~ lovely loop.
+[Get the pre-activated version here](https://github.com/belluzj/fantasque-sans/releases/download/1.8.0/FantasqueSansMono-NoLoopK.zip)
+or see the [issue #67](https://github.com/belluzj/fantasque-sans/issues/67)
+for techniques to activate the stylistic set.
+
+![](Specimen/noloopk.png)
+
+Author and license
+------------------
+
+Created by Jany Belluz \<jany.belluz AT hotmail.fr\>
+
+Licensed under the SIL Open Font License (see [LICENSE.txt](LICENSE.txt)).
+
+Please send me an e-mail or [report an issue on
+Github](http://github.com/belluzj/cosmic-sans-neue/issues) if you stumble upon
+bad design or rendering problems (with screen shot if possible), or if you need
+more characters, or if you want to compliment me (I love compliments).
+
+Installation
+------------
+
+You can [download the latest version](https://github.com/belluzj/fantasque-sans/releases/latest)
+and install it by hand. In the `NoLoopK` variant, the looped lowercase `k` is
+replaced with a straight version. The `LargeLineHeight` variant is especially
+useful for users of accented capitals. For more info, see the [CHANGELOG](CHANGELOG.md).
+
+Automatic installation on macOS with [homebrew](https://brew.sh):
+
+ brew tap homebrew/cask-fonts #You only need to do this once for cask-fonts
+ brew cask install font-fantasque-sans-mono
+
+Instructions for other platforms might follow.
+
+Building installable font files
+-------------------------------
+
+The build process requires:
+* FontForge with python scripting support,
+* `ttfautohint`
+* `sfnt2woff` (from the `woff-tools` package on Ubuntu)
+* `woff2_compress` from [the Google WOFF2
+ tools](https://github.com/google/woff2) or `woff2` package on Ubuntu
+
+Run `make`. You should see green stuff and some "OK" messages.
+
+If you are using Ubuntu, please note that the FontForge version
+in the default Ubuntu repositories is much outdated at the time of this writing,
+and that [is known to have caused subtle problems](https://github.com/belluzj/fantasque-sans/issues/59).
+You are advised to install FontForge from
+[this PPA](https://launchpad.net/~fontforge/+archive/ubuntu/fontforge)
+(using `sudo add-apt-repository ppa:fontforge/fontforge` prior to the installation).
+Alternatively, you can always [download](https://github.com/belluzj/fantasque-sans/releases/latest)
+the latest prebuilt release of these fonts.
+
+`make install` will install the TTF fonts into your local `.fonts/` directory
+and update the font cache. It comes in handy while modifying the font.
+
+[![](Specimen/Specimen.png)](Specimen/Specimen.pdf)
+
+Webfonts
+--------
+
+Each variant has a `Webfonts/` folder which contains various font formats for
+use on the web, along with the matching CSS font declarations. To use them,
+you must combine in the same folder:
+* a custom `.css` file that you can assemble from the `*-decl.css` fragments
+ (you can only pick the styles that you need, e.g. normal and bold)
+* the matching `.svg`, `.woff`, `.woff2` files from `Webfonts/`
+* the matching `.ttf` files from the `TTF/` folder
+* the matching `.otf` files from the `OTF/` folder.
+
+Versions
+--------
+
+[Check out the changelog](CHANGELOG.md).
diff --git a/init.moon b/init.moon
index f1f8616..b9dd6a3 100644
--- a/init.moon
+++ b/init.moon
@@ -8,10 +8,13 @@ export ^
for k, v in pairs require 'api'
_G[k] = v
+scriptfile = arg[#arg]
+scriptfile = nil if scriptfile == '.'
+
COMMIT = false
INPUT = Input!
STATE = State!
-SESSION = Session Script arg[#arg]
+SESSION = Session scriptfile
love.draw = ->
p = INPUT\key_down 'p'
@@ -24,8 +27,10 @@ love.draw = ->
profile.stop!
print love.timer.getFPS!
print profile.report 20
+
love.keypressed = INPUT\keypressed
love.keyreleased = INPUT\keyreleased
+love.textinput = INPUT\textinput
love.mousemoved = INPUT\mousemoved
love.mousepressed = INPUT\mousepressed
love.mousereleased = INPUT\mousereleased
diff --git a/session.moon b/session.moon
index 7549b91..da22d80 100644
--- a/session.moon
+++ b/session.moon
@@ -1,6 +1,8 @@
lfs = require 'lfs'
+utf8 = require 'utf8'
moon = require 'moonscript.base'
+{ graphics: lg } = love
trace = (msg) -> debug.traceback msg, 2
class Script
@@ -65,10 +67,25 @@ class Script
import Object from require 'object'
class Session
- new: (@script) =>
+ FONTSIZE = 20
+ new: (scriptfile) =>
@objects = {}
for i=1,4
- table.insert @objects, Object nil, random.size!/8
+ print
+ -- table.insert @objects, Object nil, random.size!/8
+
+ if scriptfile
+ @script = Script scriptfile
+
+ @font = lg.newFont 'font/FantasqueSansMono-Regular.ttf', 20
+ @ex = false
+
+ exec: (command) =>
+ switch command\match '^(%w+)'
+ when 'quit'
+ love.event.quit!
+ when 'run'
+ @script = Script command\match '^run%s+(.+)'
frame: =>
for obj in *@objects
@@ -77,12 +94,31 @@ class Session
if INPUT\key_down 'escape'
STATE\reset!
- @script\reload_and_run!
+ w,h = lg.getDimensions!
+ lg.setFont @font
- if INPUT\key_down 'space'
- @script\commit!
- STATE\reset!
+ if @script
+ @script\reload_and_run!
+
+ if INPUT\key_down 'space'
+ @script\commit!
+ STATE\reset!
+
+ lg.print "script: #{@script.file}", 10, 10
+
+ if (INPUT\key_down ':') or (INPUT\key_down ';') and INPUT\key_held 'lshift'
+ INPUT\text_capture!
+ @ex = true
+
+ if @ex
+ lg.print ":#{INPUT.text}", 10, h - 10 - FONTSIZE
+
+ apply = INPUT\key_down 'return'
+ input = if apply or INPUT\key_down 'escape'
+ @ex = nil
+ apply and @exec INPUT\text_release!
+ @exec input if input
{
:Script