M polywell/frontend/term.fnl => polywell/frontend/term.fnl +13 -10
@@ 11,16 11,16 @@
(term.setrawmode))
(fn quit []
- (term.restoremode prev-mode)
+ (when prev-mode (term.restoremode prev-mode))
(term.reset)
(os.exit 0))
(fn render-colored-line [x w color line ...]
(when (and color line)
- (term.color color)
- (term.out (line:sub 1 w))
- (when (< x w)
- (render-colored-line (- w (# line)) w ...))))
+ (term.color color)
+ (term.out (line:sub 1 w))
+ (when (< x w)
+ (render-colored-line (- w (# line)) w ...))))
(fn render-buffer [b pos w h scroll-line]
(for [i scroll-line (+ scroll-line h)]
@@ 36,12 36,14 @@
(term.out (.. modeline (string.rep " " (- w (# modeline)))))
(term.color term.colors.normal))
-(var (last-scroll last-b) nil)
+(var (last-scroll last-b last-modeline) nil)
(fn draw [b buffers-where echo-message colors get-prop minibuffer?]
(let [(h w) (term.getscrlc)
- scroll-line (or b.scroll-line 1)]
- (when (or b.dirty (not= last-scroll scroll-line) (not= b last-b))
+ scroll-line (or b.scroll-line 1)
+ modeline (b:modeline)]
+ (when (or b.dirty (not= last-scroll scroll-line)
+ (not= b last-b) (not= modeline last-modeline))
(term.clear)
(each [pos buf (pairs buffers-where)]
(render-buffer buf pos w h scroll-line))
@@ 50,8 52,9 @@
(term.golc h (+ 1 b.point)))
echo-message
(draw-modeline w h echo-message)
- (draw-modeline w h (b:modeline)))
- (set (last-b last-scroll) (values b scroll-line)))
+ (draw-modeline w h modeline))
+ (set (last-b last-scroll last-modeline)
+ (values b scroll-line modeline)))
(if (= b.path :minibuffer)
(term.golc h (+ 1 b.point))
(term.golc (- b.point-line scroll-line -1) (+ 1 b.point)))))
M polywell/handlers.fnl => polywell/handlers.fnl +5 -4
@@ 111,10 111,11 @@
(set state.b.block-input? false)
(when state.active-prefix-deactivate
(set state.active-prefix nil)))
- :textinput (fn [text allow-long?]
- (let [(_ len) (pcall utf8.len text)
- wrap (editor.get-prop :wrap wrap)]
- (when (and (not (find-binding text))
+ :textinput (fn [input allow-long?]
+ (let [(_ len) (pcall utf8.len input)
+ wrap (editor.get-prop :wrap wrap)
+ text (if (frontend.mod-down? :shift) (input:upper) input)]
+ (when (and (not (find-binding input))
(not state.b.block-input?)
(or (= len 1) allow-long?))
(editor.with-traceback wrap editor.insert [text] true))))