Compare commits

...

8 Commits

Author SHA1 Message Date
Michael Jennings f176b4632d Patch from Pavel Sanda <ps@ucw.cz> to fix copy/paste behavior with
some Qt-based apps (e.g., LyX).
2014-03-26 10:00:35 -07:00
Michael Jennings c262cddf04 Sun Sep 12 23:36:21 2010 Michael Jennings (mej)
Fix merge error and additional LibAST updates.
----------------------------------------------------------------------


SVN revision: 52177
2010-09-13 06:36:22 +00:00
Michael Jennings dba393060d Sun Sep 12 23:20:09 2010 Michael Jennings (mej)
Merge changes from 0.9.6 branch.
----------------------------------------------------------------------


SVN revision: 52176
2010-09-13 06:20:10 +00:00
Michael Jennings ddde1c6b09 Sun Oct 25 14:18:42 2009 Michael Jennings (mej)
Patch from Kim Woelders <kim@woelders.dk> that adds UTF-8 support to
Eterm (with a fix for 64-bit platforms).

This patch should be considered EXPERIMENTAL; that's why it's on the
0.10 branch.  It probably needs a lot of love, so please test and
contribute fixes.
----------------------------------------------------------------------


SVN revision: 43287
2009-10-25 21:20:23 +00:00
Michael Jennings 0266d95d87 Sun Oct 25 14:10:47 2009 Michael Jennings (mej)
Merge.
----------------------------------------------------------------------


SVN revision: 43286
2009-10-25 21:10:48 +00:00
Michael Jennings b9dbac51a3 Sun Oct 25 12:12:06 2009 Michael Jennings (mej)
Fix some bad replacements.
----------------------------------------------------------------------


SVN revision: 43279
2009-10-25 20:05:16 +00:00
Michael Jennings 7b63ff93b9 Sun Oct 25 11:35:50 2009 Michael Jennings (mej)
Merge code from 0.9.5.  0.10 branch is now up-to-date.
----------------------------------------------------------------------


SVN revision: 43274
2009-10-25 18:35:54 +00:00
Michael Jennings 4137cf0e3f Commit Eterm 0.10 as it existed in CVS.
SVN revision: 42950
2009-10-08 03:47:32 +00:00
94 changed files with 2668 additions and 1795 deletions

45
.gitignore vendored Normal file
View File

