From c5f3776055f8ae42e0cdafccf1587b7257b87624 Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Tue, 24 Oct 2017 21:58:30 -0400 Subject: [PATCH] overhauled drawing code to use new mutable cursor type --- Makefile | 2 +- edit.ml | 4 ++-- lib/draw.ml | 43 ++++++++++++++++++++----------------------- 3 files changed, 23 insertions(+), 26 deletions(-) diff --git a/Makefile b/Makefile index 3057d3b..a904b9a 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ INCS = -I . -I lib -I /usr/X11R6/include -I /usr/include/freetype2 -I /usr/X11R6 LIBS = -L/usr/X11R6/lib -lX11 -lXft -lfontconfig ifeq ($(NATIVE), 1) - OC = ocamlopt + OC = ocamlopt OCFLAGS = -g MKLIB = ocamlmklib MKLIBFLAGS = -custom diff --git a/edit.ml b/edit.ml index c3f1250..8817801 100644 --- a/edit.ml +++ b/edit.ml @@ -86,17 +86,17 @@ let onmousemove mods x y = () let onupdate width height = let csr = Draw.Cursor.make (width, height) 0 0 in - (* Draw.status csr "UNSI> *scratch*"; Draw.tags csr !tags_buf; Draw.scroll csr; Draw.edit csr !edit_buf - *) + (* let (pos : drawpos) = { x = 0; y = 0 } in let pos = draw_status pos width "UNSI> *scratch*" in let pos = draw_tags pos width (height / font.height / 4) "Sample tags data" in let pos = draw_scroll pos height in let _ = draw_edit pos width height in () + *) let onshutdown () = () diff --git a/lib/draw.ml b/lib/draw.ml index 81e4e20..945ca1f 100644 --- a/lib/draw.ml +++ b/lib/draw.ml @@ -9,15 +9,15 @@ module Cursor = struct } let make dim x y = - let height, width = dim in + let width, height = dim in { height = height; width = width; startx = x; starty = y; x = x; y = y } end -open Cursor - let font = X11.font_load "Verdana:size=11" +open Cursor + let rectangle color width height csr = X11.draw_rect (X11.make_rect csr.x csr.y width height color) @@ -38,30 +38,27 @@ let vrule height csr = rule_bkg 1 (height - csr.y) csr; csr.x <- csr.x + 1 -let status csr str = () -let tags csr buf = () -let scroll csr = () -let edit csr buf = () - -(* +let status csr str = + let height = (4 + font.height) in + dark_bkg csr.width height csr; + string str csr; + hrule csr.width csr -let draw_status pos width text = +let tags csr buf = let height = (4 + font.height) in - draw_dark_bkg width height pos; - let pos = draw_text text pos in - draw_hrule width pos + light_bkg csr.width height csr; + string "Quit Save Undo Redo Cut Copy Paste | Find " csr; + hrule csr.width csr -let draw_tags pos width maxlns text = - let bkgheight = ((font.height * maxlns) + 4) in - draw_light_bkg width bkgheight pos; - let pos = draw_text text pos in - draw_hrule width pos +let scroll csr = + rule_bkg 14 csr.height csr; + dark_bkg 14 (csr.height / 2) csr; + csr.x <- csr.x + 14; + vrule csr.height csr -let draw_scroll pos height = - let rulepos = { pos with x = 14 } in - draw_gray_bkg rulepos.x height pos; - draw_dark_bkg rulepos.x (height/2) pos; - draw_vrule height rulepos +let edit csr buf = () + +(* let draw_buffer pos width height = let x = ref pos.x and y = ref pos.y in -- 2.52.0