This is the first public availability of the work thus far on Eterm 0.9.1. There's quite a bit of new stuff here. * Added scrollbar thumb support. * Completely redid the terminfo/termcap stuff. The terminfo file is now compiled (by tic) and installed by default (unless you specify --without-terminfo). The config files still say xterm, though, because some programs (like SLang and GNU mc) use the silly algorithm of "Is $TERM set to xterm?" to detect mouse reporting support in a terminal. =P But if you don't ever use xterm, you can use Eterm's termcap and just name it "xterm" instead. Thanks to Marius Gedminas <mgedmin@takas.lt> for his patch that started this whole revamp. * Added the kEsetroot script for KDE users from Dax Games <dgames@isoc.net>. * You can now configure the Home and End emulation via --with-home= and --with-end= options to configure. The --with-terminfo option is also new, and --enable-xim is now the default. * Added a new image state, disabled, for when Eterm loses focus. This is supported by all widgets (well, all those that could possibly be on screen when Eterm lost focus), even the background image. So you could actually have all your images darken on focus out and restore to normal on focus in. * Widget colors formerly dealt with as colors (menu text color, scrollbar color, etc.) are now handled by the imageclasses. Each image state can have a foreground and background color defined. The current exception is the background image; I hope to add that later. The foreground is the text color and the background is the object color (for solid color mode). So menu text color is set by the menu imageclass. And again, for unfocused colors, use the disabled state of the imageclass. * Proportionally-spaced fonts are now handled much better. They are still forced into evenly-spaced columns (it's a terminal for crying out loud!) but at least you don't end up with Eterm's wider than your screen. :-) * Home on refresh is gone, as is home on echo. It's now much simpler. There are two options: home on output, and home on input, the former being a combination of echo and refresh. Also, keypresses that don't necessarily have corresonding output can trigger a home on input, like Ctrl-End or whatever...ones that don't have special meaning. Credit to Darren Stuart Embry <dse@louisville.edu> for pointing out this issue and the one with "m-" in font names. * I finally got around to re-merging the new parser stuff from my work on the Not Game. Closed up some old potential behavior quirks with theme parsing. * Added a new escape sequence to fork-and-exec a program. Also added a scrollback search capability to highlight all occurances of a string in your scrollback buffer. Use the new "Etsearch" utility to access it. "Etsearch string" to search for a string, then "Etsearch" by itself to reset the highlighting. * And of course, the biggie. Eterm now supports a completely- customizeable buttonbar. Not a menubar, a buttonbar. It can have an arbitrary number of buttons, and each button can perform an action, just like a menuitem. So a button could bring up a menu (like a menubar) or launch a program (like a launchbar) or perform an operation (like a toolbar). Each button can have an icon, text, or both. And you can have buttons left- or right-justified in the buttonbar. You will eventually be able to have an arbitrary number of buttonbars, but I'm still working on that. As with any change this big, things could very easily be broken. So beware. :-) I have tested this myself, and everything seems to work, but I can't test every possibility. Let me know if you find anything that's broken, and enjoy! SVN revision: 2048eterm-0.10
parent
9a0e0ce8fc
commit
42fde9c99d
62 changed files with 4685 additions and 1936 deletions
@ -1,44 +1,130 @@ |
||||
# termcap for rxvt (and xterm) -- (modified from the Midnight Commander) |
||||
# |
||||
# From: Jakub Jelinek <jj@jfch.vc.cvut.cz> 1 Sep 1995 |
||||
# This is a checked termcap entry for the xterm terminal emulator. |
||||
# It is compatible with the enclosed terminfo entry. |
||||
# Install this by cutting off the old xterm entry from /etc/termcap |
||||
# and replacing that place it with this file. |
||||
# Heavily based on xterm from: |
||||
# Eric S. Raymond <esr@snark.thyrsus.com> 30 Mar 1995 |
||||
# Note: If you use the line-drawing character set, the disable afterwards |
||||
# will leave you in US-ASCII. If you live somewhere that wants a pound sign |
||||
# at 2/3, change rmacs to "\E(A". Further note: cuf and cub don't seem |
||||
# to be reliable under my xterm, so they're commented out. |
||||
#------------------------------------------------------------------------- |
||||
# termcap for Eterm. Needs to be downsized to fit in < 1023 bytes. |
||||
# Generated by infocmp -C -r -sc -T <term> |
||||
Eterm-base|Eterm basic terminal capabilities:\ |
||||
:5i:am:bw:eo:km:mi:ms:ut:xn:xo:\ |
||||
:co#80:it#8:li#24:\ |
||||
:#2=\E[7$:#4=\E[d:%1=\E[28~:%c=\E[6$:%e=\E[5$:%i=\E[c:\ |
||||
:*4=\E[3$:*6=\E[4~:*7=\E[8$:@0=\E[1~:@1=\EOu:@7=\E[8~:\ |
||||
:@8=\EOM:AL=\E[%dL:DC=\E[%dP:DL=\E[%dM:DO=\E[%dB:\ |
||||
:F1=\E[23~:F2=\E[24~:F3=\E[25~:F4=\E[26~:F5=\E[28~:\ |
||||
:F6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E[2J\E[?47l\E8:ti=\E7\E[?47h:u7=\E[6n:u8=\E[?1;2c:\ |
||||
:u9=\E[c:ue=\E[24m:up=\E[A:us=\E[4m:vb=\E[?5h\E[?5l:\ |
||||
:ve=\E[?25h:vi=\E[?25l:vs=\E[?25h: |
||||
|
||||
Eterm-ansi|Eterm with ANSI color (X Window System):\ |
||||
:5i:am:bw:eo:km:mi:ms:ut:xn:xo:\ |
||||
:co#80:it#8:li#24:\ |
||||
:#2=\E[7$:#4=\E[d:%1=\E[28~:%c=\E[6$:%e=\E[5$:%i=\E[c:\ |
||||
:*4=\E[3$:*6=\E[4~:*7=\E[8$:@0=\E[1~:@1=\EOu:@7=\E[8~:\ |
||||
:@8=\EOM:AL=\E[%dL:DC=\E[%dP:DL=\E[%dM:DO=\E[%dB:\ |
||||
:F1=\E[23~:F2=\E[24~:F3=\E[25~:F4=\E[26~:F5=\E[28~:\ |
||||
:F6=\E[29~:F7=\E[31~:F8=\E[32~:F9=\E[33~:FA=\E[34~:\ |
||||
:IC=\E[%d@:K1=\E[7~:K2=\EOu:K3=\E[5~:K4=\E[8~:K5=\E[6~:\ |
||||
:LE=\E[%dD:RA=\E[?7l:RI=\E[%dC:SA=\E[?7h:UP=\E[%dA:\ |
||||
:ac=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~:\ |
||||
:ae=^O:al=\E[L:as=^N:bl=^G:cb=\E[1K:cd=\E[J:ce=\E[K:\ |
||||
:ch=\E[%i%dG:cl=\E[H\E[2J:cm=\E[%i%d;%dH:cr=^M:\ |
||||
:cs=\E[%i%d;%dr:ct=\E[3g:cv=\E[%i%dd:dc=\E[P:dl=\E[M:\ |
||||
:do=\E[B:eA=\E)0:ec=\E[%dX:ei=\E[4l:ho=\E[H:\ |
||||
:i1=\E[?47l\E>\E[?1l:ic=\E[@:im=\E[4h:\ |
||||
:is=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;3;4;6l\E[4l:\ |
||||
:k0=\E[21~:k1=\E[11~:k2=\E[12~:k3=\E[13~:k4=\E[14~:\ |
||||
:k5=\E[15~:k6=\E[17~:k7=\E[18~:k8=\E[19~:k9=\E[20~:\ |
||||
:k;=\E[21~:kB=\E[Z:kD=\E[3~:\ |
||||
:kE=\E[8\014rs1=\E>\E[1;3;4;5;6l\E[?7h\E[m\E[r\E[2J\E[H:\ |
||||
:kI=\E[2~:kN=\E[6~:kP=\E[5~:kb=^H:kd=\E[B:ke=:kh=\E[7~:\ |
||||
:kl=\E[D:kr=\E[C:ks=:ku=\E[A:le=^H:mb=\E[5m:md=\E[1m:\ |
||||
:me=\E[m\017:mr=\E[7m:nd=\E[C:pf=\E[4i:po=\E[5i:\ |
||||
:r2=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;3;4;6l\E[4l\E>:\ |
||||
:rc=\E8:\ |
||||
:..sa=\E[0%?%p1%p6%|%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;m%?%p9%t\016%e\017%;:\ |
||||
:sc=\E7:se=\E[27m:sf=^J:so=\E[7m:sr=\EM:st=\EH:ta=^I:\ |
||||
:te=\E[2J\E[?47l\E8:ti=\E7\E[?47h:u7=\E[6n:u8=\E[?1;2c:\ |
||||
:u9=\E[c:ue=\E[24m:up=\E[A:us=\E[4m:vb=\E[?5h\E[?5l:\ |
||||
:ve=\E[?25h:vi=\E[?25l:vs=\E[?25h: |
||||
|
||||
Eterm-mouse|Eterm with X11 mouse reporting:\ |
||||
:5i:am:bw:eo:km:mi:ms:ut:xn:xo:\ |
||||
:co#80:it#8:li#24:\ |
||||
:#2=\E[7$:#4=\E[d:%1=\E[28~:%c=\E[6$:%e=\E[5$:%i=\E[c:\ |
||||
:*4=\E[3$:*6=\E[4~:*7=\E[8$:@0=\E[1~:@1=\EOu:@7=\E[8~:\ |
||||
:@8=\EOM:AL=\E[%dL:DC=\E[%dP:DL=\E[%dM:DO=\E[%dB:\ |
||||
:F1=\E[23~:F2=\E[24~:F3=\E[25~:F4=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sa=\E[0%?%p1%p6%|%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;m%?%p9%t\016%e\017%;:\ |
||||
:sc=\E7:se=\E[27m:sf=^J:so=\E[7m:sr=\EM:st=\EH:ta=^I:\ |
||||
:te=\E[2J\E[?47l\E8:ti=\E7\E[?47h:u7=\E[6n:u8=\E[?1;2c:\ |
||||
:u9=\E[c:ue=\E[24m:up=\E[A:us=\E[4m:vb=\E[?5h\E[?5l:\ |
||||
:ve=\E[?25h:vi=\E[?25l:vs=\E[?25h: |
||||
|
||||
xterm|vs100|xterm terminal emulator (X11R6 Window System):\ |
||||
:am:bs:km:mi:ms:pt:xn:xo:co#80:li#24:it#8:\ |
||||
:AL=\E[%dL:DC=\E[%dP:DL=\E[%dM:\ |
||||
:IC=\E[%d@:LE=\E[%dD:UP=\E[%dA:\ |
||||
:ac=++\054\054..00II--``aaffgghhjjkkllmmnnooqqssttuuvvwwxx~~:\ |
||||
:ae=\E(B:al=\E[L:as=\E(0:bl=^G:cd=\E[J:ce=\E[K:\ |
||||
:cl=\E[H\E[2J:cm=\E[%i%d;%dH:cr=^M:cs=\E[%i%d;%dr:\ |
||||
:ct=\E[3k:dc=\E[P:dl=\E[M:ei=\E[4l:ho=\E[H:\ |
||||
:ic=\E[@:im=\E[4h:\ |
||||
Eterm|Eterm-color|eterm|Eterm with xterm-style color support (X Window System):\ |
||||
:5i:am:bw:eo:km:mi:ms:ut:xn:xo:\ |
||||
:Co#8:co#80:it#8:li#24:pa#64:\ |
||||
:#2=\E[7$:#4=\E[d:%1=\E[28~:%c=\E[6$:%e=\E[5$:%i=\E[c:\ |
||||
:*4=\E[3$:*6=\E[4~:*7=\E[8$:@0=\E[1~:@1=\EOu:@7=\E[8~:\ |
||||
:@8=\EOM:AB=\E[%p1%{40}%+%dm:AF=\E[%p1%{30}%+%dm:\ |
||||
:AL=\E[%dL:DC=\E[%dP:DL=\E[%dM:DO=\E[%dB:F1=\E[23~:\ |
||||
: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
||||
:kb=^H:up=\E[A:do=^J:nd=\E[C:le=^H:\ |
||||
:md=\E[1m:me=\E[m:mr=\E[7m:\ |
||||
:r2=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;3;4;6l\E[4l\E<:\ |
||||
:rc=\E8:sc=\E7:se=\E[m:sf=^J:so=\E[7m:sr=\EM:ta=^I:\ |
||||
:te=\E[2J\E[?47l\E8:ti=\E7\E[?47h:u6=\E[%d;%dR:\ |
||||
:u7=\E[6n:u8=\E[?1;2c:u9=\E[c:ue=\E[m:\ |
||||
:us=\E[4m: |
||||
xterm-color|color-xterm|xterm with color support:\ |
||||
:tc=xterm:tc=ansi-pc-color: |
||||
:k0=\E[21~:k1=\E[11~:k2=\E[12~:k3=\E[13~:k4=\E[14~:\ |
||||
:k5=\E[15~:k6=\E[17~:k7=\E[18~:k8=\E[19~:k9=\E[20~:\ |
||||
:k;=\E[21~:kB=\E[Z:kD=\E[3~:\ |
||||
:kE=\E[8\014rs1=\E>\E[1;3;4;5;6l\E[?7h\E[m\E[r\E[2J\E[H:\ |
||||
:kI=\E[2~:kN=\E[6~:kP=\E[5~:kb=^H:kd=\E[B:ke=:kh=\E[7~:\ |
||||
:kl=\E[D:kr=\E[C:ks=:ku=\E[A:le=^H:mb=\E[5m:md=\E[1m:\ |
||||
:me=\E[m\017:mr=\E[7m:nd=\E[C:op=\E[39;49m:pf=\E[4i:\ |
||||
:po=\E[5i:\ |
||||
:r2=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;3;4;6l\E[4l\E>:\ |
||||
:rc=\E8:\ |
||||
:..sa=\E[0%?%p1%p6%|%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;m%?%p9%t\016%e\017%;:\ |
||||
:sc=\E7:se=\E[27m:sf=^J:so=\E[7m:sr=\EM:st=\EH:ta=^I:\ |
||||
:te=\E[2J\E[?47l\E8:ti=\E7\E[?47h:u7=\E[6n:u8=\E[?1;2c:\ |
||||
:u9=\E[c:ue=\E[24m:up=\E[A:us=\E[4m:vb=\E[?5h\E[?5l:\ |
||||
:ve=\E[?25h:vi=\E[?25l:vs=\E[?25h: |
||||
|
@ -1,147 +1,153 @@ |
||||
#------------------------------------------------------------------------- |
||||
# terminfo for Eterm (and xterm) -- [modified from the Midnight Commander] |
||||
# |
||||
# Install using `tic Eterm.ti', to be used with the enclosed termcap |
||||
#------------------------------------------------------------------------- |
||||
|
||||
xterm-basic|xterm terminal base (X Window System), |
||||
am, km, mir, msgr, xenl, xon, cols#80, lines#24, it#8, |
||||
# Not sure about eo (Erase overstrike with a blank) |
||||
eo, |
||||
cr=\r, bel=^G, |
||||
|
||||
# Scroll text up, down |
||||
ind=\n, ri=\EM, |
||||
# Eterm terminfo file |
||||
|
||||
# Clear Screen, EOS, EOL, BOL |
||||
clear=\E[H\E[2J, ed=\E[J, el=\E[K, el1=\E[1K, |
||||
|
||||
# Change Scroll Region |
||||
csr=\E[%i%p1%d;%p2%dr, |
||||
Eterm-base|Eterm basic terminal capabilities, |
||||
# FIXME: xterm does not specify bce, bw, eo, or xon. Should we? |
||||
am, bw, bce, km, mir, msgr, xenl, xon, eo, mc5i, |
||||
cols#80, lines#24, it#8, lm#0, btns#5, |
||||
cr=\r, bel=^G, |
||||
|
||||
# Cursor Position |
||||
cup=\E[%i%p1%d;%p2%dH, |
||||
# Scroll text down/up one line |
||||
ind=\n, ri=\eM, |
||||
|
||||
# Horizontal & Vertical Position Absolute |
||||
hpa=\E[%i%p1%dG, vpa=\E[%i%p1%dd, |
||||
# Clear entire screen (home, then clear to EOS), EOS, EOL, BOL |
||||
clear=\e[H\e[2J, ed=\e[J, el=\e[K, el1=\e[1K, |
||||
|
||||
# Cursor Up/Down/Forward/Backward: any, 1 char |
||||
cuu=\E[%p1%dA, cud=\E[%p1%dB, cuf=\E[%p1%dC, cub=\E[%p1%dD, |
||||
cuu1=\E[A, cud1=\E[B, cuf1=\E[C, cub1=\b, |
||||
# Change scrolling region to lines $1+1 to $2+1 |
||||
# %i means add one to params 1 and 2; convert from 0-based to |
||||
# 1-based counting. |
||||
csr=\e[%i%p1%d;%p2%dr, |
||||
|
||||
# Misc cursor motion |
||||
home=\E[1;1H, |
||||
# Move cursor to row $1+1, column $2+1. Can end with H or f |
||||
cup=\e[%i%p1%d;%p2%dH, |
||||
# Move cursor to column n, same row; or row n, same column |
||||
hpa=\e[%i%p1%dG, vpa=\e[%i%p1%dd, |
||||
# Move cursor up/down/forward/back by n chars |
||||
cuu=\e[%p1%dA, cud=\e[%p1%dB, cuf=\e[%p1%dC, cub=\e[%p1%dD, |
||||
# Move cursor up/down/forward/back by 1 char |
||||
cuu1=\e[A, cud1=\e[B, cuf1=\e[C, cub1=\b, |
||||
# Home cursor (row 1, col 1). Was \e[1;1H but 1's are redundant |
||||
home=\e[H, |
||||
|
||||
# Enter insert mode, leave insert mode |
||||
smir=\E[4h, rmir=\E[4l, |
||||
# Enter/leave insert mode |
||||
smir=\e[4h, rmir=\e[4l, |
||||
|
||||
# Set tab stops, clear tab stops, tab character |
||||
hts=\EH, tbc=\E[3g, ht=\t, |
||||
hts=\eH, tbc=\e[3g, ht=\t, |
||||
|
||||
# Make cursor invisible, normal, bold |
||||
civis=\E[?25l, cnorm=\E[?25h, cvvis=\E[?25h, |
||||
# Turn on/off auto margins |
||||
smam=\e[?7h, rmam=\e[?7l, |
||||
# Make cursor invisible, normal, bold (not supported) |
||||
civis=\e[?25l, cnorm=\e[?25h, cvvis=\e[?25h, |
||||
# Save/restore cursor position |
||||
sc=\e7, rc=\e8, |
||||
|
||||
# Save/Restore Cursor position |
||||
sc=\E7, rc=\E8, |
||||
|
||||
# Alternate Char Set (line drawing), enable/enter/exit ACS |
||||
# Alternate character set (line drawing), enable/enter/exit ACS |
||||
acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~, |
||||
enacs=\E(B\E)0, smacs=\E(B\E)U^N, rmacs=\E(B\E)0^O, |
||||
|
||||
#-- begin AIX 3.2.5 hack |
||||
# acsc (box2 is the standard AIX form, box1 has been changed to work!) |
||||
# box1=llqqkkxxjjmmwwuuvvttnn, |
||||
# box2=lqkxjmwuvtn, |
||||
# font0=\E(B, font1=\E(0, |
||||
# position occupied by kend |
||||
# colf7=\E[8~, |
||||
#-- end AIX 3.2.5 hack |
||||
|
||||
# Delete/Insert: Chars, Lines, 1-char, 1-line |
||||
dch=\E[%p1%dP, dl=\E[%p1%dM, |
||||
ich=\E[%p1%d@, il=\E[%p1%dL, |
||||
dch1=\E[P, dl1=\E[M, |
||||
ich1=\E[@, il1=\E[L, |
||||
|
||||
# Erase Chars |
||||
ech=\E[%p1%dX, |
||||
|
||||
# Enter/Leave Fonts: Bold, Reverse, Blink, Underline |
||||
# standout (enter/leave), Define attribs 1-9 |
||||
bold=\E[1m, rev=\E[7m, blink=\E[5m, |
||||
smul=\E[4m, rmul=\E[24m, smso=\E[7m, rmso=\E[m, |
||||
|
||||
# visual bell |
||||
flash=\E[?5h\E[?5l, |
||||
|
||||
# Enter/leave keypad transmit, Cursor keys (sent by terminal). Don't touch |
||||
# cursor keys! use ANSI cursor keys rather than application cursor keys to |
||||
# avoid starting in application cursor mode when `$xterm&' is used and to |
||||
# enable the Eterm Shift/Ctrl cursor extensions. |
||||
smkx=\E=, rmkx=\E>, |
||||
kcuu1=\E[A, kcud1=\E[B, kcuf1=\E[C, kcub1=\E[D, |
||||
|
||||
# Other nice keys |
||||
ka1=\EOw, ka3=\EOy, kb2=\EOu, kc1=\EOq, kc3=\EOs |
||||
enacs=\e)0, smacs=^N, rmacs=^O, |
||||
|
||||
# Delete/insert n chars, 1 char |
||||
dch=\e[%p1%dP, ich=\e[%p1%d@, dch1=\e[P, ich1=\e[@, |
||||
# Delete/insert n lines, 1 line |
||||
dl=\e[%p1%dM, il=\e[%p1%dL, dl1=\e[M, il1=\e[L, |
||||
# Erase next n chars |
||||
ech=\e[%p1%dX, |
||||
|
||||
# Activate SGR mode: bold, reverse video, blink (bright bg color) |
||||
bold=\e[1m, rev=\e[7m, blink=\e[5m, |
||||
# Start/stop underline, standout (reverse video) |
||||
smul=\e[4m, rmul=\e[24m, smso=\e[7m, rmso=\e[27m, |
||||
# Flash the screen (sets and resets reverse video for the whole screen) |
||||
flash=\e[?5h\e[?5l, |
||||
|
||||
# Enter/leave application keypad mode. We always send the ANSI values |
||||
# because that seems to be the most portable solution. The valid escape |
||||
# sequences are here but are commented out for this reason. The 1st set |
||||
# is for keypad cursor keys, the second is for application cursor key |
||||
# mode. The third is what gets sent by default. |
||||
## smkx=\e=, rmkx=\e>, |
||||
smkx=, rmkx=, |
||||
## kcuu1=\e[Ox, kcud1=\e[Or, kcuf1=\e[Ov, kcub1=\e[Ot, |
||||
## kcuu1=\eOA, kcud1=\eOB, kcuf1=\eOC, kcub1=\eOD, |
||||
kcuu1=\e[A, kcud1=\e[B, kcuf1=\e[C, kcub1=\e[D, |
||||
|
||||
# Keypad 7, 9, 5, 1, and 3. The 1st set are the appl. keypad mode |
||||
# sequences. The 2nd set are the values for Home/End/PgUp/PgDn. |
||||
# The 5 key is the same either way. |
||||
## ka1=\eOw, ka3=\eOy, kb2=\eOu, kc1=\eOq, kc3=\eOs, |
||||
ka1=\e[7~, ka3=\e[5~, kb2=\eOu, kc1=\e[8~, kc3=\e[6~, |
||||
|
||||
# Function keys |
||||
kf0=\E[21~, |
||||
kf1=\E[11~, kf2=\E[12~, kf3=\E[13~, kf4=\E[14~, kf5=\E[15~, |
||||
kf6=\E[17~, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, kf10=\E[21~, |
||||
kf11=\E[23~, kf12=\E[24~, kf13=\E[25~, kf14=\E[26~, |
||||
kf15=\E[28~, kf16=\E[29~, kf17=\E[31~, |
||||
kf18=\E[32~, kf19=\E[33~, kf20=\E[34~, |
||||
|
||||
# Find, Insert, Delete, Select, Prior, Next |
||||
kfnd=\E[1~, kich1=\E[2~, kdch1=\E[3~, kslt=\E[4~, kpp=\E[5~, knp=\E[6~, |
||||
# Home (vt100 may use khome=\E[H), End, Backspace, Enter, Backtab |
||||
khome=\E[7~, kend=\E[8~, kbs=\177, kent=\EOM, kcbt=\E[Z, |
||||
|
||||
# Shifted Right, Left, Delete, Prior, Next, Home, End, Ctrl-End |
||||
kRIT=\E[c, kLFT=\E[d, |
||||
kDC=\E[3$, kPRV=\E[5$, kNXT=\E[6$, |
||||
kHOM=\E[7$, kEND=\E[8$, kel=\E[8^, |
||||
kf1=\e[11~, kf2=\e[12~, kf3=\e[13~, kf4=\e[14~, kf5=\e[15~, |
||||
kf6=\e[17~, kf7=\e[18~, kf8=\e[19~, kf9=\e[20~, kf10=\e[21~, |
||||
kf11=\e[23~, kf12=\e[24~, kf13=\e[25~, kf14=\e[26~, kf15=\e[28~, |
||||
kf16=\e[29~, kf17=\e[31~, kf18=\e[32~, kf19=\e[33~, kf20=\e[34~, |
||||
# F0, same as F10 |
||||
kf0=\e[21~, |
||||
|
||||
# Find, Insert, Delete, Select, Prior (PgUp), Next (PgDn). The first set of |
||||
# sequences are accurate. The second set lets Find/Select act like Home/End. |
||||
kfnd=\e[1~, kich1=\e[2~, kdch1=\e[3~, kslt=\e[4~, kpp=\e[5~, knp=\e[6~, |
||||
## kfnd=\e[7~, kich1=\e[2~, kdch1=\e[3~, kslt=\e[8~, kpp=\e[5~, knp=\e[6~, |
||||
|
||||
# Home (vt100 may use khome=\e[H), End, Backspace, Keypad Enter, Shift-Tab |
||||
# The 1st set is the default. The 2nd set is based on Linux console/vt220 |
||||
# settings for Home/End and Backspace sending Delete (^?). The 3rd set gives |
||||
# xterm's settings for Home/End. |
||||
khome=\e[7~, kend=\e[8~, kbs=\010, kent=\eOM, kcbt=\e[Z, |
||||
## khome=\e[1~, kend=\e[4~, kbs=\177, kent=\eOM, kcbt=\e[Z, |
||||
## khome=\e[H, kend=\e[F, kbs=\010, kent=\eOM, kcbt=\e[Z, |
||||
|
||||
# Help and Begin keys |
||||
khlp=\e[28~, kbeg=\eOu, |
||||
# "Shifted" right and left (actually Ctrl, not Shift) |
||||
kRIT=\e[c, kLFT=\e[d, |
||||
# Shift-Prior/Next (PgUp/PgDn). Usually, these key combos scroll. |
||||
kPRV=\e[5$, kNXT=\e[6$, |
||||
# Shift-Delete/Home/End and Ctrl-End. It's a $ instead of a ~ for |
||||
# Shift-, a ^ for Ctrl-, and @ for Ctrl-Shift-. |
||||
kDC=\e[3$, kHOM=\e[7$, kEND=\e[8$, kel=\e[8^, |
||||
|
||||
# Reset terminal, turn off all attributes |
||||
rs1=\E>\E[1;3;4;5;6l\E[?7h\E[m\E[r\E[2J\E[H, |
||||
rs2=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;3;4;6l\E[4l\E>, |
||||
# dec.ti |
||||
# rs2=@, |
||||
|
||||
rs1=\e>\e[1;3;4;5;6l\e[?7h\e[m\e[r\e[2J\e[H, |
||||
rs2=\e[r\e[m\e[2J\e[H\e[?7h\e[?1;3;4;6l\e[4l\e>, |
||||
# Init terminal |
||||
is1=\E[?47l\E=\E[?1l, |
||||
is2=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;3;4;6l\E[4l, |
||||
|
||||
# Leave/Enter CA-Mode. |
||||
smcup=\E7\E[?47h, rmcup=\E[?47l\E8, |
||||
# dec.ti |
||||
# smcup=\E[?7h\E[?1l\E(B\E=, rmcup=\E[?7h, |
||||
|
||||
# turn on/off the printer |
||||
# mc5=\E[5i, mc4=\E[4i, |
||||
mc4=\E[4i, |
||||
|
||||
# |
||||
# XTerm with color support. |
||||
# |
||||
xterm|vs100|xterm terminal emulator (X Window System), |
||||
use=xterm-basic, |
||||
# sgr=\E[0%?%p1%p6%|%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;m%?%p9%t^N%e^O%;, |
||||
sgr=\E[%?%p1%t;7%;%?%p2%t;4%;%?%p3%t;7%;%?%p4%t;5%;%?%p6%t;1%;m, |
||||
sgr0=\E[m^O, |
||||
# from dec.ti |
||||
# sgr0=\E[m\E(B, |
||||
# sgr0=\E[m, |
||||
# sgr=\E[%?%p1%t;7%;%?%p2%t;4%;%?%p3%t;7%;%?%p4%t;5%;%?%p6%t;1%;m%?%p9%t\E(0%e\E(B%;, |
||||
|
||||
xterm-color|color-xterm|Eterm|eterm|color xterm terminal emulator (X Window System), |
||||
use=xterm, colors#8, pairs#64, |
||||
|
||||
# Set all color pairs to the original ones |
||||
# op=\E[0m, |
||||
op=\E[39;49m, |
||||
|
||||
is1=\e[?47l\e>\e[?1l, |
||||
is2=\e[r\e[m\e[2J\e[H\e[?7h\e[?1;3;4;6l\e[4l, |
||||
|
||||
# Enter/leave cursor address mode. The 1st set uses the |
||||
# secondary screen. The 2nd one doesn't. |
||||
smcup=\e7\e[?47h, rmcup=\e[2J\e[?47l\e8, |
||||
## smcup=\e7, rmcup=\e8, |
||||
|
||||
# Start/stop redirection to the printpipe |
||||
mc4=\e[4i, mc5=\e[5i, |
||||
|
||||
# User-defined string capabilities |
||||
# Report current screen position |
||||
u7=\e[6n, |
||||
# vt100 answerback |
||||
u8=\e[?1;2c, |
||||
# Request identity (replies with u8) |
||||
u9=\e[c, |
||||
|
||||
###### Add ANSI color support |
||||
Eterm-ansi|Eterm with ANSI color (X Window System), |
||||
use=Eterm-base, |
||||
sgr=\e[0%?%p1%p6%|%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;m%?%p9%t^N%e^O%;, |
||||
## sgr=\e[%?%p1%t;7%;%?%p2%t;4%;%?%p3%t;7%;%?%p4%t;5%;%?%p6%t;1%;m, |
||||
sgr0=\e[m^O, |
||||
|
||||
###### Add mouse reporting |
||||
Eterm-mouse|Eterm with X11 mouse reporting, |
||||
use=Eterm-ansi, |
||||
# Mouse info packet introducer |
||||
kmous=\e[M, |
||||
|
||||
###### Add xterm-style color sequences. |
||||
Eterm|Eterm-color|eterm|Eterm with xterm-style color support (X Window System), |
||||
use=Eterm-mouse, colors#8, pairs#64, |
||||
|
||||
# Revert to the original foreground/background pair |
||||
op=\e[39;49m, |
||||
# Set foreground color, background color |
||||
setf=\E[%p1%{30}%+%dm, setb=\E[%p1%{40}%+%dm, |
||||
|
||||
#--------------------------------------------------------------------- eof |
||||
setaf=\e[%p1%{30}%+%dm, setab=\e[%p1%{40}%+%dm, |
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,781 @@ |
||||
/*
|
||||
* Copyright (C) 1997-2000, Michael Jennings |
||||
* |
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
* of this software and associated documentation files (the "Software"), to |
||||
* deal in the Software without restriction, including without limitation the |
||||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
||||
* sell copies of the Software, and to permit persons to whom the Software is |
||||
* furnished to do so, subject to the following conditions: |
||||
* |
||||
* The above copyright notice and this permission notice shall be included in |
||||
* all copies of the Software, its documentation and marketing & publicity |
||||
* materials, and acknowledgment shall be given in the documentation, materials |
||||
* and software packages that this Software was used. |
||||
* |
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
||||
* THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER |
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
||||
*/ |
||||
|
||||
static const char cvs_ident[] = "$Id$"; |
||||
|
||||
#include "config.h" |
||||
#include "feature.h" |
||||
|
||||
#include <X11/cursorfont.h> |
||||
|
||||
#include "../libmej/debug.h" |
||||
#include "../libmej/mem.h" |
||||
#include "../libmej/strings.h" |
||||
#include "buttons.h" |
||||
#include "command.h" |
||||
#include "draw.h" |
||||
#include "e.h" |
||||
#include "events.h" |
||||
#include "font.h" |
||||
#include "startup.h" |
||||
#include "menus.h" |
||||
#include "misc.h" |
||||
#include "options.h" |
||||
#include "pixmap.h" |
||||
#include "screen.h" |
||||
#include "term.h" |
||||
#include "windows.h" |
||||
|
||||
static __inline__ void draw_string(buttonbar_t *, Drawable, GC, int, int, char *, size_t); |
||||
|
||||
buttonbar_t *buttonbar = NULL; |
||||
long bbar_total_h = -1; |
||||
|
||||
static __inline__ void |
||||
draw_string(buttonbar_t *bbar, Drawable d, GC gc, int x, int y, char *str, size_t len) |
||||
{ |
||||
|
||||
D_BBAR(("Writing string \"%s\" (length %lu) onto drawable 0x%08x at %d, %d\n", str, len, d, x, y)); |
||||
|
||||
#ifdef MULTI_CHARSET |
||||
if (bbar->fontset) |
||||
XmbDrawString(Xdisplay, d, bbar->fontset, gc, x, y, str, len); |
||||
else |
||||
#endif |
||||
XDrawString(Xdisplay, d, gc, x, y, str, len); |
||||
return; |
||||
bbar = NULL; |
||||
} |
||||
|
||||
buttonbar_t * |
||||
bbar_create(void) |
||||
{ |
||||
buttonbar_t *bbar; |
||||
Cursor cursor; |
||||
long mask; |
||||
XGCValues gcvalue; |
||||
XSetWindowAttributes xattr; |
||||
|
||||
bbar = (buttonbar_t *) MALLOC(sizeof(buttonbar_t)); |
||||
MEMSET(bbar, 0, sizeof(buttonbar_t)); |
||||
|
||||
xattr.border_pixel = BlackPixel(Xdisplay, Xscreen); |
||||
xattr.save_under = FALSE; |
||||
xattr.backing_store = NotUseful; |
||||
xattr.override_redirect = TRUE; |
||||
xattr.colormap = cmap; |
||||
|
||||
cursor = XCreateFontCursor(Xdisplay, XC_left_ptr); |
||||
mask = EnterWindowMask | LeaveWindowMask | PointerMotionMask | ButtonMotionMask | ButtonPressMask | ButtonReleaseMask; |
||||
gcvalue.foreground = xattr.border_pixel; |
||||
|
||||
bbar->font = load_font(etfonts[def_font_idx], "fixed", FONT_TYPE_X); |
||||
bbar->fwidth = bbar->font->max_bounds.width; |
||||
bbar->fheight = bbar->font->ascent + bbar->font->descent + rs_line_space; |
||||
bbar->h = 1; |
||||
bbar->w = 1; |
||||
gcvalue.font = bbar->font->fid; |
||||
|
||||
bbar->win = XCreateWindow(Xdisplay, Xroot, bbar->x, bbar->y, bbar->w, bbar->h, 0, Xdepth, InputOutput, CopyFromParent, |
||||
CWOverrideRedirect | CWSaveUnder | CWBackingStore | CWBorderPixel | CWColormap, &xattr); |
||||
XDefineCursor(Xdisplay, bbar->win, cursor); |
||||
XSelectInput(Xdisplay, bbar->win, mask); |
||||
XStoreName(Xdisplay, bbar->win, "Eterm Button Bar"); |
||||
|
||||
bbar->gc = XCreateGC(Xdisplay, bbar->win, GCForeground | GCFont, &gcvalue); |
||||
bbar_set_docked(bbar, BBAR_DOCKED_TOP); |
||||
|
||||
return bbar; |
||||
} |
||||
|
||||
void |
||||
bbar_init(buttonbar_t *bbar, int width) |
||||
{ |
||||
event_register_dispatcher(bbar_dispatch_event, bbar_event_init_dispatcher); |
||||
XSetForeground(Xdisplay, bbar->gc, images[image_bbar].norm->fg); |
||||
bbar_resize(bbar, width); |
||||
bbar_reset_total_height(); |
||||
bbar_calc_total_height(); |
||||
} |
||||
|
||||
void |
||||
bbar_event_init_dispatcher(void) |
||||
{ |
||||
/* FIXME: The event subsystem needs to be able to pass a pointer to the event data structure. */ |
||||
EVENT_DATA_ADD_HANDLER(buttonbar->event_data, EnterNotify, bbar_handle_enter_notify); |
||||
EVENT_DATA_ADD_HANDLER(buttonbar->event_data, LeaveNotify, bbar_handle_leave_notify); |
||||
EVENT_DATA_ADD_HANDLER(buttonbar->event_data, ButtonPress, bbar_handle_button_press); |
||||
EVENT_DATA_ADD_HANDLER(buttonbar->event_data, ButtonRelease, bbar_handle_button_release); |
||||
EVENT_DATA_ADD_HANDLER(buttonbar->event_data, MotionNotify, bbar_handle_motion_notify); |
||||
|
||||
event_data_add_mywin(&buttonbar->event_data, buttonbar->win); |
||||
} |
||||
|
||||
unsigned char |
||||
bbar_handle_enter_notify(event_t * ev) |
||||
{ |
||||
button_t *b; |
||||
Window unused_root, unused_child; |
||||
int unused_root_x, unused_root_y; |
||||
unsigned int unused_mask; |
||||
|
||||
D_EVENTS(("bbar_handle_enter_notify(ev [%8p] on window 0x%08x)\n", ev, ev->xany.window)); |
||||
|
||||
REQUIRE_RVAL(XEVENT_IS_MYWIN(ev, &buttonbar->event_data), 0); |
||||
|
||||
bbar_draw(buttonbar, IMAGE_STATE_SELECTED, 0); |
||||
XQueryPointer(Xdisplay, buttonbar->win, &unused_root, &unused_child, &unused_root_x, &unused_root_y, &(ev->xbutton.x), &(ev->xbutton.y), &unused_mask); |
||||
b = find_button_by_coords(buttonbar, ev->xbutton.x, ev->xbutton.y); |
||||
if (b) { |
||||
bbar_select_button(buttonbar, b); |
||||
} |
||||
return 1; |
||||
} |
||||
|
||||
unsigned char |
||||
bbar_handle_leave_notify(event_t * ev) |
||||
{ |
||||
D_EVENTS(("bbar_handle_leave_notify(ev [%8p] on window 0x%08x)\n", ev, ev->xany.window)); |
||||
|
||||
REQUIRE_RVAL(XEVENT_IS_MYWIN(ev, &buttonbar->event_data), 0); |
||||
|
||||
bbar_draw(buttonbar, IMAGE_STATE_NORMAL, 0); |
||||
if (buttonbar->current) { |
||||
bbar_deselect_button(buttonbar, buttonbar->current); |
||||
} |
||||
return 1; |
||||
} |
||||
|
||||
unsigned char |
||||
bbar_handle_button_press(event_t * ev) |
||||
{ |
||||
|
||||
D_EVENTS(("bbar_handle_button_press(ev [%8p] on window 0x%08x)\n", ev, ev->xany.window)); |
||||
|
||||
REQUIRE_RVAL(XEVENT_IS_MYWIN(ev, &buttonbar->event_data), 0); |
||||
|
||||
if (buttonbar->current) { |
||||
bbar_click_button(buttonbar, buttonbar->current); |
||||
button_check_action(buttonbar, buttonbar->current, 1, ev->xbutton.time); |
||||
} |
||||
return 1; |
||||
} |
||||
|
||||
unsigned char |
||||
bbar_handle_button_release(event_t * ev) |
||||
{ |
||||
button_t *b; |
||||
Window unused_root, unused_child; |
||||
int unused_root_x, unused_root_y; |
||||
unsigned int unused_mask; |
||||
|
||||
D_EVENTS(("bbar_handle_button_release(ev [%8p] on window 0x%08x)\n", ev, ev->xany.window)); |
||||
|
||||
REQUIRE_RVAL(XEVENT_IS_MYWIN(ev, &buttonbar->event_data), 0); |
||||
|
||||
XQueryPointer(Xdisplay, buttonbar->win, &unused_root, &unused_child, &unused_root_x, &unused_root_y, &(ev->xbutton.x), &(ev->xbutton.y), &unused_mask); |
||||
|
||||
b = find_button_by_coords(buttonbar, ev->xbutton.x, ev->xbutton.y); |
||||
if (b) { |
||||
if (buttonbar->current && (b != buttonbar->current)) { |
||||
bbar_deselect_button(buttonbar, buttonbar->current); |
||||
} else { |
||||
bbar_select_button(buttonbar, b); |
||||
button_check_action(buttonbar, b, 0, ev->xbutton.time); |
||||
} |
||||
} |
||||
|
||||
return 1; |
||||
} |
||||
|
||||
unsigned char |
||||
bbar_handle_motion_notify(event_t * ev) |
||||
{ |
||||
button_t *b; |
||||
Window unused_root, unused_child; |
||||
int unused_root_x, unused_root_y; |
||||
unsigned int mask; |
||||
|
||||
D_EVENTS(("bbar_handle_motion_notify(ev [%8p] on window 0x%08x)\n", ev, ev->xany.window)); |
||||
|
||||
REQUIRE_RVAL(XEVENT_IS_MYWIN(ev, &buttonbar->event_data), 0); |
||||
|
||||
while (XCheckTypedWindowEvent(Xdisplay, ev->xany.window, MotionNotify, ev)); |
||||
XQueryPointer(Xdisplay, buttonbar->win, &unused_root, &unused_child, &unused_root_x, &unused_root_y, &(ev->xbutton.x), &(ev->xbutton.y), &mask); |
||||
D_BBAR((" -> Pointer is at %d, %d with mask 0x%08x\n", ev->xbutton.x, ev->xbutton.y, mask)); |
||||
|
||||
b = find_button_by_coords(buttonbar, ev->xbutton.x, ev->xbutton.y); |
||||
if (b != buttonbar->current) { |
||||
if (buttonbar->current) { |
||||
bbar_deselect_button(buttonbar, buttonbar->current); |
||||
} |
||||
if (b) { |
||||
if (mask & (Button1Mask | Button2Mask | Button3Mask)) { |
||||
bbar_click_button(buttonbar, b); |
||||
} else { |
||||
bbar_select_button(buttonbar, b); |
||||
} |
||||
} |
||||
} |
||||
|
||||
return 1; |
||||
} |
||||
|
||||
unsigned char |
||||
bbar_dispatch_event(event_t * ev) |
||||
{ |
||||
if (buttonbar->event_data.handlers[ev->type] != NULL) { |
||||
return ((buttonbar->event_data.handlers[ev->type]) (ev)); |
||||
} |
||||
return (0); |
||||
} |
||||
|
||||
void |
||||
bbar_add(buttonbar_t *bbar) |
||||
{ |
||||
if (buttonbar) { |
||||
buttonbar_t *bb; |
||||
|
||||
for (bb = buttonbar; bb->next; bb = bb->next); |
||||
bb->next = bbar; |
||||
} else { |
||||
buttonbar = bbar; |
||||
} |
||||
bbar->next = NULL; |
||||
bbar_reset_total_height(); |
||||
bbar_calc_total_height(); |
||||
} |
||||
|
||||
unsigned short |
||||
bbar_calc_height(buttonbar_t *bbar) |
||||
{ |
||||
button_t *b; |
||||
ImlibBorder *bbord = images[image_bbar].norm->iml->border, *bord = images[image_button].norm->iml->border; |
||||
|
||||
D_BBAR(("bbar_calc_height(%8p): fascent == %d, fdescent == %d, h == %d\n", bbar, bbar->fascent, bbar->fdescent, bbar->h)); |
||||
|
||||
bbar->h = bbar->fascent + bbar->fdescent + 1; |
||||
if (bord) { |
||||
bbar->h += bord->top + bord->bottom; |
||||
} |
||||
for (b = bbar->buttons; b; b = b->next) { |
||||
if (b->h != bbar->h) { |
||||
b->h = bbar->h; |
||||
button_calc_size(bbar, b); |
||||
} |
||||
} |
||||
for (b = bbar->rbuttons; b; b = b->next) { |
||||
if (b->h != bbar->h) { |
||||
b->h = bbar->h; |
||||
button_calc_size(bbar, b); |
||||
} |
||||
} |
||||
if (bbord) { |
||||
bbar->h += bbord->top + bbord->bottom; |
||||
} |
||||
D_BBAR(("Final height is %d\n", bbar->h)); |
||||
return bbar->h; |
||||
} |
||||
|
||||
void |
||||
bbar_calc_sizes(buttonbar_t *bbar) |
||||
{ |
||||
button_t *b; |
||||
|
||||
D_BBAR(("bbar == %8p\n", bbar)); |
||||
|
||||
for (b = bbar->buttons; b; b = b->next) { |
||||
button_calc_size(bbar, b); |
||||
} |
||||
for (b = bbar->rbuttons; b; b = b->next) { |
||||
button_calc_size(bbar, b); |
||||
} |
||||
} |
||||
|
||||
void |
||||
bbar_calc_positions(buttonbar_t *bbar) |
||||
{ |
||||
button_t *b; |
||||
unsigned short x, y; |
||||
ImlibBorder *border = images[image_bbar].norm->iml->border; |
||||
|
||||
D_BBAR(("bbar == %8p\n", bbar)); |
||||
|
||||
y = ((border) ? (border->top) : 0); |
||||
if (bbar->buttons) { |
||||
x = ((border) ? (border->left) : 0) + MENU_HGAP; |
||||
for (b = bbar->buttons; b; b = b->next) { |
||||
b->x = x; |
||||
b->y = y; |
||||
D_BBAR(("Set button \"%s\" (%8p, width %d) to coordinates %d, %d\n", b->text, b, b->w, x, y)); |
||||
x += b->w + MENU_HGAP; |
||||
button_calc_rel_coords(bbar, b); |
||||
} |
||||
} |
||||
if (bbar->rbuttons) { |
||||
x = bbar->w - ((border) ? (border->right) : 0); |
||||
for (b = bbar->rbuttons; b; b = b->next) { |
||||
x -= b->w + MENU_HGAP; |
||||
b->x = x; |
||||
b->y = y; |
||||
button_calc_rel_coords(bbar, b); |
||||
D_BBAR(("Set button \"%s\" (%8p, width %d) to coordinates %d, %d\n", b->text, b, b->w, x, y)); |
||||
} |
||||
} |
||||
} |
||||
|
||||
void |
||||
button_calc_size(buttonbar_t *bbar, button_t *button) |
||||
{ |
||||
ImlibBorder *bord = images[image_button].norm->iml->border; |
||||
int ascent, descent, direction; |
||||
XCharStruct chars; |
||||
|
||||
D_BBAR(("button_calc_size(%8p, %8p): XTextExtents(%8p, %s, %d, ...)\n", bbar, button, bbar->font, button->text, button->len)); |
||||
|
||||
button->w = 0; |
||||
if (button->len) { |
||||
XTextExtents(bbar->font, button->text, button->len, &direction, &ascent, &descent, &chars); |
||||
LOWER_BOUND(bbar->fascent, chars.ascent); |
||||
LOWER_BOUND(bbar->fdescent, chars.descent); |
||||
button->w += chars.width; |
||||
} |
||||
if (bord) { |
||||
button->w += bord->left + bord->right; |
||||
} |
||||
if (button->h == 0) { |
||||
button->h = bbar->fascent + bbar->fdescent + 1; |
||||
if (bord) { |
||||
button->h += bord->top + bord->bottom; |
||||
} |
||||
} |
||||
if (button->icon) { |
||||
unsigned short b = 0; |
||||
|
||||
if (bord) { |
||||
b = button->h - bord->top - bord->bottom; |
||||
} |
||||
button->icon_w = button->icon->iml->im->rgb_width; |
||||
button->icon_h = button->icon->iml->im->rgb_height; |
||||
D_BBAR((" -> Initial icon dimensions are %hux%hu\n", button->icon_w, button->icon_h)); |
||||
if (button->icon_h > b) { |
||||
button->icon_w = (unsigned short) ((float) button->icon_w / button->icon_h * b); |
||||
button->icon_h = b; |
||||
} |
||||
button->w += button->icon_w; |
||||
if (button->len) { |
||||
button->w += MENU_HGAP; |
||||
} |
||||
D_BBAR((" -> Final icon dimensions are %hux%hu\n", button->icon_w, button->icon_h)); |
||||
} |
||||
D_BBAR((" -> Set button to %dx%d at %d, %d and icon to %dx%d\n", button->w, button->h, button->x, button->y, button->icon_w, button->icon_h)); |
||||
} |
||||
|
||||
void |
||||
button_calc_rel_coords(buttonbar_t *bbar, button_t *button) |
||||
{ |
||||
ImlibBorder *bord = images[image_button].norm->iml->border; |
||||
|
||||
D_BBAR(("bbar == %8p, button == %8p\n", bbar, button)); |
||||
|
||||
if (button->icon) { |
||||
unsigned short b = 0; |
||||
|
||||
if (bord) { |
||||
b = button->h - bord->top - bord->bottom - 2; |
||||
} |
||||
if (button->icon_h == button->h) { |
||||
button->icon_y = button->y + ((bord) ? (bord->top) : 0); |
||||
} else { |
||||
button->icon_y = button->y + ((b - button->icon_h) / 2) + ((bord) ? (bord->top) : 0); |
||||
} |
||||
button->icon_x = button->x + ((bord) ? (bord->left) : 0); |
||||
} |
||||
if (button->len) { |
||||
button->text_x = button->x + ((button->icon_w) ? (button->icon_w + MENU_HGAP) : 0) + ((bord) ? (bord->left) : (0)); |
||||
button->text_y = button->y + button->h - ((bord) ? (bord->bottom) : (0)) - bbar->fdescent; |
||||
} |
||||
D_BBAR((" -> Text is at %d, %d and icon is at %d, %d\n", button->text_x, button->text_y, button->icon_x, button->icon_y)); |
||||
} |
||||
|
||||
void |
||||
bbar_add_button(buttonbar_t *bbar, button_t *button) |
||||
{ |
||||
button_t *b; |
||||
|
||||
D_BBAR(("bbar_add_button(%8p, %8p): Adding button \"%s\".\n", bbar, button, button->text)); |
||||
|
||||
if (bbar->buttons) {
|
||||
for (b = bbar->buttons; b->next; b = b->next); |
||||
b->next = button; |
||||
} else { |
||||
bbar->buttons = button; |
||||
} |
||||
button->next = NULL; |
||||
} |
||||
|
||||
void |
||||
bbar_add_rbutton(buttonbar_t *bbar, button_t *button) |
||||
{ |
||||
button_t *b; |
||||
|
||||
D_BBAR(("bbar_add_rbutton(%8p, %8p): Adding button \"%s\".\n", bbar, button, button->text)); |
||||
|
||||
b = ((bbar->rbuttons) ? (bbar->rbuttons) : NULL); |
||||
bbar->rbuttons = button; |
||||
button->next = b; |
||||
} |
||||
|
||||
unsigned char |
||||
bbar_set_font(buttonbar_t *bbar, const char *fontname) |
||||
{ |
||||
XFontStruct *font; |
||||
|
||||
ASSERT_RVAL(fontname != NULL, 0); |
||||
|
||||
D_BBAR(("bbar_set_font(%8p, \"%s\"): Current font is %8p, dimensions %d/%d/%d\n", bbar, fontname, bbar->font, bbar->fwidth, bbar->fheight, bbar->h)); |
||||
if (bbar->font) { |
||||
free_font(bbar->font); |
||||
} |
||||
#ifdef MULTI_CHARSET |
||||
if (bbar->fontset) { |
||||
XFreeFontSet(Xdisplay, bbar->fontset); |
||||
} |
||||
#endif |
||||
|
||||
font = (XFontStruct *) load_font(fontname, "fixed", FONT_TYPE_X); |
||||
#ifdef MULTI_CHARSET |
||||
bbar->fontset = create_fontset(fontname, etmfonts[def_font_idx]); |
||||
#endif |
||||
|
||||
bbar->font = font; |
||||
bbar->fwidth = font->max_bounds.width; |
||||
bbar->fheight = font->ascent + font->descent + rs_line_space; |
||||
XSetFont(Xdisplay, bbar->gc, font->fid); |
||||
bbar_reset_total_height(); |
||||
D_BBAR(("New dimensions are %d/%d/%d\n", bbar->fwidth, bbar->fheight, bbar->h)); |
||||
|
||||
return 1; |
||||
} |
||||
|
||||
button_t * |
||||
find_button_by_text(buttonbar_t *bbar, char *text) |
||||
{ |
||||
register button_t *b; |
||||
|
||||
REQUIRE_RVAL(text != NULL, NULL); |
||||
|
||||
for (b = bbar->buttons; b; b = b->next) { |
||||
if (!strcasecmp(b->text, text)) { |
||||
return (b); |
||||
} |
||||
} |
||||
for (b = bbar->rbuttons; b; b = b->next) { |
||||
if (!strcasecmp(b->text, text)) { |
||||
return (b); |
||||
} |
||||
} |
||||
return NULL; |
||||
} |
||||
|
||||
button_t * |
||||
find_button_by_coords(buttonbar_t *bbar, int x, int y) |
||||
{ |
||||
register button_t *b; |
||||
|
||||
ASSERT_RVAL(bbar != NULL, NULL); |
||||
|
||||
for (b = bbar->buttons; b; b = b->next) { |
||||
if ((x >= b->x) && (y >= b->y) && (x < b->x + b->w) && (y < b->y + b->h)) { |
||||
return (b); |
||||
} |
||||
} |
||||
for (b = bbar->rbuttons; b; b = b->next) { |
||||
if ((x >= b->x) && (y >= b->y) && (x < b->x + b->w) && (y < b->y + b->h)) { |
||||
return (b); |
||||
} |
||||
} |
||||
return NULL; |
||||
} |
||||
|
||||
button_t * |
||||
button_create(char *text) |
||||
{ |
||||
button_t *button; |
||||
|
||||
button = (button_t *) MALLOC(sizeof(button_t)); |
||||
MEMSET(button, 0, sizeof(button_t)); |
||||
|
||||
if (text) { |
||||
button->text = StrDup(text); |
||||
button->len = strlen(text); |
||||
} else { |
||||
button->text = ""; |
||||
button->len = 0; |
||||
} |
||||
return button; |
||||
} |
||||
|
||||
unsigned char |
||||
button_set_icon(button_t *button, simage_t * icon) |
||||
{ |
||||
ASSERT_RVAL(button != NULL, 0); |
||||
ASSERT_RVAL(icon != NULL, 0); |
||||
|
||||
button->icon = icon; |
||||
return 1; |
||||
} |
||||
|
||||
unsigned char |
||||
button_set_action(button_t *button, action_type_t type, char *action) |
||||
{ |
||||
ASSERT_RVAL(button != NULL, 0); |
||||
|
||||
button->type = type; |
||||
switch (type) { |
||||
case ACTION_MENU: |
||||
button->action.menu = find_menu_by_title(menu_list, action); |
||||
break; |
||||
case ACTION_STRING: |
||||
case ACTION_ECHO: |
||||
button->action.string = (char *) MALLOC(strlen(action) + 2); |
||||
strcpy(button->action.string, action); |
||||
parse_escaped_string(button->action.string); |
||||
break; |
||||
default: |
||||
break; |
||||
} |
||||
return 1; |
||||
} |
||||
|
||||
void |
||||
bbar_select_button(buttonbar_t *bbar, button_t *button) |
||||
{ |
||||
bbar->current = button; |
||||
if (image_mode_is(image_button, MODE_MASK)) { |
||||
paste_simage(images[image_button].selected, image_button, bbar->win, button->x, button->y, button->w, button->h); |
||||
} else { |