@ -0,0 +1,45 @@
*.log
config.sub
config.cache
config.guess
configure
ltconfig
ltmain.sh
Makefile
Makefile.in
aclocal.m4
libtool.m4
lt*.m4
config.status
config.h
libtool
stamp-h*
libast.spec
config.h.in
missing
mkinstalldirs
install-sh
Eterm*.tar.gz
*.sddf
Makefile
Makefile.in
.deps
.libs
lib*.la
*.da
*.lo
*.o
autom4te*
depcomp
*.orig
*.rej
*~
doc/Eterm.1
doc/Eterm.1.html
doc/Eterm.tcap
src/Eterm
themes/*/theme.cfg
utils/Esetroot
utils/Etbg
utils/Ettable
utils/kEsetroot

353
ChangeLog
View File

@ -4620,9 +4620,21 @@ Mon Apr 29 10:48:33 2002 Michael Jennings (mej)
Disable the screen dump escape sequence and implement a save_buff()
script function instead.
----------------------------------------------------------------------
Mon Apr 29 21:18:20 2002 Michael Jennings (mej)
Mon Apr 29 17:44:46 2002 Michael Jennings (mej)
Fixed the --install option which hasn't worked for ages.
Use the new option parser in libast. You will need the latest libast
from CVS to use this version, but if you have it, and you've always
been bugged by that -F -font-name-with-dashes problem, give this a
try.
This branch is a playground for 0.10 development. Be careful before
attempting to use anything you get from here.
----------------------------------------------------------------------
Mon Apr 29 21:06:07 2002 Michael Jennings (mej)
Oops...need to pre-parse some of those options. :)
Also fixed the --install option which hasn't worked for ages.
----------------------------------------------------------------------
Sat May 4 10:23:38 2002 Michael Jennings (mej)
@ -4643,14 +4655,19 @@ Tue May 7 10:16:56 2002 Michael Jennings (mej)
configure.in and configure.ac should no longer differ, so let's not
maintain both.
----------------------------------------------------------------------
Mon May 13 18:46:06 2002 Michael Jennings (mej)
Thu May 9 11:30:15 2002 Michael Jennings (mej)
Getting synced back up with the main trunk. This includes Azundris'
Escreen patch and re-indenting the code.
----------------------------------------------------------------------
Thu May 9 11:39:02 2002 Michael Jennings (mej)
Now works with the latest libast.
----------------------------------------------------------------------
Mon May 13 19:15:34 2002 Michael Jennings (mej)
Latest Escreen patch from Azundris <hacks@azundris.com>.
----------------------------------------------------------------------
Mon May 13 19:18:46 2002 Michael Jennings (mej)
Fixed indentation.
----------------------------------------------------------------------
Mon May 13 23:58:16 2002 Michael Jennings (mej)
Fixed a bad paste.
@ -5227,6 +5244,14 @@ events. This should correct that behavior.
----------------------------------------------------------------------
Mon Jun 28 12:34:36 2004 Michael Jennings (mej)
Cleaning up some warnings.
----------------------------------------------------------------------
Mon Jun 28 12:46:09 2004 Michael Jennings (mej)
Fixed Escreen menu file.
----------------------------------------------------------------------
Mon Jun 28 12:34:36 2004 Michael Jennings (mej)
Cleaning up some warnings.
----------------------------------------------------------------------
Wed Jul 14 16:16:48 2004 Michael Jennings (mej)
@ -5236,6 +5261,70 @@ _NET_WM_ICON property.
Fixed a couple warnings.
----------------------------------------------------------------------
Thu Jul 15 15:46:34 2004 Michael Jennings (mej)
Fixed compile error in term.c
Actions are now honest-to-goodness libast-style objects. Action
bindings for menus are currently disabled, but other stuff works.
----------------------------------------------------------------------
Fri Jul 16 17:59:48 2004 Michael Jennings (mej)
If $LANG refers to a UTF-8 or similar locale, remove that part. In
other words, en_US.utf8 becomes en_US instead.
----------------------------------------------------------------------
Fri Jul 23 12:21:25 2004 Michael Jennings (mej)
Kirby Kuehl <vacuum@technotronic.com> pointed out some portability
issues. These should now be fixed.
----------------------------------------------------------------------
Fri Jul 23 12:27:18 2004 Michael Jennings (mej)
Oops, missed one. :(
----------------------------------------------------------------------
Wed Nov 3 18:17:52 2004 Michael Jennings (mej)
Small patch for building against libast 0.6.1.
Fixed compile error when enabling OFFIX_DND support pointed out by JG
Miller <miller@yoyo.org>.
----------------------------------------------------------------------
Sun Nov 7 15:37:43 2004 Michael Jennings (mej)
Fixed minor typo.
----------------------------------------------------------------------
Tue Dec 14 17:13:02 2004 Michael Jennings (mej)
0.9.3 release
----------------------------------------------------------------------
Tue Dec 14 17:22:23 2004 Michael Jennings (mej)
The benefits of being a passenger on a long road trip... The
beginnings of EWMH opacity (a la xcompmgr) support and (hopefully)
UTF-8 support. Both as yet untested.
----------------------------------------------------------------------
Fri Dec 17 16:35:31 2004 Michael Jennings (mej)
Another attempt (and failure) at UTF-8 support. Disabled until
someone can help me out.
If you know iconv(), please have a look at the FIXME_BLOCK starting at
line 3509 of src/command.c.
----------------------------------------------------------------------
Mon Dec 20 14:31:33 2004 Michael Jennings (mej)
Okay, so my first problem was that I didn't pay close enough attention
to the iconv_open() man page and got the parameter order wrong. Duh.
Thanks to Sytse Wielinga <s.b.wielinga@student.utwente.nl> for
noticing that.
kwo suggested using XmbDrawString(), but that causes font problems I'm
not ready to diagnose just yet.
----------------------------------------------------------------------
Wed Jan 5 15:17:51 2005 Michael Jennings (mej)
Spec dependency fixes.
----------------------------------------------------------------------
Fri Jul 16 17:59:48 2004 Michael Jennings (mej)
If $LANG refers to a UTF-8 or similar locale, remove that part. In
@ -5313,6 +5402,10 @@ Fixed error in saving of cut_chars attribute.
Fixed saving/handling of beep_command attribute.
----------------------------------------------------------------------
Tue Mar 15 17:29:24 2005 Michael Jennings (mej)
Big-ass merge.
----------------------------------------------------------------------
Mon Apr 18 16:00:22 2005 Michael Jennings (mej)
Remove unused NO_XLOCALE crap and do it right.
@ -5437,3 +5530,249 @@ Fixed an incredibly-difficult-to-track-down missing "break" statement
which caused the "New..." and Ctrl-T functionality to fail to prompt
for a tab name.
----------------------------------------------------------------------
Mon Dec 5 13:33:58 2005 Michael Jennings (mej)
Merge and re-indent code.
----------------------------------------------------------------------
Mon Dec 5 15:46:34 2005 Michael Jennings (mej)
Prevent firewall bounces from trying for the same port.
----------------------------------------------------------------------
Thu Dec 22 18:32:31 2005 Michael Jennings (mej)
Cleanups and minor enhancements.
----------------------------------------------------------------------
Wed Jan 4 03:44:04 2006 Michael Jennings (mej)
X resource tracking/debugging support.
----------------------------------------------------------------------
Wed Jan 4 04:14:14 2006 Michael Jennings (mej)
Applied patches from Tres Melton <tres@mindspring.com> for SSE2
alignment and other shading-related issues.
----------------------------------------------------------------------
Wed Jan 4 04:22:13 2006 Michael Jennings (mej)
Update copyright dates.
----------------------------------------------------------------------
Thu Jan 5 14:50:53 2006 Michael Jennings (mej)
Fixed firewall bounce port checking from 2005-12-05.
----------------------------------------------------------------------
Mon Feb 6 01:02:15 2006 Michael Jennings (mej)
Fixed paste from clipboard.
----------------------------------------------------------------------
Mon Feb 6 17:15:49 2006 Michael Jennings (mej)
DragonFly BSD fixes from Joerg Sonnenberger <joerg@britannica.bec.de>.
Also some type mismatch fixes.
----------------------------------------------------------------------
Mon Feb 13 14:51:56 2006 Michael Jennings (mej)
Update to libast 0.6+ API.
----------------------------------------------------------------------
Fri Feb 24 16:58:43 2006 Michael Jennings (mej)
Add fallback attempt to open display in case NEED_LINUX_HACK is set
and shouldn't be.
----------------------------------------------------------------------
Wed May 17 15:42:28 2006 Michael Jennings (mej)
Patch from Kim Woelders <kim@woelders.dk> to optimize transparent
Eterms moved an even multiple of the desktop size (i.e., to another
desktop area).
----------------------------------------------------------------------
Fri May 19 16:46:02 2006 Michael Jennings (mej)
Fixed a problem that's been bugging me for ages: Instead of a
hard-coded delay, wait until we can connect to the ssh forwarding port
before starting the Escreen session via ssh.
Add usleep() to system() wait so as to not peg the CPU while sitting
and spinning.
----------------------------------------------------------------------
Sat Jun 17 23:06:03 2006 Michael Jennings (mej)
Daniel Macks <dmacks@netspace.org> noticed that gdb.scr wasn't being
installed. Oops. Fixed now.
----------------------------------------------------------------------
Fri Aug 18 13:41:14 2006 Michael Jennings (mej)
Addressed licensing concerns.
----------------------------------------------------------------------
Tue Aug 22 14:07:23 2006 Michael Jennings (mej)
Forgot one.
----------------------------------------------------------------------
Tue Aug 22 14:38:15 2006 Michael Jennings (mej)
Eterm 0.9.4 is final.
----------------------------------------------------------------------
Tue Sep 19 17:07:28 2006 Michael Jennings (mej)
libscream.c is licensed just like Eterm.
----------------------------------------------------------------------
Wed Oct 18 13:35:18 2006 Michael Jennings (mej)
Fixed a typo and some logic errors in libscream located by Mike
Frysinger <vapier@gentoo.org>.
----------------------------------------------------------------------
Mon Oct 30 16:11:47 2006 Michael Jennings (mej)
Patch from Jason McCarver <slam@parasite.cc> to support -S/--sticky
option for "sticky" (i.e., present on all desktops) startup.
----------------------------------------------------------------------
Tue Jul 3 20:48:46 2007 Michael Jennings (mej)
Remove some cruft from kEsetroot.
----------------------------------------------------------------------
Wed May 14 12:42:51 2008 Michael Jennings (mej)
Patch from Kim Woelders <kim@woelders.dk>:
There is a race problem with Eterm during startup related to the
shell LINES/COLUMNS env vars.
If the WM changes the window size (e.g. due to saved settings)
before mapping the window, sometimes the shell will set LINES and
COLUMNS according to the old/incorrect size and sometimes to the
new/correct size, depending on wheter the call to tt_winsize() at
command.c line 2322 (by the shell child process) or the
tt_resize() (by the Eterm process) due to the ConfigureNotify
caused by the resize (or WM ICCCM ConfigureNotify) operation
happens first.
The call in question was added by Azundris for Escreen. So far
Escreen seems to be behaving properly with this patch applied, but all
my Eterm windows (Escreen and otherwise) are pre-sized with -g anyway.
So I'm going to keep my eye on it for awhile. In case of trouble,
change the "#if 0" to "#ifdef ESCREEN" to revert to previous behavior
when in Escreen mode. Normal operation should not require the call in
question.
----------------------------------------------------------------------
Wed May 14 14:54:16 2008 Michael Jennings (mej)
Modified patch from hsim@gmx.li to allow setting of the "Urgent" hint
on beep.
----------------------------------------------------------------------
Wed May 14 15:26:13 2008 Michael Jennings (mej)
Patch from Emmanuel Anne <emmanuel.anne@gmail.com> to fix cut/paste
with KDE applications.
----------------------------------------------------------------------
Wed May 14 16:09:04 2008 Michael Jennings (mej)
(Correct) fix for CVE-2008-1692. Eterm no longer defaults to using
":0" for $DISPLAY due to the possibility that an attacker can create a
fake X server on a shared system, intercept the Eterm X connection,
and send fake keystrokes to the victim's Eterm to execute arbitrary
commands as that user.
The previous fix, while it did indeed correct the vulnerability, broke
the --display option. The original fix from Bernhard Link was more
correct, albeit not quite on target.
----------------------------------------------------------------------
Wed Jun 11 20:18:44 2008 Michael Jennings (mej)
Eterm 0.9.5 release.
----------------------------------------------------------------------
Tue Dec 16 22:03:54 2008 Michael Jennings (mej)
Fix compile errors related to the removal of unnecessary typecasting
macros.
----------------------------------------------------------------------
Mon Jan 5 23:50:28 2009 Michael Jennings (mej)
Remove fontset fallbacks. I think this might help speed up the load
time slowness some people are seeing. Let's find out.
----------------------------------------------------------------------
Tue Jan 6 01:03:35 2009 Michael Jennings (mej)
Prevent blank Escreen buttonbar on startup.
----------------------------------------------------------------------
Tue Jan 6 01:08:47 2009 Michael Jennings (mej)
Update copyright dates and fix a bad license.
----------------------------------------------------------------------
Sun Oct 25 11:35:50 2009 Michael Jennings (mej)
Merge code from 0.9.5. 0.10 branch is now up-to-date.
----------------------------------------------------------------------
Sun Oct 25 12:12:06 2009 Michael Jennings (mej)
Fix some bad replacements.
----------------------------------------------------------------------
Sun Oct 25 12:29:32 2009 Michael Jennings (mej)
Re-enable SIGPIPE after fork() for child processes who might not
re-enable it on their own. Pointed out by Sylvain Martin
<sylvain.martin@ulg.ac.be>.
----------------------------------------------------------------------
Sun Oct 25 12:36:01 2009 Michael Jennings (mej)
Patch for FreeBSD UNIX98 pty support from Ed Schouten <ed@80386.nl>.
----------------------------------------------------------------------
Sun Oct 25 12:39:34 2009 Michael Jennings (mej)
Fix for scrolling limitations from Cliff Miller <cbm@whatexit.org>.
----------------------------------------------------------------------
Sun Oct 25 13:52:40 2009 Michael Jennings (mej)
Support font effects in 8 directions. Patch supplied by Joern
Bernhardt <Joern.Bernhardt@gmx.net>.
----------------------------------------------------------------------
Sun Oct 25 14:02:14 2009 Michael Jennings (mej)
Revert bad change to borderless code. We're now doing best effort
borderless with no override_redirect (which may come back some day as
a separate option if there's a need) based on advice from raster and
kwo.
----------------------------------------------------------------------
Sun Oct 25 14:07:07 2009 Michael Jennings (mej)
Fix off-by-one error that was causing crashes with visual bell. Found
by d_willsc@cojobo.bonn.de.
----------------------------------------------------------------------
Sun Oct 25 14:18:42 2009 Michael Jennings (mej)
Patch from Kim Woelders <kim@woelders.dk> that adds UTF-8 support to
Eterm (with a fix for 64-bit platforms).
This patch should be considered EXPERIMENTAL; that's why it's on the
0.10 branch. It probably needs a lot of love, so please test and
contribute fixes.
----------------------------------------------------------------------
Thu Nov 12 16:23:46 2009 Michael Jennings (mej)
Gearing up for 0.9.6 release.
----------------------------------------------------------------------
Thu Nov 12 22:11:49 2009 Michael Jennings (mej)
Additional debugging and proper bracing.
----------------------------------------------------------------------
Sun Aug 8 16:32:44 2010 Michael Jennings (mej)
Modified patch from Paolo Ferrario <skooks@tiscali.it> based on input
from Kim Woelders <kim@woelders.dk> to allow Eterm to respond to
selection requests in UTF-8, compound text, or string only.
Previously, exotic selection request types would receive a string
back, but it would claim to be whatever type was requested. Now it
claims to be a string, which is probably more correct. This should
also eliminate server round-trips when clients ask for UTF-8, get a
string, then ask for a string (Opera).
----------------------------------------------------------------------
Sun Sep 12 23:20:09 2010 Michael Jennings (mej)
Merge changes from 0.9.6 branch.
----------------------------------------------------------------------
Sun Sep 12 23:36:21 2010 Michael Jennings (mej)
Fix merge error and additional LibAST updates.
----------------------------------------------------------------------
Wed Mar 26 10:00:18 2014 Michael Jennings (mej)
Patch from Pavel Sanda <ps@ucw.cz> to fix copy/paste behavior with
some Qt-based apps (e.g., LyX).
----------------------------------------------------------------------

View File

@ -3,21 +3,24 @@
%endif
%define __os_install_post /usr/lib/rpm/brp-compress
%if %{?optflags:1}0
%define optflags ${RPM_OPT_FLAGS:--O0 -g3}
%endif
Summary: Enlightened terminal emulator
Name: Eterm
Version: 0.9.4
Version: 0.10
#Release: 1
Release: 0.%(date '+%Y%m%d')
License: BSD
Group: User Interface/X
Requires: imlib2, imlib2-loader_jpeg, imlib2-loader_png
#BuildSuggests: xorg-x11-devel
BuildRequires: libast imlib2-devel XFree86-devel
Source0: ftp://ftp.eterm.org/pub/Eterm/%{name}-%{version}.tar.%{compression}
Source1: ftp://ftp.eterm.org/pub/Eterm/%{name}-bg-%{version}.tar.%{compression}
URL: http://www.eterm.org/
BuildRoot: /var/tmp/%{name}-%{version}-root
Source0: http://www.eterm.org/download/%{name}-%{version}.tar.%{compression}
Source1: http://www.eterm.org/download/%{name}-bg-%{version}.tar.%{compression}
#BuildSuggests: xorg-x11-devel, XFree86-devel, xorg-x11-proto-devel, libXext-devel, libXt-devel, freetype-devel
BuildRequires: libast, imlib2-devel
Requires: imlib2, imlib2-loader_jpeg, imlib2-loader_png
BuildRoot: %{?_tmppath}%{!?_tmppath:/var/tmp}/%{name}-%{version}-%{release}-root
%description
Eterm is a color vt102 terminal emulator with enhanced graphical
@ -32,8 +35,7 @@ have the Imlib2 library installed.
%setup -a 1
%build
#CFLAGS="$RPM_OPT_FLAGS"
CFLAGS="-O0 -g3"
CFLAGS="%{optflags}"
export CFLAGS
# When using the configure macro, I also specify all the directory
@ -45,21 +47,21 @@ export CFLAGS
%{__make} %{?mflags}
%install
rm -rf $RPM_BUILD_ROOT
%{__rm} -rf $RPM_BUILD_ROOT
# If the configure macro is used above (which it is), there
# is NO reason to use the makeinstall macro here, so don't.
%{__make} install DESTDIR=$RPM_BUILD_ROOT %{?mflags_install}
( cd $RPM_BUILD_ROOT
mv .%{_bindir}/%{name} .%{_bindir}/%{name}-%{version}
%{__mv} .%{_bindir}/%{name} .%{_bindir}/%{name}-%{version}
cd $RPM_BUILD_ROOT%{_bindir}
ln -f -s %{name}-%{version} %{name}
%{__ln_s} -f %{name}-%{version} %{name}
cd $RPM_BUILD_ROOT
chmod +x .%{_libdir}/lib*so* ||:
)
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/X11/applnk/Utilities
%{__mkdir_p} $RPM_BUILD_ROOT%{_sysconfdir}/X11/applnk/Utilities
cat > $RPM_BUILD_ROOT%{_sysconfdir}/X11/applnk/Utilities/Eterm.desktop <<EOF
[Desktop Entry]
Name=Eterm
@ -76,7 +78,7 @@ chmod 0644 $RPM_BUILD_ROOT%{_sysconfdir}/X11/applnk/Utilities/Eterm.desktop
/sbin/ldconfig || :
if [ -d /usr/share/terminfo -a ! -f /usr/share/terminfo/E/Eterm ]; then
tic -o/usr/share/terminfo $RPM_DOC_DIR/%{name}-%{version}/%{name}.ti || :
tic -o/usr/share/terminfo %{_docdir}/%{name}-%{version}/%{name}.ti || :
fi
%postun
@ -88,7 +90,7 @@ rm -rf $RPM_BUILD_ROOT
%files
%defattr(-, root, root)
%doc doc/Eterm_reference.html doc/Eterm.1.html doc/Eterm.tcap doc/Eterm.ti doc/README.Escreen
%doc README ReleaseNotes ReleaseNotes.1 ChangeLog
%doc LICENSE README ReleaseNotes ReleaseNotes.1 ChangeLog
%config %{_sysconfdir}/X11/applnk/Utilities/Eterm.desktop
%{_bindir}/*
%{_libdir}/*
@ -96,99 +98,3 @@ rm -rf $RPM_BUILD_ROOT
%{_datadir}/%{name}/*
%changelog
* Tue Feb 20 2001 Tim Powers <timp@redhat.com>
- builds on Alpha now. No need to excludearch (bug 28472)
* Wed Feb 14 2001 Tim Powers <timp@redhat.com>
- removed images which are from Digital Blasphemy from the extra
images tarball, had to delete those images because they are not
allowed to be redistributed on CD, or in compressed format
* Tue Jan 9 2001 Tim Powers <timp@redhat.com>
- fixed a bunch of pre and post in/uninstall brokenness by dropping
split backgrounds package, backgrounds now included in Eterm
proper. This also makes the spec file a lot cleaner :)
* Sat Aug 19 2000 Tim Powers <timp@redhat.com>
- fix bug #15687
* Tue Aug 8 2000 Tim Powers <timp@redhat.com>
- fixed bug #15687 using Hans' patch
* Wed Aug 2 2000 Tim Powers <timp@redhat.com>
- rebuilt against libpng-1.0.8
* Mon Jul 24 2000 Prospector <prospector@redhat.com>
- rebuilt
* Sat Jul 22 2000 Tim Powers <timp@redhat.com>
- fix spec file problem with configure picking up egcs and running with it,
fixes linking bugs
* Mon Jul 10 2000 Tim Powers <timp@redhat.com>
- rebuilt
* Fri Jun 2 2000 Tim Powers <timp@redhat.com>
- no more wmconfig :) converted to applnk
- fix man page location. Now FHS compliant
- use macros wherever possible
- removed redundant defines at the top of the spec
* Mon Apr 10 2000 Tim Powers <timp@redhat.com>
- rebuilt for 7.0
* Thu Feb 03 2000 Tim Powers <timp@redhat.com>
- strip debug from libraries
* Wed Feb 02 2000 Tim Powers <timp@redhat.com>
- fixed problems when upgrading and error messages due to a faulty script in
the post section for the Eterm package
* Tue Feb 01 2000 Tim Powers <timp@redhat.com>
- applied patch from Hans de Goede <hans@highrise.nl> to fix some del, home
and end issues
* Fri Jan 29 2000 Tim Powers <timp@redhat.com>
- rebuilt for 6.2 powertools
- bzipped source to conserve space
- using percent configure so that libtoolize is run, needed for some of the
newer alphas instead of ./configure --prefix=
- stripping binaries again
* Fri Dec 10 1999 Michael Jennings <mej@eterm.org>
- Added Tim's spec file to CVS as Eterm.spec.in for 0.9
* Wed Dec 8 1999 Tim Powers <timp@redhat.com>
- using unified patch for utempter and themes from Michael Jennings
* Tue Dec 7 1999 Tim Powers <timp@redhat.com>
- added wmconfig entry
- split up into 2 packages, Eterm proper, and Eterm-backgrounds
- thanks to ewt, we no longer have to make Eterm suid root, uses utempter
instead
* Mon Dec 6 1999 Tim Powers <timp@redhat.com>
- updated to 0.8.10
- patched so that Eterm finds pix/themes in the right place
- new version fixes problems with utmp, conforms to Eterm docs.
- added RedHat.Eterm_suid which includes instructions on how to run Eterm in
order to have it seen by "w" and "who" as a regular user
* Fri Aug 20 1999 Tim Powers <timp@redhat.com>
- fixed roblem with removing all files when uninstalling Eterm.
* Tue Jul 27 1999 Tim Powers <timp@redhat.com>
- updated version to 0.8.9
- cleaned up spec
- updated patch
- includes new backgrounds
- built for 6.1
* Mon Apr 05 1999 Michael Maher <mike@redhat.com>
- update to 0.8.8
* Fri Oct 23 1998 Jeff Johnson <jbj@redhat.com>
- update to 0.8.7.
* Fri Oct 08 1998 Michael Maher <mike@redhat.com>
- built eterm

23
LICENSE Normal file
View File

@ -0,0 +1,23 @@
Copyright (C) 1997-2009, 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.

View File

@ -4,6 +4,6 @@ AUTOMAKE_OPTIONS = foreign
SUBDIRS = src themes utils doc bg pix
EXTRA_DIST = README ReleaseNotes ReleaseNotes.1 CVS-README ChangeLog autogen.sh Eterm.spec
EXTRA_DIST = LICENSE README ReleaseNotes ReleaseNotes.1 CVS-README ChangeLog autogen.sh Eterm.spec
MAINTAINERCLEANFILES = Makefile.in *~ aclocal.m4 config.guess config.sub configure depcomp \
install-sh ltconfig ltmain.sh missing mkinstalldirs stamp-h* *.log config.h.in

View File

@ -4,6 +4,8 @@ DIRS = tile scale
UPDATE_SCRIPT = @top_srcdir@/utils/Etbg_update_list
EXTRA_DIST = tile/circuit.jpg scale/Neopolis-horizon.jpg README.backgrounds
MAINTAINERCLEANFILES=Makefile.in
pixmapdir = $(pkgdatadir)/pix
themedir = $(pkgdatadir)/themes
@ -16,4 +18,3 @@ install-data-hook:
done) ; \
done)
$(UPDATE_SCRIPT) $(DESTDIR)${pixmapdir}
MAINTAINERCLEANFILES=Makefile.in

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View File

@ -22,7 +22,7 @@ SAVE_AUTOHEADER="$AUTOHEADER"
SAVE_AUTOMAKE="$AUTOMAKE"
AC_INIT(src/feature.h)
AM_INIT_AUTOMAKE(Eterm, 0.9.4)
AM_INIT_AUTOMAKE(Eterm, 0.10)
dnl# Set some basic variables
DATE="`date '+%d %B %Y'`"
@ -62,7 +62,6 @@ AC_DEFINE_UNQUOTED(GRKELOT_IDENT, "`grep '$''Id:' $srcdir/src/grkelot.c | sed 's
AC_DEFINE_UNQUOTED(MAIN_IDENT, "`grep '$''Id:' $srcdir/src/main.c | sed 's/^.*\$''Id: //;s/ \$.*$//;s/.v / /;s/ Exp//'`", [main.c RCS ID])
AC_DEFINE_UNQUOTED(MENUS_IDENT, "`grep '$''Id:' $srcdir/src/menus.c | sed 's/^.*\$''Id: //;s/ \$.*$//;s/.v / /;s/ Exp//'`", [menus.c RCS ID])
AC_DEFINE_UNQUOTED(MISC_IDENT, "`grep '$''Id:' $srcdir/src/misc.c | sed 's/^.*\$''Id: //;s/ \$.*$//;s/.v / /;s/ Exp//'`", [misc.c RCS ID])
AC_DEFINE_UNQUOTED(NETDISP_IDENT, "`grep '$''Id:' $srcdir/src/netdisp.c | sed 's/^.*\$''Id: //;s/ \$.*$//;s/.v / /;s/ Exp//'`", [netdisp.c RCS ID])
AC_DEFINE_UNQUOTED(OPTIONS_IDENT, "`grep '$''Id:' $srcdir/src/options.c | sed 's/^.*\$''Id: //;s/ \$.*$//;s/.v / /;s/ Exp//'`", [options.c RCS ID])
AC_DEFINE_UNQUOTED(PIXMAP_IDENT, "`grep '$''Id:' $srcdir/src/pixmap.c | sed 's/^.*\$''Id: //;s/ \$.*$//;s/.v / /;s/ Exp//'`", [pixmap.c RCS ID])
AC_DEFINE_UNQUOTED(SCREEN_IDENT, "`grep '$''Id:' $srcdir/src/screen.c | sed 's/^.*\$''Id: //;s/ \$.*$//;s/.v / /;s/ Exp//'`", [screen.c RCS ID])
@ -111,6 +110,7 @@ fi
AC_PROG_CC
AC_PROG_CPP
AM_PROG_AS
dnl# These must be run after AC_PROG_CC but before any other macros that use
dnl# the C compiler
@ -204,8 +204,9 @@ AC_CHECK_HEADERS(fcntl.h termios.h \
sys/ioctl.h sys/select.h sys/time.h \
sys/sockio.h sys/byteorder.h malloc.h \
utmpx.h unistd.h bsd/signal.h regex.h \
regexp.h stdarg.h X11/Xmu/Atoms.h \
X11/Sunkeysym.h X11/Xlocale.h)
regexp.h stdarg.h X11/X.h X11/Xlib.h \
X11/Sunkeysym.h X11/Xlocale.h \
)
AC_HEADER_TIME
dnl# Missing typedefs and replacements
@ -219,7 +220,8 @@ AC_TYPE_SIGNAL
AC_CHECK_FUNCS(atexit _exit unsetenv setutent \
seteuid memmove putenv strsep setresuid setresgid \
memmem usleep snprintf strcasestr strcasechr \
strcasepbrk strrev nl_langinfo)
strcasepbrk strrev nl_langinfo \
)
# NOTE: The following line is NOT NOT NOT NOT NOT a typo!
# If you are having problems with it, libast.m4 is not installed
@ -255,6 +257,9 @@ AC_ARG_WITH(debugging, [ --with-debugging[=num] enable debugging output, num i
AC_DEFINE_UNQUOTED(DEBUG, 4, [Debugging level to compile in.])
])
AC_CHECK_FUNC(posix_openpt,
HAVE_POSIX_OPENPT=yes
)
AC_CHECK_FUNC(ptsname,
HAVE_PTSNAME=yes
)
@ -267,6 +272,10 @@ AC_CHECK_FUNC(unlockpt,
dnl# Check for the appropriate pty mechanism
AC_MSG_CHECKING(for pty mechanism)
PTY_MECH=""
if test ! -z "$HAVE_POSIX_OPENPT" -a ! -z "$HAVE_PTSNAME" -a ! -z "$HAVE_GRANTPT" -a ! -z "$HAVE_UNLOCKPT"; then
AC_DEFINE(HAVE_POSIX_OPENPT, , [Define for posix_openpt() support.])
PTY_MECH="POSIX $PTY_MECH"
fi
if test -c /dev/ptc ; then
AC_DEFINE(HAVE_DEV_PTC, , [Define for /dev/ptc support.])
PTY_MECH="AIX $PTY_MECH"
@ -862,16 +871,30 @@ AC_ARG_ENABLE(xim,
XIM="TRUE"
])
# For multibyte selection handling
#if test "$MULTICHAR_ENCODING" != "none"; then
AC_CHECK_LIB(Xmu, XmuInternAtom)
#fi
# check X11R6 for XIM
if test "$XIM" = "TRUE"; then
AC_CHECK_LIB(X11, XRegisterIMInstantiateCallback, AC_DEFINE(USE_X11R6_XIM, , [Define if we have X11R6 XIM.]))
fi
# Check for XResource extension
AC_CHECK_HEADER([X11/extensions/XRes.h],
[
AC_DEFINE([HAVE_X11_EXTENSIONS_XRES_H], [], [Define if we have X11/extensions/XRes.h])
], [],
[
#ifdef HAVE_X11_X_H
# include <X11/X.h>
#endif
#ifdef HAVE_X11_XLIB_H
# include <X11/Xlib.h>
#endif
])
AC_CHECK_LIB(XRes, XResQueryExtension,
[
GRLIBS="$GRLIBS -lXRes"
AC_DEFINE(HAVE_XRES_EXT, , [Define if we have the XResource extension.])
])
AC_MSG_CHECKING(for Greek keyboard support)
AC_ARG_ENABLE(greek,
[ --enable-greek compile with support for Greek keyboards], [

2
debian/copyright vendored
View File

@ -8,7 +8,7 @@ Upstream Author: Michael Jennings <mej@eterm.org>
Copyright:
Copyright (C) 1997-2004, Michael Jennings
Copyright (C) 1997-2009, 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

0
debian/rules vendored Normal file → Executable file
View File

View File

@ -457,6 +457,9 @@ Display the scrollbar only when the Eterm window is focused.
.BR "\-x", " \-\-borderless"
This option forces Eterm to have no borders.
.TP
.BR "\-S", " \-\-sticky"
Start Eterm as a sticky window (shows on all desktops)
.TP
.BR "\-m", " \-\-map-alert"
Un-iconify on beep.
.TP
@ -1734,6 +1737,11 @@ If true (default), any colored text (that is, any text not rendered
using the default foreground color) will not be given any other
special treatment for bolding (e.g., bold font or bold overstrike).
.RE
.BI sticky " boolean"
.RS 5
If true, Eterm will make its window sticky (shows on all desktops).
.RE
.RE
.TP

View File

@ -1,19 +0,0 @@
Eterm|Eterm Terminal Emulator (X11 Window System):\
:am:bw:eo:km:mi:ms:xn:xo:\
:co#80:it#8:li#24:lm#0:pa#64:Co#8:AF=\E[3%dm:AB=\E[4%dm:op=\E[39m\E[49m:\
:AL=\E[%dL:DC=\E[%dP:DL=\E[%dM:DO=\E[%dB:IC=\E[%d@:\
:K1=\E[7~:K2=\EOu:K3=\E[5~:K4=\E[8~:K5=\E[6~:LE=\E[%dD:\
:RI=\E[%dC:UP=\E[%dA:ae=^O:al=\E[L:as=^N: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[3g:dc=\E[P:dl=\E[M:do=\E[B:\
: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:\
: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~:kD=\E[3~:\
: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:rc=\E8:\
: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:ue=\E[24m:up=\E[A:\
:us=\E[4m:vb=\E[?5h\E[?5l:ve=\E[?25h:vi=\E[?25l:\
:ac=``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~:

View File

@ -4,6 +4,7 @@ EXTRA_DIST = bar_horizontal_1.png bar_horizontal_2.png bar_horizontal_3.png bar
bar_vertical_3.png button_arrow_down_1.png button_arrow_down_2.png button_arrow_down_3.png \
button_arrow_up_1.png button_arrow_up_2.png button_arrow_up_3.png menu1.png menu2.png menu3.png \
thumb_1.png thumb_2.png help.png exit.png
MAINTAINERCLEANFILES=Makefile.in
pixmapdir = $(pkgdatadir)/pix
@ -16,4 +17,3 @@ install-data-hook:
uninstall-hook:
rm -rf $(DESTDIR)$(pkgdatadir)/pix
MAINTAINERCLEANFILES=Makefile.in

Binary file not shown.

Before

Width:  |  Height:  |  Size: 722 B

After

Width:  |  Height:  |  Size: 723 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 757 B

After

Width:  |  Height:  |  Size: 758 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 715 B

After

Width:  |  Height:  |  Size: 716 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 817 B

After

Width:  |  Height:  |  Size: 818 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 812 B

After

Width:  |  Height:  |  Size: 813 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 811 B

After

Width:  |  Height:  |  Size: 812 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 746 B

After

Width:  |  Height:  |  Size: 747 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 722 B

After

Width:  |  Height:  |  Size: 723 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 723 B

After

Width:  |  Height:  |  Size: 724 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 708 B

After

Width:  |  Height:  |  Size: 709 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 696 B

After

Width:  |  Height:  |  Size: 697 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 703 B

After

Width:  |  Height:  |  Size: 704 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 KiB

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 209 B

After

Width:  |  Height:  |  Size: 210 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 209 B

After

Width:  |  Height:  |  Size: 210 B

View File

@ -9,8 +9,9 @@ done
for i in *.c src/*.c utils/*.c ; do
if test -f $i; then
echo Reformatting $i
indent -bad -bap -bbo -br -brs -cdw -ce -ci4 -cli4 -cs -di1 -i4 -l132 \
-lp -lps -nbc -nbfda -npcs -nprs -nsob -nss -nut -psl -saf -sai -saw $TYPENAMES $i
indent -bad -bap -bbo -bli0 -br -brs -cdw -ce -ci4 -cli4 -cs -di1 -i4 -l132 \
-lp -lps -nbc -nbfda -npcs -nprs -nsob -nss -nut -psl -saf -sai -saw -sbi0 \
$TYPENAMES $i
fi
done

View File

@ -9,14 +9,14 @@ MMX_OBJS = mmx_cmod.lo
SSE2_SRCS = sse2_cmod.c
SSE2_OBJS = sse2_cmod.lo
libEterm_la_SOURCES = actions.c actions.h buttons.c buttons.h command.c \
command.h draw.c draw.h e.c e.h eterm_debug.h eterm_utmp.h \
events.c events.h feature.h font.c font.h grkelot.c \
grkelot.h icon.h menus.c menus.h misc.c misc.h netdisp.c \
options.c options.h pixmap.c pixmap.h profile.h screen.c \
screen.h script.c script.h scrollbar.c scrollbar.h \
startup.c startup.h system.c system.h term.c term.h \
timer.c timer.h utmp.c windows.c windows.h defaultfont.c \
libEterm_la_SOURCES = actions.c actions.h buttons.c buttons.h command.c \
command.h draw.c draw.h e.c e.h eterm_debug.h eterm_utmp.h \
events.c events.h feature.h font.c font.h grkelot.c \
grkelot.h icon.h menus.c menus.h misc.c misc.h \
options.c options.h pixmap.c pixmap.h profile.h screen.c \
screen.h script.c script.h scrollbar.c scrollbar.h \
startup.c startup.h system.c system.h term.c term.h \
timer.c timer.h utmp.c windows.c windows.h defaultfont.c \
defaultfont.h libscream.c scream.h screamcfg.h
EXTRA_libEterm_la_SOURCES = $(MMX_SRCS) $(SSE2_SRCS)
@ -39,9 +39,9 @@ Eterm_DEPENDENCIES = libEterm.la
Eterm_LDFLAGS = -rpath $(libdir):$(pkglibdir)
Eterm_LDADD = libEterm.la
EXTRA_DIST = mmx_cmod.S sse2_cmod.c
EXTRA_DIST = gdb.scr mmx_cmod.S sse2_cmod.c
MAINTAINERCLEANFILES=Makefile.in
install-exec-hook:
$(mkinstalldirs) $(DESTDIR)$(pkgdatadir)
test ! -z "$(GDB_CMD_FILE)" && $(INSTALL_DATA) gdb.scr $(DESTDIR)$(pkgdatadir)/ || :
MAINTAINERCLEANFILES=Makefile.in
test ! -z "$(GDB_CMD_FILE)" && $(INSTALL_DATA) $(srcdir)/gdb.scr $(DESTDIR)$(pkgdatadir)/ || :

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 1997-2004, Michael Jennings
* Copyright (C) 1997-2009, 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
@ -46,78 +46,295 @@ static const char cvs_ident[] = "$Id$";
# include "screamcfg.h"
#endif
action_t *action_list = NULL;
static spif_bool_t action_handle_string(event_t *ev, spif_eterm_action_t action);
static spif_bool_t action_handle_echo(event_t *ev, spif_eterm_action_t action);
static spif_bool_t action_handle_script(event_t *ev, spif_eterm_action_t action);
static spif_bool_t action_handle_menu(event_t *ev, spif_eterm_action_t action);
static spif_bool_t action_check_button(spif_uchar_t button, int x_button);
static spif_bool_t action_check_keysym(KeySym keysym, KeySym x_keysym);
static spif_bool_t action_check_modifiers(spif_ushort_t mod, int x_mod);
static spif_bool_t action_matches_event(spif_eterm_action_t action, event_t *ev);
unsigned char
action_handle_string(event_t *ev, action_t *action)
/* Global action list. FIXME: Should be member of terminal object. */
spif_vector_t actions = NULL;
/* *INDENT-OFF* */
static SPIF_CONST_TYPE(class) ea_class = {
SPIF_DECL_CLASSNAME(eterm_action),
(spif_func_t) spif_eterm_action_new,
(spif_func_t) spif_eterm_action_init,
(spif_func_t) spif_eterm_action_done,
(spif_func_t) spif_eterm_action_del,
(spif_func_t) spif_eterm_action_show,
(spif_func_t) spif_eterm_action_comp,
(spif_func_t) spif_eterm_action_dup,
(spif_func_t) spif_eterm_action_type
};
SPIF_TYPE(class) SPIF_CLASS_VAR(eterm_action) = &ea_class;
/* *INDENT-ON* */
spif_eterm_action_t
spif_eterm_action_new(void)
{
USE_VAR(ev);
REQUIRE_RVAL(action->param.string != NULL, 0);
cmd_write((unsigned char *) action->param.string, strlen(action->param.string));
spif_eterm_action_t self;
self = SPIF_ALLOC(eterm_action);
if (!spif_eterm_action_init(self)) {
SPIF_DEALLOC(self);
self = (spif_eterm_action_t) NULL;
}
return self;
}
spif_eterm_action_t
spif_eterm_action_new_from_data(spif_eterm_action_type_t type, spif_ushort_t modifiers,
spif_uchar_t button, KeySym keysym, spif_ptr_t param)
{
spif_eterm_action_t self;
self = SPIF_ALLOC(eterm_action);
if (!spif_eterm_action_init_from_data(self, type, modifiers, button, keysym, param)) {
SPIF_DEALLOC(self);
self = (spif_eterm_action_t) NULL;
}
return self;
}
spif_bool_t
spif_eterm_action_del(spif_eterm_action_t self)
{
spif_eterm_action_done(self);
SPIF_DEALLOC(self);
return TRUE;
}
spif_bool_t
spif_eterm_action_init(spif_eterm_action_t self)
{
spif_obj_init(SPIF_OBJ(self));
spif_obj_set_class(SPIF_OBJ(self), SPIF_CLASS_VAR(eterm_action));
self->type = ETERM_ACTION_NONE;
self->modifiers = ETERM_MOD_NONE;
self->button = ETERM_BUTTON_NONE;
self->keysym = ETERM_KEYSYM_NONE;
self->handler = (spif_eterm_action_handler_t) NULL;
self->parameter = (spif_eterm_action_parameter_t) NULL;
return TRUE;
}
spif_bool_t
spif_eterm_action_init_from_data(spif_eterm_action_t self, spif_eterm_action_type_t type,
spif_ushort_t modifiers, spif_uchar_t button, KeySym keysym, spif_ptr_t param)
{
spif_obj_init(SPIF_OBJ(self));
spif_obj_set_class(SPIF_OBJ(self), SPIF_CLASS_VAR(eterm_action));
self->type = type;
self->modifiers = modifiers;
self->button = button;
self->keysym = keysym;
switch (type) {
case ETERM_ACTION_STRING:
self->handler = (spif_eterm_action_handler_t) action_handle_string;
self->parameter = (spif_obj_t) spif_str_new_from_ptr(param);
/*parse_escaped_string(self->parameter.string); */
break;
case ETERM_ACTION_ECHO:
self->handler = (spif_eterm_action_handler_t) action_handle_echo;
self->parameter = (spif_obj_t) spif_str_new_from_ptr(param);
/*parse_escaped_string(self->parameter.string); */
break;
case ETERM_ACTION_SCRIPT:
self->handler = (spif_eterm_action_handler_t) action_handle_script;
self->parameter = (spif_obj_t) spif_str_new_from_ptr(param);
break;
case ETERM_ACTION_MENU:
self->handler = (spif_eterm_action_handler_t) action_handle_menu;
/*self->parameter.menu = (menu_t *) param; */
break;
default:
break;
}
D_ACTIONS(("Added action. modifiers == 0x%08x, button == %d, keysym == 0x%08x\n",
self->modifiers, self->button, (unsigned) self->keysym));
return TRUE;
}
spif_bool_t
spif_eterm_action_done(spif_eterm_action_t self)
{
if (!SPIF_OBJ_ISNULL(self->parameter)) {
if ((self->type == ETERM_ACTION_STRING)
|| (self->type == ETERM_ACTION_ECHO)
|| (self->type == ETERM_ACTION_SCRIPT)) {
spif_str_del(SPIF_STR(self->parameter));
}
}
self->type = ETERM_ACTION_NONE;
self->modifiers = ETERM_MOD_NONE;
self->button = ETERM_BUTTON_NONE;
self->keysym = ETERM_KEYSYM_NONE;
self->handler = (spif_eterm_action_handler_t) NULL;
self->parameter = (spif_eterm_action_parameter_t) NULL;
spif_obj_done(SPIF_OBJ(self));
return TRUE;
}
spif_str_t
spif_eterm_action_show(spif_eterm_action_t self, spif_charptr_t name, spif_str_t buff, size_t indent)
{
char tmp[4096];
if (SPIF_ETERM_ACTION_ISNULL(self)) {
SPIF_OBJ_SHOW_NULL(eterm_action, name, buff, indent, tmp);
return buff;
}
memset(tmp, ' ', indent);
snprintf(tmp + indent, sizeof(tmp) - indent, "(spif_eterm_action_t) %s: {\n", name);
if (SPIF_STR_ISNULL(buff)) {
buff = spif_str_new_from_ptr(tmp);
} else {
spif_str_append_from_ptr(buff, tmp);
}
snprintf(tmp + indent, sizeof(tmp) - indent, " (spif_eterm_action_type_t) type: %d\n", self->type);
spif_str_append_from_ptr(buff, tmp);
snprintf(tmp + indent, sizeof(tmp) - indent, " (spif_ushort_t) modifiers: %c%c%c%c\n", SHOW_MODS(self->modifiers));
spif_str_append_from_ptr(buff, tmp);
snprintf(tmp + indent, sizeof(tmp) - indent, " (spif_uchar_t) button: %d\n", self->button);
spif_str_append_from_ptr(buff, tmp);
snprintf(tmp + indent, sizeof(tmp) - indent, " (KeySym) keysym: %04x\n", (unsigned) self->keysym);
spif_str_append_from_ptr(buff, tmp);
snprintf(tmp + indent, sizeof(tmp) - indent, " (spif_eterm_action_handler_t) handler: %10p\n", self->handler);
spif_str_append_from_ptr(buff, tmp);
snprintf(tmp + indent, sizeof(tmp) - indent, " (spif_eterm_action_parameter_t) parameter: %10p\n", self->parameter);
spif_str_append_from_ptr(buff, tmp);
snprintf(tmp + indent, sizeof(tmp) - indent, "}\n");
spif_str_append_from_ptr(buff, tmp);
return buff;
}
spif_cmp_t
spif_eterm_action_comp(spif_eterm_action_t self, spif_eterm_action_t other)
{
spif_cmp_t c;
SPIF_OBJ_COMP_CHECK_NULL(self, other);
c = SPIF_CMP_FROM_INT((int) (self->type) - (int) (other->type));
if (!SPIF_CMP_IS_EQUAL(c)) {
return c;
}
c = SPIF_CMP_FROM_INT((int) (self->button) - (int) (other->button));
if (!SPIF_CMP_IS_EQUAL(c)) {
return c;
}
c = SPIF_CMP_FROM_INT((int) (self->keysym) - (int) (other->keysym));
if (!SPIF_CMP_IS_EQUAL(c)) {
return c;
}
return SPIF_CMP_FROM_INT((int) (self->modifiers) - (int) (other->modifiers));
}
spif_eterm_action_t
spif_eterm_action_dup(spif_eterm_action_t self)
{
spif_eterm_action_t tmp;
REQUIRE_RVAL(!SPIF_ETERM_ACTION_ISNULL(self), (spif_eterm_action_t) NULL);
tmp = spif_eterm_action_new();
tmp->type = self->type;
tmp->modifiers = self->modifiers;
tmp->button = self->button;
tmp->keysym = self->keysym;
tmp->handler = self->handler;
tmp->parameter = self->parameter;
return tmp;
}
spif_classname_t
spif_eterm_action_type(spif_eterm_action_t self)
{
return SPIF_OBJ_CLASSNAME(self);
}
SPIF_DEFINE_PROPERTY_FUNC_NONOBJ(eterm_action, eterm_action_type, type);
SPIF_DEFINE_PROPERTY_FUNC_NONOBJ(eterm_action, ushort, modifiers);
SPIF_DEFINE_PROPERTY_FUNC_NONOBJ(eterm_action, uchar, button);
SPIF_DEFINE_PROPERTY_FUNC_C(eterm_action, KeySym, keysym);
SPIF_DEFINE_PROPERTY_FUNC_NONOBJ(eterm_action, eterm_action_handler, handler);
SPIF_DEFINE_PROPERTY_FUNC_NONOBJ(eterm_action, eterm_action_parameter, parameter);
static spif_bool_t
action_handle_string(event_t *ev, spif_eterm_action_t action)
{
REQUIRE_RVAL(!SPIF_PTR_ISNULL(ev), FALSE);
REQUIRE_RVAL(!SPIF_STR_ISNULL(action->parameter), FALSE);
cmd_write(SPIF_STR_STR(action->parameter), spif_str_get_len(SPIF_STR(action->parameter)));
return 1;
}
unsigned char
action_handle_echo(event_t *ev, action_t *action)
static spif_bool_t
action_handle_echo(event_t *ev, spif_eterm_action_t action)
{
USE_VAR(ev);
REQUIRE_RVAL(action->param.string != NULL, 0);
REQUIRE_RVAL(!SPIF_PTR_ISNULL(ev), FALSE);
REQUIRE_RVAL(!SPIF_STR_ISNULL(action->parameter), FALSE);
#ifdef ESCREEN
if (TermWin.screen && TermWin.screen->backend) {
# ifdef NS_HAVE_SCREEN
/* translate escapes */
ns_parse_screen_interactive(TermWin.screen, action->param.string);
ns_parse_screen_interactive(TermWin.screen, SPIF_STR_STR(action->parameter));
# endif
} else
#endif
tt_write((unsigned char *) action->param.string, strlen(action->param.string));
tt_write(SPIF_STR_STR(action->parameter), spif_str_get_len(SPIF_STR(action->parameter)));
return 1;
}
unsigned char
action_handle_script(event_t *ev, action_t *action)
static spif_bool_t
action_handle_script(event_t *ev, spif_eterm_action_t action)
{
USE_VAR(ev);
REQUIRE_RVAL(action->param.script != NULL, 0);
script_parse(action->param.script);
REQUIRE_RVAL(!SPIF_PTR_ISNULL(ev), FALSE);
REQUIRE_RVAL(!SPIF_STR_ISNULL(action->parameter), FALSE);
script_parse(SPIF_STR_STR(action->parameter));
return 1;
}
unsigned char
action_handle_menu(event_t *ev, action_t *action)
static spif_bool_t
action_handle_menu(event_t *ev, spif_eterm_action_t action)
{
REQUIRE_RVAL(action->param.menu != NULL, 0);
menu_invoke(ev->xbutton.x, ev->xbutton.y, TermWin.parent, action->param.menu, ev->xbutton.time);
REQUIRE_RVAL(!SPIF_PTR_ISNULL(ev), FALSE);
REQUIRE_RVAL(!SPIF_PTR_ISNULL(action->parameter), FALSE);
/*menu_invoke(ev->xbutton.x, ev->xbutton.y, TermWin.parent, action->parameter.menu, ev->xbutton.time); */
return 1;
}
action_t *action_find_match(unsigned short mod, unsigned char button, KeySym keysym)
{
action_t *action;
D_ACTIONS(("mod == 0x%08x, button == %d, keysym == 0x%08x\n", mod, button, keysym));
for (action = action_list; action; action = action->next) {
D_ACTIONS(("Checking action. mod == 0x%08x, button == %d, keysym == 0x%08x\n", action->mod, action->button,
action->keysym));
if ((action->mod == mod) && (action->button == button) && (action->keysym == keysym)) {
D_ACTIONS(("Match found at %8p\n", action));
return action;
}
}
return NULL;
}
unsigned char
action_check_button(unsigned char button, int x_button)
static spif_bool_t
action_check_button(spif_uchar_t button, int x_button)
{
/* The event we're looking at is a button press. Make sure the
current action is also, and that it matches. Continue if not. */
D_ACTIONS(("Checking button %d vs x_button %d\n", button, x_button));
if (button == BUTTON_NONE) {
if (button == ETERM_BUTTON_NONE) {
/* It was a button press, and this action is not a button action. */
return FALSE;
}
if ((button != BUTTON_ANY) && (button != x_button)) {
if ((button != ETERM_BUTTON_ANY) && (button != x_button)) {
/* It's a specific button, and the two don't match. */
return FALSE;
}
@ -125,7 +342,7 @@ action_check_button(unsigned char button, int x_button)
return TRUE;
}
unsigned char
static spif_bool_t
action_check_keysym(KeySym keysym, KeySym x_keysym)
{
/* The event we're looking at is a key press. Make sure the
@ -140,56 +357,56 @@ action_check_keysym(KeySym keysym, KeySym x_keysym)
return TRUE;
}
unsigned char
action_check_modifiers(unsigned short mod, int x_mod)
static spif_bool_t
action_check_modifiers(spif_ushort_t mod, int x_mod)
{
unsigned int m = (AltMask | MetaMask | NumLockMask);
spif_uint32_t m = (AltMask | MetaMask | NumLockMask);
/* When we do have to check the modifiers, we do so in this order to eliminate the
most popular choices first. If any test fails, we return FALSE. */
D_ACTIONS(("Checking modifier set 0x%08x (" MOD_FMT ") vs. X modifier set 0x%08x (" MOD_FMT ")\n", mod, SHOW_MODS(mod), x_mod,
SHOW_X_MODS(x_mod)));
if (mod != MOD_ANY) {
D_ACTIONS(("Checking modifier set 0x%08x (%c%c%c%c) vs. X modifier set 0x%08x (%c%c%c%c)\n",
mod, SHOW_MODS(mod), x_mod, SHOW_X_MODS(x_mod)));
if (mod != ETERM_MOD_ANY) {
/* LOGICAL_XOR() returns true if either the first parameter or the second parameter
is true, but not both...just like XOR. If the mask we're looking for is set in
mod but not in x_mod, or set in x_mod but not in mod, we don't have a match. */
if (LOGICAL_XOR((mod & MOD_CTRL), (x_mod & ControlMask))) {
if (LOGICAL_XOR((mod & ETERM_MOD_CTRL), (x_mod & ControlMask))) {
return FALSE;
}
if (LOGICAL_XOR((mod & MOD_SHIFT), (x_mod & ShiftMask))) {
if (LOGICAL_XOR((mod & ETERM_MOD_SHIFT), (x_mod & ShiftMask))) {
return FALSE;
}
if (MetaMask != AltMask) {
if (LOGICAL_XOR((mod & MOD_ALT), (x_mod & AltMask))) {
if (LOGICAL_XOR((mod & ETERM_MOD_ALT), (x_mod & AltMask))) {
return FALSE;
}
if (LOGICAL_XOR((mod & MOD_META), (x_mod & MetaMask))) {
if (LOGICAL_XOR((mod & ETERM_MOD_META), (x_mod & MetaMask))) {
return FALSE;
}
} else {
if (LOGICAL_XOR((mod & (MOD_META | MOD_ALT)), (x_mod & (MetaMask | AltMask)))) {
if (LOGICAL_XOR((mod & (ETERM_MOD_META | ETERM_MOD_ALT)), (x_mod & (MetaMask | AltMask)))) {
return FALSE;
}
}
if (LOGICAL_XOR((mod & MOD_LOCK), (x_mod & LockMask))) {
if (LOGICAL_XOR((mod & ETERM_MOD_LOCK), (x_mod & LockMask))) {
return FALSE;
}
/* These tests can't use LOGICAL_XOR because the second test has an additional
restriction that the Mod?Mask cannot be set in m; i.e., we want to ignore
any Mod?Mask assigned to Alt, Meta, or the NumLock On state. */
if (((mod & MOD_MOD1) && !(x_mod & Mod1Mask)) || (!(mod & MOD_MOD1) && (x_mod & Mod1Mask) && !(Mod1Mask & m))) {
if (((mod & ETERM_MOD_MOD1) && !(x_mod & Mod1Mask)) || (!(mod & ETERM_MOD_MOD1) && (x_mod & Mod1Mask) && !(Mod1Mask & m))) {
return FALSE;
}
if (((mod & MOD_MOD2) && !(x_mod & Mod2Mask)) || (!(mod & MOD_MOD2) && (x_mod & Mod2Mask) && !(Mod2Mask & m))) {
if (((mod & ETERM_MOD_MOD2) && !(x_mod & Mod2Mask)) || (!(mod & ETERM_MOD_MOD2) && (x_mod & Mod2Mask) && !(Mod2Mask & m))) {
return FALSE;
}
if (((mod & MOD_MOD3) && !(x_mod & Mod3Mask)) || (!(mod & MOD_MOD3) && (x_mod & Mod3Mask) && !(Mod3Mask & m))) {
if (((mod & ETERM_MOD_MOD3) && !(x_mod & Mod3Mask)) || (!(mod & ETERM_MOD_MOD3) && (x_mod & Mod3Mask) && !(Mod3Mask & m))) {
return FALSE;
}
if (((mod & MOD_MOD4) && !(x_mod & Mod4Mask)) || (!(mod & MOD_MOD4) && (x_mod & Mod4Mask) && !(Mod4Mask & m))) {
if (((mod & ETERM_MOD_MOD4) && !(x_mod & Mod4Mask)) || (!(mod & ETERM_MOD_MOD4) && (x_mod & Mod4Mask) && !(Mod4Mask & m))) {
return FALSE;
}
if (((mod & MOD_MOD5) && !(x_mod & Mod5Mask)) || (!(mod & MOD_MOD5) && (x_mod & Mod5Mask) && !(Mod5Mask & m))) {
if (((mod & ETERM_MOD_MOD5) && !(x_mod & Mod5Mask)) || (!(mod & ETERM_MOD_MOD5) && (x_mod & Mod5Mask) && !(Mod5Mask & m))) {
return FALSE;
}
}
@ -197,76 +414,49 @@ action_check_modifiers(unsigned short mod, int x_mod)
return TRUE;
}
unsigned char
action_dispatch(event_t *ev, KeySym keysym)
spif_bool_t
eterm_action_dispatch(event_t *ev)
{
action_t *action;
spif_eterm_action_t action;
spif_iterator_t iter;
ASSERT_RVAL(ev != NULL, 0);
ASSERT_RVAL(ev->xany.type == ButtonPress || ev->xany.type == KeyPress, 0);
D_ACTIONS(("Event %8p: Button %d, Keysym 0x%08x, Key State 0x%08x (modifiers " MOD_FMT ")\n", ev, ev->xbutton.button, keysym,
ev->xkey.state, SHOW_X_MODS(ev->xkey.state)));
for (action = action_list; action; action = action->next) {
/* The very first thing we do is match the event type to the type
of the current action. This means that we'll only run through
the modifier checks below if we absolutely have to. */
if ((ev->xany.type == ButtonPress && action_check_button(action->button, ev->xbutton.button))
|| (ev->xany.type == KeyPress && action_check_keysym(action->keysym, keysym))) {
if (action_check_modifiers(action->mod, ev->xkey.state)) {
D_ACTIONS(("Match found.\n"));
/* If we've passed all the above tests, it's a match. Dispatch the handler. */
return ((action->handler) (ev, action));
}
ASSERT_RVAL(ev != NULL, FALSE);
ASSERT_RVAL(ev->xany.type == ButtonPress || ev->xany.type == KeyPress, FALSE);
D_ACTIONS(("Event %8p: Button %d, Keycode %d, Key State 0x%08x (modifiers %c%c%c%c)\n",
ev, ev->xbutton.button, (int) ev->xkey.keycode, ev->xkey.state, SHOW_X_MODS(ev->xkey.state)));
D_ACTIONS(("Searching %d actions to find match.\n", SPIF_VECTOR_COUNT(actions)));
for (iter = SPIF_VECTOR_ITERATOR(actions); SPIF_ITERATOR_HAS_NEXT(iter);) {
action = (spif_eterm_action_t) SPIF_ITERATOR_NEXT(iter);
if (action_matches_event(action, ev)) {
D_ACTIONS(("Spawning handler for action object %10p.\n", action));
return (spif_bool_t) (((spif_eterm_action_handler_t) (action->handler)) (ev, action));
}
}
return (0);
return FALSE;
}
void
action_add(unsigned short mod, unsigned char button, KeySym keysym, action_type_t type, void *param)
static spif_bool_t
action_matches_event(spif_eterm_action_t action, event_t *ev)
{
action_t *action;
if (!action_list || (action = action_find_match(mod, button, keysym)) == NULL) {
action = (action_t *) MALLOC(sizeof(action_t));
action->next = action_list;
action_list = action;
/* The very first thing we do is match the event type to the type
of the current action. This means that we'll only run through
the modifier checks below if we absolutely have to. */
D_ACTIONS(("Checking action %10p for match to event %10p.\n", action, ev));
if (ev->xany.type == ButtonPress) {
if (!action_check_button(action->button, ev->xbutton.button)) {
return FALSE;
}
} else if (ev->xany.type == KeyPress) {
if (!action_check_keysym(action->keysym, XKeycodeToKeysym(Xdisplay, ev->xkey.keycode, 0))) {
return FALSE;
}
} else {
if (action->type == ACTION_STRING || action->type == ACTION_ECHO || action->type == ACTION_SCRIPT) {
if (action->param.string) {
FREE(action->param.string);
}
}
ASSERT_NOTREACHED_RVAL(FALSE);
}
action->mod = mod;
action->button = button;
action->type = type;
action->keysym = keysym;
switch (type) {
case ACTION_STRING:
action->handler = (action_handler_t) action_handle_string;
action->param.string = (char *) MALLOC(strlen((char *) param) + 2);
strcpy(action->param.string, (char *) param);
parse_escaped_string(action->param.string);
break;
case ACTION_ECHO:
action->handler = (action_handler_t) action_handle_echo;
action->param.string = (char *) MALLOC(strlen((char *) param) + 2);
strcpy(action->param.string, (char *) param);
parse_escaped_string(action->param.string);
break;
case ACTION_SCRIPT:
action->handler = (action_handler_t) action_handle_script;
action->param.script = (char *) MALLOC(strlen((char *) param) + 2);
strcpy(action->param.script, (char *) param);
break;
case ACTION_MENU:
action->handler = (action_handler_t) action_handle_menu;
action->param.menu = (menu_t *) param;
break;
default:
break;
if (action_check_modifiers(action->modifiers, ev->xkey.state)) {
D_ACTIONS(("Match found.\n"));
return TRUE;
}
D_ACTIONS(("Added action. mod == 0x%08x, button == %d, keysym == 0x%08x\n", action->mod, action->button, action->keysym));
return FALSE;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 1997-2004, Michael Jennings
* Copyright (C) 1997-2009, 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
@ -26,77 +26,91 @@
#include <X11/Xfuncproto.h>
#include <X11/Intrinsic.h> /* Xlib, Xutil, Xresource, Xfuncproto */
#include <libast.h>
#include "events.h"
#include "menus.h"
/************ Macros and Definitions ************/
typedef enum {
ACTION_NONE = 0,
ACTION_STRING,
ACTION_ECHO,
ACTION_SCRIPT,
ACTION_MENU
} action_type_t;
ETERM_ACTION_NONE = 0,
ETERM_ACTION_STRING,
ETERM_ACTION_ECHO,
ETERM_ACTION_SCRIPT,
ETERM_ACTION_MENU
} SPIF_TYPE(eterm_action_type);
typedef SPIF_TYPE(obj) SPIF_TYPE(eterm_action_parameter);
typedef spif_func_t SPIF_TYPE(eterm_action_handler);
#define KEYSYM_NONE (0UL)
#define ETERM_KEYSYM_NONE (0UL)
#define MOD_NONE (0UL)
#define MOD_CTRL (1UL << 0)
#define MOD_SHIFT (1UL << 1)
#define MOD_LOCK (1UL << 2)
#define MOD_META (1UL << 3)
#define MOD_ALT (1UL << 4)
#define MOD_MOD1 (1UL << 5)
#define MOD_MOD2 (1UL << 6)
#define MOD_MOD3 (1UL << 7)
#define MOD_MOD4 (1UL << 8)
#define MOD_MOD5 (1UL << 9)
#define MOD_ANY (1UL << 10)
#define ETERM_MOD_NONE (0UL)
#define ETERM_MOD_CTRL (1UL << 0)
#define ETERM_MOD_SHIFT (1UL << 1)
#define ETERM_MOD_LOCK (1UL << 2)
#define ETERM_MOD_META (1UL << 3)
#define ETERM_MOD_ALT (1UL << 4)
#define ETERM_MOD_MOD1 (1UL << 5)
#define ETERM_MOD_MOD2 (1UL << 6)
#define ETERM_MOD_MOD3 (1UL << 7)
#define ETERM_MOD_MOD4 (1UL << 8)
#define ETERM_MOD_MOD5 (1UL << 9)
#define ETERM_MOD_ANY (1UL << 10)
#define BUTTON_NONE (0)
#define BUTTON_ANY (0xff)
#define ETERM_BUTTON_NONE (0)
#define ETERM_BUTTON_ANY (0xff)
#define LOGICAL_XOR(a, b) !(((a) && (b)) || (!(a) && !(b)))
#define SHOW_MODS(m) ((m & MOD_CTRL) ? 'C' : 'c'), ((m & MOD_SHIFT) ? 'S' : 's'), ((m & MOD_META) ? 'M' : 'm'), ((m & MOD_ALT) ? 'A' : 'a')
#define SHOW_MODS(m) ((m & ETERM_MOD_CTRL) ? 'C' : 'c'), ((m & ETERM_MOD_SHIFT) ? 'S' : 's'), ((m & ETERM_MOD_META) ? 'M' : 'm'), ((m & ETERM_MOD_ALT) ? 'A' : 'a')
#define SHOW_X_MODS(m) ((m & ControlMask) ? 'C' : 'c'), ((m & ShiftMask) ? 'S' : 's'), ((m & MetaMask) ? 'M' : 'm'), ((m & AltMask) ? 'A' : 'a')
#define MOD_FMT "%c%c%c%c"
/************ Structures ************/
typedef struct action_struct action_t;
typedef unsigned char (*action_handler_t) (event_t *, action_t *);
struct action_struct {
unsigned short mod;
unsigned char button;
KeySym keysym;
action_type_t type;
action_handler_t handler;
union {
char *string;
char *script;
menu_t *menu;
} param;
struct action_struct *next;
/* Cast an arbitrary object pointer to a eterm_action. */
#define SPIF_ETERM_ACTION(obj) (SPIF_CAST(eterm_action) (obj))
/* Check to see if a pointer references a eterm_actioning object. */
#define SPIF_OBJ_IS_ETERM_ACTION(obj) (SPIF_OBJ_IS_TYPE(obj, eterm_action))
/* Check for NULL eterm_action object */
#define SPIF_ETERM_ACTION_ISNULL(s) SPIF_OBJ_ISNULL(SPIF_OBJ(s))
SPIF_DECL_OBJ(eterm_action) {
SPIF_DECL_PARENT_TYPE(obj);
SPIF_DECL_PROPERTY(eterm_action_type, type);
SPIF_DECL_PROPERTY(ushort, modifiers);
SPIF_DECL_PROPERTY(uchar, button);
SPIF_DECL_PROPERTY_C(KeySym, keysym);
SPIF_DECL_PROPERTY(eterm_action_handler, handler);
SPIF_DECL_PROPERTY(obj, parameter);
};
/************ Variables ************/
extern action_t *action_list;
extern spif_vector_t actions;
extern spif_class_t SPIF_CLASS_VAR(eterm_action);
extern spif_eterm_action_t spif_eterm_action_new(void);
extern spif_eterm_action_t spif_eterm_action_new_from_data(spif_eterm_action_type_t, spif_ushort_t,
spif_uchar_t, KeySym, spif_ptr_t);
extern spif_bool_t spif_eterm_action_del(spif_eterm_action_t);
extern spif_bool_t spif_eterm_action_init(spif_eterm_action_t);
extern spif_bool_t spif_eterm_action_init_from_data(spif_eterm_action_t, spif_eterm_action_type_t,
spif_ushort_t, spif_uchar_t, KeySym, spif_ptr_t);
extern spif_bool_t spif_eterm_action_done(spif_eterm_action_t);
extern spif_eterm_action_t spif_eterm_action_dup(spif_eterm_action_t);
extern spif_cmp_t spif_eterm_action_comp(spif_eterm_action_t, spif_eterm_action_t);
extern spif_str_t spif_eterm_action_show(spif_eterm_action_t, spif_charptr_t, spif_str_t, size_t);
extern spif_classname_t spif_eterm_action_type(spif_eterm_action_t);
SPIF_DECL_PROPERTY_FUNC(eterm_action, eterm_action_type, type);
SPIF_DECL_PROPERTY_FUNC(eterm_action, ushort, modifiers);
SPIF_DECL_PROPERTY_FUNC(eterm_action, uchar, button);
SPIF_DECL_PROPERTY_FUNC_C(eterm_action, KeySym, keysym);
SPIF_DECL_PROPERTY_FUNC(eterm_action, eterm_action_handler, handler);
SPIF_DECL_PROPERTY_FUNC(eterm_action, eterm_action_parameter, parameter);
/************ Function Prototypes ************/
_XFUNCPROTOBEGIN
extern unsigned char action_handle_string(event_t *ev, action_t *action);
extern unsigned char action_handle_echo(event_t *ev, action_t *action);
extern unsigned char action_handle_script(event_t *ev, action_t *action);
extern unsigned char action_handle_menu(event_t *ev, action_t *action);
extern action_t *action_find_match(unsigned short mod, unsigned char button, KeySym keysym);
extern unsigned char action_check_button(unsigned char button, int x_button);
extern unsigned char action_check_keysym(KeySym keysym, KeySym x_keysym);
extern unsigned char action_check_modifiers(unsigned short mod, int x_mod);
extern unsigned char action_dispatch(event_t *ev, KeySym keysym);
extern void action_add(unsigned short mod, unsigned char button, KeySym keysym, action_type_t type, void *param);
_XFUNCPROTOEND
extern spif_bool_t eterm_action_dispatch(event_t *ev);
#endif /* _ACTIONS_H_ */

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 1997-2004, Michael Jennings
* Copyright (C) 1997-2009, 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
@ -193,7 +193,7 @@ bbar_handle_enter_notify(event_t *ev)
REQUIRE_RVAL(XEVENT_IS_MYWIN(ev, &buttonbar->event_data), 0);
if ((bbar = find_bbar_by_window(ev->xany.window)) == NULL) {
if (!(bbar = find_bbar_by_window(ev->xany.window))) {
return 0;
}
bbar_draw(bbar, IMAGE_STATE_SELECTED, 0);
@ -215,7 +215,7 @@ bbar_handle_leave_notify(event_t *ev)
REQUIRE_RVAL(XEVENT_IS_MYWIN(ev, &buttonbar->event_data), 0);
if ((bbar = find_bbar_by_window(ev->xany.window)) == NULL) {
if (!(bbar = find_bbar_by_window(ev->xany.window))) {
return 0;
}
bbar_draw(bbar, IMAGE_STATE_NORMAL, 0);
@ -234,7 +234,7 @@ bbar_handle_button_press(event_t *ev)
REQUIRE_RVAL(XEVENT_IS_MYWIN(ev, &buttonbar->event_data), 0);
if ((bbar = find_bbar_by_window(ev->xany.window)) == NULL) {
if (!(bbar = find_bbar_by_window(ev->xany.window))) {
D_EVENTS((" -> No buttonbar found for this window.\n"));
return 0;
}
@ -326,7 +326,7 @@ bbar_handle_button_release(event_t *ev)
REQUIRE_RVAL(XEVENT_IS_MYWIN(ev, &buttonbar->event_data), 0);
if ((bbar = find_bbar_by_window(ev->xany.window)) == NULL) {
if (!(bbar = find_bbar_by_window(ev->xany.window))) {
D_EVENTS((" -> No buttonbar found for this window.\n"));
return 0;
}
@ -364,7 +364,7 @@ bbar_handle_motion_notify(event_t *ev)
REQUIRE_RVAL(XEVENT_IS_MYWIN(ev, &buttonbar->event_data), 0);
if ((bbar = find_bbar_by_window(ev->xany.window)) == NULL) {
if (!(bbar = find_bbar_by_window(ev->xany.window))) {
return 0;
}
while (XCheckTypedWindowEvent(Xdisplay, ev->xany.window, MotionNotify, ev));
@ -392,7 +392,7 @@ bbar_handle_motion_notify(event_t *ev)
unsigned char
bbar_dispatch_event(event_t *ev)
{
if (buttonbar->event_data.handlers[ev->type] != NULL) {
if (buttonbar->event_data.handlers[ev->type]) {
return ((buttonbar->event_data.handlers[ev->type]) (ev));
}
return (0);
@ -721,7 +721,7 @@ button_t *find_button_by_index(buttonbar_t *bbar, long idx)
} else {
b = bbar->buttons;
}
for (i = 0; (b != NULL) && (i < idx); b = b->next, i++);
for (i = 0; (b) && (i < idx); b = b->next, i++);
return ((i == idx) ? (b) : (NULL));
}
@ -770,7 +770,7 @@ button_free(button_t *button)
if (button->text) {
FREE(button->text);
}
if (button->type == ACTION_STRING || button->type == ACTION_ECHO) {
if (button->type == ETERM_ACTION_STRING || button->type == ETERM_ACTION_ECHO) {
FREE(button->action.string);
}
if (button->icon) {
@ -808,27 +808,27 @@ button_set_icon(button_t *button, simage_t *icon)
}
unsigned char
button_set_action(button_t *button, action_type_t type, char *action)
button_set_action(button_t *button, spif_eterm_action_type_t type, char *action)
{
ASSERT_RVAL(button != NULL, 0);
button->type = type;
switch (type) {
case ACTION_MENU:
case ETERM_ACTION_MENU:
button->action.menu = find_menu_by_title(menu_list, action);
return ((button->action.menu == NULL) ? (0) : (1));
return ((!button->action.menu) ? (0) : (1));
break;
case ACTION_STRING:
case ACTION_ECHO:
case ETERM_ACTION_STRING:
case ETERM_ACTION_ECHO:
button->action.string = (char *) MALLOC(strlen(action) + 2);
strcpy(button->action.string, action);
parse_escaped_string(button->action.string);
return ((button->action.string == NULL) ? (0) : (1));
return ((!button->action.string) ? (0) : (1));
break;
case ACTION_SCRIPT:
case ETERM_ACTION_SCRIPT:
button->action.script = (char *) MALLOC(strlen(action) + 2);
strcpy(button->action.script, action);
return ((button->action.script == NULL) ? (0) : (1));
return ((!button->action.script) ? (0) : (1));
break;
default:
break;
@ -909,13 +909,13 @@ button_check_action(buttonbar_t *bbar, button_t *button, unsigned char press, Ti
bbar, (int) press, (int) prvs, (unsigned long) t));
switch (button->type) {
case ACTION_MENU:
case ETERM_ACTION_MENU:
D_BBAR((" -> Menu button found.\n"));
if (press) {
menu_invoke(button->x, button->y + button->h, bbar->win, button->action.menu, t);
}
break;
case ACTION_STRING:
case ETERM_ACTION_STRING:
D_BBAR((" -> String button found.\n"));
if (!press) {
size_t len;
@ -925,7 +925,7 @@ button_check_action(buttonbar_t *bbar, button_t *button, unsigned char press, Ti
cmd_write((unsigned char *) button->action.string, strlen(button->action.string));
}
break;
case ACTION_ECHO:
case ETERM_ACTION_ECHO:
D_BBAR((" -> Echo button found.\n"));
if (!press) {
size_t len;
@ -990,7 +990,7 @@ button_check_action(buttonbar_t *bbar, button_t *button, unsigned char press, Ti
tt_write((unsigned char *) button->action.string, len);
}
break;
case ACTION_SCRIPT:
case ETERM_ACTION_SCRIPT:
D_BBAR((" -> Script button found.\n"));
if (!press) {
script_parse((char *) button->action.script);

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 1997-2004, Michael Jennings
* Copyright (C) 1997-2009, 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
@ -25,6 +25,7 @@
# define _BUTTONS_H
# include <X11/Xfuncproto.h>
# include <libast.h>
# include "actions.h"
# include "events.h"
# include "menus.h"
@ -59,7 +60,7 @@
/************ Structures ************/
typedef struct button_struct {
simage_t *icon;
action_type_t type;
spif_eterm_action_type_t type;
union {
menu_t *menu;
char *script;
@ -130,7 +131,7 @@ extern button_t *button_create(char *text);
extern void button_free(button_t *);
extern unsigned char button_set_text(button_t *button, const char *text);
extern unsigned char button_set_icon(button_t *button, simage_t *icon);
extern unsigned char button_set_action(button_t *button, action_type_t type, char *action);
extern unsigned char button_set_action(button_t *button, spif_eterm_action_type_t type, char *action);
extern void bbar_select_button(buttonbar_t *bbar, button_t *button);
extern void bbar_deselect_button(buttonbar_t *bbar, button_t *button);
extern void bbar_click_button(buttonbar_t *bbar, button_t *button);

View File

@ -1,38 +1,25 @@
/*--------------------------------*-C-*---------------------------------*
* File: command.c
/*
* Copyright (C) 1997-2009, 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.
*/
/* notes: */
/*----------------------------------------------------------------------*
* Copyright 1992 John Bovey, University of Kent at Canterbury.
*
* You can do what you like with this source code as long as
* you don't try to make money out of it and you include an
* unaltered copy of this message (including the copyright).
*
* This module has been very heavily modified by R. Nation
* <nation@rocket.sanders.lockheed.com>
* No additional restrictions are applied
*
* Additional modification by Garrett D'Amore <garrett@netcom.com> to
* allow vt100 printing. No additional restrictions are applied.
*
* Integrated modifications by Steven Hirsch <hirsch@emba.uvm.edu> to
* properly support X11 mouse report mode and support for DEC
* "private mode" save/restore functions.
*
* Integrated key-related changes by Jakub Jelinek <jj@gnu.ai.mit.edu>
* to handle Shift+function keys properly.
* Should be used with enclosed termcap / terminfo database.
*
* Extensive modifications by mj olesen <olesen@me.QueensU.CA>
* No additional restrictions.
*
* Further modification and cleanups for Solaris 2.x and Linux 1.2.x
* by Raul Garcia Garcia <rgg@tid.es>. No additional restrictions.
*
* As usual, the author accepts no responsibility for anything, nor does
* he guarantee anything whatsoever.
*----------------------------------------------------------------------*/
static const char cvs_ident[] = "$Id$";
@ -67,6 +54,9 @@ static const char cvs_ident[] = "$Id$";
#include <X11/Xos.h>
#include <X11/Xproto.h>
#include <X11/IntrinsicP.h>
#ifdef HAVE_XRES_EXT
# include <X11/extensions/XRes.h>
#endif
#ifdef PTY_GRP_NAME
# include <grp.h>
#endif
@ -147,6 +137,7 @@ TW_DECL_MAGIC(libscream_magic);
static RETSIGTYPE handle_child_signal(int);
static RETSIGTYPE handle_exit_signal(int);
static RETSIGTYPE handle_crash(int);
static RETSIGTYPE x_resource_dump(int);
/* local variables */
int my_ruid, my_euid, my_rgid, my_egid;
@ -999,13 +990,15 @@ void
dump_stack_trace(void)
{
char cmd[256];
#ifdef GDB
struct stat st;
#endif
#ifdef NO_STACK_TRACE
return;
#endif
print_error("Attempting to dump a stack trace....\n");
libast_print_error("Attempting to dump a stack trace....\n");
signal(SIGTSTP, exit); /* Don't block on tty output, just die */
#ifdef HAVE_U_STACK_TRACE
@ -1027,7 +1020,7 @@ dump_stack_trace(void)
snprintf(cmd, sizeof(cmd), "/bin/echo 'where\ndetach' | " DBX " %s %d", orig_argv0, getpid());
# endif
#else
print_error("Your system does not support any of the methods Eterm uses. Exiting.\n");
libast_print_error("Your system does not support any of the methods Eterm uses. Exiting.\n");
return;
#endif
signal(SIGALRM, (eterm_sighandler_t) hard_exit);
@ -1080,7 +1073,7 @@ static RETSIGTYPE
handle_exit_signal(int sig)
{
print_error("Received terminal signal %s (%d)\n", sig_to_str(sig), sig);
libast_print_error("Received terminal signal %s (%d)\n", sig_to_str(sig), sig);
signal(sig, SIG_DFL);
#ifdef UTMP_SUPPORT
@ -1099,7 +1092,7 @@ static RETSIGTYPE
handle_crash(int sig)
{
print_error("Received terminal signal %s (%d)\n", sig_to_str(sig), sig);
libast_print_error("Received terminal signal %s (%d)\n", sig_to_str(sig), sig);
signal(sig, SIG_DFL); /* Let the OS handle recursive seg faults */
/* Lock down security so we don't write any core files as root. */
@ -1114,6 +1107,116 @@ handle_crash(int sig)
SIG_RETURN(0);
}
#ifdef HAVE_XRES_EXT
static RETSIGTYPE
x_resource_dump(int sig)
{
int event_base, error_base, count, i;
unsigned long bytes;
XResClient *clients = NULL;
XResType *types = NULL;
Atom pixmap_atom, gc_atom, font_atom;
pid_t my_pid;
char *title, *ptitle;
USE_VAR(sig);
my_pid = getpid();
/* Create type atoms for future use. */
pixmap_atom = XInternAtom(Xdisplay, "PIXMAP", False);
gc_atom = XInternAtom(Xdisplay, "GC", False);
font_atom = XInternAtom(Xdisplay, "FONT", False);
/* Look at what *we* think our consumption is. */
#if DEBUG >= DEBUG_MEM
if (DEBUG_LEVEL >= DEBUG_MEM) {
PIXMAP_DUMP();
GC_DUMP();
}
#endif
/* Make sure we have the extension loaded. */
if (!XResQueryExtension(Xdisplay, &event_base, &error_base)) {
fprintf(stderr, "XResource extension not available on current display.\n");
return;
}
D_X11(("Got XResource extension values: %d (0x%08x) / %d (0x%08x)\n",
event_base, event_base, error_base, error_base));
/* Get a list of X clients and find our window ID in the list. */
if (!XResQueryClients(Xdisplay, &count, &clients)) {
if (clients) {
XFree(clients);
}
D_X11((" -> Unable to query clients.\n"));
return;
}
D_X11((" -> Got %d clients.\n", count));
if (count == 0) {
D_X11((" -> Nothing to do!\n"));
return;
}
for (i = 0; i < count; i++) {
Window win;
win = clients[i].resource_base & (~clients[i].resource_mask);
D_X11(("Checking client: base %d, mask %d, window 0x%08x\n", clients[i].resource_base,
clients[i].resource_mask, win));
if ((TermWin.parent & (~clients[i].resource_mask)) == win) {
break;
}
}
if (i == count) {
D_X11((" -> No client found with window 0x%08x (0x%08x\n", TermWin.parent,
(TermWin.parent & (~clients[i].resource_mask))));
return;
}
/* Request resource info for our client ID. */
if (!XResQueryClientResources(Xdisplay, clients[i].resource_base, &count, &types)
|| !XResQueryClientPixmapBytes(Xdisplay, clients[i].resource_base, &bytes)) {
if (types) {
XFree(types);
}
D_X11((" -> Unable to query resources.\n"));
return;
}
D_X11((" -> Got %d types.\n", count));
/* Get and sanitize window title for easier identification. */
XFetchName(Xdisplay, TermWin.parent, &title);
if (title) {
for (ptitle = title; *ptitle; ptitle++) {
if (!isprint(*ptitle)) {
*ptitle = ' ';
}
}
}
for (i = 0; i < count; i++) {
if (types[i].resource_type == pixmap_atom) {
fprintf(stderr, "Process %lu, window 0x%08x (%s): %d pixmaps (%lu bytes).\n", (unsigned long) my_pid,
(unsigned int) TermWin.parent, NONULL(title), types[i].count, bytes);
} else if (types[i].resource_type == gc_atom) {
fprintf(stderr, "Process %lu, window 0x%08x (%s): %d GC's (%d bytes).\n", (unsigned long) my_pid,
(unsigned int) TermWin.parent, NONULL(title), types[i].count,
types[i].count * (sizeof(XGCValues) + sizeof(GC)));
} else if (types[i].resource_type == font_atom) {
fprintf(stderr, "Process %lu, window 0x%08x (%s): %d fonts (%d bytes).\n", (unsigned long) my_pid,
(unsigned int) TermWin.parent, NONULL(title), types[i].count,
types[i].count * (sizeof(XFontStruct) + sizeof(Font)));
}
}
XFree(clients);
XFree(types);
if (title) {
XFree(title);
}
}
#endif
void
install_handlers(void)
{
@ -1133,6 +1236,11 @@ install_handlers(void)
signal(SIGILL, handle_crash);
signal(SIGSYS, handle_crash);
signal(SIGPIPE, SIG_IGN);
#ifdef HAVE_XRES_EXT
signal(SIGUSR1, x_resource_dump);
#else
signal(SIGUSR1, SIG_IGN);
#endif
}
/* Exit gracefully, clearing the utmp entry and restoring tty attributes */
@ -1151,14 +1259,16 @@ clean_exit(void)
font_cache_clear();
eterm_font_list_clear();
# ifdef PIXMAP_SUPPORT
FOREACH_IMAGE(free_eterm_image(&(images[idx])););
FOREACH_IMAGE({
free_eterm_image(&(images[idx]));
});
# endif
for (i = 0; i < NRS_COLORS; i++) {
if (rs_color[i]) {
FREE(rs_color[i]);
}
}
conf_free_subsystem();
spifconf_free_subsystem();
# ifdef USE_XIM
if (xim_input_context) {
XUnsetICFocus(xim_input_context);
@ -1222,7 +1332,7 @@ sgi_get_pty(void)
privileges(INVOKE);
ptydev = ttydev = _getpty(&fd, O_RDWR | O_NDELAY, 0620, 0);
privileges(REVERT);
return (ptydev == NULL ? -1 : fd);
return (!ptydev ? -1 : fd);
}
#endif
@ -1278,29 +1388,33 @@ sco_get_pty(void)
}
#endif
#ifdef HAVE_DEV_PTMX
inline int svr_get_pty(void);
#if defined(HAVE_POSIX_OPENPT) || defined(HAVE_DEV_PTMX)
inline int posix_get_pty(void);
inline int
svr_get_pty(void)
posix_get_pty(void)
{
int fd = -1;
/* open the STREAMS, clone device /dev/ptmx (master pty) */
#if defined(HAVE_POSIX_OPENPT)
if ((fd = posix_openpt(O_RDWR|O_NOCTTY)) < 0) {
#else
if ((fd = open("/dev/ptmx", O_RDWR)) < 0) {
#endif
return (-1);
} else {
if (grantpt(fd) != 0) {
print_error("grantpt(%d) failed: %s\n", fd, strerror(errno));
libast_print_error("grantpt(%d) failed: %s\n", fd, strerror(errno));
return (-1);
} else if (unlockpt(fd) != 0) {
print_error("unlockpt(%d) failed: %s\n", fd, strerror(errno));
libast_print_error("unlockpt(%d) failed: %s\n", fd, strerror(errno));
return (-1);
} else {
ptydev = ttydev = ptsname(fd);
if (ttydev == NULL) {
print_error("ptsname(%d) failed: %s\n", fd, strerror(errno));
if (!ttydev) {
libast_print_error("ptsname(%d) failed: %s\n", fd, strerror(errno));
return (-1);
}
}
@ -1347,12 +1461,12 @@ get_pty(void)
int fd = -1;
#if defined(__sgi)
#if defined(HAVE_POSIX_OPENPT) || defined(HAVE_DEV_PTMX)
fd = posix_get_pty();
#elif defined(__sgi)
fd = sgi_get_pty();
#elif defined(HAVE_DEV_PTC)
fd = aix_get_pty();
#elif defined(HAVE_DEV_PTMX)
fd = svr_get_pty();
#elif defined(HAVE_SCO_PTYS)
fd = sco_get_pty();
#endif
@ -1365,7 +1479,7 @@ get_pty(void)
fcntl(fd, F_SETFL, O_NDELAY);
return (fd);
} else {
print_error("Can't open pseudo-tty -- %s\n", strerror(errno));
libast_print_error("Can't open pseudo-tty -- %s\n", strerror(errno));
return (-1);
}
}
@ -1397,11 +1511,11 @@ get_tty(void)
#endif /* ultrix */
privileges(INVOKE);
if (ttydev == NULL) {
print_error("Slave tty device name is NULL. Failed to open slave pty.\n");
if (!ttydev) {
libast_print_error("Slave tty device name is NULL. Failed to open slave pty.\n");
exit(EXIT_FAILURE);
} else if ((fd = open(ttydev, O_RDWR)) < 0) {
print_error("Can't open slave tty %s -- %s\n", ttydev, strerror(errno));
libast_print_error("Can't open slave tty %s -- %s\n", ttydev, strerror(errno));
exit(EXIT_FAILURE);
} else {
D_TTY(("Opened slave tty %s\n", ttydev));
@ -1745,33 +1859,34 @@ create_fontset(const char *font1, const char *font2)
XFontSet fontset = 0;
char *fontname, **ml, *ds;
int mc;
const char fs_base[] = ",-misc-fixed-*-r-*-*-*-120-*-*-*-*-*-*,*";
/*const char fs_base[] = ",-misc-fixed-*-r-*-*-*-120-*-*-*-*-*-*,*";*/
ASSERT_RVAL(font1 != NULL, (XFontSet) 0);
if (font2) {
fontname = MALLOC(strlen(font1) + strlen(font2) + sizeof(fs_base) + 2);
fontname = MALLOC(strlen(font1) + strlen(font2) /*+ sizeof(fs_base)*/ + 2);
if (fontname) {
strcpy(fontname, font1);
strcat(fontname, ",");
strcat(fontname, font2);
strcat(fontname, fs_base);
/*strcat(fontname, fs_base);*/
}
} else {
fontname = MALLOC(strlen(font1) + sizeof(fs_base) + 1);
fontname = MALLOC(strlen(font1) /*+ sizeof(fs_base)*/ + 1);
if (fontname) {
strcpy(fontname, font1);
strcat(fontname, fs_base);
/*strcat(fontname, fs_base);*/
}
}
if (fontname) {
setlocale(LC_ALL, "");
fontset = XCreateFontSet(Xdisplay, fontname, &ml, &mc, &ds);
D_FONT(("Created fontset from %s, %d missing charsets, default string \"%s\".\n", fontname, mc, NONULL(ds)));
fontset = XCreateFontSet(Xdisplay, fontname, &ml, &mc, NULL);
D_FONT(("Created fontset from %s, %d missing charsets (\"%s\").\n", fontname, mc,
((mc > 0) ? (ml[0]) : ("N/A"))));
FREE(fontname);
if (mc) {
XFreeStringList(ml);
fontset = 0;
/*fontset = 0;*/
}
}
return fontset;
@ -1795,8 +1910,8 @@ init_locale(void)
locale = setlocale(LC_ALL, "");
XSetLocaleModifiers("");
TermWin.fontset = (XFontSet) 0;
if ((locale == NULL) || (!XSupportsLocale())) {
print_warning("Locale not supported; defaulting to portable \"C\" locale.\n");
if ((!locale) || (!XSupportsLocale())) {
libast_print_warning("Locale not supported; defaulting to portable \"C\" locale.\n");
locale = setlocale(LC_ALL, "C");
XSetLocaleModifiers("");
REQUIRE(locale);
@ -1843,7 +1958,7 @@ xim_send_spot(void)
static XPoint oldSpot = { -1, -1 };
XVaNestedList preedit_attr;
if (xim_input_context == NULL) {
if (!xim_input_context) {
return;
}
@ -1932,8 +2047,8 @@ xim_real_init(void)
*(end + 1) = '\0';
if (*s) {
snprintf(buf, sizeof(buf), "@im=%s", s);
if (((p = XSetLocaleModifiers(buf)) != NULL) && (*p)
&& ((xim_input_method = XOpenIM(Xdisplay, NULL, NULL, NULL)) != NULL)) {
if (((p = XSetLocaleModifiers(buf))) && (*p)
&& ((xim_input_method = XOpenIM(Xdisplay, NULL, NULL, NULL)))) {
break;
}
}
@ -1944,20 +2059,20 @@ xim_real_init(void)
}
/* try with XMODIFIERS env. var. */
if (xim_input_method == NULL && getenv("XMODIFIERS") && (p = XSetLocaleModifiers("")) != NULL && *p) {
if (!xim_input_method && getenv("XMODIFIERS") && (p = XSetLocaleModifiers("")) && *p) {
xim_input_method = XOpenIM(Xdisplay, NULL, NULL, NULL);
}
/* try with no modifiers base */
if (xim_input_method == NULL && (p = XSetLocaleModifiers("@im=none")) != NULL && *p) {
if (!xim_input_method && (p = XSetLocaleModifiers("@im=none")) && *p) {
xim_input_method = XOpenIM(Xdisplay, NULL, NULL, NULL);
}
if (xim_input_method == NULL) {
if (!xim_input_method) {
xim_input_method = XOpenIM(Xdisplay, NULL, NULL, NULL);
}
if (xim_input_method == NULL) {
if (!xim_input_method) {
return -1;
}
#ifdef USE_X11R6_XIM
@ -1967,13 +2082,13 @@ xim_real_init(void)
destroy_cb.callback = xim_destroy_cb;
destroy_cb.client_data = NULL;
if (XSetIMValues(xim_input_method, XNDestroyCallback, &destroy_cb, NULL)) {
print_error("Could not set destroy callback to IM\n");
libast_print_error("Could not set destroy callback to IM\n");
}
}
#endif
if ((XGetIMValues(xim_input_method, XNQueryInputStyle, &xim_styles, NULL)) || (!xim_styles)) {
print_error("input method doesn't support any style\n");
libast_print_error("input method doesn't support any style\n");
XCloseIM(xim_input_method);
return -1;
}
@ -2007,14 +2122,14 @@ xim_real_init(void)
XFree(xim_styles);
if (found == 0) {
print_error("input method doesn't support my preedit type\n");
libast_print_error("input method doesn't support my preedit type\n");
XCloseIM(xim_input_method);
return -1;
}
if ((xim_input_style != (XIMPreeditNothing | XIMStatusNothing))
&& (xim_input_style != (XIMPreeditArea | XIMStatusArea))
&& (xim_input_style != (XIMPreeditPosition | XIMStatusNothing))) {
print_error("This program does not support the preedit type\n");
libast_print_error("This program does not support the preedit type\n");
XCloseIM(xim_input_method);
return -1;
}
@ -2044,8 +2159,8 @@ xim_real_init(void)
if (status_attr) {
XFree(status_attr);
}
if (xim_input_context == NULL) {
print_error("Failed to create input context\n");
if (!xim_input_context) {
libast_print_error("Failed to create input context\n");
XCloseIM(xim_input_method);
return -1;
}
@ -2151,7 +2266,7 @@ run_command(char **argv)
# if defined (__sun__)
on_exit(clean_exit, NULL); /* non-ANSI exit handler */
# else
print_error("no atexit(), UTMP entries can't be cleaned\n");
libast_print_error("no atexit(), UTMP entries can't be cleaned\n");
# endif
#endif
@ -2179,7 +2294,7 @@ run_command(char **argv)
cmd_pid = fork();
D_CMD(("After fork(), cmd_pid == %d\n", cmd_pid));
if (cmd_pid < 0) {
print_error("fork(): %s\n", strerror(errno));
libast_print_error("fork(): %s\n", strerror(errno));
return (-1);
}
if (cmd_pid == 0) {
@ -2195,6 +2310,7 @@ run_command(char **argv)
signal(SIGILL, SIG_DFL);
signal(SIGSYS, SIG_DFL);
signal(SIGALRM, SIG_DFL);
signal(SIGPIPE, SIG_DFL);
#ifdef SIGTSTP
signal(SIGTSTP, SIG_IGN);
signal(SIGTTIN, SIG_IGN);
@ -2211,7 +2327,11 @@ run_command(char **argv)
get_tty();
SET_TTYMODE(0, &tio);
tt_winsize(0);
#if 0
if (TermWin.screen_mode != NS_MODE_NONE) {
tt_winsize(0);
}
#endif
/* become virtual console, fail silently */
if (BITFIELD_IS_SET(vt_options, VT_OPTIONS_CONSOLE)) {
@ -2256,9 +2376,9 @@ run_command(char **argv)
#endif
D_CMD(("[%d] About to spawn shell\n", getpid()));
if (chdir(initial_dir)) {
print_warning("Unable to chdir to \"%s\" -- %s\n", initial_dir, strerror(errno));
libast_print_warning("Unable to chdir to \"%s\" -- %s\n", initial_dir, strerror(errno));
}
if (argv != NULL) {
if (argv) {
#if DEBUG >= DEBUG_CMD
if (DEBUG_LEVEL >= DEBUG_CMD) {
int i;
@ -2270,12 +2390,12 @@ run_command(char **argv)
#endif
D_CMD(("[%d] execvp(\"%s\", %8p) is next. I'm outta here!\n", getpid(), NONULL(argv[0]), argv));
execvp(argv[0], argv);
print_error("execvp() failed, cannot execute \"%s\": %s\n", argv[0], strerror(errno));
libast_print_error("execvp() failed, cannot execute \"%s\": %s\n", argv[0], strerror(errno));
} else {
const char *argv0, *shell;
if ((shell = getenv("SHELL")) == NULL || *shell == '\0')
if (!(shell = getenv("SHELL")) || *shell == '\0')
shell = "/bin/sh";
argv0 = my_basename(shell);
@ -2287,7 +2407,7 @@ run_command(char **argv)
argv0 = p;
}
execlp(shell, argv0, NULL);
print_error("execlp() failed, cannot execute \"%s\": %s\n", shell, strerror(errno));
libast_print_error("execlp() failed, cannot execute \"%s\": %s\n", shell, strerror(errno));
}
sleep(3); /* Sleep to make sure fork() returns in the parent, and so user can read error message */
exit(EXIT_FAILURE);
@ -2373,7 +2493,7 @@ static button_t *screen_button_create(char *text, char code)
p[1] = code;
p[2] = '\0';
D_ESCREEN(("Creating button \"%s\" for display %c (%s)\n", NONULL(text), code, safe_print_string(p, 2)));
button_set_action(b, ACTION_ECHO, p);
button_set_action(b, ETERM_ACTION_ECHO, p);
b->flags |= NS_SCREAM_BUTTON;
return b;
@ -2575,11 +2695,16 @@ err_msg(void *xd, int err, char *msg)
static int
inp_text(void *xd, int id, char *txt)
{
USE_VAR(xd);
int which = (int) xd;
USE_VAR(id);
D_ESCREEN(("Writing \"%s\" to subprocess.\n", safe_print_string(txt, strlen(txt))));
tt_write(txt, strlen(txt));
if (which) {
D_ESCREEN(("Writing \"%s\" to screen.\n", safe_print_string(txt, strlen(txt))));
cmd_write(txt, strlen(txt));
} else {
D_ESCREEN(("Writing \"%s\" to subprocess.\n", safe_print_string(txt, strlen(txt))));
tt_write(txt, strlen(txt));
}
return NS_SUCC;
}
@ -2608,11 +2733,10 @@ exe_prg(void *xd, char **argv)
/****** Azundris' playthings :-) ******/
#ifdef ESCREEN_FX
#define DIRECT_MASK (~(RS_Cursor|RS_Select|RS_fontMask))
#define COLOUR_MASK (RS_fgMask|RS_bgMask)
#define DIRECT_SET_SCREEN(x,y,fg,bg) (screen.text[ys+y])[x]=fg; (screen.rend[ys+y])[x]=bg&DIRECT_MASK;
#define CLEAR (1<<16)
#define CLEAR (RS_None | bgColor)
static void
direct_write_screen(int x, int y, char *fg, rend_t bg)
@ -2629,6 +2753,7 @@ direct_write_screen(int x, int y, char *fg, rend_t bg)
}
}
#ifdef ESCREEN_FX
static void
bosconian(int n)
{
@ -2782,8 +2907,9 @@ waitstate(void *xd, int ms)
matrix(31);
unbosconian();
}
bosconian(4);
bosconian(20);
unbosconian();
scr_refresh(SLOW_REFRESH);
}
direct_write_screen(0, y++, " **** COMMODORE 64 BASIC V2 ****", (0 << 8) | CLEAR);
@ -2793,12 +2919,30 @@ waitstate(void *xd, int ms)
screen.row = y;
screen.col = 0;
scr_refresh(FAST_REFRESH);
scr_refresh(SLOW_REFRESH);
sleep(dur);
return 0;
}
#else
static int
waitstate(void *xd, int ms)
{
USE_VAR(xd);
direct_write_screen(TERM_WINDOW_GET_REPORTED_COLS() / 2 - 17, TERM_WINDOW_GET_ROWS() / 2,
"**** Initializing, please wait ****", (15 << 9) | CLEAR);
screen.row = 0;
screen.col = 0;
scr_refresh(SLOW_REFRESH);
sleep((time_t) (ms / 1000));
return 0;
}
#endif
static _ns_efuns *
@ -2829,9 +2973,7 @@ escreen_reg_funcs(void)
ns_register_inp(efuns, input_dialog);
ns_register_tab(efuns, menu_tab);
#ifdef ESCREEN_FX
ns_register_fun(efuns, waitstate);
#endif
return efuns;
}
@ -2920,7 +3062,7 @@ make_escreen_menu(buttonbar_t *bbar)
#endif
if ((button = button_create(NS_MENU_TITLE))) {
if ((button_set_action(button, ACTION_MENU, NS_MENU_TITLE))) {
if ((button_set_action(button, ETERM_ACTION_MENU, NS_MENU_TITLE))) {
bbar_add_rbutton(bbar, button);
bbar_calc_button_sizes(bbar);
}
@ -2949,14 +3091,14 @@ escreen_init(char **argv)
efuns = escreen_reg_funcs();
/* Create buttonbar for Escreen's use. */
if ((bbar = bbar_create()) == NULL) {
if (buttonbar != NULL) {
if (!(bbar = bbar_create())) {
if (buttonbar) {
bbar = buttonbar;
} else {
return -1;
}
} else {
if (buttonbar == NULL) {
if (!buttonbar) {
buttonbar = bbar;
}
bbar_set_font(bbar, ((rs_es_font) ? (rs_es_font) : ("-*-helvetica-medium-r-normal--10-*-*-*-p-*-iso8859-1")));
@ -2965,7 +3107,7 @@ escreen_init(char **argv)
}
BITFIELD_SET(eterm_options, ETERM_OPTIONS_PAUSE);
if ((TermWin.screen = ns_attach_by_URL(rs_url, rs_hop, &efuns, &ns_err, bbar)) == NULL) {
if (!(TermWin.screen = ns_attach_by_URL(rs_url, rs_hop, &efuns, &ns_err, bbar))) {
D_CMD(("ns_attach_by_URL(%s,%s) failed\n", rs_url, rs_hop));
return -1;
}
@ -3030,7 +3172,7 @@ init_command(char **argv)
AT_LEAST(num_fds, ((unsigned int) (pipe_fd + 1)));
}
if ((cmd_fd = command_func(argv)) < 0) {
print_error("Unable to run sub-command.\n");
libast_print_error("Unable to run sub-command.\n");
paused = 1;
rs_finished_text = "Hit a key to exit...";
}
@ -3144,7 +3286,7 @@ check_pixmap_change(int sig)
last_update = now;
old_handler = signal(SIGALRM, check_pixmap_change);
alarm(rs_anim_delay);
if (rs_anim_pixmaps[image_idx] == NULL) {
if (!rs_anim_pixmaps[image_idx]) {
image_idx = 0;
}
}
@ -3250,7 +3392,7 @@ cmd_getc(void)
XNextEvent(Xdisplay, &ev);
#ifdef USE_XIM
if (xim_input_context != NULL) {
if (xim_input_context) {
if (!XFilterEvent(&ev, ev.xkey.window)) {
event_dispatch(&ev);
}
@ -3317,12 +3459,12 @@ cmd_getc(void)
if (retval < 0) {
if (cmd_fd >= 0 && FD_ISSET(cmd_fd, &readfds)) {
if (errno != EINTR) { /* may have rcvd SIGCHLD or so */
print_error(" (%ld) Error reading from tty -- %s\n", getpid(), strerror(errno));
libast_print_error(" (%ld) Error reading from tty -- %s\n", getpid(), strerror(errno));
cmd_fd = -1;
}
}
if (pipe_fd >= 0 && FD_ISSET(pipe_fd, &readfds)) {
print_error("Error reading from pipe -- %s\n", strerror(errno));
libast_print_error("Error reading from pipe -- %s\n", strerror(errno));
pipe_fd = -1;
}
if (pipe_fd < 0 && cmd_fd < 0 && !paused) {
@ -3539,8 +3681,8 @@ main_loop(void)
set_multichar_encoding("utf8");
}
handle = iconv_open("WCHAR_T", "UTF-8");
if (handle == SPIF_CAST_C(iconv_t) - 1) {
print_error("Unable to decode UTF-8 locale %s to WCHAR_T. Defaulting to portable C locale.\n",
if (handle == (iconv_t) -1) {
libast_print_error("Unable to decode UTF-8 locale %s to WCHAR_T. Defaulting to portable C locale.\n",
setlocale(LC_ALL, ""));
setlocale(LC_ALL, "C");
scr_add_lines(str, nlines, (cmdbuf_ptr - str));
@ -3553,45 +3695,45 @@ main_loop(void)
pinbuff = (char *) str;
bufflen = cmdbuf_ptr - str;
outlen = bufflen * 6;
poutbuff = outbuff = SPIF_CAST_C(char *) MALLOC(outlen);
poutbuff = outbuff = (char *) MALLOC(outlen);
errno = 0;
D_VT(("Allocated output buffer of %lu chars at %010p against input buffer of %lu\n", bufflen * 6, outbuff,
bufflen));
print_warning("Moo: %s\n", safe_print_string(str, bufflen));
libast_print_warning("Moo: %s\n", safe_print_string(str, bufflen));
retval = iconv(handle, &pinbuff, &bufflen, &poutbuff, &outlen);
outlen = (size_t) (poutbuff - outbuff);
if (retval != (size_t) - 1) {
errno = 0;
}
if (errno == E2BIG) {
print_error("My UTF-8 decode buffer was too small by %lu bytes?!\n", bufflen);
libast_print_error("My UTF-8 decode buffer was too small by %lu bytes?!\n", bufflen);
} else if (errno == EILSEQ) {
print_error("Illegal multibyte sequence encountered at \'%c\' (0x%02x); skipping.\n", *pinbuff, *pinbuff);
libast_print_error("Illegal multibyte sequence encountered at \'%c\' (0x%02x); skipping.\n", *pinbuff, *pinbuff);
*pinbuff = ' ';
pinbuff++;
} else if (errno == EINVAL) {
D_VT(("Incomplete multibyte sequence encountered.\n"));
print_warning("Converted %lu input chars to %lu output chars before incomplete sequence.\n",
libast_print_warning("Converted %lu input chars to %lu output chars before incomplete sequence.\n",
(cmdbuf_ptr - str), outlen);
} else {
print_warning("Converted %lu input chars to %lu output chars.\n", (cmdbuf_ptr - str), outlen);
libast_print_warning("Converted %lu input chars to %lu output chars.\n", (cmdbuf_ptr - str), outlen);
}
print_warning("Moo2: %s\n", safe_print_string(outbuff, outlen));
libast_print_warning("Moo2: %s\n", safe_print_string(outbuff, outlen));
MEMSET(outbuff + outlen, 0, sizeof(wchar_t));
wcbuff = SPIF_CAST_C(wchar_t *) outbuff;
wcbuff = (wchar_t *) outbuff;
MEMSET(&mbs, 0, sizeof(mbstate_t));
outlen = wcsrtombs(NULL, &wcbuff, 0, &mbs) + 1;
if (outlen > 0) {
outbuff = SPIF_CAST_C(char *) MALLOC(outlen);
outbuff = (char *) MALLOC(outlen);
outlen = wcsrtombs(outbuff, &wcbuff, outlen, &mbs);
if ((long) outlen >= 0) {
FREE(wcbuff);
print_error("I win!\n");
libast_print_error("I win!\n");
} else {
print_error("wcsrtombs() returned %ld (errno is %d (%s))\n", (unsigned long) outlen, errno,
libast_print_error("wcsrtombs() returned %ld (errno is %d (%s))\n", (unsigned long) outlen, errno,
strerror(errno));
}
if (pinbuff > (char *) str) {
@ -3599,7 +3741,7 @@ main_loop(void)
scr_add_lines(outbuff, nlines, outlen);
}
} else {
print_error("wcsrtombs(NULL, %10p, 0) returned %ld (errno is %d (%s))\n", wcbuff, (unsigned long) outlen,
libast_print_error("wcsrtombs(NULL, %10p, 0) returned %ld (errno is %d (%s))\n", wcbuff, (unsigned long) outlen,
errno, strerror(errno));
}
FREE(outbuff);
@ -3663,7 +3805,7 @@ v_writeBig(int f, char *d, int len)
int written;
int c = len;
if (v_bufstr == NULL && len > 0) {
if (!v_bufstr && len > 0) {
v_buffer = MALLOC(len);
v_bufstr = v_buffer;
@ -3702,7 +3844,7 @@ v_writeBig(int f, char *d, int len)
v_bufend = v_bufptr + len;
} else {
/* no memory: ignore entire write request */
print_error("cannot allocate buffer space\n");
libast_print_error("cannot allocate buffer space\n");
v_buffer = v_bufstr; /* restore clobbered pointer */
c = 0;
}

View File

@ -1,22 +1,25 @@
/*--------------------------------*-C-*---------------------------------*
* File: command.h
/*
* Copyright (C) 1997-2009, Michael Jennings
*
* Copyright 1992 John Bovey, University of Kent at Canterbury.
* 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:
*
* You can do what you like with this source code as long as you don't try
* to make money out of it and you include an unaltered copy of this
* message (including the copyright).
* 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.
*
* This module has been heavily modified by R. Nation
* <nation@rocket.sanders.lockheed.com>
* No additional restrictions are applied.
*
* Additional modifications by mj olesen <olesen@me.QueensU.CA>
* No additional restrictions are applied.
*
* As usual, the author accepts no responsibility for anything, nor does
* he guarantee anything whatsoever.
*----------------------------------------------------------------------*/
* 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.
*/
#ifndef _COMMAND_H_
# define _COMMAND_H_
# include <signal.h>
@ -266,7 +269,7 @@ if (test) PrivateModes |= (bit); else PrivateModes &= ~(bit);} while (0)
#define CHARS_READ() (cmdbuf_ptr < cmdbuf_endp)
#define CHARS_BUFFERED() (count != CMD_BUF_SIZE)
#define RETURN_CHAR() do { \
char c = *cmdbuf_ptr++; \
unsigned char c = *cmdbuf_ptr++; \
refreshed = 0; \
if (c < 32) D_VT(("RETURN_CHAR(): \'%s\' (%d 0x%02x %03o)\n", get_ctrl_char_name(c), c, c, c)); \
else D_VT(("RETURN_CHAR(): \'%c\' (%d 0x%02x %03o)\n", c, c, c, c)); \
@ -386,9 +389,6 @@ extern void tt_printf(const unsigned char *, ...);
extern void main_loop(void);
extern int v_doPending(void);
extern void v_writeBig(int, char *, int);
#ifdef DISPLAY_IS_IP
extern char *network_display(const char *);
#endif
_XFUNCPROTOEND

View File

@ -178,10 +178,10 @@ eterm_default_font_locale(char ***fonts, char ***mfonts, char **mencoding, int *
int j, k;
locale = setlocale(LC_CTYPE, "");
if (locale == NULL)
if ((locale = getenv("LC_ALL")) == NULL)
if ((locale = getenv("LC_CTYPE")) == NULL)
if ((locale = getenv("LANG")) == NULL)
if (!locale)
if (!(locale = getenv("LC_ALL")))
if (!(locale = getenv("LC_CTYPE")))
if (!(locale = getenv("LANG")))
locale = "C"; /* failsafe */
/* Obtain a "normalized" name of current encoding.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 1997-2004, Michael Jennings
* Copyright (C) 1997-2009, 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
@ -168,7 +168,7 @@ bevel_pixmap(Pixmap p, int w, int h, Imlib_Border * bord, unsigned char up)
real_depth = Xdepth;
}
ximg = XGetImage(Xdisplay, p, 0, 0, w, h, -1, ZPixmap);
if (ximg == NULL) {
if (!ximg) {
return;
}
/* Determine bitshift and bitmask values */

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 1997-2004, Michael Jennings
* Copyright (C) 1997-2009, 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

14
src/e.c
View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 1997-2004, Michael Jennings
* Copyright (C) 1997-2009, 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
@ -96,7 +96,7 @@ enl_ipc_get_win(void)
if (tmp) {
ver = tmp + 1;
tmp = strchr((char *) ver, ' ');
if (! tmp) {
if (!tmp) {
tmp = strchr((char *) ver, '-');
}
if (tmp) {
@ -104,8 +104,8 @@ enl_ipc_get_win(void)
}
/* Make sure the version string is within the acceptable range. */
if (SPIF_CMP_IS_LESS(spiftool_version_compare(SPIF_CAST(charptr) str, SPIF_CAST(charptr) "0.16.4"))
|| SPIF_CMP_IS_GREATER(spiftool_version_compare(SPIF_CAST(charptr) str, SPIF_CAST(charptr) "0.16.999"))) {
if (SPIF_CMP_IS_LESS(spiftool_version_compare((spif_charptr_t) str, (spif_charptr_t) "0.16.4"))
|| SPIF_CMP_IS_GREATER(spiftool_version_compare((spif_charptr_t) str, (spif_charptr_t) "0.16.999"))) {
D_ENL((" -> IPC version string \"%s\" out of range. I'll have to ignore it.\n"));
ipc_win = None;
}
@ -156,12 +156,12 @@ enl_ipc_send(char *str)
unsigned short len;
XEvent ev;
if (str == NULL) {
if (!str) {
ASSERT(last_msg != NULL);
str = last_msg;
D_ENL(("Resending last message \"%s\" to Enlightenment.\n", str));
} else {
if (last_msg != NULL) {
if (last_msg) {
FREE(last_msg);
}
last_msg = STRDUP(str);
@ -246,7 +246,7 @@ enl_ipc_get(const char *msg_data)
}
buff[12] = 0;
blen = strlen(buff);
if (message != NULL) {
if (message) {
len += blen;
message = (char *) REALLOC(message, len + 1);
strcat(message, buff);

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 1997-2004, Michael Jennings
* Copyright (C) 1997-2009, 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

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 1997-2004, Michael Jennings
* Copyright (C) 1997-2009, 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

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 1997-2004, Michael Jennings
* Copyright (C) 1997-2009, 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

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 1997-2004, Michael Jennings
* Copyright (C) 1997-2009, 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

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 1997-2004, Michael Jennings
* Copyright (C) 1997-2009, 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
@ -69,8 +69,9 @@
# ifdef HAVE_LASTLOG_H
# include <lastlog.h>
# endif
# if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__bsdi__)
# if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__bsdi__) || defined(__DragonFly__)
# include <ttyent.h>
# define NEW_BSD_UTMP
# endif
# ifdef HAVE_LIBUTEMPTER

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 1997-2004, Michael Jennings
* Copyright (C) 1997-2009, 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
@ -200,20 +200,25 @@ event_win_is_parent(register event_dispatcher_data_t *data, Window win)
unsigned char
handle_key_press(event_t *ev)
{
XWMHints *wm_hints;
#ifdef COUNT_X_EVENTS
static unsigned long keypress_cnt = 0;
#endif
PROF_INIT(handle_key_press);
D_EVENTS(("handle_key_press(ev [%8p] on window 0x%08x)\n", ev, ev->xany.window));
#if UNUSED_BLOCK
REQUIRE_RVAL(XEVENT_IS_MYWIN(ev, &primary_data), 0);
#endif
COUNT_EVENT(keypress_cnt);
if (!(BITFIELD_IS_SET(eterm_options, ETERM_OPTIONS_NO_INPUT))) {
lookup_key(ev);
}
if (BITFIELD_IS_SET(vt_options, VT_OPTIONS_URG_ALERT)) {
wm_hints = XGetWMHints(Xdisplay, TermWin.parent);
wm_hints->flags &= ~XUrgencyHint;
XSetWMHints(Xdisplay, TermWin.parent, wm_hints);
XFree(wm_hints);
}
PROF_DONE(handle_key_press);
PROF_TIME(handle_key_press);
return 1;
@ -346,7 +351,7 @@ handle_client_message(event_t *ev)
XGetWindowProperty(Xdisplay, Xroot, props[PROP_DND_SELECTION], 0L, 1000000L, False, AnyPropertyType, &ActualType,
&ActualFormat, &Size, &RemainingBytes, &data);
if (data != NULL) {
if (data) {
XChangeProperty(Xdisplay, Xroot, XA_CUT_BUFFER0, XA_STRING, 8, PropModeReplace, data, strlen(data));
selection_paste(XA_CUT_BUFFER0);
XSetInputFocus(Xdisplay, Xroot, RevertToNone, CurrentTime);
@ -453,6 +458,7 @@ handle_leave_notify(event_t *ev)
unsigned char
handle_focus_in(event_t *ev)
{
XWMHints *wm_hints;
D_EVENTS(("handle_focus_in(ev [%8p] on window 0x%08x)\n", ev, ev->xany.window));
@ -485,9 +491,15 @@ handle_focus_in(event_t *ev)
}
bbar_draw_all(IMAGE_STATE_NORMAL, MODE_SOLID);
#ifdef USE_XIM
if (xim_input_context != NULL)
if (xim_input_context)
XSetICFocus(xim_input_context);
#endif
if (BITFIELD_IS_SET(vt_options, VT_OPTIONS_URG_ALERT)) {
wm_hints = XGetWMHints(Xdisplay, TermWin.parent);
wm_hints->flags &= ~XUrgencyHint;
XSetWMHints(Xdisplay, TermWin.parent, wm_hints);
XFree(wm_hints);
}
}
return 1;
}
@ -513,7 +525,7 @@ handle_focus_out(event_t *ev)
}
bbar_draw_all(IMAGE_STATE_DISABLED, MODE_SOLID);
#ifdef USE_XIM
if (xim_input_context != NULL)
if (xim_input_context)
XUnsetICFocus(xim_input_context);
#endif
}
@ -629,7 +641,7 @@ handle_button_press(event_t *ev)
REQUIRE_RVAL(XEVENT_IS_MYWIN(ev, &primary_data), 0);
if (action_dispatch(ev, 0)) {
if (eterm_action_dispatch(ev)) {
button_state.ignore_release = 1;
return 1;
}
@ -704,15 +716,15 @@ handle_button_press(event_t *ev)
* This is also true for the scroll() function in script.c.
*/
case Button4:
if (action_check_modifiers(MOD_CTRL, ev->xbutton.state)) {
if (ev->xbutton.state & ETERM_MOD_CTRL) {
scr_page(UP, (TermWin.nrow * 5) - CONTEXT_LINES);
} else if (action_check_modifiers(MOD_SHIFT, ev->xbutton.state)) {
} else if (ev->xbutton.state & ETERM_MOD_SHIFT) {
scr_page(UP, 1);
} else if (action_check_modifiers(MOD_ALT, ev->xbutton.state)) {
} else if (ev->xbutton.state & ETERM_MOD_ALT) {
tt_write("\033[5~", 4);
} else if (action_check_modifiers((MOD_ALT | MOD_SHIFT), ev->xbutton.state)) {
} else if (ev->xbutton.state & (ETERM_MOD_ALT | ETERM_MOD_SHIFT)) {
tt_write("\033[A", 3);
} else if (action_check_modifiers((MOD_ALT | MOD_CTRL), ev->xbutton.state)) {
} else if (ev->xbutton.state & (ETERM_MOD_ALT | ETERM_MOD_CTRL)) {
tt_write("\033[5~\033[5~\033[5~\033[5~\033[5~", 20);
} else {
scr_page(UP, TermWin.nrow - CONTEXT_LINES);
@ -720,15 +732,15 @@ handle_button_press(event_t *ev)
button_state.last_button_press = 4;
break;
case Button5:
if (action_check_modifiers(MOD_CTRL, ev->xbutton.state)) {
if (ev->xbutton.state & ETERM_MOD_CTRL) {
scr_page(DN, (TermWin.nrow * 5) - CONTEXT_LINES);
} else if (action_check_modifiers(MOD_SHIFT, ev->xbutton.state)) {
} else if (ev->xbutton.state & ETERM_MOD_SHIFT) {
scr_page(DN, 1);
} else if (action_check_modifiers(MOD_ALT, ev->xbutton.state)) {
} else if (ev->xbutton.state & ETERM_MOD_ALT) {
tt_write("\033[6~", 4);
} else if (action_check_modifiers((MOD_ALT | MOD_SHIFT), ev->xbutton.state)) {
} else if (ev->xbutton.state & (ETERM_MOD_ALT | ETERM_MOD_SHIFT)) {
tt_write("\033[B", 3);
} else if (action_check_modifiers((MOD_ALT | MOD_CTRL), ev->xbutton.state)) {
} else if (ev->xbutton.state & (ETERM_MOD_ALT | ETERM_MOD_CTRL)) {
tt_write("\033[6~\033[6~\033[6~\033[6~\033[6~", 20);
} else {
scr_page(DN, TermWin.nrow - CONTEXT_LINES);
@ -860,7 +872,7 @@ process_x_event(event_t *ev)
#if 0
D_EVENTS(("process_x_event(ev [%8p] %s on window 0x%08x)\n", ev, event_type_to_name(ev->xany.type), ev->xany.window));
#endif
if (primary_data.handlers[ev->type] != NULL) {
if (primary_data.handlers[ev->type]) {
return ((primary_data.handlers[ev->type]) (ev));
}
return (0);
@ -874,7 +886,7 @@ xerror_handler(Display * display, XErrorEvent * event)
strcpy(err_string, "");
XGetErrorText(display, event->error_code, err_string, sizeof(err_string));
print_error("XError in function %s, resource 0x%08x (request %d.%d): %s (error %d)\n",
libast_print_error("XError in function %s, resource 0x%08x (request %d.%d): %s (error %d)\n",
request_code_to_name(event->request_code), (int) event->resourceid, event->request_code, event->minor_code,
err_string, event->error_code);
#if DEBUG > DEBUG_X11
@ -882,6 +894,6 @@ xerror_handler(Display * display, XErrorEvent * event)
dump_stack_trace();
}
#endif
print_error("Attempting to continue...\n");
libast_print_error("Attempting to continue...\n");
return 0;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 1997-2004, Michael Jennings
* Copyright (C) 1997-2009, 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
@ -62,21 +62,21 @@ typedef unsigned char (*event_dispatcher_t)(event_t *);
typedef unsigned char (*event_handler_t)(event_t *);
typedef void (*event_dispatcher_init_t)(void);
typedef struct {
event_dispatcher_t *dispatchers;
unsigned char num_dispatchers;
event_dispatcher_t *dispatchers;
unsigned char num_dispatchers;
} event_master_t;
typedef struct {
event_handler_t handlers[LASTEvent];
unsigned char num_my_windows;
Window *my_windows;
unsigned char num_my_parents;
Window *my_parents;
event_handler_t handlers[LASTEvent];
unsigned char num_my_windows;
Window *my_windows;
unsigned char num_my_parents;
Window *my_parents;
} event_dispatcher_data_t;
typedef struct {
unsigned short clicks, bypass_keystate, report_mode, mouse_offset;
Time button_press, last_button_press, activate_time;
unsigned char ignore_release;
unsigned short clicks, bypass_keystate, report_mode, mouse_offset;
Time button_press, last_button_press, activate_time;
unsigned char ignore_release;
} mouse_button_state_t;
/************ Variables ************/

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 1997-2004, Michael Jennings
* Copyright (C) 1997-2009, 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
@ -54,7 +54,9 @@
# endif
# ifdef __GNUC__
# define _GNU_SOURCE
# ifndef _GNU_SOURCE
# define _GNU_SOURCE
# endif
# else
# define _XOPEN_SOURCE 600
# define _XOPEN_SOURCE_EXTENDED 1
@ -95,7 +97,6 @@
# include <stdio.h>
# include <stdlib.h>
# define LIBAST_COMPAT_05_API 1
# include <libast.h>
# include "eterm_debug.h"
@ -111,8 +112,9 @@
/* Disable the secondary screen ("\E[?47h" / "\E[?47l") */
/* #define NO_SECONDARY_SCREEN */
/* The number of screenfuls between refreshes. */
# define REFRESH_PERIOD 2
/* The number of screenfuls between refreshes. Anything higher than 1
* will cause gaps in the scrollback buffer. */
# define REFRESH_PERIOD 1
/* This will force clearing of characters before writing new ones on top of
* them. This is experimental - added in order to try and fix pixel dropping
@ -206,9 +208,6 @@
/********************* Miscellaneous options *********************/
/* To have $DISPLAY and the "\E[7n" response be IP addresses rather than FQDN's */
/* #define DISPLAY_IS_IP */
/* To have "\E[7n" reply with the display name. This is a potential security risk,
* so its use is discouraged and unsupported. */
/* #define ENABLE_DISPLAY_ANSWER */
@ -300,6 +299,10 @@ inline void *memmove(void *, const void *, size_t);
# define NO_DELETE_KEY /* These systems seem to be anal this way*/
#endif
#if !defined(HAVE_X11_EXTENSIONS_XRES_H)
# undef HAVE_XRES_EXT
#endif
#ifndef PATH_ENV
# define PATH_ENV "ETERMPATH"
#endif

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 1997-2004, Michael Jennings
* Copyright (C) 1997-2009, 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
@ -52,7 +52,7 @@ const char *def_mfontName[] = { MFONT0, MFONT1, MFONT2, MFONT3, MFONT4 };
#endif
const char *def_fontName[] = { FONT0, FONT1, FONT2, FONT3, FONT4 };
unsigned char font_chg = 0;
fontshadow_t fshadow = { {0, 0, 0, 0}, {0, 0, 0, 1}, 1 };
fontshadow_t fshadow = { {0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 1}, 1 };
static cachefont_t *font_cache = NULL, *cur_font = NULL;
static void font_cache_add(const char *name, unsigned char type, void *info);
@ -179,7 +179,7 @@ font_cache_add(const char *name, unsigned char type, void *info)
D_FONT((" -> Created new cachefont_t struct at %p: \"%s\", %d, %p\n", font, font->name, font->type, font->fontinfo.xfontinfo));
/* Actually add the struct to the end of our cache linked list. */
if (font_cache == NULL) {
if (!font_cache) {
font_cache = cur_font = font;
font->next = NULL;
D_FONT((" -> Stored as first font in cache. font_cache == cur_font == font == %p\n", font_cache));
@ -202,7 +202,7 @@ font_cache_del(const void *info)
D_FONT(("font_cache_del(%8p) called.\n", info));
if (font_cache == NULL) {
if (!font_cache) {
return; /* No fonts in the cache. Theoretically this should never happen, but... */
}
@ -376,7 +376,7 @@ load_font(const char *name, const char *fallback, unsigned char type)
}
/* Specify some sane fallbacks */
if (name == NULL) {
if (!name) {
if (fallback) {
name = fallback;
fallback = "fixed";
@ -388,14 +388,14 @@ load_font(const char *name, const char *fallback, unsigned char type)
fallback = "-misc-fixed-medium-r-normal--13-120-75-75-c-60-iso8859-1";
#endif
}
} else if (fallback == NULL) {
} else if (!fallback) {
fallback = "fixed";
}
D_FONT((" -> Using name == \"%s\" and fallback == \"%s\"\n", name, fallback));
/* Look for the font name in the cache. If it's there, add one to the
reference count and return the existing fontinfo pointer to the caller. */
if ((font = font_cache_find(name, type)) != NULL) {
if ((font = font_cache_find(name, type))) {
font_cache_add_ref(font);
D_FONT((" -> Font found in cache. Incrementing reference count to %d and returning existing data.\n", font->ref_cnt));
switch (type) {
@ -416,10 +416,10 @@ load_font(const char *name, const char *fallback, unsigned char type)
/* No match in the cache, so we'll have to add it. */
if (type == FONT_TYPE_X) {
if ((xfont = XLoadQueryFont(Xdisplay, name)) == NULL) {
print_error("Unable to load font \"%s\". Falling back on \"%s\"\n", name, fallback);
if ((xfont = XLoadQueryFont(Xdisplay, fallback)) == NULL) {
fatal_error("Couldn't load the fallback font either. Giving up.\n");
if (!(xfont = XLoadQueryFont(Xdisplay, name))) {
libast_print_error("Unable to load font \"%s\". Falling back on \"%s\"\n", name, fallback);
if (!(xfont = XLoadQueryFont(Xdisplay, fallback))) {
libast_fatal_error("Couldn't load the fallback font either. Giving up.\n");
} else {
font_cache_add(fallback, type, (void *) xfont);
}
@ -461,7 +461,7 @@ change_font(int init, const char *fontname)
if (init) {
ASSERT(etfonts != NULL);
if ((def_font_idx >= font_cnt) || (etfonts[def_font_idx] == NULL)) {
if ((def_font_idx >= font_cnt) || (!etfonts[def_font_idx])) {
def_font_idx = font_idx;
} else {
font_idx = def_font_idx;
@ -518,7 +518,7 @@ change_font(int init, const char *fontname)
}
/* If we get here with a non-NULL fontname, we have to load a new font. Rats. */
if (fontname != NULL) {
if (fontname) {
eterm_font_add(&etfonts, fontname, font_idx);
} else if (font_idx == old_idx) {
/* Sigh. What a waste of time, changing to the same font. */
@ -539,7 +539,7 @@ change_font(int init, const char *fontname)
}
#ifndef NO_BOLDFONT
if (init && rs_boldFont != NULL) {
if (init && rs_boldFont) {
/* If we're initializing, load the bold font too. */
boldFont = load_font(rs_boldFont, "-misc-fixed-bold-r-semicondensed--13-120-75-75-c-60-iso8859-1", FONT_TYPE_X);
}
@ -636,7 +636,7 @@ change_font(int init, const char *fontname)
/* Check the bold font size and make sure it matches the normal font */
#ifndef NO_BOLDFONT
TermWin.boldFont = NULL; /* FIXME: Memory leak? Not that anyone uses bold fonts.... */
if (boldFont != NULL) {
if (boldFont) {
fw = boldFont->min_bounds.width;
fh = boldFont->ascent + boldFont->descent + rs_line_space;
@ -689,10 +689,18 @@ get_corner(const char *corner)
{
if (!BEG_STRCASECMP(corner, "tl ") || !BEG_STRCASECMP(corner, "top_left")) {
return SHADOW_TOP_LEFT;
} else if (!BEG_STRCASECMP(corner, "t ") || !BEG_STRCASECMP(corner, "top")) {
return SHADOW_TOP;
} else if (!BEG_STRCASECMP(corner, "tr ") || !BEG_STRCASECMP(corner, "top_right")) {
return SHADOW_TOP_RIGHT;
} else if (!BEG_STRCASECMP(corner, "l ") || !BEG_STRCASECMP(corner, "left")) {
return SHADOW_LEFT;
} else if (!BEG_STRCASECMP(corner, "r ") || !BEG_STRCASECMP(corner, "right")) {
return SHADOW_RIGHT;
} else if (!BEG_STRCASECMP(corner, "bl ") || !BEG_STRCASECMP(corner, "bottom_left")) {
return SHADOW_BOTTOM_LEFT;
} else if (!BEG_STRCASECMP(corner, "b ") || !BEG_STRCASECMP(corner, "bottom")) {
return SHADOW_BOTTOM;
} else if (!BEG_STRCASECMP(corner, "br ") || !BEG_STRCASECMP(corner, "bottom_right")) {
return SHADOW_BOTTOM_RIGHT;
} else {
@ -705,7 +713,7 @@ set_shadow_color_by_name(unsigned char which, const char *color_name)
{
Pixel p;
ASSERT(which <= 4);
ASSERT(which <= 7); // which = 0-7 [SHADOW_TOP_LEFT - SHADOW_BOTTOM_RIGHT]
p = get_color_by_name(color_name, "#000000");
fshadow.color[which] = p;
@ -715,7 +723,7 @@ set_shadow_color_by_name(unsigned char which, const char *color_name)
void
set_shadow_color_by_pixel(unsigned char which, Pixel p)
{
ASSERT(which <= 4);
ASSERT(which <= 7); // which = 0-7 [SHADOW_TOP_LEFT - SHADOW_BOTTOM_RIGHT]
fshadow.color[which] = p;
fshadow.shadow[which] = fshadow.do_shadow = 1;
@ -740,7 +748,7 @@ parse_font_fx(char *line)
ASSERT_RVAL(line != NULL, 0);
n = num_words(line);
n = spiftool_num_words(line);
if (!BEG_STRCASECMP(line, "none")) {
MEMSET(&fshadow, 0, sizeof(fontshadow_t));
@ -748,22 +756,24 @@ parse_font_fx(char *line)
if (n != 2) {
return 0;
}
color = get_word(2, line);
color = spiftool_get_word(2, line);
p = get_color_by_name(color, "black");
FREE(color);
for (which = 0; which < 4; which++) {
for (which = 0; which < 8; which++) {
set_shadow_color_by_pixel(which, p);
}
} else if (!BEG_STRCASECMP(line, "shadow")) {
if (n == 2) {
which = SHADOW_BOTTOM_RIGHT;
color = get_word(2, line);
color = spiftool_get_word(2, line);
} else if (n == 3) {
color = get_word(3, line);
corner = get_pword(2, line);
color = spiftool_get_word(3, line);
corner = spiftool_get_pword(2, line);
which = get_corner(corner);
if (which >= 4) {
if (which >= 8) {
return 0;
} else if (which != SHADOW_BOTTOM_RIGHT) {
fshadow.shadow[SHADOW_BOTTOM_RIGHT] = 0;
}
} else {
return 0;
@ -774,26 +784,30 @@ parse_font_fx(char *line)
if (n != 3) {
return 0;
}
color = get_word(2, line);
color = spiftool_get_word(2, line);
p = get_color_by_name(color, "black");
set_shadow_color_by_pixel(SHADOW_BOTTOM, p);
set_shadow_color_by_pixel(SHADOW_BOTTOM_RIGHT, p);
FREE(color);
color = get_word(3, line);
color = spiftool_get_word(3, line);
p = get_color_by_name(color, "white");
set_shadow_color_by_pixel(SHADOW_TOP_LEFT, p);
set_shadow_color_by_pixel(SHADOW_TOP, p);
FREE(color);
} else if (!BEG_STRCASECMP(line, "carved")) {
if (n != 3) {
return 0;
}
color = get_word(2, line);
color = spiftool_get_word(2, line);
p = get_color_by_name(color, "black");
set_shadow_color_by_pixel(SHADOW_TOP_LEFT, p);
set_shadow_color_by_pixel(SHADOW_TOP, p);
FREE(color);
color = get_word(3, line);
color = spiftool_get_word(3, line);
p = get_color_by_name(color, "white");
set_shadow_color_by_pixel(SHADOW_BOTTOM, p);
set_shadow_color_by_pixel(SHADOW_BOTTOM_RIGHT, p);
FREE(color);
} else {
@ -803,15 +817,15 @@ parse_font_fx(char *line)
which = get_corner(line);
if (which >= 4) {
which = i;
color = get_word(1, line);
line = get_pword(2, line);
color = spiftool_get_word(1, line);
line = spiftool_get_pword(2, line);
} else {
color = get_word(2, line);
line = get_pword(3, line);
color = spiftool_get_word(2, line);
line = spiftool_get_pword(3, line);
}
set_shadow_color_by_name(which, color);
FREE(color);
if (line == NULL) {
if (!line) {
break;
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 1997-2004, Michael Jennings
* Copyright (C) 1997-2009, 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
@ -24,9 +24,71 @@
#ifndef _FONT_H_
#define _FONT_H_
#include <stdio.h>
#include <X11/Xfuncproto.h>
#include <X11/Intrinsic.h> /* Xlib, Xutil, Xresource, Xfuncproto */
#include <X11/Intrinsic.h> /* Xlib, Xutil, Xresource, Xfuncproto */
#include <libast.h>
/************ ************/
/************ Generic eterm_font object interface. ************/
/* Cast an arbitrary object pointer to an eterm_font. */
#define SPIF_ETERM_FONT(o) (SPIF_CAST(eterm_font) (o))
#define SPIF_ETERM_FONT_CLASS(o) (SPIF_CAST(eterm_font_class) SPIF_OBJ_CLASS(o))
/* Name of class variable associated with eterm_font interface */
#define SPIF_ETERM_FONT_CLASS_VAR(type) spif_ ## type ## _eterm_font_class
/* Check if a eterm_font is NULL */
#define SPIF_ETERM_FONT_ISNULL(o) (SPIF_ETERM_FONT(o) == SPIF_NULL_TYPE(eterm_font))
/* Check if an object is a eterm_font */
#define SPIF_OBJ_IS_ETERM_FONT(o) SPIF_OBJ_IS_TYPE(o, eterm_font)
/* Call a method on an instance of an implementation class */
#define SPIF_ETERM_FONT_CALL_METHOD(o, meth) SPIF_ETERM_FONT_CLASS(o)->meth
/* Calls to the basic functions. */
#define SPIF_ETERM_FONT_NEW(type) SPIF_ETERM_FONT((SPIF_CLASS(SPIF_ETERM_FONT_CLASS_VAR(type)))->noo())
#define SPIF_ETERM_FONT_INIT(o) SPIF_OBJ_INIT(o)
#define SPIF_ETERM_FONT_DONE(o) SPIF_OBJ_DONE(o)
#define SPIF_ETERM_FONT_DEL(o) SPIF_OBJ_DEL(o)
#define SPIF_ETERM_FONT_SHOW(o, b, i) SPIF_OBJ_SHOW(o, b, i)
#define SPIF_ETERM_FONT_COMP(o1, o2) SPIF_OBJ_COMP(o1, o2)
#define SPIF_ETERM_FONT_DUP(o) SPIF_OBJ_DUP(o)
#define SPIF_ETERM_FONT_TYPE(o) SPIF_OBJ_TYPE(o)
typedef SPIF_TYPE(obj) SPIF_TYPE(eterm_font);
SPIF_DECL_OBJ(eterm_font_class) {
SPIF_DECL_PARENT_TYPE(class);
};
/************ ************/
#define SPIF_ETERM_FONT_X(obj) (SPIF_CAST(eterm_font_x) (obj))
#define SPIF_ETERM_FONT_X_ISNULL(o) (SPIF_ETERM_FONT_X(o) == SPIF_NULL_TYPE(eterm_font_x))
#define SPIF_OBJ_IS_ETERM_FONT_X(o) (SPIF_OBJ_IS_TYPE((o), eterm_font_x))
SPIF_DECL_OBJ(eterm_font_x) {
SPIF_DECL_PARENT_TYPE(obj);
};
extern spif_eterm_font_class_t SPIF_ETERM_FONT_CLASS_VAR(eterm_font);
/************ ************/
extern spif_vector_t fonts;
extern spif_class_t SPIF_CLASS_VAR(eterm_font);
extern spif_eterm_font_t spif_eterm_font_new(void);
extern spif_bool_t spif_eterm_font_del(spif_eterm_font_t);
extern spif_bool_t spif_eterm_font_init(spif_eterm_font_t);
extern spif_bool_t spif_eterm_font_done(spif_eterm_font_t);
extern spif_eterm_font_t spif_eterm_font_dup(spif_eterm_font_t);
extern spif_cmp_t spif_eterm_font_comp(spif_eterm_font_t, spif_eterm_font_t);
extern spif_str_t spif_eterm_font_show(spif_eterm_font_t, spif_charptr_t, spif_str_t, size_t);
extern spif_classname_t spif_eterm_font_type(spif_eterm_font_t);
/************ Macros and Definitions ************/
#define FONT_TYPE_X (0x01)
@ -42,9 +104,13 @@
/* These are subscripts for the arrays in a fontshadow_t */
#define SHADOW_TOP_LEFT 0
#define SHADOW_TOP_RIGHT 1
#define SHADOW_BOTTOM_LEFT 2
#define SHADOW_BOTTOM_RIGHT 3
#define SHADOW_TOP 1
#define SHADOW_TOP_RIGHT 2
#define SHADOW_LEFT 3
#define SHADOW_RIGHT 4
#define SHADOW_BOTTOM_LEFT 5
#define SHADOW_BOTTOM 6
#define SHADOW_BOTTOM_RIGHT 7
/* The macros are used to advance to the next/previous font as with Ctrl-> and Ctrl-< */
#define NEXT_FONT(i) do { if (font_idx + ((i)?(i):1) >= font_cnt) {font_idx = font_cnt - 1;} else {font_idx += ((i)?(i):1);} \
@ -67,8 +133,8 @@ typedef struct cachefont_struct {
} cachefont_t;
typedef struct fontshadow_struct {
Pixel color[4];
unsigned char shadow[4];
Pixel color[8];
unsigned char shadow[8];
unsigned char do_shadow;
} fontshadow_t;

View File

@ -250,7 +250,7 @@ kstate_add_xlat(char *str)
char *sval;
int i;
if (str == NULL)
if (!str)
return;
/* add a new xlat table in state */
if (pStateNow->num_xlat == 0) {
@ -263,11 +263,11 @@ kstate_add_xlat(char *str)
xlat->last = (u_int) atoi(strtok(NULL, ":"));
i = 0;
pval_tmp = CALLOC(MAX_VAL, sizeof(K_XLAT));
while ((sval = strtok(NULL, ",")) != NULL) {
while ((sval = strtok(NULL, ","))) {
pval_tmp[i++] = (u_int) (atoi(sval));
}
xlat->pval = CALLOC(i, sizeof(K_XLAT));
if (xlat->pval != NULL)
if (xlat->pval)
memcpy(xlat->pval, pval_tmp, i * sizeof(u_int));
FREE(pval_tmp);
pStateNow->num_xlat++;
@ -281,7 +281,7 @@ kstate_add_switcher(char *str)
{
K_SWITCH *switcher;
if (str == NULL)
if (!str)
return;
if (pStateNow->num_switcher >= MAX_SWITCHER)
return;

View File

@ -14,7 +14,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Header$
* $Header: /cvsroot/enlightenment/eterm/Eterm/src/grkelot.h,v 1.2 1999/08/18 01:12:44 mej Exp $
*/
#ifndef _GRKELOT_H

View File

@ -8,6 +8,7 @@
* and vice versa. several sessions can be open at once.
*
* Lesser GNU Public Licence applies.
* Distributed with Eterm under the same license terms as Eterm itself.
* Thread-safe: untested
*
* 2002/04/19 Azundris incept
@ -39,6 +40,7 @@
#include <limits.h> /* PATH_MAX */
#include <ctype.h> /* isspace() */
#include <errno.h> /* errno */
#include <sys/socket.h>
#include "config.h"
#include "feature.h"
@ -203,22 +205,35 @@ ns_new_hop(int lp, char *fw, int fp, int delay, _ns_sess * s)
bzero(h, sizeof(_ns_hop));
if ((h->fw = STRDUP(fw))) {
if (!lp) {
lp = NS_MIN_PORT; /* local port defaults to */
if (ha) { /* NS_MIN_PORT. if that's */
int f; /* taken, use next FREE port. */
int tmp_sock;
do { /* FREE as in, not used by us. */
_ns_hop *i = ha;
tmp_sock = socket(PF_INET, SOCK_STREAM, 6);
if (tmp_sock > 0) {
struct sockaddr_in addr;
f = 0;
while (i)
if (i->localport == lp) {
f = 1;
lp++;
i = NULL;
} else
i = i->next;
} while (f);
addr.sin_family = AF_INET;
addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
for (lp = NS_MIN_PORT; (lp > 0) && (lp < NS_MAX_PORT); lp++) {
addr.sin_port = htons(lp);
if (bind(tmp_sock, (struct sockaddr *) &addr, sizeof(struct sockaddr_in))) {
D_ESCREEN(("Unable to bind socket %d to 127.0.0.1:%hd -- %s\n", tmp_sock, lp, strerror(errno)));
} else if (listen(tmp_sock, 1)) {
D_ESCREEN(("Unable to listen on port %hd -- %s\n", lp, strerror(errno)));
} else {
/* We can listen on this port. Use it! */
/* FIXME: Minor race condition between port selection and ssh call. */
D_ESCREEN(("Got available listening port %d.\n", lp));
break;
}
}
if ((lp < 0) || (lp == NS_MAX_PORT)) {
/* We're going to fail anyway, so just throw something in. */
lp = NS_MIN_PORT + (random() % (NS_MAX_PORT - NS_MIN_PORT));
BOUND(lp, NS_MIN_PORT, NS_MAX_PORT);
D_ESCREEN(("Chose random listening port %d.\n", lp));
}
close(tmp_sock);
}
}
h->delay = (delay ? delay : NS_TUNNEL_DELAY);
@ -1066,6 +1081,42 @@ ns_attach_lcl(_ns_sess ** sp)
}
static int
ns_wait_for_socket(int port)
{
int tmp_sock, ret = -1;
time_t start_time;
D_ESCREEN(("Waiting for forwarder to begin listening on port %d.\n", port));
tmp_sock = socket(PF_INET, SOCK_STREAM, 6);
start_time = time(NULL);
if (tmp_sock >= 0) {
struct sockaddr_in addr;
char timeout = 0;
addr.sin_family = AF_INET;
addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
addr.sin_port = htons(port);
do {
usleep(100);
if ((time(NULL) - start_time) >= NS_TUNNEL_DELAY) {
timeout = 1;
break;
}
} while (connect(tmp_sock, (struct sockaddr *) &addr, sizeof(struct sockaddr_in)));
if (timeout) {
D_ESCREEN((" -> Unable to connect; timeout after %d seconds.\n", NS_TUNNEL_DELAY));
sleep(1);
return -1;
} else {
ret = time(NULL) - start_time;
D_ESCREEN((" -> Connected after %d seconds.\n", ret));
}
close(tmp_sock);
}
return ret;
}
/* attach a remote session (using screen/scream via ssh)
sp the session
@ -1101,22 +1152,36 @@ ns_attach_ssh(_ns_sess ** sp)
if (sess->hop) {
if (sess->hop->established == NS_HOP_DOWN) { /* the nightmare foe */
_ns_efuns *efuns = NULL;
ret = snprintf(cmd, NS_MAXCMD, "%s %s -p %d -L %d:%s:%d %s@%s",
NS_SSH_CALL, NS_SSH_TUNNEL_OPTS, sess->hop->fwport, sess->hop->localport, sess->host, sess->port,
sess->user, sess->hop->fw);
if (ret < 0 || ret > NS_MAXCMD)
return NS_FAIL;
D_ESCREEN(("Spawning forwarder: %s\n", cmd));
ns_run(sess->efuns, cmd);
sleep(sess->hop->delay);
if (NS_EFUN_EXISTS(efuns, sess, NULL, inp_text)) {
char tmp_buff[] = "Waiting for forwarder...";
efuns->inp_text((void *) 1, sess->fd, tmp_buff);
}
if ((ns_wait_for_socket(sess->hop->localport) < 0) && efuns) {
char tmp_buff[] = "...timed out.";
efuns->inp_text((void *) 1, sess->fd, tmp_buff);
}
}
ret = snprintf(cmd, NS_MAXCMD, "%s %s -p %d %s@localhost \"%s%s\"",
NS_SSH_CALL, NS_SSH_OPTS, sess->hop->localport, sess->user, call, ((sess->backend == NS_MODE_SCREEN)
|| (sess->backend ==
NS_MODE_NEGOTIATE)) ? esc : "");
D_ESCREEN(("Spawning screen session: %s\n", cmd));
} else {
ret =
snprintf(cmd, NS_MAXCMD, "%s %s -p %d %s@%s \"%s%s\"", NS_SSH_CALL, NS_SSH_OPTS, sess->port, sess->user, sess->host,
call, ((sess->backend == NS_MODE_SCREEN) || (sess->backend == NS_MODE_NEGOTIATE)) ? esc : "");
D_ESCREEN(("Spawning screen session: %s\n", cmd));
}
ns_free(&call);
@ -1424,6 +1489,7 @@ ns_attach_by_URL(char *url, char *hop, _ns_efuns ** ef, int *err, void *xd)
#warning compiling in libscream
#ifdef NS_HAVE_SCREEN
if (!strcmp(sess->proto, "screen")) {
D_ESCREEN(("Using session protocol \"%s\"\n", sess->proto));
sess->backend = NS_MODE_SCREEN;
} else
#warning compiling in support for GNU screen
@ -1433,6 +1499,7 @@ ns_attach_by_URL(char *url, char *hop, _ns_efuns ** ef, int *err, void *xd)
if (!strcmp(sess->proto, "twin")) {
char *twd = getenv("TWDISPLAY");
D_ESCREEN(("Using session protocol \"%s\"\n", sess->proto));
sess->backend = NS_MODE_TWIN;
/* fall back on TWDISPLAY env var only if host not set yet */
@ -1459,6 +1526,7 @@ ns_attach_by_URL(char *url, char *hop, _ns_efuns ** ef, int *err, void *xd)
} else
#endif
if (!strcmp(sess->proto, "scream")) {
D_ESCREEN(("Using session protocol \"%s\"\n", sess->proto));
sess->backend = NS_MODE_SCREAM;
} else {
*err = NS_UNKNOWN_PROTO;
@ -1466,6 +1534,8 @@ ns_attach_by_URL(char *url, char *hop, _ns_efuns ** ef, int *err, void *xd)
fprintf(stderr, "protocol \"%s\" not known...\n", sess->proto);
goto fail;
}
} else {
D_ESCREEN(("No session protocol specified.\n"));
}
if ((sess->disp < 0) || (sess->disp > NS_MAX_PORT))
@ -1573,10 +1643,10 @@ ns_tog_disp(_ns_sess * s)
switch (s->backend) {
#ifdef NS_HAVE_SCREEN
case NS_MODE_SCREEN:
case NS_MODE_SCREEN:
/* return ns_screen_command(s, "\x01\x01"); */
return ns_statement(s, "other");
break;
return ns_statement(s, "other");
break;
#endif
default:
return NS_FAIL;
@ -1594,16 +1664,17 @@ ns_go2_disp(_ns_sess * s, int d)
switch (s->backend) {
#ifdef NS_HAVE_SCREEN
case NS_MODE_SCREEN:
{
case NS_MODE_SCREEN:
{
/* char b[] = "\x01_";
b[1] = '0' + d;
return ns_screen_command(s, b); */
char b[] = "select _";
b[7] = '0' + d;
return ns_statement(s, b);
}
break;
char b[] = "select _";
b[7] = '0' + d;
return ns_statement(s, b);
}
break;
#endif
#ifdef NS_HAVE_TWIN
case NS_MODE_TWIN:
@ -1636,16 +1707,16 @@ ns_mon_disp(_ns_sess * s, int no, int quiet)
switch (s->backend) {
#ifdef NS_HAVE_SCREEN
case NS_MODE_SCREEN:
if (no >= 0)
ns_go2_disp(s, no);
if (quiet == NS_MON_TOGGLE_QUIET)
s->flags |= NS_SESS_NO_MON_MSG;
else
s->flags &= (~NS_SESS_NO_MON_MSG);
case NS_MODE_SCREEN:
if (no >= 0)
ns_go2_disp(s, no);
if (quiet == NS_MON_TOGGLE_QUIET)
s->flags |= NS_SESS_NO_MON_MSG;
else
s->flags &= (~NS_SESS_NO_MON_MSG);
/* return ns_screen_command(s, "\x01M"); */
return ns_statement(s, "monitor");
break;
return ns_statement(s, "monitor");
break;
#endif
}
return NS_FAIL;
@ -1660,11 +1731,11 @@ ns_sbb_disp(_ns_sess * s, int no)
switch (s->backend) {
#ifdef NS_HAVE_SCREEN
case NS_MODE_SCREEN:
ns_go2_disp(s, no);
case NS_MODE_SCREEN:
ns_go2_disp(s, no);
/* return ns_screen_command(s, "\x01\x1b"); */
return ns_statement(s, "copy");
break;
return ns_statement(s, "copy");
break;
#endif
default:
return NS_FAIL;
@ -1728,21 +1799,21 @@ ns_add_disp(_ns_sess * s, int after, char *name)
switch (s->backend) {
#ifdef NS_HAVE_SCREEN
case NS_MODE_SCREEN:
if (after >= 0)
ns_go2_disp(s, after);
case NS_MODE_SCREEN:
if (after >= 0)
ns_go2_disp(s, after);
/* if (ns_screen_command(s, "\x01\x03") == NS_SUCC) { */
ret = ns_statement(s, "screen");
if (ret == NS_SUCC) {
D_ESCREEN(("Sent \"screen\" command, now renaming tab.\n"));
if (!name || strlen(name)) {
ns_ren_disp(s, -2, name);
}
ret = ns_mon_disp(s, -2, NS_MON_TOGGLE_QUIET);
} else {
D_ESCREEN(("ns_statement(screen) returned %d\n", ret));
}
break;
ret = ns_statement(s, "screen");
if (ret == NS_SUCC) {
D_ESCREEN(("Sent \"screen\" command, now renaming tab.\n"));
if (!name || strlen(name)) {
ns_ren_disp(s, -2, name);
}
ret = ns_mon_disp(s, -2, NS_MON_TOGGLE_QUIET);
} else {
D_ESCREEN(("ns_statement(screen) returned %d\n", ret));
}
break;
#endif
#ifdef NS_HAVE_TWIN
case NS_MODE_TWIN:
@ -1839,12 +1910,12 @@ ns_rem_disp(_ns_sess * s, int d, int ask)
if (*i == 'y' || *i == 'Y') {
switch (s->backend) {
#ifdef NS_HAVE_SCREEN
case NS_MODE_SCREEN:
ns_go2_disp(s, d);
case NS_MODE_SCREEN:
ns_go2_disp(s, d);
/* ret = ns_screen_command(s, "\x01ky\r"); */
if ((ret = ns_statement(s, "kill")) == NS_SUCC)
ret = ns_screen_command(s, "y\r");
break;
if ((ret = ns_statement(s, "kill")) == NS_SUCC)
ret = ns_screen_command(s, "y\r");
break;
#endif
}
}
@ -1868,7 +1939,7 @@ int
ns_ren_disp(_ns_sess * s, int d, char *name)
{
char *i = NULL, *n;
size_t l;
size_t l = 0;
int ret = NS_FAIL;
if (!s) {
@ -1969,14 +2040,14 @@ ns_rel_region(_ns_sess * s, _ns_disp * d, int n)
switch (s->backend) {
#ifdef NS_HAVE_SCREEN
case NS_MODE_SCREEN:
if (n < 0)
return NS_FAIL;
do {
case NS_MODE_SCREEN:
if (n < 0)
return NS_FAIL;
do {
/* ret = ns_screen_command(s, "\x01\x09"); */
ret = ns_statement(s, "focus");
} while (--n && (ret == NS_SUCC));
break;
ret = ns_statement(s, "focus");
} while (--n && (ret == NS_SUCC));
break;
#endif
}
return ret;
@ -1997,10 +2068,10 @@ ns_add_region(_ns_sess * s, _ns_disp * d, int after, char *name)
switch (s->backend) {
#ifdef NS_HAVE_SCREEN
case NS_MODE_SCREEN:
case NS_MODE_SCREEN:
/* ret = ns_screen_command(s, "\x01S"); */
ret = ns_statement(s, "split");
break;
ret = ns_statement(s, "split");
break;
#endif
}
return ret;
@ -2031,10 +2102,10 @@ ns_rem_region(_ns_sess * s, _ns_disp * d, int r, int ask)
switch (s->backend) {
#ifdef NS_HAVE_SCREEN
case NS_MODE_SCREEN:
case NS_MODE_SCREEN:
/* ret = ns_screen_command(s, "\x01X"); */
ret = ns_statement(s, "remove");
break;
ret = ns_statement(s, "remove");
break;
#endif
}
return ret;
@ -2054,10 +2125,10 @@ ns_one_region(_ns_sess * s, _ns_disp * d, int r)
switch (s->backend) {
#ifdef NS_HAVE_SCREEN
case NS_MODE_SCREEN:
case NS_MODE_SCREEN:
/* ret = ns_screen_command(s, "\x01Q"); */
ret = ns_statement(s, "only");
break;
ret = ns_statement(s, "only");
break;
#endif
}
return ret;
@ -2141,16 +2212,20 @@ ns_scroll2y(_ns_sess * s, int y)
int
ns_upd_stat(_ns_sess * s)
{
D_ESCREEN(("Forcing update of status line for session 0x%p.\n", s));
if (!s) {
return NS_FAIL;
}
switch (s->backend) {
/* FIXME: Causes other problems. case NS_MODE_NEGOTIATE:*/
#ifdef NS_HAVE_SCREEN
case NS_MODE_SCREEN:
D_ESCREEN(("Calling ns_screen_command(0x%p, %s)\n", s, NS_SCREEN_UPDATE));
return ns_screen_command(s, NS_SCREEN_UPDATE);
#endif
default:
D_ESCREEN(("Failed; backend set to %d\n", s->backend));
return NS_FAIL;
}
}
@ -2195,8 +2270,7 @@ ns_statement(_ns_sess * s, char *c)
s->escape = x;
}
ret = ns_screen_xcommand(s, NS_SCREEN_CMD, i ? i : c);
D_ESCREEN(("ns_screen_xcommand(%10p, NS_SCREEN_CMD, %s) returned %d.\n",
s, NONULL(((i) ? (i) : (c))), ret));
D_ESCREEN(("ns_screen_xcommand(%10p, NS_SCREEN_CMD, %s) returned %d.\n", s, NONULL(((i) ? (i) : (c))), ret));
s->escape = y;
} else if (ret == NS_NOT_ALLOWED) {
ns_inp_dial(s, "Sorry, David, I cannot allow that.", 0, NULL, NULL);
@ -2554,6 +2628,7 @@ ns_screen_command(_ns_sess * sess, char *cmd)
char *c;
int ret = NS_SUCC;
D_ESCREEN(("Sending command \"%s\"\n", NONULL(cmd)));
if (!cmd || !*cmd) {
return NS_FAIL;
}
@ -3060,9 +3135,10 @@ ns_parse_screen_msg(_ns_sess * screen, char *p)
} else if (!strcmp(p, "New screen...") ||
!strncmp(p, "msgwait", strlen("msgwait")) ||
!strncmp(p, "msgminwait", strlen("msgminwait")) ||
!strcmp(p, "Press ^@ to destroy or ^@ to resurrect window") || !strcmp(p, "Aborted because of window size change."))
!strcmp(p, "Press ^@ to destroy or ^@ to resurrect window")
|| !strcmp(p, "Aborted because of window size change.")) {
p = NULL;
else if ((screen->flags & NS_SESS_NO_MON_MSG) &&
} else if ((screen->flags & NS_SESS_NO_MON_MSG) &&
((sscanf(p, "Window %d (%s) is now being monitored for all activity.", &n, win) == 2) ||
(sscanf(p, "Window %d (%s) is no longer being monitored for activity.", &n, win) == 2))) {
D_ESCREEN(("activity toggled quietly for window %d-%s\n", n, win));
@ -3093,16 +3169,17 @@ ns_parse_screen_msg(_ns_sess * screen, char *p)
p = NULL;
D_ESCREEN(("ns_parse_screen_msg: scre%s %d.%2d.%2d %s a/o %s -> mode %d\n", vtype, ma, mi, mu, vrem, vdate,
screen->backend));
} else if (!strcmp(p, NS_SCREEN_NO_DEBUG))
} else if (!strcmp(p, NS_SCREEN_NO_DEBUG)) {
p = "debug info was not compiled into \"screen\"...";
else if (!strncmp(p, NS_SCREEN_DK_CMD_T, strlen(NS_SCREEN_DK_CMD_T))) {
} else if (!strncmp(p, NS_SCREEN_DK_CMD_T, strlen(NS_SCREEN_DK_CMD_T))) {
p[strlen(p) - 1] = '\0';
p2 = &p[strlen(NS_SCREEN_DK_CMD_T)];
p = "unknown screen statement ignored";
}
if (p) { /* status. send to status-line or dialog or whatever */
if (NS_EFUN_EXISTS(efuns, screen, NULL, err_msg))
if (NS_EFUN_EXISTS(efuns, screen, NULL, err_msg)) {
ret = efuns->err_msg(NULL, type, p);
}
}
return ret;
}
@ -3150,6 +3227,8 @@ ns_parse_screen(_ns_sess * screen, int force, int width, char *p)
if (!force && screen->timestamp)
return NS_SUCC;
D_ESCREEN(("ns_parse_screen(0x%08x, %d, %d, \"%s\")\n", screen, force, width,
safe_print_string(p, width)));
if ((p = STRDUP(p))) {
_ns_parse pd[NS_MAX_DISPS];
@ -3163,7 +3242,7 @@ ns_parse_screen(_ns_sess * screen, int force, int width, char *p)
*p2 = 0; /* make darn sure it's NUL-terminated */
}
D_ESCREEN(("parse_screen: screen sends (%d) ::%s::\n", strlen(p), p));
D_ESCREEN(("parse_screen: screen sends \"%s\" (%d)\n", p, strlen(p)));
if (strlen(p) < 2) { /* special case: display 0 */
disp = screen->dsps; /* might not get a status-line in d0! */
@ -3191,9 +3270,19 @@ ns_parse_screen(_ns_sess * screen, int force, int width, char *p)
if (NS_EFUN_EXISTS(efuns, screen, NULL, waitstate)) {
ret = efuns->waitstate(NULL, screen->delay * 1000);
}
(void) ns_upd_stat(screen);
if (screen->where == NS_LCL) {
D_ESCREEN(("Sending update request.\n"));
ns_upd_stat(screen);
} else {
D_ESCREEN(("Not sending update request (%d).\n", screen->where));
}
} else {
(void) ns_screen_command(screen, NS_SCREEN_INIT);
if (screen->where == NS_LCL) {
D_ESCREEN(("Sending init request.\n"));
(void) ns_screen_command(screen, NS_SCREEN_INIT);
} else {
D_ESCREEN(("Not sending init request (%d).\n", screen->where));
}
screen->timestamp = 1;
}
} else if ((screen->timestamp > 1) && (time(NULL) >= screen->timestamp)) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 1997-2004, Michael Jennings
* Copyright (C) 1997-2009, 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

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 1997-2004, Michael Jennings
* Copyright (C) 1997-2009, 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
@ -301,7 +301,7 @@ menu_handle_button_release(event_t *ev)
if (button_press_time && (ev->xbutton.time - button_press_time > MENU_CLICK_TIME)) {
/* Take action here based on the current menu item */
if ((item = menuitem_get_current(current_menu)) != NULL) {
if ((item = menuitem_get_current(current_menu))) {
if (item->type == MENUITEM_SUBMENU) {
menu_display_submenu(current_menu, item);
} else {
@ -326,7 +326,7 @@ menu_handle_button_release(event_t *ev)
if (current_menu && (ev->xbutton.x >= 0) && (ev->xbutton.y >= 0) && (ev->xbutton.x < current_menu->w)
&& (ev->xbutton.y < current_menu->h)) {
/* Click inside the menu window. Activate the current item. */
if ((item = menuitem_get_current(current_menu)) != NULL) {
if ((item = menuitem_get_current(current_menu))) {
if (item->type == MENUITEM_SUBMENU) {
menu_display_submenu(current_menu, item);
} else {
@ -415,7 +415,7 @@ menu_handle_motion_notify(event_t *ev)
unsigned char
menu_dispatch_event(event_t *ev)
{
if (menu_event_data.handlers[ev->type] != NULL) {
if (menu_event_data.handlers[ev->type]) {
return ((menu_event_data.handlers[ev->type]) (ev));
}
return (0);
@ -467,8 +467,9 @@ menu_t *menu_create(char *title)
xattr.colormap = cmap;
cursor = XCreateFontCursor(Xdisplay, XC_left_ptr);
mask = KeyPressMask | PointerMotionMask | ButtonMotionMask | ButtonPressMask | ButtonReleaseMask
| Button1MotionMask | Button2MotionMask | Button3MotionMask;
mask =
PointerMotionMask | ButtonMotionMask | ButtonPressMask | ButtonReleaseMask | Button1MotionMask | Button2MotionMask |
Button3MotionMask;
}
menu = (menu_t *) MALLOC(sizeof(menu_t));
MEMSET(menu, 0, sizeof(menu_t));
@ -599,7 +600,7 @@ menu_is_child(menu_t *menu, menu_t *submenu)
for (i = 0; i < menu->numitems; i++) {
item = menu->items[i];
if (item->type == MENUITEM_SUBMENU && item->action.submenu != NULL) {
if (item->type == MENUITEM_SUBMENU && item->action.submenu) {
if (item->action.submenu == submenu) {
return 1;
} else if (menu_is_child(item->action.submenu, submenu)) {
@ -686,8 +687,8 @@ menuitem_change_current(menuitem_t *item)
menuitem_deselect(current_menu);
/* If we're changing from one submenu to another and neither is a child of the other, or if we're changing from a submenu to
no current item at all, reset the tree for the current submenu */
if (current->type == MENUITEM_SUBMENU && current->action.submenu != NULL) {
if ((item && item->type == MENUITEM_SUBMENU && item->action.submenu != NULL
if (current->type == MENUITEM_SUBMENU && current->action.submenu) {
if ((item && item->type == MENUITEM_SUBMENU && item->action.submenu
&& !menu_is_child(current->action.submenu, item->action.submenu)
&& !menu_is_child(item->action.submenu, current->action.submenu))
|| (!item)) {
@ -839,7 +840,7 @@ menu_reset_all(menulist_t *list)
return;
D_MENU(("menu_reset_all(%8p) called\n", list));
if (current_menu && menuitem_get_current(current_menu) != NULL) {
if (current_menu && menuitem_get_current(current_menu)) {
menuitem_deselect(current_menu);
}
for (i = 0; i < list->nummenus; i++) {
@ -862,7 +863,7 @@ menu_reset_tree(menu_t *menu)
}
for (i = 0; i < menu->numitems; i++) {
item = menu->items[i];
if (item->type == MENUITEM_SUBMENU && item->action.submenu != NULL) {
if (item->type == MENUITEM_SUBMENU && item->action.submenu) {
menu_reset_tree(item->action.submenu);
}
}
@ -880,7 +881,7 @@ menu_reset_submenus(menu_t *menu)
D_MENU(("menu_reset_submenus(menu %8p \"%s\"), window 0x%08x\n", menu, menu->title, menu->win));
for (i = 0; i < menu->numitems; i++) {
item = menu->items[i];
if (item->type == MENUITEM_SUBMENU && item->action.submenu != NULL) {
if (item->type == MENUITEM_SUBMENU && item->action.submenu) {
menu_reset_tree(item->action.submenu);
}
}
@ -1239,7 +1240,7 @@ menu_action(menuitem_t *item)
menu_dialog(NULL, item->action.alert, 0, NULL, NULL);
break;
default:
fatal_error("Internal Program Error: Unknown menuitem type: %u\n", item->type);
libast_fatal_error("Internal Program Error: Unknown menuitem type: %u\n", item->type);
break;
}
}
@ -1344,11 +1345,11 @@ menu_dialog(void *xd, char *prompt, int maxlen, char **retstr, int (*inp_tab) (v
inp_tab = NULL;
maxlen = 0;
retstr = NULL;
if ((b = STRDUP("Press \"Return\" to continue...")) == NULL) {
if (!(b = STRDUP("Press \"Return\" to continue..."))) {
return ret;
}
} else {
if (((b = MALLOC(maxlen + 1)) == NULL)) {
if ((!(b = MALLOC(maxlen + 1)))) {
return ret;
} else if (*retstr) {
strncpy(b, *retstr, maxlen);

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 1997-2004, Michael Jennings
* Copyright (C) 1997-2009, 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
@ -59,38 +59,38 @@
typedef struct menu_t_struct menu_t;
typedef struct {
simage_t *icon;
unsigned char type, state;
union {
menu_t *submenu;
char *string;
char *script;
char *alert;
} action;
char *text, *rtext;
unsigned short len, rlen;
unsigned short x, y, w, h;
simage_t *icon;
unsigned char type, state;
union {
menu_t *submenu;
char *string;
char *script;
char *alert;
} action;
char *text, *rtext;
unsigned short len, rlen;
unsigned short x, y, w, h;
} menuitem_t;
struct menu_t_struct {
char *title;
Window win, swin;
Pixmap bg;
unsigned short x, y, w, h;
GC gc;
unsigned char state;
XFontStruct *font;
char *title;
Window win, swin;
Pixmap bg;
unsigned short x, y, w, h;
GC gc;
unsigned char state;
XFontStruct *font;
#ifdef MULTI_CHARSET
XFontSet fontset;
XFontSet fontset;
#endif
unsigned short fwidth, fheight;
unsigned short numitems, curitem;
menuitem_t **items;
unsigned short fwidth, fheight;
unsigned short numitems, curitem;
menuitem_t **items;
};
typedef struct {
unsigned char nummenus;
menu_t **menus;
unsigned char nummenus;
menu_t **menus;
} menulist_t;
/************ Variables ************/

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 1997-2004, Michael Jennings
* Copyright (C) 1997-2009, 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
@ -75,12 +75,12 @@ char *
str_trim(char *str)
{
register char *tmp = str;
register spif_charptr_t tmp = (spif_charptr_t) str;
size_t n;
if (str && *str) {
chomp(str);
spiftool_chomp(str);
n = strlen(str);
if (!n) {
@ -216,7 +216,7 @@ parse_escaped_string(char *str)
#if DEBUG >= DEBUG_STRINGS
if (DEBUG_LEVEL >= DEBUG_STRINGS) {
D_STRINGS(("New value is:\n"));
hex_dump(str, (size_t) (pnew - str));
spiftool_hex_dump(str, (size_t) (pnew - str));
}
#endif
@ -234,7 +234,7 @@ escape_string(spif_charptr_t str, spif_char_t quote, spif_int32_t maxlen)
}
/* The escaped string will be at most twice the length of the original. */
buff = SPIF_CAST(charptr) MALLOC(strlen(SPIF_CAST_PTR(char) str) * 2 + 1);
buff = (spif_charptr_t) MALLOC(strlen((char *) str) * 2 + 1);
/* Copy and escape the string from str into buff. */
for (pbuff = buff; (*s); s++, pbuff++) {
@ -285,7 +285,7 @@ safe_print_string(const char *str, unsigned long len)
rb_size = 0;
return ((char *) NULL);
}
if (ret_buff == NULL) {
if (!ret_buff) {
rb_size = len;
ret_buff = (char *) MALLOC(rb_size + 1);
} else if (len > rb_size) {
@ -316,7 +316,7 @@ add_carriage_returns(unsigned char *buff, unsigned long cnt)
register unsigned char *out, *outp, *in;
register unsigned long i;
D_CMD(("buff == %8p \"%s\", cnt == %lu\n", buff, safe_print_string(buff, cnt), cnt));
D_CMD(("buff == %8p \"%s\", cnt == %lu\n", buff, safe_print_string((spif_charptr_t) buff, cnt), cnt));
outp = out = (unsigned char *) MALLOC(cnt * 2);
for (i = 0, in = buff; i < cnt; i++) {
if (*in == '\n') {
@ -327,14 +327,14 @@ add_carriage_returns(unsigned char *buff, unsigned long cnt)
i = (unsigned long) (out - outp);
memcpy(buff, outp, i);
FREE(outp);
D_CMD(("buff == %8p \"%s\", i == %lu\n", buff, safe_print_string(buff, i), i));
D_CMD(("buff == %8p \"%s\", i == %lu\n", buff, safe_print_string((spif_charptr_t) buff, i), i));
return i;
}
unsigned char
mkdirhier(const char *path)
{
char *str, *pstr;
spif_charptr_t str, pstr;
struct stat dst;
D_CMD(("path == %s\n", path));

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 1997-2004, Michael Jennings
* Copyright (C) 1997-2009, 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

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 1997-2004, Michael Jennings
* Copyright (C) 1997-2009, 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

View File

@ -1,127 +0,0 @@
/*----------------------------------------------------------------------*
* support for resolving the actual IP number of the host for remote
* DISPLAYs. When the display is local (i.e. :0), we add support for
* sending the first non-loopback interface IP number as the DISPLAY
* instead of just sending the incorrect ":0". This way telnet/rlogin
* shells can actually get the correct information into DISPLAY for
* xclients.
*
* Copyright 1996 Chuck Blake <cblake@BBN.COM>
*
+ * Cleaned up somewhat by mj olesen <olesen@me.queensu.ca>
+ *
* You can do what you like with this source code as long as you don't try
* to make money out of it and you include an unaltered copy of this
* message (including the copyright).
*
* As usual, the author accepts no responsibility for anything, nor does
* he guarantee anything whatsoever.
*----------------------------------------------------------------------*/
static const char cvs_ident[] = "$Id$";
#include "config.h"
#include "feature.h"
#ifdef DISPLAY_IS_IP
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <errno.h>
#ifdef HAVE_FCNTL_H
# include <fcntl.h>
#endif
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#include <sys/types.h>
#include <sys/socket.h>
#ifdef HAVE_SYS_SOCKIO_H
# include <sys/sockio.h>
#endif
#ifdef HAVE_SYS_BYTEORDER_H
# include <sys/byteorder.h>
#endif
#ifdef TIME_WITH_SYS_TIME
# include <sys/time.h>
# include <time.h>
#else
# ifdef HAVE_SYS_TIME_H
# include <sys/time.h>
# else
# include <time.h>
# endif
#endif
#ifdef HAVE_SYS_IOCTL_H
# include <sys/ioctl.h>
#endif
#include <netinet/in.h>
#include <arpa/inet.h>
#include <net/if.h>
#include <net/if_arp.h>
#include "startup.h"
/* return a pointer to a static buffer */
char *
network_display(const char *display)
{
static char ipaddress[32] = "";
char buffer[1024], *rval = NULL;
struct ifconf ifc;
struct ifreq *ifr;
int i, skfd;
if (display[0] != ':' && strncmp(display, "unix:", 5))
return display; /* nothing to do */
ifc.ifc_len = sizeof(buffer); /* Get names of all ifaces */
ifc.ifc_buf = buffer;
if ((skfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
perror("socket");
return NULL;
}
if (ioctl(skfd, SIOCGIFCONF, &ifc) < 0) {
perror("SIOCGIFCONF");
close(skfd);
return NULL;
}
for (i = 0, ifr = ifc.ifc_req; i < (ifc.ifc_len / sizeof(struct ifreq)); i++, ifr++) {
struct ifreq ifr2;
snprintf(ifr2.ifr_name, sizeof(ifr2.ifr_name), ifr->ifr_name);
if (ioctl(skfd, SIOCGIFADDR, &ifr2) >= 0) {
unsigned long addr;
struct sockaddr_in *p_addr;
p_addr = (struct sockaddr_in *) &(ifr2.ifr_addr);
addr = htonl((unsigned long) p_addr->sin_addr.s_addr);
/*
* not "0.0.0.0" or "127.0.0.1" - so format the address
*/
if (addr && addr != 0x7F000001) {
char *colon = strchr(display, ':');
if (colon == NULL)
colon = ":0.0";
sprintf(ipaddress, "%d.%d.%d.%d%s", (int) ((addr >> 030) & 0xFF), (int) ((addr >> 020) & 0xFF),
(int) ((addr >> 010) & 0xFF), (int) (addr & 0xFF), colon);
rval = ipaddress;
break;
}
}
}
close(skfd);
return rval;
}
#endif /* DISPLAY_IS_IP */
/*----------------------- end-of-file (C source) -----------------------*/

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 1997-2004, Michael Jennings
* Copyright (C) 1997-2009, 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
@ -42,6 +42,7 @@
# define VT_OPTIONS_BOLD_BRIGHTENS_FOREGROUND (1LU << 11)
# define VT_OPTIONS_BLINK_BRIGHTENS_BACKGROUND (1LU << 12)
# define VT_OPTIONS_COLORS_SUPPRESS_BOLD (1LU << 13)
# define VT_OPTIONS_URG_ALERT (1LU << 14)
# define ETERM_OPTIONS_LOGIN_SHELL (1LU << 0)
# define ETERM_OPTIONS_ICONIC (1LU << 1)
@ -61,6 +62,7 @@
# define ETERM_OPTIONS_DOUBLE_BUFFER (1LU << 15)
# define ETERM_OPTIONS_MBYTE_CURSOR (1LU << 16)
# define ETERM_OPTIONS_RESIZE_GRAVITY (1LU << 17)
# define ETERM_OPTIONS_STICKY (1LU << 18)
# define IMAGE_OPTIONS_TRANS (1U << 0)
# define IMAGE_OPTIONS_ITRANS (1U << 1)
@ -81,7 +83,7 @@
} while (0)
#define CHECK_VALID_INDEX(i) (((i) >= image_bg) && ((i) < image_max))
#define RESET_AND_ASSIGN(var, val) do {if ((var) != NULL) FREE(var); (var) = (val);} while (0)
#define RESET_AND_ASSIGN(var, val) do {if ((var)) FREE(var); (var) = (val);} while (0)
#define BITFIELD_SET(var, field) ((var) |= (field))
#define BITFIELD_CLEAR(var, field) ((var) &= ~(field))
@ -152,7 +154,7 @@ extern KeySym ks_smallfont;
/************ Function Prototypes ************/
_XFUNCPROTOBEGIN
extern char *conf_parse_theme(char **theme, char *conf_name, unsigned char fallback);
extern char *spifconf_parse_theme(char **theme, char *spifconf_name, unsigned char fallback);
extern void init_libast(void);
extern void init_defaults(void);
extern void post_parse(void);

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 1997-2004, Michael Jennings
* Copyright (C) 1997-2009, 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
@ -263,7 +263,7 @@ set_pixmap_scale(const char *geom, pixmap_t *pmap)
char *p, *opstr;
int n;
if (geom == NULL)
if (!geom)
return 0;
D_PIXMAP(("scale_pixmap(\"%s\")\n", geom));
@ -272,13 +272,13 @@ set_pixmap_scale(const char *geom, pixmap_t *pmap)
xterm_seq(ESCSEQ_XTERM_TITLE, str);
return 0;
}
if ((opstr = strchr(geom, ':')) != NULL) {
if ((opstr = strchr(geom, ':'))) {
*opstr++ = '\0';
op = parse_pixmap_ops(opstr);
} else {
op = pmap->op;
}
if ((p = strchr(geom, ';')) == NULL)
if (!(p = strchr(geom, ';')))
p = strchr(geom, '\0');
n = (p - geom);
if (n > GEOM_LEN - 1)
@ -625,7 +625,7 @@ check_image_ipc(unsigned char reset)
snprintf(buff, sizeof(buff), "imageclass %s query", iclass);
reply = enl_send_and_wait(buff);
if (strstr(reply, "not")) {
print_error("ImageClass \"%s\" is not defined in Enlightenment. Disallowing \"auto\" mode for this image.\n", iclass);
libast_print_error("ImageClass \"%s\" is not defined in Enlightenment. Disallowing \"auto\" mode for this image.\n", iclass);
image_mode_fallback(i);
} else if (strstr(reply, "Error")) {
/* *INDENT-OFF* */
@ -642,7 +642,7 @@ check_image_ipc(unsigned char reset)
}
);
/* *INDENT-ON* */
print_error("Looks like this version of Enlightenment doesn't support the IPC "
libast_print_error("Looks like this version of Enlightenment doesn't support the IPC "
"commands I need. Disallowing \"auto\" mode for all images.\n");
FREE(reply);
checked = 2;
@ -686,23 +686,17 @@ create_trans_pixmap(simage_t *simg, unsigned char which, Drawable d, int x, int
D_PIXMAP(("Created p [0x%08x] as a %hux%hu pixmap at %d, %d relative to window 0x%08x\n", p, width, height, x, y,
desktop_window));
if (p != None) {
if (pw < scr->width || ph < scr->height) {
D_PIXMAP(("Tiling %ux%u desktop pixmap 0x%08x onto p.\n", pw, ph, desktop_pixmap));
XSetTile(Xdisplay, gc, desktop_pixmap);
XSetTSOrigin(Xdisplay, gc, pw - (x % pw), ph - (y % ph));
XSetFillStyle(Xdisplay, gc, FillTiled);
XFillRectangle(Xdisplay, p, gc, 0, 0, width, height);
} else {
D_PIXMAP(("Copying %hux%hu rectangle at %d, %d from %ux%u desktop pixmap 0x%08x onto p.\n", width, height, x, y, pw, ph,
desktop_pixmap));
XCopyArea(Xdisplay, desktop_pixmap, p, gc, x, y, width, height, 0, 0);
}
D_PIXMAP(("Tiling %ux%u desktop pixmap 0x%08x onto p.\n", pw, ph, desktop_pixmap));
XSetTile(Xdisplay, gc, desktop_pixmap);
XSetTSOrigin(Xdisplay, gc, pw - (x % pw), ph - (y % ph));
XSetFillStyle(Xdisplay, gc, FillTiled);
XFillRectangle(Xdisplay, p, gc, 0, 0, width, height);
if ((which != image_bg || (BITFIELD_IS_SET(image_options, IMAGE_OPTIONS_ITRANS))
|| images[image_bg].current != images[image_bg].norm)
&& need_colormod(simg->iml)) {
colormod_trans(p, simg->iml, gc, width, height);
}
if (simg->iml->bevel != NULL) {
if (simg->iml->bevel) {
D_PIXMAP(("Beveling pixmap 0x%08x with edges %d, %d, %d, %d\n", p, simg->iml->bevel->edges->left,
simg->iml->bevel->edges->top, simg->iml->bevel->edges->right, simg->iml->bevel->edges->bottom));
bevel_pixmap(p, width, height, simg->iml->bevel->edges, simg->iml->bevel->up);
@ -759,7 +753,7 @@ create_viewport_pixmap(simage_t *simg, Drawable d, int x, int y, unsigned short
imlib_render_pixmaps_for_whole_image(&viewport_pixmap, &mask);
}
if (viewport_pixmap == None) {
print_error("Delayed image load failure for \"%s\". Using solid color mode.\n", imlib_image_get_filename());
libast_print_error("Delayed image load failure for \"%s\". Using solid color mode.\n", imlib_image_get_filename());
image_set_mode(image_bg, MODE_SOLID);
reset_simage(simg, RESET_ALL_SIMG);
return None;
@ -834,13 +828,13 @@ paste_simage(simage_t *simg, unsigned char which, Window win, Drawable d, unsign
snprintf(buff, sizeof(buff), "imageclass %s apply_copy 0x%x %s %hd %hd", iclass, (int) d, state, w, h);
reply = enl_send_and_wait(buff);
if (strstr(reply, "Error")) {
print_error
libast_print_error
("Enlightenment didn't seem to like something about my syntax. Disallowing \"auto\" mode for this image.\n");
image_mode_fallback(which);
FREE(reply);
} else {
pmap = (Pixmap) strtoul(reply, (char **) NULL, 0);
mask = (Pixmap) strtoul(get_pword(2, reply), (char **) NULL, 0);
mask = (Pixmap) strtoul(spiftool_get_pword(2, reply), (char **) NULL, 0);
FREE(reply);
enl_ipc_sync();
if (pmap) {
@ -853,7 +847,7 @@ paste_simage(simage_t *simg, unsigned char which, Window win, Drawable d, unsign
LIBAST_X_FREE_GC(gc);
return;
} else {
print_error
libast_print_error
("Enlightenment returned a null pixmap, which I can't use. Disallowing \"auto\" mode for this image.\n");
FREE(reply);
image_mode_fallback(which);
@ -878,7 +872,7 @@ paste_simage(simage_t *simg, unsigned char which, Window win, Drawable d, unsign
gc = LIBAST_X_CREATE_GC(0, NULL);
p = create_viewport_pixmap(simg, win, x, y, w, h);
if (simg->iml->bevel != NULL) {
if (simg->iml->bevel) {
bevel_pixmap(p, w, h, simg->iml->bevel->edges, simg->iml->bevel->up);
}
XCopyArea(Xdisplay, p, d, gc, 0, 0, w, h, x, y);
@ -888,7 +882,7 @@ paste_simage(simage_t *simg, unsigned char which, Window win, Drawable d, unsign
}
if (((which == image_max) || (image_mode_is(which, MODE_IMAGE) && image_mode_is(which, ALLOW_IMAGE)))
&& (simg->iml != NULL)) {
&& (simg->iml)) {
imlib_context_set_image(simg->iml->im);
imlib_context_set_drawable(d);
imlib_context_set_anti_alias(1);
@ -906,7 +900,7 @@ paste_simage(simage_t *simg, unsigned char which, Window win, Drawable d, unsign
imlib_render_pixmaps_for_whole_image_at_size(&pmap, &mask, w, h);
}
if (pmap == None) {
print_error("Delayed image load failure for \"%s\".\n", NONULL(imlib_image_get_filename()));
libast_print_error("Delayed image load failure for \"%s\".\n", NONULL(imlib_image_get_filename()));
reset_simage(simg, RESET_ALL_SIMG);
return;
}
@ -1064,7 +1058,7 @@ render_simage(simage_t *simg, Window win, unsigned short width, unsigned short h
height);
reply = enl_send_and_wait(buff);
if (strstr(reply, "Error")) {
print_error
libast_print_error
("Enlightenment didn't seem to like something about my syntax. Disallowing \"auto\" mode for this image.\n");
image_mode_fallback(which);
FREE(reply);
@ -1072,7 +1066,7 @@ render_simage(simage_t *simg, Window win, unsigned short width, unsigned short h
Pixmap pmap, mask;
pmap = (Pixmap) strtoul(reply, (char **) NULL, 0);
mask = (Pixmap) strtoul(get_pword(2, reply), (char **) NULL, 0);
mask = (Pixmap) strtoul(spiftool_get_pword(2, reply), (char **) NULL, 0);
FREE(reply);
enl_ipc_sync();
if (pmap) {
@ -1094,7 +1088,7 @@ render_simage(simage_t *simg, Window win, unsigned short width, unsigned short h
snprintf(buff, sizeof(buff), "imageclass %s free_pixmap 0x%08x", iclass, (int) pmap);
enl_ipc_send(buff);
} else {
print_error
libast_print_error
("Enlightenment returned a null pixmap, which I can't use. Disallowing \"auto\" mode for this image.\n");
FREE(reply);
image_mode_fallback(which);
@ -1251,12 +1245,13 @@ render_simage(simage_t *simg, Window win, unsigned short width, unsigned short h
} else if (renderop & RENDER_FORCE_PIXMAP) {
pixmap = simg->pmap->pixmap;
simg->pmap->pixmap = LIBAST_X_CREATE_PIXMAP(width, height);
D_PIXMAP(("Replacing pixmap 0x%08x with new pixmap 0x%08x.\n", pixmap, simg->pmap->pixmap));
XCopyArea(Xdisplay, pixmap, simg->pmap->pixmap, gc, 0, 0, width, height, 0, 0);
IMLIB_FREE_PIXMAP(pixmap);
} else {
shaped_window_apply_mask(win, simg->pmap->mask);
}
if (simg->iml->bevel != NULL) {
if (simg->iml->bevel) {
bevel_pixmap(simg->pmap->pixmap, width, height, simg->iml->bevel->edges, simg->iml->bevel->up);
}
D_PIXMAP(("Setting background of window 0x%08x to 0x%08x\n", win, simg->pmap->pixmap));
@ -1273,7 +1268,7 @@ render_simage(simage_t *simg, Window win, unsigned short width, unsigned short h
}
}
} else {
print_error("Delayed image load failure for \"%s\". Using solid color mode.\n", imlib_image_get_filename());
libast_print_error("Delayed image load failure for \"%s\". Using solid color mode.\n", imlib_image_get_filename());
image_set_mode(which, MODE_SOLID);
reset_simage(simg, RESET_ALL_SIMG);
}
@ -1290,14 +1285,14 @@ render_simage(simage_t *simg, Window win, unsigned short width, unsigned short h
copy_buffer_pixmap(MODE_SOLID, (unsigned long) PixColors[bgColor], width, height);
XSetWindowBackgroundPixmap(Xdisplay, win, buffer_pixmap);
} else {
if ((renderop & RENDER_FORCE_PIXMAP) || (simg->iml->bevel != NULL)) {
if ((renderop & RENDER_FORCE_PIXMAP) || (simg->iml->bevel)) {
if (simg->pmap->pixmap != None) {
LIBAST_X_FREE_PIXMAP(simg->pmap->pixmap);
}
simg->pmap->pixmap = LIBAST_X_CREATE_PIXMAP(width, height);
XSetForeground(Xdisplay, gc, ((which == image_bg) ? (PixColors[bgColor]) : (simg->bg)));
XFillRectangle(Xdisplay, simg->pmap->pixmap, gc, 0, 0, width, height);
if (simg->iml->bevel != NULL && simg->iml->bevel->edges != NULL) {
if (simg->iml->bevel && simg->iml->bevel->edges) {
DRAW_SOLID_BEVEL(simg->pmap->pixmap, width, height, simg->bg, simg->iml->bevel->up,
simg->iml->bevel->edges->left);
}
@ -1350,7 +1345,7 @@ search_path(const char *pathlist, const char *file)
D_OPTIONS(("Unable to access %s -- %s\n", name, strerror(errno)));
}
if ((p = strchr(file, '@')) == NULL)
if (!(p = strchr(file, '@')))
p = strchr(file, '\0');
len = (p - file);
/* leave room for an extra '/' and trailing '\0' */
@ -1375,11 +1370,11 @@ search_path(const char *pathlist, const char *file)
} else {
D_OPTIONS(("Unable to access %s -- %s\n", name, strerror(errno)));
}
for (path = pathlist; path != NULL && *path != '\0'; path = p) {
for (path = pathlist; path && *path != '\0'; path = p) {
int n;
/* colon delimited */
if ((p = strchr(path, ':')) == NULL)
if (!(p = strchr(path, ':')))
p = strchr(path, '\0');
n = (p - path);
if (*p != '\0')
@ -1438,21 +1433,21 @@ load_image(const char *file, simage_t *simg)
ASSERT_RVAL(simg != NULL, 0);
D_PIXMAP(("load_image(%s, %8p)\n", file, simg));
if (*file != '\0') {
if ((geom = strchr(file, '@')) != NULL) {
if ((geom = strchr(file, '@'))) {
*geom++ = 0;
} else if ((geom = strchr(file, ';')) != NULL) {
} else if ((geom = strchr(file, ';'))) {
*geom++ = 0;
}
if (geom != NULL) {
if (geom) {
set_pixmap_scale(geom, simg->pmap);
}
if ((f = search_path(rs_path, file)) == NULL) {
if (!(f = search_path(rs_path, file))) {
f = search_path(getenv(PATH_ENV), file);
}
if (f != NULL) {
if (f) {
im = imlib_load_image_with_error_return(f, &im_err);
if (im == NULL) {
print_error("Unable to load image file \"%s\" -- %s\n", file, imlib_strerror(im_err));
if (!im) {
libast_print_error("Unable to load image file \"%s\" -- %s\n", file, imlib_strerror(im_err));
return 0;
} else {
reset_simage(simg, (RESET_IMLIB_IM | RESET_PMAP_PIXMAP | RESET_PMAP_MASK));
@ -1461,7 +1456,7 @@ load_image(const char *file, simage_t *simg)
D_PIXMAP(("Found image %8p.\n", im));
return 1;
} else {
print_error("Unable to locate file \"%s\" in image path.\n");
libast_print_error("Unable to locate file \"%s\" in image path.\n");
}
}
reset_simage(simg, RESET_ALL_SIMG);
@ -1587,13 +1582,13 @@ shade_ximage_15(void *data, int bpl, int w, int h, int rm, int gm, int bm)
int r, g, b;
b = ((DATA16 *) ptr)[x];
r = (((b >> 10) & 0x001f ) * rm) >> 8;
r = (((b >> 10) & 0x001f) * rm) >> 8;
r = (r > 0x001f) ? 0x7c00 : (r << 10);
g = (((b >> 5) & 0x001f ) * gm) >> 8;
g = (((b >> 5) & 0x001f) * gm) >> 8;
g = (g > 0x001f) ? 0x03e0 : (g << 5);
b = (((b >> 0) & 0x001f ) * bm) >> 8;
b = (((b >> 0) & 0x001f) * bm) >> 8;
b = (b > 0x001f) ? 0x001f : (b << 0);
((DATA16 *) ptr)[x] = (r|g|b);
((DATA16 *) ptr)[x] = (r | g | b);
}
ptr += bpl;
}
@ -1631,12 +1626,12 @@ shade_ximage_16(void *data, int bpl, int w, int h, int rm, int gm, int bm)
b = ((DATA16 *) ptr)[x];
r = (((b >> 11) & 0x001f) * rm) >> 8;
r = (r > 0x001f) ? 0xf800 : (r << 11);
g = (((b >> 5) & 0x003f) * gm) >> 8;
g = (g > 0x003f) ? 0x07e0 : (g << 5);
b = (((b >> 0) & 0x001f) * bm) >> 8;
b = (b > 0x001f) ? 0x001f : (b << 0);
((DATA16 *) ptr)[x] = (r|g|b);
r = (r > 0x001f) ? 0xf800 : (r << 11);
g = (((b >> 5) & 0x003f) * gm) >> 8;
g = (g > 0x003f) ? 0x07e0 : (g << 5);
b = (((b >> 0) & 0x001f) * bm) >> 8;
b = (b > 0x001f) ? 0x001f : (b << 0);
((DATA16 *) ptr)[x] = (r | g | b);
}
ptr += bpl;
}
@ -1671,20 +1666,21 @@ shade_ximage_32(void *data, int bpl, int w, int h, int rm, int gm, int bm)
for (y = h; --y >= 0;) {
for (x = -(w * 4); x < 0; x += 4) {
int r, g, b;
# if WORDS_BIGENDIAN
r = (ptr[x + 1] * rm) >> 8;
ptr[x + 1] = r|(!(r >> 8) - 1);
ptr[x + 1] = r | (!(r >> 8) - 1);
g = (ptr[x + 2] * gm) >> 8;
ptr[x + 2] = g|(!(g >> 8) - 1);
ptr[x + 2] = g | (!(g >> 8) - 1);
b = (ptr[x + 3] * bm) >> 8;
ptr[x + 3] = b|(!(b >> 8) - 1);
ptr[x + 3] = b | (!(b >> 8) - 1);
# else
r = (ptr[x + 2] * rm) >> 8;
ptr[x + 2] = r|(!(r >> 8) - 1);
ptr[x + 2] = r | (!(r >> 8) - 1);
g = (ptr[x + 1] * gm) >> 8;
ptr[x + 1] = g|(!(g >> 8) - 1);
ptr[x + 1] = g | (!(g >> 8) - 1);
b = (ptr[x + 0] * bm) >> 8;
ptr[x + 0] = b|(!(b >> 8) - 1);
ptr[x + 0] = b | (!(b >> 8) - 1);
# endif
}
ptr += bpl;
@ -1724,18 +1720,18 @@ shade_ximage_24(void *data, int bpl, int w, int h, int rm, int gm, int bm)
# if WORDS_BIGENDIAN
r = (ptr[x + 0] * rm) >> 8;
ptr[x + 0] = r|(!(r >> 8) - 1);
ptr[x + 0] = r | (!(r >> 8) - 1);
g = (ptr[x + 1] * gm) >> 8;
ptr[x + 1] = g|(!(g >> 8) - 1);
ptr[x + 1] = g | (!(g >> 8) - 1);
b = (ptr[x + 2] * bm) >> 8;
ptr[x + 2] = b|(!(b >> 8) - 1);
ptr[x + 2] = b | (!(b >> 8) - 1);
# else
r = (ptr[x + 2] * rm) >> 8;
ptr[x + 2] = r|(!(r >> 8) - 1);
ptr[x + 2] = r | (!(r >> 8) - 1);
g = (ptr[x + 1] * gm) >> 8;
ptr[x + 1] = g|(!(g >> 8) - 1);
ptr[x + 1] = g | (!(g >> 8) - 1);
b = (ptr[x + 0] * bm) >> 8;
ptr[x + 0] = b|(!(b >> 8) - 1);
ptr[x + 0] = b | (!(b >> 8) - 1);
# endif
}
ptr += bpl;
@ -1747,14 +1743,7 @@ shade_ximage_24(void *data, int bpl, int w, int h, int rm, int gm, int bm)
void
colormod_trans(Pixmap p, imlib_t *iml, GC gc, unsigned short w, unsigned short h)
{
#ifdef HAVE_SSE2
XImage * __attribute__ ((aligned (16))) ximg;
#elif defined HAVE_MMX
XImage * __attribute__ ((aligned (8))) ximg;
#else
XImage *ximg;
#endif
register unsigned long i;
#if 0
@ -1822,8 +1811,8 @@ colormod_trans(Pixmap p, imlib_t *iml, GC gc, unsigned short w, unsigned short h
real_depth = Xdepth;
}
ximg = XGetImage(Xdisplay, p, 0, 0, w, h, -1, ZPixmap);
if (ximg == NULL) {
print_warning("XGetImage(Xdisplay, 0x%08x, 0, 0, %d, %d, -1, ZPixmap) returned NULL.\n", p, w, h);
if (!ximg) {
libast_print_warning("XGetImage(Xdisplay, 0x%08x, 0, 0, %d, %d, -1, ZPixmap) returned NULL.\n", p, w, h);
return;
}
D_PIXMAP(("XGetImage(Xdisplay, 0x%08x, 0, 0, %d, %d, -1, ZPixmap) returned %8p.\n", p, w, h, ximg));
@ -1886,6 +1875,7 @@ colormod_trans(Pixmap p, imlib_t *iml, GC gc, unsigned short w, unsigned short h
if (ximg->bits_per_pixel != 32) {
D_PIXMAP(("Rendering 24 bit\n"));
shade_ximage_24(ximg->data, ximg->bytes_per_line, w, h, rm, gm, bm);
break;
}
/* drop */
case 32:
@ -1901,7 +1891,7 @@ colormod_trans(Pixmap p, imlib_t *iml, GC gc, unsigned short w, unsigned short h
#endif
break;
default:
print_warning("Bit depth of %d is unsupported for tinting/shading.\n", real_depth);
libast_print_warning("Bit depth of %d is unsupported for tinting/shading.\n", real_depth);
return;
}
}
@ -1926,7 +1916,7 @@ update_desktop_info(int *w, int *h)
get_desktop_window();
}
if (desktop_window == None) {
print_error("Unable to locate desktop window. If you are running Enlightenment, please\n"
libast_print_error("Unable to locate desktop window. If you are running Enlightenment, please\n"
"restart. If not, please set your background image with Esetroot, then try again.");
return 0;
}
@ -1944,7 +1934,7 @@ update_desktop_info(int *w, int *h)
XGetGeometry(Xdisplay, desktop_pixmap, &dummy, &px, &py, &pw, &ph, &pb, &pd);
}
if ((pw <= 0) || (ph <= 0)) {
print_error("Value of desktop pixmap property is invalid. Please restart your \n"
libast_print_error("Value of desktop pixmap property is invalid. Please restart your \n"
"window manager or use Esetroot to set a new one.");
desktop_pixmap = None;
return 0;
@ -2181,15 +2171,15 @@ set_icon_pixmap(char *filename, XWMHints * pwm_hints)
imlib_context_set_color_modifier(tmp_cmod);
imlib_reset_color_modifier();
if (filename && *filename) {
if ((icon_path = search_path(rs_path, filename)) == NULL)
if (!(icon_path = search_path(rs_path, filename)))
icon_path = search_path(getenv(PATH_ENV), filename);
if (icon_path != NULL) {
if (icon_path) {
XIconSize *icon_sizes;
int count, i;
temp_im = imlib_load_image_with_error_return(icon_path, &im_err);
if (temp_im == NULL) {
print_error("Unable to load icon file \"%s\" -- %s\n", icon_path, imlib_strerror(im_err));
if (!temp_im) {
libast_print_error("Unable to load icon file \"%s\" -- %s\n", icon_path, imlib_strerror(im_err));
} else {
/* If we're going to render the image anyway, might as well be nice and give it to the WM in a size it likes. */
if (XGetIconSizes(Xdisplay, Xroot, &icon_sizes, &count)) {
@ -2216,7 +2206,7 @@ set_icon_pixmap(char *filename, XWMHints * pwm_hints)
}
}
if (temp_im == NULL) {
if (!temp_im) {
w = h = 48;
temp_im = imlib_create_image_using_data(48, 48, (DATA32 *) (icon_data + 2));
imlib_context_set_image(temp_im);

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 1997-2004, Michael Jennings
* Copyright (C) 1997-2009, 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

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 1997-2004, Michael Jennings
* Copyright (C) 1997-2009, 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

View File

@ -54,7 +54,7 @@
#define NS_SCREEN_PRVS_REG "\x01:focus up\r"
#define NS_DFLT_SSH_PORT 22
#define NS_MIN_PORT 1025
#define NS_MIN_PORT 47323
#define NS_MAX_PORT 65535
#define NS_MAX_DISPS 512
@ -68,12 +68,12 @@
#define NS_SCREEN_ACT_T "Activity in window "
/* should be 1s */
#define NS_INIT_DELAY 1
#define NS_INIT_DELAY 2
/* how many seconds to wait for an SSH-tunnel to build when using the
-Z option (tunnel through firewall). 2 for very fast networks,
much more for slow connections. */
#define NS_TUNNEL_DELAY 3
#define NS_TUNNEL_DELAY 30
/* what to call the menu entry for Escreen */
#define NS_MENU_TITLE "Escreen"

View File

@ -26,9 +26,7 @@ static const char cvs_ident[] = "$Id$";
#include <errno.h>
#include <X11/Xatom.h>
#include <X11/Xmd.h> /* CARD32 */
#ifdef HAVE_X11_XMU_ATOMS_H
# include <X11/Xmu/Atoms.h>
#endif
#include <iconv.h>
#include "buttons.h"
#include "command.h"
@ -112,9 +110,10 @@ blank_line(text_t *et, rend_t *er, int width, rend_t efs)
register unsigned int i = width;
rend_t *r = er, fs = efs;
MEMSET(et, ' ', i);
for (; i--;)
for (; i--;) {
*et++ = ' ';
*r++ = fs;
}
}
/* Create a new row in the screen buffer and initialize it. */
@ -124,15 +123,18 @@ blank_screen_mem(text_t **tp, rend_t **rp, int row, rend_t efs)
{
register unsigned int i = TERM_WINDOW_GET_REPORTED_COLS();
rend_t *r, fs = efs;
text_t *et;
if (tp[row] == NULL) {
if (!tp[row]) {
tp[row] = MALLOC(sizeof(text_t) * (TERM_WINDOW_GET_REPORTED_COLS() + 1));
rp[row] = MALLOC(sizeof(rend_t) * TERM_WINDOW_GET_REPORTED_COLS());
}
MEMSET(tp[row], ' ', i);
tp[row][i] = 0;
for (r = rp[row]; i--;)
et = tp[row];
for (r = rp[row]; i--;) {
*et++ = ' ';
*r++ = fs;
}
}
void
@ -267,7 +269,7 @@ scr_reset(void)
screen.row += k;
TermWin.nscrolled -= k;
for (i = TermWin.saveLines - TermWin.nscrolled; k--; i--) {
if (screen.text[i] == NULL) {
if (!screen.text[i]) {
blank_screen_mem(screen.text, screen.rend, i, DEFAULT_RSTYLE);
}
}
@ -389,7 +391,7 @@ scr_poweron(void)
/*
* Save and Restore cursor
* XTERM_SEQ: Save cursor : ESC 7
* XTERM_SEQ: Save cursor : ESC 7
* XTERM_SEQ: Restore cursor: ESC 8
*/
void
@ -458,7 +460,7 @@ scr_change_screen(int scrn)
if (current_screen == PRIMARY) {
scroll_text(0, (TERM_WINDOW_GET_REPORTED_ROWS() - 1), TERM_WINDOW_GET_REPORTED_ROWS(), 0);
for (i = TermWin.saveLines; i < TERM_WINDOW_GET_REPORTED_ROWS() + TermWin.saveLines; i++)
if (screen.text[i] == NULL) {
if (!screen.text[i]) {
blank_screen_mem(screen.text, screen.rend, i, DEFAULT_RSTYLE);
}
}
@ -637,7 +639,7 @@ scroll_text(int row1, int row2, int count, int spec)
for (i = 0, j = row1; i < count; i++, j++) {
buf_text[i] = screen.text[j];
buf_rend[i] = screen.rend[j];
if (buf_text[i] == NULL) {
if (!buf_text[i]) {
/* A new ALLOC is done with size ncol and
blankline with size prev_ncol -- Sebastien van K */
buf_text[i] = MALLOC(sizeof(text_t) * (prev_ncol + 1));
@ -664,7 +666,7 @@ scroll_text(int row1, int row2, int count, int spec)
for (i = 0, j = row2; i < count; i++, j--) {
buf_text[i] = screen.text[j];
buf_rend[i] = screen.rend[j];
if (buf_text[i] == NULL) {
if (!buf_text[i]) {
/* A new ALLOC is done with size ncol and
blankline with size prev_ncol -- Sebastien van K */
buf_text[i] = MALLOC(sizeof(text_t) * (prev_ncol + 1));
@ -690,6 +692,43 @@ scroll_text(int row1, int row2, int count, int spec)
return count;
}
#undef FIXME_BLOCK
#define FIXME_BLOCK 1
#define UTF8_DEBUG 0
static text_t *
mb2text(const char *str, size_t *len)
{
static iconv_t ih = (iconv_t)-1;
text_t *tstr;
char *pi, *po;
size_t olen, maxolen;
//printf("mb2text(\"%s\", %d)\n", str, *len); fflush(stdout);
maxolen = *len * sizeof(text_t);
tstr = MALLOC(maxolen);
//printf("Allocated buffer of size %d\n", maxolen); fflush(stdout);
pi = (char*)str;
po = (char*)tstr;
if (ih == (iconv_t)-1)
ih = iconv_open("UCS-2", "UTF-8");
olen = maxolen;
iconv(ih, &pi, len, &po, &olen);
//printf("iconv returned output length of %d\n", olen); fflush(stdout);
olen = (maxolen - olen) / 2;
//printf("Output string length is %d\n", olen); fflush(stdout);
#if UTF8_DEBUG
int i;
printf("TO UCS2:");
for (i = 0; i < olen; i++)
printf(" %04x", tstr[i]);
printf(" UCS2 len=%d\n\n", olen); fflush(stdout);
#endif
*len = olen;
return tstr;
}
/*
* Add text given in <str> of length <len> to screen struct
*/
@ -697,17 +736,19 @@ void
scr_add_lines(const unsigned char *str, int nlines, int len)
{
/* char c; */
register char c;
register text_t c;
/* int i, j, row, last_col; */
int last_col;
register int i, j, row;
text_t *stp;
text_t *stp, *tstr;
rend_t *srp;
row_col_t beg, end;
size_t slen;
if (len <= 0) /* sanity */
return;
slen = len;
last_col = TERM_WINDOW_GET_REPORTED_COLS();
@ -731,7 +772,7 @@ scr_add_lines(const unsigned char *str, int nlines, int len)
BOUND(screen.row, -TermWin.nscrolled, TERM_WINDOW_GET_REPORTED_ROWS() - 1);
row = screen.row + TermWin.saveLines;
if (screen.text[row] == NULL) {
if (!screen.text[row]) {
blank_screen_mem(screen.text, screen.rend, row, DEFAULT_RSTYLE);
} /* avoid segfault -- added by Sebastien van K */
beg.row = screen.row;
@ -745,8 +786,11 @@ scr_add_lines(const unsigned char *str, int nlines, int len)
chstat = WBYTE;
#endif
for (i = 0; i < len;) {
c = str[i++];
/* Convert incoming (mb) string to UCS-2 */
tstr = mb2text(str, &slen);
for (i = 0; i < slen;) {
c = tstr[i++];
#ifdef MULTI_CHARSET
if ((encoding_method != LATIN1) && (chstat == WBYTE)) {
rstyle |= RS_multiMask; /* multibyte 2nd byte */
@ -829,6 +873,9 @@ scr_add_lines(const unsigned char *str, int nlines, int len)
screen.flags &= ~Screen_WrapNext;
}
}
FREE(tstr);
LOWER_BOUND(stp[last_col], screen.col);
if (screen.col == 0) {
end.col = last_col - 1;
@ -1329,7 +1376,7 @@ scr_rvideo_mode(int mode)
maxlines = TermWin.saveLines + TERM_WINDOW_GET_REPORTED_ROWS();
for (i = TermWin.saveLines; i < maxlines; i++)
for (j = 0; j < TERM_WINDOW_GET_REPORTED_COLS() + 1; j++)
for (j = 0; j < TERM_WINDOW_GET_REPORTED_COLS(); j++)
screen.rend[i][j] ^= RS_RVid;
scr_refresh(SLOW_REFRESH);
}
@ -1543,7 +1590,7 @@ scr_page(int direction, int nlines)
D_SCREEN(("scr_page(%s, %d) view_start:%d\n", ((direction == UP) ? "UP" : "DN"), nlines, TermWin.view_start));
start = TermWin.view_start;
BOUND(nlines, 1, TERM_WINDOW_GET_REPORTED_ROWS());
BOUND(nlines, 1, TermWin.nscrolled);
TermWin.view_start += ((direction == UP) ? nlines : (-nlines));
BOUND(TermWin.view_start, 0, TermWin.nscrolled);
return (TermWin.view_start - start);
@ -1552,6 +1599,14 @@ scr_page(int direction, int nlines)
void
scr_bell(void)
{
XWMHints *wm_hints;
if (BITFIELD_IS_SET(vt_options, VT_OPTIONS_URG_ALERT)) {
wm_hints = XGetWMHints(Xdisplay, TermWin.parent);
wm_hints->flags |= XUrgencyHint;
XSetWMHints(Xdisplay, TermWin.parent, wm_hints);
XFree(wm_hints);
}
#ifndef NO_MAPALERT
#ifdef MAPALERT_OPTION
if (BITFIELD_IS_SET(vt_options, VT_OPTIONS_MAP_ALERT))
@ -1562,7 +1617,7 @@ scr_bell(void)
scr_rvideo_mode(!rvideo);
scr_rvideo_mode(!rvideo);
} else if (!SPIF_PTR_ISNULL(rs_beep_command) && (*rs_beep_command)) {
system_no_wait(SPIF_CAST_C(char *)rs_beep_command);
system_no_wait((char *) rs_beep_command);
} else {
XBell(Xdisplay, 0);
}
@ -1576,7 +1631,7 @@ scr_printscreen(int fullhist)
text_t *t;
FILE *fd;
if ((fd = popen_printer()) == NULL)
if (!(fd = popen_printer()))
return;
nrows = TERM_WINDOW_GET_REPORTED_ROWS();
if (fullhist) {
@ -1621,6 +1676,50 @@ scr_multi2(void)
}
#endif /* MULTI_CHARSET */
static int
scr_draw_string(Display *dpy, Drawable draw, GC gc, int x, int y, text_t *str, int len)
{
unsigned short buf[2048];
int i;
if (len > 2048)
len = 2048;
#if UTF8_DEBUG
for (i = 0; i < len; i++)
{
buf[i] = (str[i] >> 8) | (str[i] << 8);
printf(" %04x", buf[i]);
}
printf("\n");
#else
for (i = 0; i < len; i++)
buf[i] = (str[i] >> 8) | (str[i] << 8);
#endif
XDrawString16(dpy, draw, gc, x, y, (XChar2b*)buf, len);
}
static int
scr_draw_image_string(Display *dpy, Drawable draw, GC gc, int x, int y, text_t *str, int len)
{
unsigned short buf[2048];
int i;
if (len > 2048)
len = 2048;
#if UTF8_DEBUG
for (i = 0; i < len; i++)
{
buf[i] = (str[i] >> 8) | (str[i] << 8);
printf(" %04x", buf[i]);
}
printf("\n");
#else
for (i = 0; i < len; i++)
buf[i] = (str[i] >> 8) | (str[i] << 8);
#endif
XDrawImageString16(dpy, draw, gc, x, y, (XChar2b*)buf, len);
}
/*
* Refresh the screen
* drawn_text/drawn_rend contain the screen information before the update.
@ -1653,8 +1752,8 @@ scr_refresh(int type)
rend_t *drp, *srp; /* drawn-rend-pointer, screen-rend-pointer */
text_t *dtp, *stp; /* drawn-text-pointer, screen-text-pointer */
XGCValues gcvalue; /* Graphics Context values */
char buf[MAX_COLS + 1];
register char *buffer = buf;
text_t buf[MAX_COLS + 1];
register text_t *buffer = buf;
Pixmap pmap = images[image_bg].current->pmap->pixmap;
int (*draw_string) (), (*draw_image_string) ();
register int low_x = 99999, low_y = 99999, high_x = 0, high_y = 0;
@ -1701,8 +1800,8 @@ scr_refresh(int type)
XSetFont(Xdisplay, TermWin.gc, TermWin.font->fid);
#if FIXME_BLOCK
draw_string = XmbDrawString;
draw_image_string = XmbDrawImageString;
draw_string = scr_draw_string;
draw_image_string = scr_draw_image_string;
#else
draw_string = XDrawString;
draw_image_string = XDrawImageString;
@ -1792,8 +1891,8 @@ scr_refresh(int type)
wbyte = 1;
XSetFont(Xdisplay, TermWin.gc, TermWin.mfont->fid);
# if FIXME_BLOCK
draw_string = XmbDrawString;
draw_image_string = XmbDrawImageString;
draw_string = scr_draw_string;
draw_image_string = scr_draw_image_string;
# else
draw_string = XDrawString16;
draw_image_string = XDrawImageString16;
@ -1835,8 +1934,8 @@ scr_refresh(int type)
wbyte = 0;
XSetFont(Xdisplay, TermWin.gc, TermWin.font->fid);
# if FIXME_BLOCK
draw_string = XmbDrawString;
draw_image_string = XmbDrawImageString;
draw_string = scr_draw_string;
draw_image_string = scr_draw_image_string;
# else
draw_string = XDrawString;
draw_image_string = XDrawImageString;
@ -1940,7 +2039,7 @@ scr_refresh(int type)
XChangeGC(Xdisplay, TermWin.gc, gcmask, &gcvalue);
}
#ifndef NO_BOLDFONT
if (!wbyte && MONO_BOLD(rend) && TermWin.boldFont != NULL) {
if (!wbyte && MONO_BOLD(rend) && TermWin.boldFont) {
XSetFont(Xdisplay, TermWin.gc, TermWin.boldFont->fid);
bfont = 1;
} else if (bfont) {
@ -2006,11 +2105,11 @@ scr_refresh(int type)
ww = Width2Pixel(wlen);
hh = Height2Pixel(1);
CLEAR_CHARS(xpixel, ypixel - ascent, len);
if (fshadow.shadow[SHADOW_TOP_LEFT] || fshadow.shadow[SHADOW_TOP_RIGHT]) {
if (fshadow.shadow[SHADOW_TOP_LEFT] || fshadow.shadow[SHADOW_TOP] || fshadow.shadow[SHADOW_TOP_RIGHT]) {
yy--;
hh++;
}
if (fshadow.shadow[SHADOW_BOTTOM_LEFT] || fshadow.shadow[SHADOW_BOTTOM_RIGHT]) {
if (fshadow.shadow[SHADOW_BOTTOM_LEFT] || fshadow.shadow[SHADOW_BOTTOM] || fshadow.shadow[SHADOW_BOTTOM_RIGHT]) {
hh++;
if (row < nrows - 1) {
int ii;
@ -2027,6 +2126,13 @@ scr_refresh(int type)
dtp[col - 1] = 0;
}
}
if (fshadow.shadow[SHADOW_TOP]) {
XSetForeground(Xdisplay, TermWin.gc, fshadow.color[SHADOW_TOP]);
DRAW_STRING(draw_string, xpixel, ypixel - 1, buffer, wlen);
if (col) {
dtp[col] = 0;
}
}
if (fshadow.shadow[SHADOW_TOP_RIGHT]) {
XSetForeground(Xdisplay, TermWin.gc, fshadow.color[SHADOW_TOP_RIGHT]);
DRAW_STRING(draw_string, xpixel + 1, ypixel - 1, buffer, wlen);
@ -2034,6 +2140,20 @@ scr_refresh(int type)
dtp[col + 1] = 0;
}
}
if (fshadow.shadow[SHADOW_LEFT]) {
XSetForeground(Xdisplay, TermWin.gc, fshadow.color[SHADOW_LEFT]);
DRAW_STRING(draw_string, xpixel - 1, ypixel, buffer, wlen);
if (col) {
dtp[col - 1] = 0;
}
}
if (fshadow.shadow[SHADOW_RIGHT]) {
XSetForeground(Xdisplay, TermWin.gc, fshadow.color[SHADOW_RIGHT]);
DRAW_STRING(draw_string, xpixel + 1, ypixel, buffer, wlen);
if (col < ncols - 1) {
dtp[col + 1] = 0;
}
}
if (fshadow.shadow[SHADOW_BOTTOM_LEFT]) {
XSetForeground(Xdisplay, TermWin.gc, fshadow.color[SHADOW_BOTTOM_LEFT]);
DRAW_STRING(draw_string, xpixel - 1, ypixel + 1, buffer, wlen);
@ -2041,6 +2161,13 @@ scr_refresh(int type)
dtp[col - 1] = 0;
}
}
if (fshadow.shadow[SHADOW_BOTTOM]) {
XSetForeground(Xdisplay, TermWin.gc, fshadow.color[SHADOW_BOTTOM]);
DRAW_STRING(draw_string, xpixel, ypixel + 1, buffer, wlen);
if (col) {
dtp[col] = 0;
}
}
if (fshadow.shadow[SHADOW_BOTTOM_RIGHT]) {
XSetForeground(Xdisplay, TermWin.gc, fshadow.color[SHADOW_BOTTOM_RIGHT]);
DRAW_STRING(draw_string, xpixel + 1, ypixel + 1, buffer, wlen);
@ -2155,37 +2282,37 @@ scr_refresh(int type)
D_SCREEN(("Update box dimensions: from (%d, %d) to (%d, %d). Dimensions %dx%d\n", low_x, low_y, high_x, high_y,
high_x - low_x + 1, high_y - low_y + 1));
XClearArea(Xdisplay, TermWin.vt, low_x, low_y, high_x - low_x + 1, high_y - low_y + 1, False);
if (fshadow.shadow[SHADOW_TOP_LEFT] || fshadow.shadow[SHADOW_BOTTOM_LEFT]) {
if (fshadow.shadow[SHADOW_TOP_LEFT] || fshadow.shadow[SHADOW_LEFT] || fshadow.shadow[SHADOW_BOTTOM_LEFT]) {
XCopyArea(Xdisplay, pmap, buffer_pixmap, TermWin.gc, TermWin.internalBorder - 1, 0, 1, TermWin_TotalHeight() - 1,
TermWin.internalBorder - 1, 0);
XClearArea(Xdisplay, TermWin.vt, TermWin.internalBorder - 1, 0, 1, TermWin_TotalHeight() - 1, False);
}
if (fshadow.shadow[SHADOW_TOP_RIGHT] || fshadow.shadow[SHADOW_BOTTOM_RIGHT] || boldlast) {
if (fshadow.shadow[SHADOW_TOP_RIGHT] || fshadow.shadow[SHADOW_RIGHT] || fshadow.shadow[SHADOW_BOTTOM_RIGHT] || boldlast) {
XCopyArea(Xdisplay, pmap, buffer_pixmap, TermWin.gc, TermWin_TotalWidth() - 2, 0, 1, TermWin_TotalHeight() - 1,
TermWin_TotalWidth() - 2, 0);
XClearArea(Xdisplay, TermWin.vt, TermWin_TotalWidth() - 2, 0, 1, TermWin_TotalHeight() - 1, False);
}
if (fshadow.shadow[SHADOW_TOP_LEFT] || fshadow.shadow[SHADOW_TOP_RIGHT]) {
if (fshadow.shadow[SHADOW_TOP_LEFT] || fshadow.shadow[SHADOW_TOP] || fshadow.shadow[SHADOW_TOP_RIGHT]) {
XCopyArea(Xdisplay, pmap, buffer_pixmap, TermWin.gc, 0, TermWin.internalBorder - 1, TermWin_TotalWidth() - 1, 1, 0,
TermWin.internalBorder - 1);
XClearArea(Xdisplay, TermWin.vt, 0, TermWin.internalBorder - 1, TermWin_TotalWidth() - 1, 1, False);
}
if (fshadow.shadow[SHADOW_BOTTOM_LEFT] || fshadow.shadow[SHADOW_BOTTOM_RIGHT]) {
if (fshadow.shadow[SHADOW_BOTTOM_LEFT] || fshadow.shadow[SHADOW_BOTTOM] || fshadow.shadow[SHADOW_BOTTOM_RIGHT]) {
XCopyArea(Xdisplay, pmap, buffer_pixmap, TermWin.gc, 0, TermWin_TotalHeight() - TermWin.internalBorder,
TermWin_TotalWidth() - 1, 1, 0, TermWin_TotalHeight() - TermWin.internalBorder);
XClearArea(Xdisplay, TermWin.vt, 0, TermWin_TotalHeight() - TermWin.internalBorder, TermWin_TotalWidth() - 1, 1, False);
}
} else {
if (fshadow.shadow[SHADOW_TOP_LEFT] || fshadow.shadow[SHADOW_BOTTOM_LEFT]) {
if (fshadow.shadow[SHADOW_TOP_LEFT] || fshadow.shadow[SHADOW_LEFT] || fshadow.shadow[SHADOW_BOTTOM_LEFT]) {
XClearArea(Xdisplay, TermWin.vt, TermWin.internalBorder - 1, 0, 1, TermWin_TotalHeight() - 1, False);
}
if ((fshadow.shadow[SHADOW_TOP_RIGHT] || fshadow.shadow[SHADOW_BOTTOM_RIGHT] || boldlast) && TermWin.internalBorder) {
if ((fshadow.shadow[SHADOW_TOP_RIGHT] || fshadow.shadow[SHADOW_RIGHT] || fshadow.shadow[SHADOW_BOTTOM_RIGHT] || boldlast) && TermWin.internalBorder) {
XClearArea(Xdisplay, TermWin.vt, TermWin_TotalWidth() - 2, 0, 1, TermWin_TotalHeight() - 1, False);
}
if (fshadow.shadow[SHADOW_TOP_LEFT] || fshadow.shadow[SHADOW_TOP_RIGHT]) {
if (fshadow.shadow[SHADOW_TOP_LEFT] || fshadow.shadow[SHADOW_TOP] || fshadow.shadow[SHADOW_TOP_RIGHT]) {
XClearArea(Xdisplay, TermWin.vt, 0, TermWin.internalBorder - 1, TermWin_TotalWidth() - 1, 1, False);
}
if (fshadow.shadow[SHADOW_BOTTOM_LEFT] || fshadow.shadow[SHADOW_BOTTOM_RIGHT]) {
if (fshadow.shadow[SHADOW_BOTTOM_LEFT] || fshadow.shadow[SHADOW_BOTTOM] || fshadow.shadow[SHADOW_BOTTOM_RIGHT]) {
XClearArea(Xdisplay, TermWin.vt, 0, TermWin_TotalHeight() - TermWin.internalBorder, TermWin_TotalWidth() - 1, 1, False);
}
}
@ -2217,14 +2344,14 @@ scr_strmatch(unsigned long row, unsigned long col, const char *str)
void
scr_search_scrollback(char *str)
{
unsigned char *c;
text_t *c;
char *s;
static char *last_str = NULL;
unsigned int *i;
unsigned long row, lrow, col, rows, cols, len, k;
if (str == NULL) {
if ((str = last_str) == NULL) {
if (!str) {
if (!(str = last_str)) {
return;
}
} else {
@ -2465,16 +2592,16 @@ selection_fetch(Window win, unsigned prop, int delete)
if ((XGetWindowProperty
(Xdisplay, win, prop, (nread / 4), PROP_SIZE, delete, AnyPropertyType, &actual_type, &actual_fmt, &nitems,
&bytes_after, &data) != Success)
|| (actual_type == None) || (data == NULL)) {
|| (actual_type == None) || (!data)) {
D_SELECT(("Unable to fetch the value of property %d from window 0x%08x\n", (int) prop, (int) win));
if (data != NULL) {
if (data) {
XFree(data);
}
return;
}
nread += nitems;
D_SELECT(("Got selection info: Actual type %d (format %d), %lu items at 0x%08x, %lu bytes left over.\n", (int) actual_type,
actual_fmt, nitems, data, bytes_after));
D_SELECT(("Got selection info: Actual type %d (format %d), %lu items at 0x%08x, %lu bytes left over.\n",
(int) actual_type, actual_fmt, nitems, data, bytes_after));
if (nitems == 0) {
D_SELECT(("Retrieval of incremental selection complete.\n"));
@ -2523,15 +2650,17 @@ selection_fetch(Window win, unsigned prop, int delete)
void
selection_copy_string(Atom sel, char *str, size_t len)
{
if (str == NULL || len == 0) {
D_SELECT(("Copying %ul bytes from 0x%08x to selection %d\n", len, str, (int) sel));
if (!str || len == 0) {
return;
}
if (IS_SELECTION(sel)) {
D_SELECT(("Copying selection to selection %d\n", (int) sel));
D_SELECT(("Changing ownership of selection %d to my window 0x%08x\n", (int) sel, (int) TermWin.vt));
XSetSelectionOwner(Xdisplay, sel, TermWin.vt, CurrentTime);
if (XGetSelectionOwner(Xdisplay, sel) != TermWin.vt) {
print_error("Can't take ownership of selection\n");
libast_print_error("Can't take ownership of selection\n");
}
XFlush(Xdisplay);
} else {
D_SELECT(("Copying selection to cut buffer %d\n", (int) sel));
XChangeProperty(Xdisplay, Xroot, sel, XA_STRING, 8, PropModeReplace, str, len);
@ -2549,30 +2678,25 @@ selection_copy(Atom sel)
void
selection_paste(Atom sel)
{
if (selection.text != NULL) {
D_SELECT(("Attempting to paste selection %d.\n", (int) sel));
if (selection.text) {
/* If we have a selection of our own, paste it. */
D_SELECT(("Pasting my current selection of length %lu\n", selection.len));
selection_write(selection.text, selection.len);
} else if (IS_SELECTION(sel)) {
if (XGetSelectionOwner(Xdisplay, sel) == None) {
/* If nobody owns the current selection, just try to paste it ourselves. */
D_SELECT(("Current selection %d unowned. Attempting to paste the default cut buffer.\n", (int) sel));
selection_fetch(Xroot, XA_CUT_BUFFER0, False);
/* Request the current selection be converted to the appropriate
form (usually XA_STRING) and save it for us in the VT_SELECTION
property. We'll then get a SelectionNotify. */
D_SELECT(("Requesting current selection (%d) -> VT_SELECTION (%d)\n", sel, props[PROP_SELECTION_DEST]));
#if defined(MULTI_CHARSET)
if (encoding_method != LATIN1) {
XConvertSelection(Xdisplay, sel, props[PROP_COMPOUND_TEXT], props[PROP_SELECTION_DEST], TermWin.vt, CurrentTime);
} else {
/* If someone owns the current selection, send a request to that client to
convert the selection to the appropriate form (usually XA_STRING) and
save it for us in the VT_SELECTION property. We'll then get a SelectionNotify. */
D_SELECT(("Requesting current selection (%d) -> VT_SELECTION (%d)\n", sel, props[PROP_SELECTION_DEST]));
#if defined(MULTI_CHARSET) && defined(HAVE_X11_XMU_ATOMS_H)
if (encoding_method != LATIN1) {
XConvertSelection(Xdisplay, sel, XA_COMPOUND_TEXT(Xdisplay), props[PROP_SELECTION_DEST], TermWin.vt, CurrentTime);
} else {
XConvertSelection(Xdisplay, sel, XA_STRING, props[PROP_SELECTION_DEST], TermWin.vt, CurrentTime);
}
#else
XConvertSelection(Xdisplay, sel, XA_STRING, props[PROP_SELECTION_DEST], TermWin.vt, CurrentTime);
#endif
}
#else
XConvertSelection(Xdisplay, sel, XA_STRING, props[PROP_SELECTION_DEST], TermWin.vt, CurrentTime);
#endif
} else {
D_SELECT(("Pasting cut buffer %d.\n", (int) sel));
selection_fetch(Xroot, sel, False);
@ -2700,7 +2824,7 @@ selection_start_colrow(int col, int row)
selection.mark.row = row;
}
/*
/*
* Copy a selection into the cut buffer
* EXT: button 1 or 3 release
*/
@ -2828,9 +2952,9 @@ selection_click(int clicks, int x, int y)
/* what do we want: spaces/tabs are delimiters or cutchars or non-cutchars */
#ifdef CUTCHAR_OPTION
# define DELIMIT_TEXT(x) (strchr((rs_cutchars?rs_cutchars:CUTCHARS), (x)) != NULL)
# define DELIMIT_TEXT(x) (strchr((rs_cutchars ? rs_cutchars : CUTCHARS), (x)))
#else
# define DELIMIT_TEXT(x) (strchr(CUTCHARS, (x)) != NULL)
# define DELIMIT_TEXT(x) (strchr(CUTCHARS, (x)))
#endif
#ifdef MULTI_CHARSET
#define DELIMIT_REND(x) (((x) & RS_multiMask) ? 1 : 0)
@ -3238,7 +3362,7 @@ selection_extend_colrow(int col, int row, int flag, int cont)
D_SELECT(("(c:%d,r:%d)-(c:%d,r:%d) old (c:%d,r:%d)-(c:%d,r:%d)\n", selection.beg.col, selection.beg.row,
selection.end.col, selection.end.row, old_beg.col, old_beg.row, old_end.col, old_end.row));
/*
/*
* B1: clear anything before the current selection
*/
if ((old_beg.row < selection.beg.row) || (old_beg.row == selection.beg.row && old_beg.col < selection.beg.col)) {
@ -3251,7 +3375,7 @@ selection_extend_colrow(int col, int row, int flag, int cont)
}
selection_setclr(0, old_beg.row, old_beg.col, row, col);
}
/*
/*
* B2: clear anything after the current selection
*/
if ((old_end.row > selection.end.row) || (old_end.row == selection.end.row && old_end.col > selection.end.col)) {
@ -3264,7 +3388,7 @@ selection_extend_colrow(int col, int row, int flag, int cont)
}
selection_setclr(0, row, col, old_end.row, old_end.col);
}
/*
/*
* B3: set everything
*/
/* TODO: optimise this */
@ -3287,13 +3411,6 @@ selection_rotate(int x, int y)
selection_extend_colrow(col, row, 1, 0);
}
/*
* On some systems, the Atom typedef is 64 bits wide. We need to have a type
* that is exactly 32 bits wide, because a format of 64 is not allowed by
* the X11 protocol.
*/
typedef CARD32 Atom32;
/*
* Respond to a request for our current selection
* EXT: SelectionRequest
@ -3302,7 +3419,7 @@ void
selection_send(XSelectionRequestEvent * rq)
{
XEvent ev;
Atom32 target_list[2];
long target_list[2];
ev.xselection.type = SelectionNotify;
ev.xselection.property = None;
@ -3313,14 +3430,31 @@ selection_send(XSelectionRequestEvent * rq)
ev.xselection.time = rq->time;
if (rq->target == props[PROP_SELECTION_TARGETS]) {
target_list[0] = (Atom32) props[PROP_SELECTION_TARGETS];
target_list[1] = (Atom32) XA_STRING;
target_list[0] = props[PROP_SELECTION_TARGETS];
target_list[1] = XA_STRING;
XChangeProperty(Xdisplay, rq->requestor, rq->property, rq->target,
(8 * sizeof(target_list[0])), PropModeReplace, (unsigned char *) target_list,
32, PropModeReplace, (unsigned char *) target_list,
(sizeof(target_list) / sizeof(target_list[0])));
ev.xselection.property = rq->property;
#if defined(MULTI_CHARSET) && defined(HAVE_X11_XMU_ATOMS_H)
} else if (rq->target == XA_TEXT(Xdisplay) || rq->target == XA_COMPOUND_TEXT(Xdisplay)) {
#ifdef MULTI_CHARSET
# ifdef X_HAVE_UTF8_STRING
} else if (rq->target == props[PROP_UTF8_STRING]) {
XTextProperty xtextp;
char *l[1];
*l = selection.text;
xtextp.value = NULL;
xtextp.nitems = 0;
if (XmbTextListToTextProperty(Xdisplay, l, 1, XUTF8StringStyle, &xtextp) == Success) {
if (xtextp.nitems > 0 && xtextp.value) {
XChangeProperty(Xdisplay, rq->requestor, rq->property,
rq->target, 8, PropModeReplace, xtextp.value, xtextp.nitems);
ev.xselection.property = rq->property;
XFree(xtextp.value);
}
}
# endif /* X_HAVE_UTF8_STRING */
} else if (rq->target == props[PROP_TEXT] || rq->target == props[PROP_COMPOUND_TEXT]) {
XTextProperty xtextp;
char *l[1];
@ -3328,15 +3462,16 @@ selection_send(XSelectionRequestEvent * rq)
xtextp.value = NULL;
xtextp.nitems = 0;
if (XmbTextListToTextProperty(Xdisplay, l, 1, XCompoundTextStyle, &xtextp) == Success) {
if (xtextp.nitems > 0 && xtextp.value != NULL) {
XChangeProperty(Xdisplay, rq->requestor, rq->property, XA_COMPOUND_TEXT(Xdisplay), 8, PropModeReplace, xtextp.value,
xtextp.nitems);
if (xtextp.nitems > 0 && xtextp.value) {
XChangeProperty(Xdisplay, rq->requestor, rq->property, props[PROP_COMPOUND_TEXT],
8, PropModeReplace, xtextp.value, xtextp.nitems);
ev.xselection.property = rq->property;
XFree(xtextp.value);
}
}
#endif
} else if (rq->target == XA_STRING) {
XChangeProperty(Xdisplay, rq->requestor, rq->property, rq->target, 8, PropModeReplace, selection.text, selection.len);
#endif /* MULTI_CHARSET */
} else {
XChangeProperty(Xdisplay, rq->requestor, rq->property, XA_STRING, 8, PropModeReplace, selection.text, selection.len);
ev.xselection.property = rq->property;
}
XSendEvent(Xdisplay, rq->requestor, False, 0, &ev);

View File

@ -16,16 +16,12 @@
#include <X11/Xfuncproto.h>
#include "startup.h"
#ifndef XA_CLIPBOARD
# define XA_CLIPBOARD(d) XA_PRIMARY
#endif
/************ Macros and Definitions ************/
#define WRAP_CHAR (0xff)
#define PROP_SIZE 4096
#define TABSIZE 8 /* default tab size */
#define IS_SELECTION(a) (((a) == XA_PRIMARY) || ((a) == XA_SECONDARY) || ((a) == XA_CLIPBOARD(Xdisplay)))
#define IS_SELECTION(a) (((a) == XA_PRIMARY) || ((a) == XA_SECONDARY) || ((a) == props[PROP_CLIPBOARD]))
#define IS_CUT_BUFFER(a) (((a) >= XA_CUT_BUFFER0) && ((a) <= XA_CUT_BUFFER7))
#define ZERO_SCROLLBACK do { \
@ -159,7 +155,7 @@ enum {
many lines back into the scrollback buffer the currently-visible data
is. (0 means we're at the bottom and not in scrollback.)
*/
typedef unsigned char text_t;
typedef unsigned short text_t;
typedef unsigned int rend_t;
typedef enum {
SELECTION_CLEAR = 0,

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 1997-2004, Michael Jennings
* Copyright (C) 1997-2009, 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
@ -103,13 +103,13 @@ eterm_handle_winop(char *action)
int x, y, n;
char *xx, *yy;
n = num_words(action);
n = spiftool_num_words(action);
if (n == 3 || n == 4) {
if (n == 3) {
win = TermWin.parent;
}
xx = get_pword(n - 1, action);
yy = get_pword(n, action);
xx = spiftool_get_pword(n - 1, action);
yy = spiftool_get_pword(n, action);
x = (int) strtol(xx, (char **) NULL, 0);
y = (int) strtol(yy, (char **) NULL, 0);
XMoveWindow(Xdisplay, win, x, y);
@ -118,13 +118,13 @@ eterm_handle_winop(char *action)
int w, h, n;
char *ww, *hh;
n = num_words(action);
n = spiftool_num_words(action);
if (n == 3 || n == 4) {
if (n == 3) {
win = TermWin.parent;
}
ww = get_pword(n - 1, action);
hh = get_pword(n, action);
ww = spiftool_get_pword(n - 1, action);
hh = spiftool_get_pword(n, action);
w = (int) strtol(ww, (char **) NULL, 0);
h = (int) strtol(hh, (char **) NULL, 0);
XResizeWindow(Xdisplay, win, w, h);
@ -134,7 +134,7 @@ eterm_handle_winop(char *action)
} else if (!BEG_STRCASECMP(action, "iconify")) {
XIconifyWindow(Xdisplay, win, Xscreen);
} else {
print_error("IPC Error: Unrecognized window operation \"%s\"\n", action);
libast_print_error("IPC Error: Unrecognized window operation \"%s\"\n", action);
}
}
#endif
@ -153,25 +153,25 @@ eterm_handle_winop(char *action)
* the "primary" buffer (XA_PRIMARY in Xlib-speak).
*/
void
script_handler_copy(char **params)
script_handler_copy(spif_charptr_t *params)
{
unsigned char i;
char *buffer_id;
Atom sel = XA_PRIMARY;
if (params) {
for (i = 0; (buffer_id = params[i]) != NULL; i++) {
for (i = 0; (buffer_id = params[i]); i++) {
if (*buffer_id) {
if (*buffer_id >= '0' && *buffer_id <= '7') {
sel = (Atom) ((int) XA_CUT_BUFFER0 + (int) (*buffer_id - '0'));
} else if (!BEG_STRCASECMP(buffer_id, "clipboard")) {
sel = XA_CLIPBOARD(Xdisplay);
sel = props[PROP_CLIPBOARD];
} else if (!BEG_STRCASECMP(buffer_id, "primary")) {
sel = XA_PRIMARY;
} else if (!BEG_STRCASECMP(buffer_id, "secondary")) {
sel = XA_SECONDARY;
} else {
print_error("Invalid parameter to copy(): \"%s\"\n", buffer_id);
libast_print_error("Invalid parameter to copy(): \"%s\"\n", buffer_id);
}
}
}
@ -186,9 +186,9 @@ script_handler_copy(char **params)
* <string> is the string of characters to send to the pty.
*/
void
script_handler_echo(char **params)
script_handler_echo(spif_charptr_t *params)
{
char **tmp;
spif_charptr_t *tmp;
for (tmp = params; tmp && *tmp; tmp++) {
tt_write(*tmp, strlen(*tmp));
@ -205,7 +205,7 @@ script_handler_echo(char **params)
* and no message.
*/
void
script_handler_exit(char **params)
script_handler_exit(spif_charptr_t *params)
{
unsigned char code = 0;
char *tmp;
@ -214,7 +214,7 @@ script_handler_exit(char **params)
if (isdigit(params[0][0]) || (params[0][0] == '-' && isdigit(params[0][1]))) {
code = (unsigned char) atoi(params[0]);
} else {
tmp = join(" ", params);
tmp = spiftool_join(" ", params);
printf("Exiting: %s\n", tmp);
FREE(tmp);
}
@ -230,7 +230,7 @@ script_handler_exit(char **params)
* specified, SIGTERM is the default.
*/
void
script_handler_kill(char **params)
script_handler_kill(spif_charptr_t *params)
{
int sig;
@ -254,25 +254,25 @@ script_handler_kill(char **params)
* the "primary" buffer (XA_PRIMARY in Xlib-speak).
*/
void
script_handler_paste(char **params)
script_handler_paste(spif_charptr_t *params)
{
unsigned char i;
char *buffer_id;
Atom sel = XA_PRIMARY;
if (params) {
for (i = 0; (buffer_id = params[i]) != NULL; i++) {
for (i = 0; (buffer_id = params[i]); i++) {
if (*buffer_id) {
if (*buffer_id >= '0' && *buffer_id <= '7') {
sel = (Atom) ((int) XA_CUT_BUFFER0 + (int) (*buffer_id - '0'));
} else if (!BEG_STRCASECMP(buffer_id, "clipboard")) {
sel = XA_CLIPBOARD(Xdisplay);
sel = props[PROP_CLIPBOARD];
} else if (!BEG_STRCASECMP(buffer_id, "primary")) {
sel = XA_PRIMARY;
} else if (!BEG_STRCASECMP(buffer_id, "secondary")) {
sel = XA_SECONDARY;
} else {
print_error("Invalid parameter to paste(): \"%s\"\n", buffer_id);
libast_print_error("Invalid parameter to paste(): \"%s\"\n", buffer_id);
}
}
}
@ -291,7 +291,7 @@ script_handler_paste(char **params)
* will be theme.cfg.
*/
void
script_handler_save(char **params)
script_handler_save(spif_charptr_t *params)
{
if (params && *params) {
if (!strcasecmp(params[0], "theme")) {
@ -312,7 +312,7 @@ script_handler_save(char **params)
* the specified file.
*/
void
script_handler_save_buff(char **params)
script_handler_save_buff(spif_charptr_t *params)
{
if (params && *params) {
scr_dump_to_file(params[0]);
@ -334,7 +334,7 @@ script_handler_save_buff(char **params)
* and the type may be passed as a second parameter if you wish.
*/
void
script_handler_scroll(char **params)
script_handler_scroll(spif_charptr_t *params)
{
char *type;
double cnt_float;
@ -361,7 +361,7 @@ script_handler_scroll(char **params)
} else if (str_leading_match("buffers", type)) {
count = (long) (cnt_float * (TermWin.nrow + TermWin.saveLines));
} else {
print_error("Invalid modifier \"%s\" in scroll()\n", type);
libast_print_error("Invalid modifier \"%s\" in scroll()\n", type);
return;
}
} else {
@ -384,12 +384,12 @@ script_handler_scroll(char **params)
* search() will clear the previously-highlighted search term.
*/
void
script_handler_search(char **params)
script_handler_search(spif_charptr_t *params)
{
static char *search = NULL;
if (params && *params) {
if (search != NULL) {
if (search) {
FREE(search);
}
search = STRDUP(*params);
@ -406,12 +406,12 @@ script_handler_search(char **params)
* If no command is specified, the default is to execute another Eterm.
*/
void
script_handler_spawn(char **params)
script_handler_spawn(spif_charptr_t *params)
{
char *tmp;
if (params && *params) {
tmp = join(" ", params);
tmp = spiftool_join(" ", params);
system_no_wait(tmp);
FREE(tmp);
} else {
@ -426,9 +426,9 @@ script_handler_spawn(char **params)
* <string> is the string of characters to send to the handler.
*/
void
script_handler_string(char **params)
script_handler_string(spif_charptr_t *params)
{
char **tmp;
spif_charptr_t *tmp;
for (tmp = params; tmp && *tmp; tmp++) {
cmd_write(*tmp, strlen(*tmp));
@ -442,13 +442,13 @@ script_handler_string(char **params)
* <command> is the command to be executed.
*/
void
script_handler_exec_dialog(char **params)
script_handler_exec_dialog(spif_charptr_t *params)
{
char *tmp;
int ret;
if (params && *params) {
tmp = join(" ", params);
tmp = spiftool_join(" ", params);
} else {
tmp = NULL;
}
@ -469,12 +469,12 @@ script_handler_exec_dialog(char **params)
* <message> is the message to present.
*/
void
script_handler_msgbox(char **params)
script_handler_msgbox(spif_charptr_t *params)
{
char *tmp;
if (params && *params) {
tmp = join(" ", params);
tmp = spiftool_join(" ", params);
scr_refresh(DEFAULT_REFRESH);
menu_dialog(NULL, tmp, 1, NULL, NULL);
FREE(tmp);
@ -500,7 +500,7 @@ script_handler_msgbox(char **params)
* scrollback - View the scrollback for a display
*/
void
script_handler_es_display(char **params)
script_handler_es_display(spif_charptr_t *params)
{
_ns_sess *sess = TermWin.screen;
char *p, *a;
@ -511,7 +511,7 @@ script_handler_es_display(char **params)
return;
}
p = downcase_str(*params);
p = spiftool_downcase_str(*params);
a = params[index++];
if (a && isdigit(*a)) {
no = atoi(a);
@ -565,7 +565,7 @@ script_handler_es_display(char **params)
D_ESCREEN(("View scrollback on display %d\n", no));
ns_sbb_disp(sess, no);
} else {
print_error("Error in script: \"display\" has no sub-function \"%s\".\n", p);
libast_print_error("Error in script: \"display\" has no sub-function \"%s\".\n", p);
}
}
@ -588,7 +588,7 @@ script_handler_es_display(char **params)
* scrollback - View the scrollback for a region
*/
void
script_handler_es_region(char **params)
script_handler_es_region(spif_charptr_t *params)
{
_ns_sess *sess = TermWin.screen;
_ns_disp *disp;
@ -606,7 +606,7 @@ script_handler_es_region(char **params)
return;
}
p = downcase_str(*params);
p = spiftool_downcase_str(*params);
a = params[index++];
if (a && isdigit(*a)) {
no = atoi(a);
@ -626,7 +626,7 @@ script_handler_es_region(char **params)
} else if (!strcmp(p, "toggle")) {
D_ESCREEN(("Toggle region of display %8p\n", disp));
ns_tog_region(sess, disp);
} else if (!strcmp(p, "new") || !strcmp(p, "split")) {
} else if (!strcmp(p, "new") || !strcmp(p, "spiftool_split")) {
if (!a || !*a || !strcasecmp(a, "ask")) {
D_ESCREEN(("region new ask\n"));
ns_add_region(sess, disp, no, NULL);
@ -660,7 +660,7 @@ script_handler_es_region(char **params)
D_ESCREEN(("View scrollback for region %d of display %8p\n", no, disp));
ns_sbb_region(sess, disp, no);
} else {
print_error("Error in script: \"region\" has no sub-function \"%s\".\n", p);
libast_print_error("Error in script: \"region\" has no sub-function \"%s\".\n", p);
}
}
@ -671,12 +671,12 @@ script_handler_es_region(char **params)
* <statement> is the Escreen (screen) statement to execute.
*/
void
script_handler_es_statement(char **params)
script_handler_es_statement(spif_charptr_t *params)
{
char *tmp;
if (params && *params) {
tmp = join(" ", params);
tmp = spiftool_join(" ", params);
ns_statement(TermWin.screen, tmp);
FREE(tmp);
} else {
@ -689,7 +689,7 @@ script_handler_es_statement(char **params)
* Syntax: es_reset()
*/
void
script_handler_es_reset(char **params)
script_handler_es_reset(spif_charptr_t *params)
{
USE_VAR(params);
ns_reset(TermWin.screen, 0);
@ -703,7 +703,7 @@ script_handler_es_reset(char **params)
* This function can be used to cancel undesired default behavior.
*/
void
script_handler_nop(char **params)
script_handler_nop(spif_charptr_t *params)
{
USE_VAR(params);
}
@ -728,7 +728,7 @@ eterm_script_handler_t *script_find_handler(const char *name)
void
script_parse(char *s)
{
char **token_list, **param_list;
spif_charptr_t *token_list, *param_list;
register char *pstr;
register unsigned long i;
char *func_name, *params, *tmp;
@ -739,59 +739,59 @@ script_parse(char *s)
D_SCRIPT(("Parsing: \"%s\"\n", s));
token_list = split(";", s);
if (token_list == NULL) {
token_list = spiftool_split(";", s);
if (!token_list) {
D_SCRIPT(("No tokens found; ignoring script.\n"));
return;
}
for (i = 0; token_list[i]; i++) {
pstr = token_list[i];
chomp(pstr);
spiftool_chomp(pstr);
if (!(*pstr)) {
continue;
}
if ((params = strchr(pstr, '(')) != NULL) {
if ((params = strchr(pstr, '('))) {
if (params != pstr) {
len = params - pstr;
func_name = (char *) MALLOC(len + 1);
strncpy(func_name, pstr, len);
func_name[len] = 0;
} else {
print_error("Error in script \"%s\": Missing function name before \"%s\".\n", s, params);
free_array((void **) token_list, 0);
libast_print_error("Error in script \"%s\": Missing function name before \"%s\".\n", s, params);
spiftool_free_array((void **) token_list, 0);
return;
}
} else {
func_name = STRDUP(pstr);
}
if (!func_name) {
free_array((void **) token_list, 0);
spiftool_free_array((void **) token_list, 0);
return;
}
if (params) {
params++;
if ((tmp = strrchr(params, ')')) != NULL) {
if ((tmp = strrchr(params, ')'))) {
*tmp = 0;
} else {
print_error("Error in script \"%s\": Missing closing parentheses for \"%s\".\n", s, token_list[i]);
free_array((void **) token_list, 0);
libast_print_error("Error in script \"%s\": Missing closing parentheses for \"%s\".\n", s, token_list[i]);
spiftool_free_array((void **) token_list, 0);
return;
}
param_list = split(", \t", params);
param_list = spiftool_split(", \t", params);
} else {
param_list = NULL;
}
D_SCRIPT(("Calling function %s with parameters: %s\n", func_name, NONULL(params)));
if ((func = script_find_handler(func_name)) != NULL) {
if ((func = script_find_handler(func_name))) {
(func->handler) (param_list);
} else {
print_error("Error in script \"%s\": No such function \"%s\".\n", s, func_name);
libast_print_error("Error in script \"%s\": No such function \"%s\".\n", s, func_name);
}
}
if (params) {
free_array((void **) param_list, 0);
spiftool_free_array((void **) param_list, 0);
}
free_array((void **) token_list, 0);
spiftool_free_array((void **) token_list, 0);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 1997-2004, Michael Jennings
* Copyright (C) 1997-2009, 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
@ -31,7 +31,7 @@
/************ Macros and Definitions ************/
/************ Structures ************/
typedef void (*eterm_script_handler_function_t)(char **);
typedef void (*eterm_script_handler_function_t)(spif_charptr_t *);
typedef struct {
char *name;
eterm_script_handler_function_t handler;
@ -43,26 +43,26 @@ typedef struct {
_XFUNCPROTOBEGIN
/* Handlers */
extern void script_handler_copy(char **);
extern void script_handler_echo(char **);
extern void script_handler_exec_dialog(char **);
extern void script_handler_exit(char **);
extern void script_handler_kill(char **);
extern void script_handler_msgbox(char **);
extern void script_handler_paste(char **);
extern void script_handler_save(char **);
extern void script_handler_save_buff(char **);
extern void script_handler_scroll(char **);
extern void script_handler_search(char **);
extern void script_handler_spawn(char **);
extern void script_handler_string(char **);
extern void script_handler_nop(char **);
extern void script_handler_copy(spif_charptr_t *);
extern void script_handler_echo(spif_charptr_t *);
extern void script_handler_exec_dialog(spif_charptr_t *);
extern void script_handler_exit(spif_charptr_t *);
extern void script_handler_kill(spif_charptr_t *);
extern void script_handler_msgbox(spif_charptr_t *);
extern void script_handler_paste(spif_charptr_t *);
extern void script_handler_save(spif_charptr_t *);
extern void script_handler_save_buff(spif_charptr_t *);
extern void script_handler_scroll(spif_charptr_t *);
extern void script_handler_search(spif_charptr_t *);
extern void script_handler_spawn(spif_charptr_t *);
extern void script_handler_string(spif_charptr_t *);
extern void script_handler_nop(spif_charptr_t *);
#ifdef ESCREEN
extern void script_handler_es_display(char **);
extern void script_handler_es_region(char **);
extern void script_handler_es_statement(char **);
extern void script_handler_es_reset(char **);
extern void script_handler_es_display(spif_charptr_t *);
extern void script_handler_es_region(spif_charptr_t *);
extern void script_handler_es_statement(spif_charptr_t *);
extern void script_handler_es_reset(spif_charptr_t *);
#endif
/* Engine */

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 1997-2004, Michael Jennings
* Copyright (C) 1997-2009, 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
@ -357,7 +357,7 @@ sb_handle_motion_notify(event_t *ev)
unsigned char
scrollbar_dispatch_event(event_t *ev)
{
if (scrollbar_event_data.handlers[ev->type] != NULL) {
if (scrollbar_event_data.handlers[ev->type]) {
return ((scrollbar_event_data.handlers[ev->type]) (ev));
}
return (0);
@ -698,8 +698,9 @@ scrollbar_init(int width, int height)
Attributes.override_redirect = TRUE;
Attributes.save_under = TRUE;
cursor = XCreateFontCursor(Xdisplay, XC_left_ptr);
mask = KeyPressMask | ExposureMask | EnterWindowMask | LeaveWindowMask | ButtonPressMask | ButtonReleaseMask
| Button1MotionMask | Button2MotionMask | Button3MotionMask;
mask =
ExposureMask | EnterWindowMask | LeaveWindowMask | ButtonPressMask | ButtonReleaseMask | Button1MotionMask |
Button2MotionMask | Button3MotionMask;
scrollbar_calc_size(width, height);
scrollbar.anchor_top = scrollbar.scrollarea_start;
scrollbar.anchor_bottom = scrollbar.scrollarea_end;
@ -923,7 +924,7 @@ scrollbar_drawing_init(void)
#ifdef XTERM_SCROLLBAR
gcvalue.stipple = XCreateBitmapFromData(Xdisplay, scrollbar.win, (char *) xterm_sb_bits, 12, 2);
if (!gcvalue.stipple) {
print_error("Unable to create xterm scrollbar bitmap.\n\n");
libast_print_error("Unable to create xterm scrollbar bitmap.\n\n");
if (scrollbar_get_type() == SCROLLBAR_XTERM) {
scrollbar_set_type(SCROLLBAR_MOTIF);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 1997-2004, Michael Jennings
* Copyright (C) 1997-2009, 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

View File

@ -1,12 +1,17 @@
/* File: sse2_cmod.c
* Written and Copyright (C) 2005 by Tres Melton
/*
* Copyright (C) 1997-2009, Michael Jennings
*
* Permission is hereby granted to Michael Jennings to license this code as
* he sees fit. I'd prefer the GPL but he will choose the BSD. The debate
* is moot as this is to become a part of the Eterm project, for which he is
* the primary author. For users of this code I ask that any modifications
* be released back into the community but with Michael Jennings chooses the
* BSD license then that request has no backing in law.
* 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,
@ -15,8 +20,9 @@
* 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.
*
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* Ported from <willem@stack.nl> Willem Monsuwe's original x86/MMX assembly
* code by Tres Melton in 2005 and 2006. Anything copyrightable by me is
* assigned to the Eterm project and its founder/maintainer: Michael Jennings.
*
* Much inspiration was drawn from the original x86 MMX port written by
* Willem Monsuwe <willem@stack.nl> in pure x86/MMX Assembly. The MMX
@ -25,6 +31,8 @@
* ensure they worked with various gcc options. Further the code was
* extended to take advantage of the 128 bit xmm registers in SSE2.
*
* The imlib2 code in Enlightenment also has a lot to teach on the subject.
*
* Manuals used in this port:
* The Gnu Assembler
* http://www.gnu.org/software/binutils/manual/gas-2.9.1/html_mono/as.html
@ -65,21 +73,7 @@
* assembly code in C functions is the only way to ensure that this code will continue to
* function through a (however unlikely) change. If pure assembly were to be used as the
* original MMX author, Willem Monsuwe, did and the ABI changed then this code would cease
* to function properly. After examination of Willem's code I'm wondering if he
* wrote it for GNU/Linux originally. The ENTER and LEAVE macros put all of the
* parameters on the stack so that they can be accessed by references to the Base_Pointer
* the way that ANSI C is defined. If he originally wrote this for GNU/Linux then he most
* likely would have just used the registers instead of unwinding those optimizations
* manually by pushing them to the stack. And if he explicitly wanted to use the stack
* then there are parameters to gcc that would have performed those operations for him:
* -mregparm/-mmemparm. Other gcc options that can tweak with the stack and the number
* of registers available for function parameters are: -fcall-used/-fcall-saved,
* -fcaller-saves, -fstack-protector, -fPIC/-fpic, -mno-push-args, etc.. It might be
* advisable to check for these switches when using the original MMX code and emit a
* warning if any are enabled. I know that the PIC option trashes the BX register and
* that both Willem and I use that register. In other words If you do manage to get it
* to compile & run w/ -fpic it WILL break. On the plus side, you can keep the pieces! :-)
* On the other hand I could be wrong about everything
* to function properly.
*
* In Conclusion:
* Using C functions and inline assembly code should alleviate all of the concerns as the
@ -126,8 +120,8 @@ void shade_ximage_15_sse2( volatile void *data, volatile int bpl, volatile int w
"jns 3f \n\t"
"2: \n\t" /* Start of the inner loop (pixels 8 at a time --> 8 * 16 = 128bits/xmm register ) */
"movdqu (%%rsi, %%rcx, 2), %%xmm0\n\t" /* Load the 16 bits of the pixel (5 bits for red, 6 bits for green, 5 bits for blue) */
"movdqu %%xmm0, %%xmm1 \n\t" /* Create a copy of the pixel for the green color */
"movdqu %%xmm0, %%xmm2 \n\t" /* Create a copy of the pixel for the blue color */
"movdqa %%xmm0, %%xmm1 \n\t" /* Create a copy of the pixel for the green color */
"movdqa %%xmm0, %%xmm2 \n\t" /* Create a copy of the pixel for the blue color */
"psrlw $5, %%xmm1 \n\t" /* Packed Shift Right Logical Words */
/* From A64_128bit_Media_Programming (p. 347) */
/* Shifts the blue off of the green color */
@ -191,8 +185,8 @@ void shade_ximage_15_sse2( volatile void *data, volatile int bpl, volatile int w
"jns 8f \n\t"
"7: \n\t"
"movdqu (%%rsi, %%rcx, 2), %%xmm0\n\t"
"movdqu %%xmm0, %%xmm1 \n\t"
"movdqu %%xmm0, %%xmm2 \n\t"
"movdqa %%xmm0, %%xmm1 \n\t"
"movdqa %%xmm0, %%xmm2 \n\t"
"psrlw $5, %%xmm1 \n\t"
"psrlw $10, %%xmm0 \n\t"
"psllw $11, %%xmm2 \n\t"
@ -301,8 +295,8 @@ void shade_ximage_16_sse2( volatile void *data, volatile int bpl, volatile int w
"jns 3f \n\t"
"2: \n\t" /* Start of the inner loop (pixels 8 at a time --> 8 * 16 = 128bits/xmm register ) */
"movdqu (%%rsi, %%rcx, 2), %%xmm0\n\t" /* Load the 16 bits of the pixel (5 bits for red, 6 bits for green, 5 bits for blue) */
"movdqu %%xmm0, %%xmm1 \n\t" /* Create a copy of the pixel for the green color */
"movdqu %%xmm0, %%xmm2 \n\t" /* Create a copy of the pixel for the blue color */
"movdqa %%xmm0, %%xmm1 \n\t" /* Create a copy of the pixel for the green color */
"movdqa %%xmm0, %%xmm2 \n\t" /* Create a copy of the pixel for the blue color */
"psrlw $5, %%xmm1 \n\t" /* Packed Shift Right Logical Words */
/* From A64_128bit_Media_Programming (p. 347) */
/* Shifts the blue off of the green color */
@ -359,7 +353,7 @@ void shade_ximage_16_sse2( volatile void *data, volatile int bpl, volatile int w
"pcmpeqw %%xmm3, %%xmm3 \n\t" /* Packed Compare Equal Words */
/* From A64_128bit_Media_Programming (p. 276) */
/* This sets xmm3 to 128 1's (since mm6 = mm6) */
"movdqu %%xmm3, %%xmm4 \n\t" /* Make copy of 128 ones */
"movdqa %%xmm3, %%xmm4 \n\t" /* Make copy of 128 ones */
"psllw $5, %%xmm3 \n\t" /* xmm3 = 8 copies of 1111 1111 1110 0000 */
"psllw $6, %%xmm4 \n\t" /* xmm4 = 8 copies of 1111 1111 1100 0000 */
"6: \n\t"
@ -368,8 +362,8 @@ void shade_ximage_16_sse2( volatile void *data, volatile int bpl, volatile int w
"jns 8f \n\t"
"7: \n\t"
"movdqu (%%rsi, %%rcx, 2), %%xmm0\n\t"
"movdqu %%xmm0, %%xmm1 \n\t"
"movdqu %%xmm0, %%xmm2 \n\t"
"movdqa %%xmm0, %%xmm1 \n\t"
"movdqa %%xmm0, %%xmm2 \n\t"
"psrlw $5, %%xmm1 \n\t"
"psrlw $11, %%xmm0 \n\t"
"psllw $11, %%xmm2 \n\t"
@ -480,7 +474,7 @@ void shade_ximage_32_sse2( volatile void *data, volatile int bpl, volatile int w
"psllw $15, %%xmm6 \n\t" /* Packed Shift Left Logical Words */
/* From A64_128bit_Media_Programming (p. 330) */
/* This sets 8 16 bit values of 1000 0000 0000 0000 in the 128 bit word */
"movdqu %%xmm6, %%xmm5 \n\t" /* Copy mm6 to mm5 (we need mm6 later) */
"movdqa %%xmm6, %%xmm5 \n\t" /* Copy mm6 to mm5 (we need mm6 later) */
"pmulhw %%xmm4, %%xmm5 \n\t" /* Packed Multiply High Signed Word */
/* mm4 = ( mm4 * mm5 ) >> 16 (8 times, once for each 16bit value) */
/* For each color_ modifier (cm) */

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 1997-2004, Michael Jennings
* Copyright (C) 1997-2009, 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
@ -73,7 +73,6 @@ Atom props[NUM_PROPS];
int
eterm_bootstrap(int argc, char *argv[])
{
int i;
char *val;
@ -81,7 +80,7 @@ eterm_bootstrap(int argc, char *argv[])
static char windowid_string[20], *display_string, *term_string;
orig_argv0 = argv[0];
/* Security enhancements -- mej */
putenv("IFS= \t\n");
my_ruid = getuid();
@ -96,9 +95,7 @@ eterm_bootstrap(int argc, char *argv[])
init_libast();
/* Open display, get options/resources and create the window */
if (getenv("DISPLAY") == NULL) {
display_name = STRDUP(":0");
} else {
if (getenv("DISPLAY")) {
display_name = STRDUP(getenv("DISPLAY"));
}
@ -116,8 +113,10 @@ eterm_bootstrap(int argc, char *argv[])
#ifdef NEED_LINUX_HACK
privileges(REVERT);
#endif
if (!Xdisplay) {
print_error("can't open display %s\n", display_name);
if (!Xdisplay && !(Xdisplay = XOpenDisplay(display_name))) {
libast_print_error("Can't open display %s. Set $DISPLAY or use --display\n",
NONULL(display_name));
exit(EXIT_FAILURE);
}
XSetErrorHandler((XErrorHandler) xerror_handler);
@ -139,6 +138,10 @@ eterm_bootstrap(int argc, char *argv[])
/* Get all our properties set up. */
MEMSET(props, 0, sizeof(props));
props[PROP_TEXT] = XInternAtom(Xdisplay, "TEXT", False);
props[PROP_COMPOUND_TEXT] = XInternAtom(Xdisplay, "COMPOUND_TEXT", False);
props[PROP_UTF8_STRING] = XInternAtom(Xdisplay, "UTF8_STRING", False);
props[PROP_CLIPBOARD] = XInternAtom(Xdisplay, "CLIPBOARD", False);
props[PROP_DESKTOP] = XInternAtom(Xdisplay, "_NET_WM_DESKTOP", False);
props[PROP_TRANS_PIXMAP] = XInternAtom(Xdisplay, "_XROOTPMAP_ID", False);
props[PROP_TRANS_COLOR] = XInternAtom(Xdisplay, "_XROOTCOLOR_PIXEL", False);
@ -154,21 +157,21 @@ eterm_bootstrap(int argc, char *argv[])
props[PROP_EWMH_ICON] = XInternAtom(Xdisplay, "_NET_WM_ICON", False);
props[PROP_EWMH_OPACITY] = XInternAtom(Xdisplay, "_NET_WM_WINDOW_OPACITY", True);
props[PROP_EWMH_STARTUP_ID] = XInternAtom(Xdisplay, "_NET_STARTUP_ID", False);
props[PROP_EWMH_STATE] = XInternAtom(Xdisplay, "_NET_WM_STATE", False);
props[PROP_EWMH_STATE_STICKY] = XInternAtom(Xdisplay, "_NET_WM_STATE_STICKY", False);
if ((theme_dir = conf_parse_theme(&rs_theme, THEME_CFG, PARSE_TRY_ALL)) != NULL) {
if ((theme_dir = spifconf_parse_theme(&rs_theme, THEME_CFG, PARSE_TRY_ALL))) {
char *tmp;
D_OPTIONS(("conf_parse_theme() returned \"%s\"\n", theme_dir));
D_OPTIONS(("spifconf_parse_theme() returned \"%s\"\n", theme_dir));
tmp = (char *) MALLOC(strlen(theme_dir) + sizeof("ETERM_THEME_ROOT=\0"));
sprintf(tmp, "ETERM_THEME_ROOT=%s", theme_dir);
putenv(tmp);
}
if ((user_dir =
conf_parse_theme(&rs_theme, (rs_config_file ? rs_config_file : USER_CFG),
(PARSE_TRY_USER_THEME | PARSE_TRY_NO_THEME))) != NULL) {
if ((user_dir = spifconf_parse_theme(&rs_theme, (rs_config_file ? rs_config_file : USER_CFG), (PARSE_TRY_USER_THEME | PARSE_TRY_NO_THEME)))) {
char *tmp;
D_OPTIONS(("conf_parse_theme() returned \"%s\"\n", user_dir));
D_OPTIONS(("spifconf_parse_theme() returned \"%s\"\n", user_dir));
tmp = (char *) MALLOC(strlen(user_dir) + sizeof("ETERM_USER_ROOT=\0"));
sprintf(tmp, "ETERM_USER_ROOT=%s", user_dir);
putenv(tmp);
@ -262,24 +265,10 @@ eterm_bootstrap(int argc, char *argv[])
}
#endif
#ifdef DISPLAY_IS_IP
/* Fixup display_name for export over pty to any interested terminal
* clients via "ESC[7n" (e.g. shells). Note we use the pure IP number
* (for the first non-loopback interface) that we get from
* network_display(). This is more "name-resolution-portable", if you
* will, and probably allows for faster x-client startup if your name
* server is beyond a slow link or overloaded at client startup. Of
* course that only helps the shell's child processes, not us.
*
* Giving out the display_name also affords a potential security hole
*/
val = display_name = network_display(display_name);
if (val == NULL)
#endif /* DISPLAY_IS_IP */
val = XDisplayString(Xdisplay);
if (display_name == NULL)
display_name = val; /* use broken `:0' value */
val = XDisplayString(Xdisplay);
if (!display_name) {
display_name = val;
}
i = strlen(val);
display_string = MALLOC(i + 9);
@ -301,7 +290,7 @@ eterm_bootstrap(int argc, char *argv[])
putenv("COLORTERM_BCE=" COLORTERMENV "-mono");
putenv("TERM=" TERMENV);
} else {
if (rs_term_name != NULL) {
if (rs_term_name) {
i = strlen(rs_term_name);
term_string = MALLOC(i + 6);

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 1997-2004, Michael Jennings
* Copyright (C) 1997-2009, 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
@ -91,6 +91,10 @@
#endif
enum {
PROP_TEXT,
PROP_COMPOUND_TEXT,
PROP_UTF8_STRING,
PROP_CLIPBOARD,
PROP_DESKTOP,
PROP_TRANS_PIXMAP,
PROP_TRANS_COLOR,
@ -106,6 +110,8 @@ enum {
PROP_EWMH_ICON,
PROP_EWMH_OPACITY,
PROP_EWMH_STARTUP_ID,
PROP_EWMH_STATE,
PROP_EWMH_STATE_STICKY,
NUM_PROPS
};

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 1997-2004, Michael Jennings
* Copyright (C) 1997-2009, 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
@ -52,6 +52,7 @@ wait_for_chld(int system_pid)
while (1) {
do {
errno = 0;
usleep(10);
} while ((((pid = waitpid(system_pid, &status, WNOHANG)) == -1) && (errno == EINTR)) || !pid);
/* If the child that exited is the command we spawned, or if the
child exited before fork() returned in the parent, it must be
@ -79,32 +80,20 @@ wait_for_chld(int system_pid)
}
/* Replace the system() call with a fork-and-exec that unprivs the child process */
int
system_wait(char *command)
{
pid_t pid;
D_OPTIONS(("system_wait(%s) called.\n", command));
if (!(pid = fork())) {
setreuid(my_ruid, my_ruid);
setregid(my_rgid, my_rgid);
execl("/bin/sh", "sh", "-c", command, (char *) NULL);
print_error("execl(%s) failed -- %s\n", command, strerror(errno));
exit(EXIT_FAILURE);
} else {
D_OPTIONS(("%d: fork() returned %d\n", getpid(), pid));
return (wait_for_chld(pid));
}
ASSERT_NOTREACHED_RVAL(0);
pid = system_no_wait(command);
return (wait_for_chld(pid));
}
int
pid_t
system_no_wait(char *command)
{
pid_t pid;
D_OPTIONS(("system_no_wait(%s) called.\n", command));
@ -113,8 +102,9 @@ system_no_wait(char *command)
setreuid(my_ruid, my_ruid);
setregid(my_rgid, my_rgid);
execl("/bin/sh", "sh", "-c", command, (char *) NULL);
print_error("execl(%s) failed -- %s\n", command, strerror(errno));
libast_print_error("execl(%s) failed -- %s\n", command, strerror(errno));
exit(EXIT_FAILURE);
}
return (0);
D_OPTIONS(("%d: fork() returned %d\n", getpid(), pid));
return (pid);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 1997-2004, Michael Jennings
* Copyright (C) 1997-2009, 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
@ -36,6 +36,6 @@ typedef RETSIGTYPE (*eterm_sighandler_t)(int);
extern int wait_for_chld(int);
extern int system_wait(char *);
extern int system_no_wait(char *);
extern pid_t system_no_wait(char *);
#endif /* _SYSTEM_H_ */

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 1997-2004, Michael Jennings
* Copyright (C) 1997-2009, 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
@ -473,7 +473,7 @@ lookup_key(XEvent * ev)
PrivMode((!numlock_state), PrivMode_aplKP);
}
#ifdef USE_XIM
if (xim_input_context != NULL) {
if (xim_input_context) {
Status status_return;
kbuf[0] = '\0';
@ -531,7 +531,7 @@ lookup_key(XEvent * ev)
#endif
/* Check for a corresponding action binding. If there is one, we're done with this event. */
if (action_dispatch(ev, keysym)) {
if (eterm_action_dispatch(ev)) {
LK_RET();
}
if (len) {
@ -561,15 +561,15 @@ lookup_key(XEvent * ev)
}
#endif
#if defined(HAVE_X11_SUNKEYSYM_H) && defined(HAVE_X11_XMU_ATOMS_H)
#if defined(HAVE_X11_SUNKEYSYM_H)
switch (keysym) {
case SunXK_Copy:
case SunXK_Cut:
selection_copy(XA_CLIPBOARD(Xdisplay));
selection_copy(props[PROP_CLIPBOARD]);
LK_RET();
break;
case SunXK_Paste:
selection_paste(XA_CLIPBOARD(Xdisplay));
selection_paste(props[PROP_CLIPBOARD]);
LK_RET();
break;
case SunXK_Front:
@ -680,7 +680,7 @@ lookup_key(XEvent * ev)
if (keysym >= 0xff00 && keysym <= 0xffff) {
#ifdef KEYSYM_ATTRIBUTE
/* The "keysym" attribute in the config file gets handled here. */
if (!(shft | ctrl) && KeySym_map[keysym - 0xff00] != NULL) {
if (!(shft | ctrl) && KeySym_map[keysym - 0xff00]) {
const unsigned char *tmpbuf;
unsigned int len;
@ -1077,11 +1077,11 @@ popen_printer(void)
FILE *stream;
if (((my_ruid != my_euid) || (my_rgid != my_egid)) && (strcmp(rs_print_pipe, PRINTPIPE))) {
print_warning("Running setuid/setgid. Refusing to use custom printpipe.\n");
libast_print_warning("Running setuid/setgid. Refusing to use custom printpipe.\n");
RESET_AND_ASSIGN(rs_print_pipe, STRDUP(PRINTPIPE));
}
if ((stream = (FILE *) popen(rs_print_pipe, "w")) == NULL) {
print_error("Can't open printer pipe \"%s\" -- %s\n", rs_print_pipe, strerror(errno));
if (!(stream = (FILE *)popen(rs_print_pipe, "w"))) {
libast_print_error("Can't open printer pipe \"%s\" -- %s\n", rs_print_pipe, strerror(errno));
}
return stream;
}
@ -1102,7 +1102,7 @@ process_print_pipe(void)
int index;
FILE *fd;
if ((fd = popen_printer()) != NULL) {
if ((fd = popen_printer())) {
for (index = 0; index < 4; /* nil */ ) {
unsigned char ch = cmd_getc();
@ -2081,7 +2081,7 @@ append_to_title(const char *str)
REQUIRE(str != NULL);
XFetchName(Xdisplay, TermWin.parent, &name);
if (name != NULL) {
if (name) {
buff = (char *) MALLOC(strlen(name) + strlen(str) + 1);
strcpy(buff, name);
strcat(buff, str);
@ -2098,7 +2098,7 @@ append_to_icon_name(const char *str)
REQUIRE(str != NULL);
XGetIconName(Xdisplay, TermWin.parent, &name);
if (name != NULL) {
if (name) {
buff = (char *) MALLOC(strlen(name) + strlen(str) + 1);
strcpy(buff, name);
strcat(buff, str);
@ -2158,19 +2158,19 @@ xterm_seq(int op, const char *str)
set_title(str);
break;
case ESCSEQ_XTERM_PROP: /* 3 */
if ((nstr = (char *) strsep(&tnstr, ";")) == NULL) {
if (!(nstr = (char *)strsep(&tnstr, ";"))) {
break;
}
if ((valptr = strchr(nstr, '=')) != NULL) {
if ((valptr = strchr(nstr, '='))) {
*(valptr++) = 0;
}
set_text_property(TermWin.parent, nstr, valptr);
break;
case ESCSEQ_XTERM_CHANGE_COLOR: /* Changing existing colors 256 */
while ((nstr = (char *) strsep(&tnstr, ";")) != NULL) {
while ((nstr = (char *)strsep(&tnstr, ";"))) {
i = (unsigned int) strtoul(nstr, (char **) NULL, 0);
nstr = (char *) strsep(&tnstr, ";");
if ((i < 256) && (nstr != NULL)) {
if ((i < 256) && (nstr)) {
D_COLORS(("Changing color : [%d] -> %s\n", i, nstr));
set_window_color(i, nstr);
}
@ -2256,7 +2256,7 @@ xterm_seq(int op, const char *str)
case 1:
changed = 0;
for (; 1;) {
if ((color = (char *) strsep(&tnstr, ";")) == NULL) {
if (!(color = (char *)strsep(&tnstr, ";"))) {
break;
}
which = image_max;
@ -2264,13 +2264,13 @@ xterm_seq(int op, const char *str)
which = idx; break;}
);
if (which != image_max) {
if ((color = (char *) strsep(&tnstr, ";")) == NULL) {
if (!(color = (char *)strsep(&tnstr, ";"))) {
break;
}
} else {
which = image_bg;
}
if ((mod = (char *) strsep(&tnstr, ";")) == NULL) {
if (!(mod = (char *)strsep(&tnstr, ";"))) {
break;
}
if (!strcasecmp(mod, "clear")) {
@ -2297,7 +2297,7 @@ xterm_seq(int op, const char *str)
changed = 1;
continue;
}
if ((valptr = (char *) strsep(&tnstr, ";")) == NULL) {
if (!(valptr = (char *)strsep(&tnstr, ";"))) {
break;
}
D_CMD(("Modifying the %s attribute of the %s color modifier of the %s image to be %s\n",
@ -2314,7 +2314,7 @@ xterm_seq(int op, const char *str)
if (!strcasecmp(color, "image")) {
imlib_t *iml = images[which].current->iml;
if (iml->mod == NULL) {
if (!iml->mod) {
iml->mod = create_colormod();
}
if (!BEG_STRCASECMP(mod, "brightness")) {
@ -2331,7 +2331,7 @@ xterm_seq(int op, const char *str)
} else if (!strcasecmp(color, "red")) {
imlib_t *iml = images[which].current->iml;
if (iml->rmod == NULL) {
if (!iml->rmod) {
iml->rmod = create_colormod();
}
if (!BEG_STRCASECMP(mod, "brightness")) {
@ -2348,7 +2348,7 @@ xterm_seq(int op, const char *str)
} else if (!strcasecmp(color, "green")) {
imlib_t *iml = images[which].current->iml;
if (iml->gmod == NULL) {
if (!iml->gmod) {
iml->gmod = create_colormod();
}
if (!BEG_STRCASECMP(mod, "brightness")) {
@ -2365,7 +2365,7 @@ xterm_seq(int op, const char *str)
} else if (!strcasecmp(color, "blue")) {
imlib_t *iml = images[which].current->iml;
if (iml->bmod == NULL) {
if (!iml->bmod) {
iml->bmod = create_colormod();
}
if (!BEG_STRCASECMP(mod, "bright")) {
@ -2387,14 +2387,14 @@ xterm_seq(int op, const char *str)
case 2:
changed = 0;
which = image_max;
if ((nstr = (char *) strsep(&tnstr, ";")) == NULL || (valptr = (char *) strsep(&tnstr, ";")) == NULL) {
if (!(nstr = (char *)strsep(&tnstr, ";")) || !(valptr = (char *)strsep(&tnstr, ";"))) {
break;
}
FOREACH_IMAGE(if (!strcasecmp(valptr, (get_image_type(idx) + 6))) {
which = idx; break;}
);
if (which != image_max) {
if ((valptr = (char *) strsep(&tnstr, ";")) == NULL) {
if (!(valptr = (char *)strsep(&tnstr, ";"))) {
break;
}
} else {
@ -2408,7 +2408,7 @@ xterm_seq(int op, const char *str)
s = (int) strtol(valptr, (char **) NULL, 0);
s = ((100 - s) << 8) / 100;
if (s == 0x100) {
if (iml->mod != NULL) {
if (iml->mod) {
if (iml->mod->brightness != 0x100) {
iml->mod->brightness = 0x100;
changed = 1;
@ -2418,7 +2418,7 @@ xterm_seq(int op, const char *str)
}
}
} else {
if (iml->mod == NULL) {
if (!iml->mod) {
iml->mod = create_colormod();
}
if (iml->mod->brightness != s) {
@ -2438,7 +2438,7 @@ xterm_seq(int op, const char *str)
}
r = (t & 0xff0000) >> 16;
if (r == 0xff) {
if (iml->rmod != NULL) {
if (iml->rmod) {
if (iml->rmod->brightness != 0x100) {
iml->rmod->brightness = 0x100;
changed = 1;
@ -2448,7 +2448,7 @@ xterm_seq(int op, const char *str)
}
}
} else {
if (iml->rmod == NULL) {
if (!iml->rmod) {
iml->rmod = create_colormod();
}
if (iml->rmod->brightness != (int) r) {
@ -2458,7 +2458,7 @@ xterm_seq(int op, const char *str)
}
g = (t & 0xff00) >> 8;
if (g == 0xff) {
if (iml->gmod != NULL) {
if (iml->gmod) {
if (iml->gmod->brightness != 0x100) {
iml->gmod->brightness = 0x100;
changed = 1;
@ -2468,7 +2468,7 @@ xterm_seq(int op, const char *str)
}
}
} else {
if (iml->gmod == NULL) {
if (!iml->gmod) {
iml->gmod = create_colormod();
}
if (iml->gmod->brightness != (int) g) {
@ -2478,7 +2478,7 @@ xterm_seq(int op, const char *str)
}
b = t & 0xff;
if (b == 0xff) {
if (iml->bmod != NULL) {
if (iml->bmod) {
if (iml->bmod->brightness != 0x100) {
iml->bmod->brightness = 0x100;
changed = 1;
@ -2488,7 +2488,7 @@ xterm_seq(int op, const char *str)
}
}
} else {
if (iml->bmod == NULL) {
if (!iml->bmod) {
iml->bmod = create_colormod();
iml->bmod->contrast = iml->bmod->gamma = 0x100;
}
@ -2526,22 +2526,22 @@ xterm_seq(int op, const char *str)
#ifdef XTERM_SCROLLBAR
scrollbar_change_type(SCROLLBAR_XTERM);
#else
print_error("Support for xterm scrollbars was not compiled in. Sorry.\n");
libast_print_error("Support for xterm scrollbars was not compiled in. Sorry.\n");
#endif
} else if (!strcasecmp(nstr, "next")) {
#ifdef NEXT_SCROLLBAR
scrollbar_change_type(SCROLLBAR_NEXT);
#else
print_error("Support for NeXT scrollbars was not compiled in. Sorry.\n");
libast_print_error("Support for NeXT scrollbars was not compiled in. Sorry.\n");
#endif
} else if (!strcasecmp(nstr, "motif")) {
#ifdef MOTIF_SCROLLBAR
scrollbar_change_type(SCROLLBAR_MOTIF);
#else
print_error("Support for motif scrollbars was not compiled in. Sorry.\n");
libast_print_error("Support for motif scrollbars was not compiled in. Sorry.\n");
#endif
} else {
print_error("Unrecognized scrollbar type \"%s\".\n", nstr);
libast_print_error("Unrecognized scrollbar type \"%s\".\n", nstr);
}
}
nstr = (char *) strsep(&tnstr, ";");
@ -2619,6 +2619,10 @@ xterm_seq(int op, const char *str)
XSetWMHints(Xdisplay, TermWin.parent, wm_hints);
XFree(wm_hints);
break;
case 28:
nstr = (char *) strsep(&tnstr, ";");
OPT_SET_OR_TOGGLE(nstr, vt_options, VT_OPTIONS_URG_ALERT);
break;
case 40:
nstr = (char *) strsep(&tnstr, ";");
if (nstr) {
@ -2705,54 +2709,54 @@ xterm_seq(int op, const char *str)
#ifdef XTERM_COLOR_CHANGE
case ESCSEQ_XTERM_FGCOLOR: /* 10 */
if ((nstr = (char *) strsep(&tnstr, ";")) != NULL) {
if ((nstr = (char *)strsep(&tnstr, ";"))) {
set_window_color(fgColor, nstr);
}
/* drop */
case ESCSEQ_XTERM_BGCOLOR: /* 11 */
if ((nstr = (char *) strsep(&tnstr, ";")) != NULL) {
if ((nstr = (char *)strsep(&tnstr, ";"))) {
set_window_color(bgColor, nstr);
}
/* drop */
case ESCSEQ_XTERM_CURSOR_COLOR: /* 12 */
if ((nstr = (char *) strsep(&tnstr, ";")) != NULL) {
if ((nstr = (char *)strsep(&tnstr, ";"))) {
# ifndef NO_CURSORCOLOR
set_window_color(cursorColor, nstr);
# endif
}
/* drop */
case ESCSEQ_XTERM_PTR_FGCOLOR: /* 13 */
if ((nstr = (char *) strsep(&tnstr, ";")) != NULL) {
if ((nstr = (char *)strsep(&tnstr, ";"))) {
set_pointer_colors(nstr, NULL);
}
/* drop */
case ESCSEQ_XTERM_PTR_BGCOLOR: /* 14 */
if ((nstr = (char *) strsep(&tnstr, ";")) != NULL) {
if ((nstr = (char *)strsep(&tnstr, ";"))) {
/* UNSUPPORTED */
}
/* drop */
case ESCSEQ_XTERM_TEK_FGCOLOR: /* 15 */
if ((nstr = (char *) strsep(&tnstr, ";")) != NULL) {
if ((nstr = (char *)strsep(&tnstr, ";"))) {
/* UNSUPPORTED */
}
/* drop */
case ESCSEQ_XTERM_TEK_BGCOLOR: /* 16 */
if ((nstr = (char *) strsep(&tnstr, ";")) != NULL) {
if ((nstr = (char *)strsep(&tnstr, ";"))) {
/* UNSUPPORTED */
}
/* drop */
case ESCSEQ_XTERM_HILIGHT_COLOR: /* 17 */
if ((nstr = (char *) strsep(&tnstr, ";")) != NULL) {
if ((nstr = (char *)strsep(&tnstr, ";"))) {
/* UNSUPPORTED */
}
/* drop */
case ESCSEQ_XTERM_BOLD_COLOR: /* 18 */
if ((nstr = (char *) strsep(&tnstr, ";")) != NULL) {
if ((nstr = (char *)strsep(&tnstr, ";"))) {
set_window_color(colorBD, nstr);
}
/* drop */
case ESCSEQ_XTERM_ULINE_COLOR: /* 19 */
if ((nstr = (char *) strsep(&tnstr, ";")) != NULL) {
if ((nstr = (char *)strsep(&tnstr, ";"))) {
set_window_color(colorUL, nstr);
}
#endif

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 1997-2004, Michael Jennings
* Copyright (C) 1997-2009, 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

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 1997-2004, Michael Jennings
* Copyright (C) 1997-2009, 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

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 1997-2004, Michael Jennings
* Copyright (C) 1997-2009, 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

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 1997-2004, Michael Jennings
* Copyright (C) 1997-2009, 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
@ -38,9 +38,9 @@ static const char cvs_ident[] = "$Id$";
# endif
/* don't go off end of ut_id & remember if an entry has been made */
# if defined(USE_SYSV_UTMP) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__)
# if defined(USE_SYSV_UTMP) || defined(__OpenBSD__)
static char ut_id[5]; /* remember if entry to utmp made */
# else
# elif !defined(NEW_BSD_UTMP)
static int utmp_pos; /* BSD position of utmp-stamp */
# endif
@ -117,7 +117,7 @@ add_utmp_entry(const char *pty, const char *hostname, int fd)
if (sscanf(pty, "pts/%d", &n) == 1)
sprintf(ut_id, "vt%02x", n); /* sysv naming */
else {
print_error("can't parse tty name \"%s\"\n", pty);
libast_print_error("can't parse tty name \"%s\"\n", pty);
ut_id[0] = '\0'; /* entry not made */
return;
}
@ -181,7 +181,7 @@ remove_utmp_entry(void)
setutent();
strncpy(utmp.ut_id, ut_id, sizeof(utmp.ut_id));
utmp.ut_type = USER_PROCESS;
if (getutid(&utmp) == NULL) {
if (!getutid(&utmp)) {
return;
}
utmp.ut_type = DEAD_PROCESS;
@ -204,7 +204,7 @@ remove_utmp_entry(void)
* The following code waw copied from the poeigl-1.20 login/init package.
* Special thanks to poe for the code examples.
*/
while ((putmp = getutent()) != NULL) {
while ((putmp = getutent())) {
if (putmp->ut_pid == pid) {
putmp->ut_type = DEAD_PROCESS;
putmp->ut_pid = 0;
@ -222,7 +222,7 @@ remove_utmp_entry(void)
# else /* USE_SYSV_UTMP */
/* BSD utmp support */
# if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__bsdi__)
# ifdef NEW_BSD_UTMP
/* used to hold the line we are using */
static char ut_line[32];
@ -270,7 +270,7 @@ b_login(struct utmp *ut)
}
}
# else /* __FreeBSD__ || NetBSD || BSDI */
# else /* NEW_BSD_UTMP */
static int utmp_pos = 0; /* position of utmp-stamp */
/*----------------------------------------------------------------------*
@ -286,10 +286,10 @@ get_tslot(const char *ttyname)
char buf[256], name[256];
FILE *fd;
if ((fd = fopen(UTMP_FILENAME, "r")) != NULL) {
if ((fd = fopen(UTMP_FILENAME, "r"))) {
int i;
for (i = 1; fgets(buf, sizeof(buf), fd) != NULL; i++) {
for (i = 1; fgets(buf, sizeof(buf), fd); i++) {
if (*buf == '#' || sscanf(buf, "%s", name) != 1)
continue;
if (!strcmp(ttyname, name)) {
@ -313,7 +313,7 @@ write_utmp(struct utmp *putmp)
fprintf(stderr, "Utmp file is %s\n", UTMP_FILENAME);
privileges(INVOKE);
if ((fd = fopen(UTMP_FILENAME, "r+")) != NULL) {
if ((fd = fopen(UTMP_FILENAME, "r+"))) {
utmp_pos = get_tslot(putmp->ut_line) * sizeof(struct utmp);
if (utmp_pos >= 0) {
@ -328,7 +328,7 @@ write_utmp(struct utmp *putmp)
return rval;
}
# endif /* __FreeBSD__ || NetBSD || BSDI */
# endif /* NEW_BSD_UTMP */
void
add_utmp_entry(const char *pty, const char *hostname, int fd)
@ -340,15 +340,8 @@ add_utmp_entry(const char *pty, const char *hostname, int fd)
if (!strncmp(pty, "/dev/", 5))
pty += 5; /* skip /dev/ prefix */
if (!strncmp(pty, "pty", 3) || !strncmp(pty, "tty", 3))
strncpy(ut_id, (pty + 3), sizeof(ut_id)); /* bsd naming */
else {
print_error("can't parse tty name \"%s\"\n", pty);
ut_id[0] = '\0'; /* entry not made */
return;
}
# if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__bsdi__)
# ifdef NEW_BSD_UTMP
strncpy(ut_line, pty, 31);
strncpy(utmp.ut_line, pty, UT_LINESIZE);
@ -357,7 +350,15 @@ add_utmp_entry(const char *pty, const char *hostname, int fd)
utmp.ut_time = time(NULL);
b_login(&utmp);
# else /* __FreeBSD__ || NetBSD || BSDI */
# else /* NEW_BSD_UTMP */
if (!strncmp(pty, "pty", 3) || !strncmp(pty, "tty", 3))
strncpy(ut_id, (pty + 3), sizeof(ut_id)); /* bsd naming */
else {
libast_print_error("can't parse tty name \"%s\"\n", pty);
ut_id[0] = '\0'; /* entry not made */
return;
}
strncpy(utmp.ut_line, ut_id, sizeof(utmp.ut_line));
strncpy(utmp.ut_name, pwent->pw_name, sizeof(utmp.ut_name));
strncpy(utmp.ut_host, hostname, sizeof(utmp.ut_host));
@ -376,14 +377,14 @@ add_utmp_entry(const char *pty, const char *hostname, int fd)
void
remove_utmp_entry(void)
{
# if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__bsdi__)
# ifdef NEW_BSD_UTMP
logout(ut_line);
logwtmp(ut_line, "", "");
# else /* __FreeBSD__ */
# else /* NEW_BSD_UTMP */
FILE *fd;
privileges(INVOKE);
if (!ut_id[0] && (fd = fopen(UTMP_FILENAME, "r+")) != NULL) {
if (!ut_id[0] && (fd = fopen(UTMP_FILENAME, "r+"))) {
struct utmp utmp;
MEMSET(&utmp, 0, sizeof(struct utmp));
@ -393,7 +394,7 @@ remove_utmp_entry(void)
fclose(fd);
}
privileges(REVERT);
# endif /* __FreeBSD__ || NetBSD || BSDI */
# endif /* NEW_BSD_UTMP */
}
# endif /* USE_SYSV_UTMP */

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 1997-2004, Michael Jennings
* Copyright (C) 1997-2009, 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
@ -69,7 +69,7 @@ set_text_property(Window win, char *propname, char *value)
ASSERT(propname != NULL);
if (value == NULL) {
if (!value) {
atom = XInternAtom(Xdisplay, propname, True);
if (atom == None) {
return;
@ -96,7 +96,7 @@ get_tint_by_color_name(const char *color)
D_PIXMAP(("Tint string is \"%s\", white color is rgbi:%d/%d/%d\n", color, wcol.red, wcol.green, wcol.blue));
if (!XParseColor(Xdisplay, cmap, color, &xcol)) {
print_error("Unable to parse tint color \"%s\". Ignoring.\n", color);
libast_print_error("Unable to parse tint color \"%s\". Ignoring.\n", color);
return 0xffffff;
}
@ -144,7 +144,7 @@ get_bottom_shadow_color(Pixel norm_color, const char *type)
xcol.blue /= 2;
if (!XAllocColor(Xdisplay, cmap, &xcol)) {
print_error("Unable to allocate \"%s\" (0x%08x: 0x%04x, 0x%04x, 0x%04x) in the color map.\n", type, xcol.pixel, xcol.red,
libast_print_error("Unable to allocate \"%s\" (0x%08x: 0x%04x, 0x%04x, 0x%04x) in the color map.\n", type, xcol.pixel, xcol.red,
xcol.green, xcol.blue);
xcol.pixel = PixColors[minColor];
}
@ -177,7 +177,7 @@ get_top_shadow_color(Pixel norm_color, const char *type)
xcol.blue = MIN(white.blue, (xcol.blue * 7) / 5);
if (!XAllocColor(Xdisplay, cmap, &xcol)) {
print_error("Unable to allocate \"%s\" (0x%08x: 0x%04x, 0x%04x, 0x%04x) in the color map.\n", type, xcol.pixel, xcol.red,
libast_print_error("Unable to allocate \"%s\" (0x%08x: 0x%04x, 0x%04x, 0x%04x) in the color map.\n", type, xcol.pixel, xcol.red,
xcol.green, xcol.blue);
xcol.pixel = PixColors[WhiteColor];
}
@ -189,8 +189,8 @@ get_color_by_name(const char *name, const char *fallback)
{
XColor xcol;
if (name == NULL) {
if (fallback == NULL) {
if (!name) {
if (!fallback) {
return ((Pixel) - 1);
} else {
name = fallback;
@ -204,11 +204,11 @@ get_color_by_name(const char *name, const char *fallback)
}
}
if (!XParseColor(Xdisplay, cmap, name, &xcol)) {
print_warning("Unable to resolve \"%s\" as a color name. Falling back on \"%s\".\n", name, NONULL(fallback));
libast_print_warning("Unable to resolve \"%s\" as a color name. Falling back on \"%s\".\n", name, NONULL(fallback));
name = fallback;
if (name) {
if (!XParseColor(Xdisplay, cmap, name, &xcol)) {
print_warning
libast_print_warning
("Unable to resolve \"%s\" as a color name. This should never fail. Please repair/restore your RGB database.\n",
name);
return ((Pixel) - 1);
@ -218,12 +218,12 @@ get_color_by_name(const char *name, const char *fallback)
}
}
if (!XAllocColor(Xdisplay, cmap, &xcol)) {
print_warning("Unable to allocate \"%s\" (0x%08x: 0x%04x, 0x%04x, 0x%04x) in the color map. Falling back on \"%s\".\n",
libast_print_warning("Unable to allocate \"%s\" (0x%08x: 0x%04x, 0x%04x, 0x%04x) in the color map. Falling back on \"%s\".\n",
name, xcol.pixel, xcol.red, xcol.green, xcol.blue, NONULL(fallback));
name = fallback;
if (name) {
if (!XAllocColor(Xdisplay, cmap, &xcol)) {
print_warning("Unable to allocate \"%s\" (0x%08x: 0x%04x, 0x%04x, 0x%04x) in the color map.\n", name, xcol.pixel,
libast_print_warning("Unable to allocate \"%s\" (0x%08x: 0x%04x, 0x%04x, 0x%04x) in the color map.\n", name, xcol.pixel,
xcol.red, xcol.green, xcol.blue);
return ((Pixel) - 1);
}
@ -241,19 +241,19 @@ get_color_by_pixel(Pixel pixel, Pixel fallback)
xcol.pixel = pixel;
if (!XQueryColor(Xdisplay, cmap, &xcol)) {
print_warning("Unable to convert pixel value 0x%08x to an XColor structure. Falling back on 0x%08x.\n", pixel, fallback);
libast_print_warning("Unable to convert pixel value 0x%08x to an XColor structure. Falling back on 0x%08x.\n", pixel, fallback);
xcol.pixel = fallback;
if (!XQueryColor(Xdisplay, cmap, &xcol)) {
print_warning("Unable to convert pixel value 0x%08x to an XColor structure.\n", xcol.pixel);
libast_print_warning("Unable to convert pixel value 0x%08x to an XColor structure.\n", xcol.pixel);
return ((Pixel) 0);
}
}
if (!XAllocColor(Xdisplay, cmap, &xcol)) {
print_warning("Unable to allocate 0x%08x (0x%04x, 0x%04x, 0x%04x) in the color map. Falling back on 0x%08x.\n", xcol.pixel,
libast_print_warning("Unable to allocate 0x%08x (0x%04x, 0x%04x, 0x%04x) in the color map. Falling back on 0x%08x.\n", xcol.pixel,
xcol.red, xcol.green, xcol.blue, fallback);
xcol.pixel = fallback;
if (!XAllocColor(Xdisplay, cmap, &xcol)) {
print_warning("Unable to allocate 0x%08x (0x%04x, 0x%04x, 0x%04x) in the color map.\n", xcol.pixel, xcol.red,
libast_print_warning("Unable to allocate 0x%08x (0x%04x, 0x%04x, 0x%04x) in the color map.\n", xcol.pixel, xcol.red,
xcol.green, xcol.blue);
return ((Pixel) 0);
}
@ -348,13 +348,13 @@ set_pointer_colors(const char *fg_name, const char *bg_name)
{
XColor fg, bg;
if (fg_name != NULL) {
if (fg_name) {
fg.pixel = get_color_by_name(fg_name, COLOR_NAME(pointerColor));
} else {
fg.pixel = PixColors[pointerColor];
}
XQueryColor(Xdisplay, cmap, &fg);
if (bg_name != NULL) {
if (bg_name) {
bg.pixel = get_color_by_name(bg_name, COLOR_NAME(bgColor));
} else {
bg.pixel = PixColors[bgColor];
@ -378,15 +378,8 @@ Create_Windows(int argc, char *argv[])
MWMHints mwmhints;
if (BITFIELD_IS_SET(eterm_options, ETERM_OPTIONS_BORDERLESS)) {
prop = XInternAtom(Xdisplay, "_MOTIF_WM_INFO", True);
if (prop == None) {
print_warning("Window Manager does not support MWM hints. Bypassing window manager control for borderless window.\n");
Attributes.override_redirect = TRUE;
mwmhints.flags = 0;
} else {
mwmhints.flags = MWM_HINTS_DECORATIONS;
mwmhints.decorations = 0;
}
mwmhints.flags = MWM_HINTS_DECORATIONS;
mwmhints.decorations = 0;
} else {
mwmhints.flags = 0;
}
@ -498,10 +491,16 @@ Create_Windows(int argc, char *argv[])
XChangeProperty(Xdisplay, TermWin.parent, props[PROP_DESKTOP], XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &val, 1);
}
/* Make window sticky if requested */
if (BITFIELD_IS_SET(eterm_options, ETERM_OPTIONS_STICKY)) {
XChangeProperty(Xdisplay, TermWin.parent, props[PROP_EWMH_STATE], XA_ATOM, 32, PropModeReplace,
(unsigned char *) &props[PROP_EWMH_STATE_STICKY], 1);
}
/* Set startup ID property if given by the launching application. */
if (getenv("DESKTOP_STARTUP_ID")) {
Atom atom;
unsigned char *tmp = SPIF_CAST_PTR(uchar) getenv("DESKTOP_STARTUP_ID");
unsigned char *tmp = (spif_uchar_t *) getenv("DESKTOP_STARTUP_ID");
atom = XInternAtom(Xdisplay, "UTF8_STRING", False);
XChangeProperty(Xdisplay, TermWin.parent, props[PROP_EWMH_STARTUP_ID], atom, 8, PropModeReplace, tmp, strlen(tmp) + 1);
@ -511,9 +510,9 @@ Create_Windows(int argc, char *argv[])
/* Set window opacity if needed. */
if ((props[PROP_EWMH_OPACITY] != None) && (rs_opacity != 0xff)) {
XChangeProperty(Xdisplay, TermWin.parent, props[PROP_EWMH_OPACITY],
XA_CARDINAL, 32, PropModeReplace, SPIF_CAST_PTR(uchar) & rs_opacity, 1);
XA_CARDINAL, 32, PropModeReplace, (spif_uchar_t *) &rs_opacity, 1);
XChangeProperty(Xdisplay, TermWin.vt, props[PROP_EWMH_OPACITY],
XA_CARDINAL, 32, PropModeReplace, SPIF_CAST_PTR(uchar) & rs_opacity, 1);
XA_CARDINAL, 32, PropModeReplace, (spif_uchar_t *) &rs_opacity, 1);
}
/* We're done creating our windows. Now let's initialize the event subsystem to handle them. */
@ -691,11 +690,19 @@ handle_resize(unsigned int width, unsigned int height)
void
handle_move(int x, int y)
{
int dx, dy;
if ((TermWin.x != x) || (TermWin.y != y)) {
dx = abs(TermWin.x - x);
dy = abs(TermWin.y - y);
TermWin.x = x;
TermWin.y = y;
/* If we've moved an even multiple of the screen size, there's no
need to redraw trans/viewport images; the images will line up. */
if (image_mode_any(MODE_TRANS | MODE_VIEWPORT)) {
redraw_images_by_mode(MODE_TRANS | MODE_VIEWPORT);
if ((dx % DisplayWidth(Xdisplay, Xscreen)) || (dy % DisplayHeight(Xdisplay, Xscreen))) {
redraw_images_by_mode(MODE_TRANS | MODE_VIEWPORT);
}
}
}
}
@ -728,7 +735,7 @@ set_window_color(int idx, const char *color)
D_X11(("idx == %d, color == \"%s\"\n", idx, NONULL(color)));
if (color == NULL || *color == '\0')
if (!color || *color == '\0')
return;
/* handle color aliases */
@ -740,12 +747,12 @@ set_window_color(int idx, const char *color)
} else if (i >= 0 && i <= 7) { /* normal colors */
PixColors[idx] = PixColors[minColor + i];
} else {
print_warning("Color index %d is invalid.\n", i);
libast_print_warning("Color index %d is invalid.\n", i);
return;
}
} else if (XParseColor(Xdisplay, cmap, color, &xcol)) {
if (!XAllocColor(Xdisplay, cmap, &xcol)) {
print_warning("Unable to allocate \"%s\" in the color map.\n", color);
libast_print_warning("Unable to allocate \"%s\" in the color map.\n", color);
return;
}
if ((idx > maxBright) && (idx < 256) && (PixColors[idx])) {
@ -753,7 +760,7 @@ set_window_color(int idx, const char *color)
}
PixColors[idx] = xcol.pixel;
} else {
print_warning("Unable to resolve \"%s\" as a color name.\n", color);
libast_print_warning("Unable to resolve \"%s\" as a color name.\n", color);
return;
}
set_colorfgbg();

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 1997-2004, Michael Jennings
* Copyright (C) 1997-2009, 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

View File

@ -1 +0,0 @@
timestamp

View File

@ -4,6 +4,7 @@ THEMES = Eterm auto Escreen trans
EXTRA_DIST = Eterm/theme.cfg.in Escreen/theme.cfg.in trans/theme.cfg.in auto/theme.cfg.in \
Eterm/menus.cfg Escreen/menus.cfg trans/menus.cfg auto/menus.cfg
MAINTAINERCLEANFILES=Makefile.in
install-data-hook:
$(mkinstalldirs) $(DESTDIR)$(pkgdatadir)/themes
@ -30,4 +31,3 @@ install-data-hook:
uninstall-hook:
rm -rf $(DESTDIR)$(pkgdatadir)/themes
MAINTAINERCLEANFILES=Makefile.in

View File

@ -181,7 +181,7 @@ main(int argc, char *argv[])
imlib_context_set_display(Xdisplay);
imlib_context_set_visual(DefaultVisual(Xdisplay, DefaultScreen(Xdisplay)));
im = imlib_load_image_immediately(fname);
if (im == NULL) {
if (!im) {
fprintf(stderr, "%s: Unable to load image file \"%s\".\n", *argv, fname);
exit(1);
} else if (debug) {

View File

@ -5,7 +5,7 @@
* This program is distributed under the GNU Public License (GPL) as
* outlined in the COPYING file.
*
* Copyright (C) 1997-2000, Brian McFee.
* Copyright (C) 1997-2009, Brian McFee.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@ -1,25 +1,25 @@
/* Ettable -- Eterm ASCII Table Display Utility
* This file is original work by Michael Jennings <mej@eterm.org>.
* This program is distributed under the GNU Public License (GPL) as
* outlined in the COPYING file.
*
* Copyright (C) 1997-2004, Michael Jennings
* Copyright (C) 1997-2009, Michael Jennings
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* 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$";

View File

@ -56,7 +56,7 @@ while (<in>) {
}
close (in);
system("@BINDIR@/Esetroot $PixMapMode-display :0 $PixMap");
system("@BINDIR@/Esetroot $PixMapMode $PixMap");
if (!-e "$HOME/Desktop/Autostart/kEsetroot.kdelnk") {
print "Do you want to start kEsetroot when KDE starts? y/n [y] ";