Re: [NTG-context] hotkey definitions again

2007-05-13 Thread Wolfgang Schuster
On Fri, 11 May 2007 20:01:55 +0300
Vyatcheslav Yatskovsky [EMAIL PROTECTED] wrote:

 Hello,
 
 I have following two definitions for hotkeys
 
 \def\hotkey#1{\inframed[corner=00, offset=0pt]{\ #1\ }}
 
 \def\hotkey#1{\inframed[corner=00, offset=0pt]{\enspace#1\enspace}}
 
 The first is my favorite since it looks compact, but one-letter hotkeys look 
 odd (the frame's height is more then width). 
 
 \hotkey{Ctrl} - nice
 \hotkey{T} - not nice
 
 The second definition works better for one-letter hotkeys.
 
 \hotkey{Ctrl} - not nice
 \hotkey{T} - nice
 
 My question is: can I set the MINIMUM width of a box to have boxes not less 
 then, say, squared.
 
 -- 
 Best regards,
 Vyatcheslav Yatskovsky

Hi Vyatcheslav, 

you can measure the width of your text by saving the content in a box
and using the \wd primitve afterwards.

\def\hotkey#1%
  {\bgroup
   \setupframed[corner=00,offset=0pt]
   \setbox\scratchbox\hbox{#1}%
   \ifdim\wd\scratchbox\dimexpr\strutht+\strutdp\relax
 \dimen0\dimexpr\strutht+\strutdp\relax
 \advance\dimen0-\wd\scratchbox
 \divide\dimen0 by2
 \inframed{\kern\dimen0\box\scratchbox\kern\dimen0}%
   \else
 \inframed{\enspace\box\scratchbox\enspace}%
   \fi
   \egroup}

\starttext

text \hotkey{Ctrl} text \hotkey{T} text

text \hotkey{Ctrl} text \hotkey{I} text

\stoptext

You should think about a fixed width for Ctrl, Alt ...

Wolfgang
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] hotkey definitions again

2007-05-12 Thread Wolfgang Schuster
Hi,

I have another solution for your problem. I send this to you via
private mail because you need a extra module I wrote to enable seperate
offsets for the left and right margin.

You can find the solution in the file key.tex. Another examples for my
module can be found in the source of wolf-rul.tex.

Gruß

Wolfgang
\usemodule[wolf-rul]

\starttext

\def\hotkey#1{\inframed[corner=00, offset=0pt]{\ #1\ }}

text \hotkey{Ctrl} text \hotkey{T} text

\def\hotkey#1{\inframed[corner=00, offset=0pt]{\enspace#1\enspace}}

text \hotkey{Ctrl} text \hotkey{T} text

\def\hotkey#1%
  {\inframed
 [corner=00,
  offset=0pt,
  leftoffset=1ex,
  rightoffset=1ex]
 {#1}}

text \hotkey{Ctrl} text \hotkey{T} text

\stoptext
%D \module
%D   [   file=wolf-con,
%Dversion=2006.11.13,
%D  title=\CONTEXT\ User Module,
%D   subtitle=Constants,
%D author=Wolfgang Schuster,
%D   date=\currentdate,
%D  copyright=Wolfgang Schuster]

\writestatus{loading}{Context User Module / Constants}

%D Necessary variables wolf-job

\startvariablesall

partition: partition
 particle: particle
\stopvariables

%D Necessary constants for wolf-rul

\startconstantsall

linestyle: linestyle
 leftrule: leftrule
rightrule: rightrule
  toprule: toprule
   bottomrule: bottomrule
\stopconstants

%D Necessary variables for wolf-rul

\startvariablesall

   dashed: dashed
  stroked: stroked
 rule: rule
\stopvariables

%D Necessary constants for wolf-brf

\startconstantsall

  graphic: graphic
 head: head
 foot: foot
  backaddress: backaddress
  topmark: topmark
  botmark: botmark
  cutmark: cutmark
  endmark: endmark
 usermark: usermark
 foldmark: foldmark
extension: extension
\stopconstants

%D Necessary variables for wolf-brf

\startvariablesall

   secondpage: secondpage
  backaddress: backaddress
 foot: foot
  topmark: topmark
  botmark: botmark
  cutmark: cutmark
  endmark: endmark
reference: reference
   option: option
  address: address
 foldmark: foldmark
 usermark: usermark
  opening: opening
  closing: closing
\stopvariables

\endinput
%D \module
%D   [   file=wolf-rul,
%Dversion=2006.11.04,
%D  title=\CONTEXT\ User Module,
%D   subtitle=Ruled Stuff Handling,
%D author=Wolfgang Schuster,
%D   date=\currentdate,
%D  copyright=Wolfgang Schuster]

\writestatus{loading}{Context User Module / Ruled Stuff Handling}

\unprotect

%D Needed because I defined a few constants and variables that
%D are currently only stored in my private macros files.
%D To prevent double loading on my system I put
%D \tex{enablemode[wolf]} in my \type{cont-sys.tex} file
%D and let \CONTEXT\ load the \type{wolf-con.tex} file only
%D on third party systems.

\doifnotmode{wolf}{\readfile{wolf-con}\donothing\donothing}

%D This module was created to allow different offsets
%D on all for sides in a frame.
%D
%D The development had shown I can intagrate more options:
%D
%D \startitemize
%D \item including offsets for the top, bottom, left and right
%D \item I intagrated also the option to use a different
%D   to use a different rulethickness for every frame
%D \item after a questions on the mailing list I tried to
%D   add another option, you can now select a dashed
%D   frame and set the dashpattern
%D \item the methods for dashed and solid rules has been merged
%D \stopitemize
%D
%D What need to be done on the module:
%D
%D \startitemize
%D \item is the beagaviour with \type{frame=overlay} oder
%D   \type{offset=overlay} with with different rulethickness
%D   correct or need it to be changed
%D \item dash parameter in combination with rules produce
%D   a dashed border and no round corners, should I give
%D   give round corner a higher priority
%D \item my long if test for every offset and rule need to
%D   cleaned up or nested in a macro, something that is
%D   faster than the current solution
%D \item the module need a big test with existing document
%D   to find bugs or wrong behaviours/presets
%D \item use less parameters to control the rulethickness,
%D   enabling and disabling the frame with processaction
%D \item use leaders for solid and dashed lines and not two
%D   seperate ways
%D \item give the use a message in the log that it is not
%D   possible to used dashed lines and round corners at
%D   the same 

[NTG-context] hotkey definitions again

2007-05-11 Thread Vyatcheslav Yatskovsky
Hello,

I have following two definitions for hotkeys

\def\hotkey#1{\inframed[corner=00, offset=0pt]{\ #1\ }}

\def\hotkey#1{\inframed[corner=00, offset=0pt]{\enspace#1\enspace}}

The first is my favorite since it looks compact, but one-letter hotkeys look 
odd (the frame's height is more then width). 

\hotkey{Ctrl} - nice
\hotkey{T} - not nice

The second definition works better for one-letter hotkeys.

\hotkey{Ctrl} - not nice
\hotkey{T} - nice

My question is: can I set the MINIMUM width of a box to have boxes not less 
then, say, squared.

-- 
Best regards,
Vyatcheslav Yatskovsky

___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___