From e945a98c5494f988bc9b22142c7c588473f08f02 Mon Sep 17 00:00:00 2001
From: Glen Whitney Original Version: Michael Haardt
\n"
"Current Maintainer: Joerg Walter
\n"
- "Contibutions by: Glen Whitney
\b"
+ "Contributions by: Glen Whitney
\b"
"Home Page: http://www.syntax-k.de/projekte/teapot/
Copyright 1995-2006 Michael Haardt,
\n"
"Copyright 2009-2010 Joerg Walter (info@syntax-k.de)
"
- "Copyright 2019 Glen Whitney
This program is free software: you can redistribute it and/or modify\n" "it under the terms of the GNU General Public License as published by\n" diff --git a/src/display.c b/src/display.c index d6e08b4..d0c28f8 100644 --- a/src/display.c +++ b/src/display.c @@ -1123,7 +1123,9 @@ static Key wgetc(void) /* Control R, recalculate sheet */ case '\022': return K_RECALC; - /* Control S, clock sheet */ + /* F8, F9 or Control S, clock sheet */ + case KEY_F(8): + case KEY_F(9): case '\023': return K_CLOCK; /* Control X, get one more key */ diff --git a/src/fteapot.fl b/src/fteapot.fl index f6d255f..953b1ce 100644 --- a/src/fteapot.fl +++ b/src/fteapot.fl @@ -1,4 +1,12 @@ # data file for the Fltk User Interface Designer (fluid) +# Code replacements for dummy numerical constants: +# 9999100/*fontsize*/ +# 9999112/*fontsize + 12*/ +# 9999114/*fontsize + 14*/ +# 9999110/*fontsize + 10*/ +# 9999224/*2*fontsize + 24*/ +# 99990336/*600 - 3*fontsize - 36*/ +# 99990112/*600 - fontsize - 12*/ version 1.0300 header_name {.h} code_name {.cxx} @@ -320,6 +328,8 @@ class TeapotTable {open : {public Fl_Table}} case FL_Escape: k = K_INVALID; break; case FL_BackSpace: k = K_BACKSPACE; break; case FL_F+1: k = ctrl?K_ABOUT:K_HELP; break; + case FL_F+2: k = K_LOADMENU; break; + case FL_F+3: k = K_SAVE; break; case FL_F+8: k = ctrl?K_RECALC:K_CLOCK; break; case FL_F+9: k = ctrl?K_RECALC:K_CLOCK; break; case FL_F+10: k = (Key)'/'; break; @@ -389,14 +399,14 @@ class TeapotTable {open : {public Fl_Table}} case FL_Page_Up: k = shift ? K_PSHEET : ctrl ? K_FIRSTL : K_PPAGE; break; + default: + /* Handle shifted keys */ + if (Fl::event_length() == 1) k = (Key)(Fl::event_text()[0]); } + /* This short circuit perhaps needs an explanation: */ if (k > 0 && (ctrl || alt)) return 0; - // Quick and dirty upper-case fix, fails for international chars on keyboards... - if (shift && !alt && !ctrl && k >= 'a' && k <= 'z') - k = (Key)(k - 'a' + 'A'); - do_sheetcmd(cursheet, k, cursheet->moveonly); do_callback(ACTION, 0, 0); redraw(); @@ -440,6 +450,8 @@ class TeapotTable {open : {public Fl_Table}} //printf(" : t: %i, w: %i, p: %i, r: %i\\n", tow, w, xpos, x2+1); cols(x2+1); } + visible_cells(y1, y2, x1, x2); + cursheet->width = x2 - x1 + 1; if (y2+2 < rows() && (size_t)rows() > cursheet->dim[Y]) rows((size_t)y2+2 < cursheet->dim[Y] ? cursheet->dim[Y] : y2+2); @@ -492,218 +504,229 @@ class MainWindow {open} table->update_table(); table->redraw(); } - open xywh {0 0 800 25} class Fl_Sys_Menu_Bar + open xywh {0 0 800 9999112} class Fl_Sys_Menu_Bar + code0 { + menu->textsize(fontsize); + } } { - Submenu {} {label {&File} xywh {25 25 67 24} } { + Submenu {} {label {&File} xywh {25 25 67 24} labelsize 0 } { MenuItem {} { label {&Open...} user_data K_LOADMENU - xywh {5 5 30 20} shortcut 0x4006f + xywh {5 5 30 20} labelsize 0 shortcut 0x4006f } MenuItem {} { label {&Save} user_data K_SAVE - xywh {0 0 30 20} shortcut 0x40073 + xywh {0 0 30 20} labelsize 0 shortcut 0x40073 } MenuItem {} { label {Save &As...} user_data K_NAME - xywh {0 0 30 20} shortcut 0x50053 divider + xywh {0 0 30 20} labelsize 0 shortcut 0x50053 divider } MenuItem {} { label {&Quit} user_data K_QUIT - xywh {0 0 30 20} shortcut 0x40071 + xywh {0 0 30 20} labelsize 0 shortcut 0x40071 } } - Submenu {} {label {&Block} xywh {25 25 67 24} } { + Submenu {} {label {&Block} xywh {25 25 67 24} labelsize 0 } { MenuItem {} { label {&Insert} user_data BLOCK_INSERT - xywh {0 0 30 20} shortcut 0x90069 + xywh {0 0 30 20} labelsize 0 shortcut 0x90069 } MenuItem {} { label {&Delete} user_data BLOCK_DELETE - xywh {0 0 30 20} shortcut 0x90064 divider + xywh {0 0 30 20} labelsize 0 shortcut 0x90064 divider } MenuItem {} { label {&Move} user_data BLOCK_MOVE - xywh {0 0 30 20} shortcut 0x9006d + xywh {0 0 30 20} labelsize 0 shortcut 0x9006d } MenuItem {} { label {&Copy} user_data BLOCK_COPY - xywh {0 0 36 21} shortcut 0x90063 divider + xywh {0 0 36 21} labelsize 0 shortcut 0x90063 divider } MenuItem {} { label {&Fill} user_data BLOCK_FILL - xywh {0 0 36 21} shortcut 0x90066 + xywh {0 0 36 21} labelsize 0 shortcut 0x90066 } MenuItem {} { label {FillWith} user_data FILL_BLOCK - xywh {0 0 36 30} - } + xywh {0 0 36 30} labelsize 0 } MenuItem {} { label {C&lear} user_data BLOCK_CLEAR - xywh {0 0 36 21} shortcut 0x9006c divider + xywh {0 0 36 21} labelsize 0 shortcut 0x9006c divider } MenuItem {} { label {&Sort} user_data BLOCK_SORT - xywh {0 0 36 21} shortcut 0x90073 + xywh {0 0 36 21} labelsize 0 shortcut 0x90073 } MenuItem {} { label {Mi&rror} user_data BLOCK_MIRROR - xywh {0 0 36 21} shortcut 0x90072 + xywh {0 0 36 21} labelsize 0 shortcut 0x90072 } } - Submenu {} {label {&View} xywh {0 0 70 21}} { + Submenu {} {label {&View} xywh {0 0 70 21} labelsize 0 } { MenuItem {} { label {Column &Width...} user_data K_COLWIDTH - xywh {0 0 36 21} shortcut 0x80077 + xywh {0 0 36 21} labelsize 0 shortcut 0x80077 + } + MenuItem {} { + label {Row &Height...} + user_data K_ROWHEIGHT + xywh {0 0 36 21} labelsize 0 shortcut 0x80068 } MenuItem {} { label {&Goto} user_data K_GOTO - xywh {0 0 36 21} shortcut 0x40067 + xywh {0 0 36 21} labelsize 0 shortcut 0x40067 } } - Submenu {} {label {F&ormat} open xywh {5 5 70 21}} { + Submenu {} {label {F&ormat} open xywh {5 5 70 21} labelsize 0 } { MenuItem {} { label {L&abel...} user_data ADJUST_LABEL - xywh {0 0 36 21} shortcut 0x80061 divider + xywh {0 0 36 21} labelsize 0 shortcut 0x80061 divider } MenuItem dim { label {&Dim} user_data ADJUST_DIM - protected xywh {0 0 34 21} + protected xywh {0 0 34 21} labelsize 0 shortcut 0x40064 code0 {o->flags |= FL_MENU_TOGGLE;} } MenuItem bold { label {&Bold} user_data ADJUST_BOLD - protected xywh {0 0 34 21} shortcut 0x80062 + protected xywh {0 0 34 21} labelsize 0 shortcut 0x40062 code0 {o->flags |= FL_MENU_TOGGLE;} } MenuItem italic { label {&Italic} user_data ADJUST_ITALIC - protected xywh {0 0 34 21} + protected xywh {0 0 34 21} labelsize 0 shortcut 0x40069 code0 {o->flags |= FL_MENU_TOGGLE;} } MenuItem underline { label {&Underline} user_data ADJUST_UNDERLINE - protected xywh {0 0 34 21} shortcut 0x80075 divider + protected xywh {0 0 34 21} labelsize 0 shortcut 0x40075 + divider code0 {o->flags |= FL_MENU_TOGGLE;} } MenuItem left { label {&Left} user_data ADJUST_LEFT - protected xywh {0 0 36 21} shortcut 0x8006c + protected xywh {0 0 36 21} labelsize 0 shortcut 0x8006c code0 {o->flags |= FL_MENU_RADIO;} } MenuItem right { label {&Right} user_data ADJUST_RIGHT - protected xywh {0 0 36 21} shortcut 0x80072 + protected xywh {0 0 36 21} labelsize 0 shortcut 0x80072 code0 {o->flags |= FL_MENU_RADIO;} } MenuItem center { label {&Center} user_data ADJUST_CENTER - protected xywh {0 0 36 21} shortcut 0x80063 divider + protected xywh {0 0 36 21} labelsize 0 shortcut 0x80063 + divider code0 {o->flags |= FL_MENU_RADIO;} } MenuItem {} { label {&Precision...} user_data ADJUST_PRECISION - xywh {0 0 36 21} shortcut 0x80070 + xywh {0 0 36 21} labelsize 0 shortcut 0x80070 } MenuItem {} { label {&Foreground...} user_data ADJUST_FOREGROUND - xywh {0 0 36 21} + xywh {0 0 36 21} labelsize 0 } MenuItem {} { label {&Background...} user_data ADJUST_BACKGROUND - xywh {0 0 36 21} divider + xywh {0 0 36 21} labelsize 0 divider } menuitem dec { label {&Decimal} user_data ADJUST_DECIMAL - protected xywh {0 0 36 21} + protected xywh {0 0 36 21} labelsize 0 code0 {o->flags |= FL_MENU_RADIO;} } MenuItem sci { label {&Scientific} user_data ADJUST_SCIENTIFIC - protected xywh {0 0 36 21} shortcut 0x80073 + protected xywh {0 0 36 21} labelsize 0 shortcut 0x80073 code0 {o->flags |= FL_MENU_RADIO;} } MenuItem cpt { label {Co&mpact} user_data ADJUST_COMPACT - protected xywh {0 0 36 21} + protected xywh {0 0 36 21} labelsize 0 code0 {o->flags |= FL_MENU_RADIO;} } MenuItem hex { label {He&xact} user_data ADJUST_COMPACT - protected xywh {0 0 36 21} divider + protected xywh {0 0 36 21} labelsize 0 divider code0 {o->flags |= FL_MENU_RADIO;} } MenuItem shadow { label {Shadow&ed} user_data ADJUST_SHADOW - protected xywh {0 0 36 21} shortcut 0x80065 + protected xywh {0 0 36 21} labelsize 0 shortcut 0x80065 code0 {o->flags |= FL_MENU_TOGGLE;} } MenuItem transparent { label {&Transparent} user_data ADJUST_TRANSPARENT - protected xywh {0 0 36 21} shortcut 0x80074 divider + protected xywh {0 0 36 21} labelsize 0 shortcut 0x80074 + divider code0 {o->flags |= FL_MENU_TOGGLE;} } MenuItem lock { label {Lo&ck} user_data ADJUST_LOCK - protected xywh {0 0 36 21} shortcut 0x80063 + protected xywh {0 0 36 21} labelsize 0 shortcut 0x80063 code0 {o->flags |= FL_MENU_TOGGLE;} } MenuItem ignore { label {&Ignore} user_data ADJUST_IGNORE - protected xywh {0 0 36 21} shortcut 0x80069 + protected xywh {0 0 36 21} labelsize 0 shortcut 0x80069 code0 {o->flags |= FL_MENU_TOGGLE;} } } - Submenu {} {label {&Help} open xywh {25 25 67 24}} { + Submenu {} {label {Help} open xywh {25 25 67 24} labelsize 0 } { MenuItem {} { label {&Manual} user_data K_HELP - xywh {0 0 30 20} shortcut 0xffbe + xywh {0 0 30 20} labelsize 0 shortcut 0xffbe } MenuItem {} { label {&About} user_data K_ABOUT - xywh {0 0 30 20} + xywh {0 0 30 20} labelsize 0 } } } Fl_Group line_label { label { Input:} open - protected xywh {0 25 800 25} box ROUND_UP_BOX align 20 deactivate + protected xywh {0 9999112 800 9999112} labelsize 9999100 + box ROUND_UP_BOX align 20 deactivate } { Fl_Input line_input { @@ -717,8 +740,12 @@ class MainWindow {open} line_label->deactivate(); } } - protected xywh {75 27 723 21} box ROUND_DOWN_BOX + protected xywh {75 9999114 723 9999110} box PLASTIC_DOWN_BOX + labelsize 9999100 labeltype NO_LABEL align 20 when 6 deactivate + code0 { + line_input->textsize(fontsize); + } } } Fl_Box table { @@ -802,14 +829,15 @@ class MainWindow {open} case FLT_NO_FORMAT: ; } } - protected xywh {0 50 800 525} box DOWN_FRAME + protected xywh {0 9999224 800 99990336} box DOWN_FRAME labeltype NO_LABEL resizable code0 { table->sheet(sheet); } class TeapotTable } Fl_Box status { label {teapot ready.} - protected xywh {0 575 800 25} box GTK_ROUND_DOWN_BOX align 20 + protected xywh {0 99990112 800 9999112} + box GTK_ROUND_DOWN_BOX align 20 } } code { current = this; diff --git a/src/tools/interpolate.py b/src/tools/interpolate.py new file mode 100644 index 0000000..9792c58 --- /dev/null +++ b/src/tools/interpolate.py @@ -0,0 +1,39 @@ +# To get around the fact that fluid only allows numerical constants +# in some places that expressions would be preferred, this +# file takes a fluid file which may contain numerical constants of the form +# +# 9999NNN/*REPLACEMENT*/ +# +# where the NNN are distinct digit sequences (of any length) +# and the corresponding fluid output and replaces any 9999NNN in the output +# with REPLACEMENT (which can of course be any text). Note that the +# entire numerical constant with its replacement comment must occur within +# a single line of the fluid file. The result is written +# to a new output file with the literal string `_interpolated` interpolated +# before its extension. + +from pathlib import Path +import re +import sys + +fluidin = sys.argv[1] +genfile = Path(sys.argv[2]) +outfile = genfile.with_stem(genfile.stem + '_interpolated') + +# First collect all of the replacements from the fluidfile +replacerPattern = re.compile(r"(9999\d*)/[*](.*)[*]/") +replacement = {} +with open(fluidin) as fluidf: + for line in fluidf: + foundpat = replacerPattern.search(line) + if foundpat: + replacement[foundpat[1]] = foundpat[2] + +# Now make all replacements in the generated file +with open(outfile, 'w') as outf: + with open(genfile) as genf: + for line in genf: + line = line[:-1] + for key in replacement: + line = line.replace(key, replacement[key]) + print(line, file=outf) diff --git a/teapot.1 b/teapot.1 index 70ad9b5..f5b9fbe 100644 --- a/teapot.1 +++ b/teapot.1 @@ -62,6 +62,8 @@ Display strings definitely NOT quoted or definitely quoted, respectively. Redraw the terminal window more often. .It Fl p Ar digits Set default precision of displayed numbers. +.It Fl F Ar digits +Set the general font size on pixels (fteapot only). .El .\" .\"