pax_global_header00006660000000000000000000000064117647157320014527gustar00rootroot0000000000000052 comment=fd89f3b32eaec68a61bf679189de53a897219ed7 nonstop-termit-fd89f3b/000077500000000000000000000000001176471573200152405ustar00rootroot00000000000000nonstop-termit-fd89f3b/.gitignore000066400000000000000000000002751176471573200172340ustar00rootroot00000000000000config.h CMakeFiles CMakeCache.txt install_manifest.txt tags cscope.out Makefile termit.spec termit.SlackBuild termit-*.ebuild *~ *.gmo cmake_install.cmake cmake_uninstall.cmake src/termit nonstop-termit-fd89f3b/CMakeLists.txt000066400000000000000000000045141176471573200200040ustar00rootroot00000000000000# Copyright (C) 2007-2010, Evgeny Ratnikov # # This file is part of termit. # termit is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 # as published by the Free Software Foundation. # termit 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 termit. If not, see . PROJECT(TERMIT C) cmake_minimum_required(VERSION 2.6.1 FATAL_ERROR) SET(CMAKE_VERSION "${CMAKE_CACHE_MAJOR_VERSION}.${CMAKE_CACHE_MINOR_VERSION}.${CMAKE_CACHE_RELEASE_VERSION}") INCLUDE(UsePkgConfig) ADD_DEFINITIONS(-Wall) SET(DEFAULT_XDG_DIR "/etc/xdg") string(REPLACE ":" ";" XDG_DIRS "$ENV{XDG_CONFIG_DIRS}") FOREACH(xdgDir ${XDG_DIRS}) SET(XDG_DIR ${xdgDir}) BREAK() ENDFOREACH() IF(NOT XDG_DIR) SET(XDG_DIR "/etc/xdg") ENDIF(NOT XDG_DIR) SET(DEBUG FALSE CACHE BOOL "debug info") SET(ENABLE_NLS TRUE CACHE BOOL "enable translation") SET(XDG_DIR ${XDG_DIR} CACHE STRING "default xdg dir") SET(TERMIT_PACKAGE "termit") SET(TERMIT_PACKAGE_VERSION "2.9.4") SET(TERMIT_LOCALE_DIR "${CMAKE_INSTALL_PREFIX}/share/locale") SET(TERMIT_XDG_DIR "${XDG_DIR}/termit") SET(TERMIT_PACKAGE_NAME "termit - terminal emulator") SET(TERMIT_PACKAGE_STRING "${TERMIT_PACKAGE} ${TERMIT_PACKAGE_VERSION}") SET(TERMIT_PACKAGE_BUGREPORT "ratnikov.ev@gmail.com") CONFIGURE_FILE(${TERMIT_SOURCE_DIR}/config.h.in ${TERMIT_SOURCE_DIR}/config.h) CONFIGURE_FILE( "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/cmake/cmake_uninstall.cmake" IMMEDIATE @ONLY) ADD_CUSTOM_TARGET(uninstall "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake/cmake_uninstall.cmake") ADD_SUBDIRECTORY(doc) ADD_SUBDIRECTORY(src) IF(ENABLE_NLS) ADD_SUBDIRECTORY(po) ENDIF(ENABLE_NLS) ADD_SUBDIRECTORY(utils) ADD_SUBDIRECTORY(etc) MESSAGE("\n termit ${TERMIT_PACKAGE_VERSION}\n") MESSAGE("Prefix dir:.......... ${CMAKE_INSTALL_PREFIX}") IF(ENABLE_NLS) MESSAGE("Locales dir:......... ${TERMIT_LOCALE_DIR}") ENDIF(ENABLE_NLS) MESSAGE("Xdg dir:............. ${TERMIT_XDG_DIR}") MESSAGE("Debug:............... ${DEBUG}") MESSAGE("\n") nonstop-termit-fd89f3b/COPYING000066400000000000000000000431221176471573200162750ustar00rootroot00000000000000 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. nonstop-termit-fd89f3b/ChangeLog000066400000000000000000000134011176471573200170110ustar00rootroot00000000000000version 2.9.4 fix hyphen-used-as-minus-sign in manpage (by Thomas Koch) new options: hideTabbar (by Anurag Priyam) new Lua functions: toggleTabbar added Polish translation (by Miś Uszatek) added Danish translation added support for Lua 5.2 fixed docs version 2.9.3 fixed installing as non-root added Spanish translation (by Martintxo) added German translation (by Dennis Ploeger) updated Hungarian translation (by Peter Polonkai) apply foreground color for bold fonts added several WM-specific commandline options: --name, --class, --role version 2.9.2 fix build with --as-needed linker flags enabled (patch by Artur Frysiak) Meta, Super and Hyper in keybindings (patch by Artur Frysiak) project language set to C new Lua functions: feed feedChild fixed some compilation issues when using Gtk+3 added Japanese translation (by Nobuhiro Iwamatsu) version 2.9.1 fixed setEncoding in termit.utils module fixed possible zombie process version 2.9.0 new Lua functions: setColormap added support for system-wide rc.lua added support for using modules in rc.lua added several predefined colormaps version 2.8.1 fixed bug in currentTabIndex version 2.8.0 search in vte buffer (only for vte >= 0.26) new Lua functions forEachRow forEachVisibleRow findDlg findNext findPrev new options backspaceBinding deleteBinding setStatusbar extra warnings when compiling in DEBUG mode fixed docs version 2.7.1 display proper encoding when switching pages version 2.7.0 refactored reading table from Lua fixed working with sessions new options: imageFile - path to image to be set on the background colormap - instead of setColormap matches - instead of setMatches tabs - opened by default tabs changed default binding for 'closeTab' from 'Ctrl-w' to 'CtrlShift-w' cleanup fixed docs version 2.6.0 fixed -e option: read configs first only then execute accelerators for user menus new Lua functions setTabTitleDlg loadSessionDlg saveSessionDlg preferencesDlg quit cleanup fixed docs removed support for deprecated: use rc.lua instead of init.lua in openTab use title instead of name and workingDir instead of working_dir action in menuitem must be lua-function version 2.5.0 GPLv2 license agreement in every source file new Lua functions selection currentTab global array 'tabs' with tab settings fixed bug: hidden menu appears after reconfigure deprecated: use rc.lua instead of init.lua in openTab use title instead of name and workingDir instead of working_dir fixed docs version 2.4.0 new Lua functions setColormap version 2.3.0 read rc.lua instead of init.lua (init.lua is deprecated) new Lua functions new options audibleBell, visibleBell, setMatches, spawn, urgencyOnBell version 2.2.0 mixed modifiers (e.g. AltCtrl, AltShift, etc.) new Lua functions setTabForegroundColor, setTabBackgroundColor, bindMouse, toggleMenubar, setWindowTitle, currentTabIndex, getTabTitle, getWindowTitle new options per-tab foreground/background colors, fillTabbar, hideMenubar, changeTitle version 2.1.1 fixed typo in docs, init foreground color with "gray", proper Lua-includes when building from source version 2.1.0 added support for changing foreground color added man page cmake_minimum_required changed to 2.6.1, 2.6.0 have problems with FindLua51.cmake module fixed reconfigure when running with --init option version 2.0.0 embedded Lua - configs and sessions replaced with lua-scripts xterm-like dynamic window title version 1.3.5 added Korean translation (by SeonKon Choi) added termit.spec.in for Fedora 8 (by SeonKon Choi) fixed bug with show/hide scrollbar version 1.3.4 fixes Hungarian translation (by Peter Polonkai) version 1.3.3 added termit.SlackBuild and termit.ebuild added support for kb_policy (for shortcuts) versoin 1.3.2 fixed loading default options when no config file was found added session.example to installed docs version 1.3.1 added show_scrollbar option in popup menu and termit.cfg shell_cmd variable splitted into shell (eg bash, zsh, python, etc) and shell_cmd (eg -c 'su - root', etc) updated documentation bugfix with uninitialized GError fixed --usage output fixed statusbar encoding when loading session fixed compilation warnings version 1.3 when both -s and -e options are presented at command line load session and add tab with command added --execute/-e command-line option added hide_single_tab options in termit.cfg (hide tab tray when only one tab is opened) added configurable keybindings (example here: doc/termit.example) added support for shell_cmd in session file added transparent background options in termit.cfg (patch by Tetralet) added doc/session.example code cleanup version 1.2 tabs are reordable for Gtk versions > 2.10.0 added geometry option in termit.cfg (setting COLSxROWS) --help support added initial Translation Chinese translation (author Ming Lu) version 1.1.3 default Sans font replaced with Monospace fixed linking with option "--as-needed" (patch by Andrew Borodin) version 1.1.2 bugfix with GError when parsing config files added hungarian translation (author Peter Polonkai) added french translation (author Mallory Mollo) version 1.1.1 important for 64bit platforms: fixes a cast of a pointer to "int" use pkg-config for detecting vte library version 1.1 build system changed to CMake (http://www.cmake.org/) --version (-v) support added session support added desktop file according to "Desktop Entry Specification" v1.0 config file placement changed according to "XDG Base Directory Specification" v0.6 version 1.0.3 double-click on empty space in tabbar opens new tab in debug mode prints pid of child shell process version 1.0.2 only fixing bootstrap.sh version 1.0.1 removed unneccessary free - potential "double-free" error version 1.0 initial release nonstop-termit-fd89f3b/INSTALL000066400000000000000000000006331176471573200162730ustar00rootroot00000000000000Installation Instructions ************************* Termit requires CMake (version 2.4 or later). You can obtain CMake sources here http://cmake.org/. Run CMake generator: cmake . Then configure termit: ccmake . Then make: make And finally install: make install Package makers can specify DESTDIR: make install DESTDIR="destdir" To remove termit: make uninstall nonstop-termit-fd89f3b/TODO000066400000000000000000000004561176471573200157350ustar00rootroot00000000000000-- names for sessions -- encode displayed buffer (hmmm it seems vte doesn't support that) -- store in TermitTab only flags: SET_NAME, SET_FG_FONT, SET_BG_FONT, etc values are already stored in VteTerminal, so we can simply read VteTerminal properties on demand thus we can achieve smaller memory usage nonstop-termit-fd89f3b/cmake/000077500000000000000000000000001176471573200163205ustar00rootroot00000000000000nonstop-termit-fd89f3b/cmake/cmake_uninstall.cmake.in000066400000000000000000000030761176471573200231060ustar00rootroot00000000000000# Copyright (C) 2007-2010, Evgeny Ratnikov # # This file is part of termit. # termit is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 # as published by the Free Software Foundation. # termit 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 termit. If not, see . IF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") MESSAGE(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"") ENDIF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") FILE(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files) STRING(REGEX REPLACE "\n" ";" files "${files}") FOREACH(file ${files}) MESSAGE(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"") IF(EXISTS "$ENV{DESTDIR}${file}") EXEC_PROGRAM( "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\"" OUTPUT_VARIABLE rm_out RETURN_VALUE rm_retval ) IF(NOT "${rm_retval}" STREQUAL 0) MESSAGE(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"") ENDIF(NOT "${rm_retval}" STREQUAL 0) ELSE(EXISTS "$ENV{DESTDIR}${file}") MESSAGE(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.") ENDIF(EXISTS "$ENV{DESTDIR}${file}") ENDFOREACH(file) nonstop-termit-fd89f3b/config.h.in000066400000000000000000000022731176471573200172670ustar00rootroot00000000000000/* Copyright (C) 2007-2010, Evgeny Ratnikov This file is part of termit. termit is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation. termit 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 termit. If not, see .*/ /* Gettext locale dir */ #define LOCALEDIR "${TERMIT_LOCALE_DIR}" /* Name of package */ #define PACKAGE "${TERMIT_PACKAGE}" /* Define to the address where bug reports for this package should be sent. */ #define PACKAGE_BUGREPORT "${TERMIT_PACKAGE_BUGREPORT}" /* Define to the full name of this package. */ #define PACKAGE_NAME "${TERMIT_PACKAGE_NAME}" /* Define to the full name and version of this package. */ #define PACKAGE_STRING "${TERMIT_PACKAGE_STRING}" /* Define to the version of this package. */ #define PACKAGE_VERSION "${TERMIT_PACKAGE_VERSION}" nonstop-termit-fd89f3b/doc/000077500000000000000000000000001176471573200160055ustar00rootroot00000000000000nonstop-termit-fd89f3b/doc/CMakeLists.txt000066400000000000000000000016571176471573200205560ustar00rootroot00000000000000# Copyright (C) 2007-2010, Evgeny Ratnikov # # This file is part of termit. # termit is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 # as published by the Free Software Foundation. # termit 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 termit. If not, see . SET(TERMIT_DOCS ../COPYING README lua_api.txt rc.lua.example) INSTALL(FILES ${TERMIT_DOCS} DESTINATION ${CMAKE_INSTALL_PREFIX}/share/doc/${TERMIT_PACKAGE}) INSTALL(FILES termit.1 DESTINATION ${CMAKE_INSTALL_PREFIX}/share/man/man1) INSTALL(FILES termit.desktop DESTINATION ${CMAKE_INSTALL_PREFIX}/share/applications) nonstop-termit-fd89f3b/doc/README000066400000000000000000000015521176471573200166700ustar00rootroot00000000000000 Termit Simple terminal emulator based on vte library, extensible via lua. Features: * multiple tabs * switching encodings * sessions * configurable keybindings * embedded Lua Configuration can be changed via $HOME/.config/termit/rc.lua file (example is provided). Command-line arguments: * --version (-v) - prints version info * --init=init_file - use init_file instead of standard rc.lua * --execute=cmd - execute command (also -e) Keybindings can be configured via rc.lua. Defaults are: Alt-Left - previous tab Alt-Right - next tab Ctrl-t - open tab Ctlr-w - close tab Ctrl-Insert - copy Shift-Insert - paste Lua API is described in lua_api.txt nonstop-termit-fd89f3b/doc/lua_api.txt000066400000000000000000000150261176471573200201640ustar00rootroot00000000000000h4. Functions *activateTab(_tab_index_)* - Activates tab by index. _tab_index_ - index of tab to activate. Index of the first tab is 1. *addMenu(_menu_)* - Adds menu in menubar. _menu_ - table of TermitMenuItem type. *addPopupMenu(_menu_)* - Adds menu in popup menu, similar to addMenu. _menu_ - table of TermitMenuItem type. *bindKey(_keys_, _luaFunction_)* - Sets new keybinding. If luaFunction is nil removes keybinding. _keys_ - string with keybinding. Available modifiers are Alt Ctrl Shift Meta Super Hyper. _luaFunction_ - callback function pre. Example: don't close tab with Ctrl-w, use CtrlShift-w bindKey('Ctrl-w', nil) bindKey('CtrlShift-w', closeTab) *bindMouse(_event_, _luaFunction_)* - Sets new mouse-binding. If luaFunction is nil removes mouse-binding. _event_ - string with one of those values: DoubleClick _luaFunction_ - callback function *closeTab()* - Closes active tab. *copy()* - Copies selection into tab's buffer. *currentTab()* - Returns current tab of TermitTabInfo. *currentTabIndex()* - Returns current tab index. *feed(data)* - Interprets data as if it were data received from a terminal process. *feedChild(data)* - Sends a data to the terminal as if it were data entered by the user at the keyboard. *findDlg()* - Opens find entry. (Enabled when build with vte version >= 0.26) *findNext()* - Searches the next string matching search regex. (Enabled when build with vte version >= 0.26) *findPrev()* - Searches the previous string matching search regex. (Enabled when build with vte version >= 0.26) *forEachRow(_func_)* - For each terminal row in entire scrollback buffer executes function passing row as argument. _func_ - function to be called. *forEachVisibleRow(_func_)* - For each visible terminal row executes function passing row as argument. _func_ - function to be called. *loadSessionDlg()* - Displays "Load session" dialog. *nextTab()* - Activates next tab. *openTab(_tabInfo_)* - Opens new tab. _tabinfo_ - table of TermitTabInfo with tab settings. pre. Example: tabInfo = {} tabInfo.title = 'Zsh tab' tabInfo.command = 'zsh' tabInfo.encoding = 'UTF-8' tabInfo.workingDir = '/tmp' openTab(tabInfo) *paste()* - Pastes tab's buffer. *preferencesDlg()* - Displays "Preferences" dialog. *prevTab()* - Activates previous tab. *quit()* - Quit. *reconfigure()* - Sets all configurable variables to defaults and forces rereading rc.lua. *saveSessionDlg()* - Displays "Save session" dialog. *selection()* - Returns selected text from current tab. *setColormap(_colormap_)* - Changes colormap for active tab. _colormap_ - array with 8 or 16 or 24 colors. *setEncoding(_encoding_)* - Changes encoding for active tab. _encoding_ - string with encoding name. pre. Example: setEncoding('UTF-8') *setKbPolicy(_kb_policy_)* - Sets keyuboard policy for shortcuts. _kb_policy_ - string with one of those values: * keycode - use hardware keyboard codes (XkbLayout-independent) * keysym - use keysym values (XkbLayout-dependent) pre. Example: treat keys via current XkbLayout setKbPolicy('keysym') *setOptions(_opts_)* - Changes default options. _opts_ - table of TermitOptions type with new options: *setTabBackgroundColor(_color_)* - Changes background color for active tab. _color_ - string with new color. *setTabFont(_font_)* - Changes font for active tab. _font_ - string with new font. *setTabForegroundColor(_color_)* - Changes foreground (e.g. font) color for active tab. _color_ - string with new color. *setTabTitle(_tabTitle_)* - Changes title for active tab. _tabTitle_ - string with new tab title. *setTabTitleDlg()* - Displays "Set tab title" dialog. *setWindowTitle(_title_)* - Changes termit window title. _title_ - string with new title. *spawn(_command_) - Spawns command (works via shell). _command_ - string with command and arguments. *toggleMenubar()* - Displays or hides menubar. *toggleTabbar()* - Displays or hides tabbar. h4. Types *TermitEraseBinding* - one of those string values: * Auto - VTE_ERASE_AUTO * AsciiBksp - VTE_ERASE_ASCII_BACKSPACE * AsciiDel - VTE_ERASE_ASCII_DELETE * EraseDel - VTE_ERASE_DELETE_SEQUENCE * EraseTty - VTE_ERASE_TTY For detailed description look into Vte docs. *TermitKeybindings* - table with predefined keybindings. * closeTab - 'Ctrl-w' * copy - 'Ctrl-Insert' * nextTab - 'Alt-Right' * openTab - 'Ctrl-t' * paste - 'Shift-Insert' * prevTab - 'Alt-Left' pre. Example: enable Gnome-like tab switching keys = {} keys.nextTab = 'Ctrl-Page_Down' keys.prevTab = 'Ctrl-Page_Up' setKeys(keys) *TermitMenuItem* - table for menuitems. * accel - accelerator for menuitem. String with keybinding * action - lua-function to execute when item activated * name - name for menuitem *TermitOptions* - table with termit options. * allowChangingTitle - auto change title (similar to xterm) * audibleBell - enables audible bell * backgroundColor - background color * backspaceBinding - reaction on backspace key (one of TermitEraseBinding) * colormap - array with 8 or 16 or 24 colors * deleteBinding - reaction on delete key (one of TermitEraseBinding) * encoding - default encoding * fillTabbar - expand tabs' titles to fill whole tabbar * font - font name * foregroundColor - foreground color * geometry - cols x rows to start with * getTabTitle - lua function to generate new tab title * getWindowTitle - lua function to generate new window title * hideMenubar - hide menubar * hideTabbar - hide tabbar * hideSingleTab - hide menubar when only 1 tab present * imageFile - path to image to be set on the background * matches - table with items of TermitMatch type * scrollbackLines - the length of scrollback buffer * setStatusbar - lua function to generate new statusbar message * showScrollbar - display scrollbar * tabName - default tab name * tabs - table with items of TermitTabInfo type * transparency - use transparency level [0,1] * visibleBell - enables visible bell * urgencyOnBell - set WM-hint 'urgent' on termit window when bell * wordChars - word characters (double click selects word) *TermitTabInfo* - table with tab settings: * command * encoding * font - font string * fontSize - font size * pid - process id * title * workingDir h4. Globals *tabs* - Readonly table with tab settings, access specific tabs by index. h4. Bugs After start sometimes there is black screen. Resizing termit window helps. In options table 'tabs' field should be the last one. When loading all settings are applied in the same order as they are set in options table. So if you set tabs and only then colormap, these tabs would have default colormap. nonstop-termit-fd89f3b/doc/rc.lua.example000066400000000000000000000100521176471573200205440ustar00rootroot00000000000000require("termit.colormaps") require("termit.utils") defaults = {} defaults.windowTitle = 'Termit' defaults.tabName = 'Terminal' defaults.encoding = 'UTF-8' defaults.wordChars = '+-AA-Za-z0-9,./?%&#:_~' defaults.font = 'Terminus 12' --defaults.foregroundColor = 'gray' --defaults.backgroundColor = 'black' defaults.showScrollbar = true defaults.transparency = 0.7 --defaults.imageFile = '/tmp/img.png' defaults.hideSingleTab = false defaults.hideTabbar = false defaults.hideMenubar = false --defaults.fillTabbar = false defaults.fillTabbar = true defaults.scrollbackLines = 4096 defaults.geometry = '80x24' defaults.allowChangingTitle = false --defaults.backspaceBinding = 'AsciiBksp' --defaults.deleteBinding = 'AsciiDel' defaults.setStatusbar = function (tabInd) tab = tabs[tabInd] if tab then return tab.encoding..' Bksp: '..tab.backspaceBinding..' Del: '..tab.deleteBinding end return '' end --defaults.changeTitle = function (title) -- print('title='..title) -- newTitle = 'Termit: '..title -- return newTitle --end defaults.colormap = termit.colormaps.delicate defaults.matches = {['http[^ ]+'] = function (url) print('Matching url: '..url) end} --defaults.tabs = {{title = 'Test new tab 1'; workingDir = '/tmp'}; --{title = 'Test new tab 2'; workingDir = '/tmp'}} setOptions(defaults) bindKey('Ctrl-Page_Up', prevTab) bindKey('Ctrl-Page_Down', nextTab) bindKey('Ctrl-F', findDlg) bindKey('Ctrl-2', function () print('Hello2!') end) bindKey('Ctrl-3', function () print('Hello3!') end) bindKey('Ctrl-3', nil) -- remove previous binding -- don't close tab with Ctrl-w, use CtrlShift-w bindKey('Ctrl-w', nil) bindKey('CtrlShift-w', closeTab) setKbPolicy('keycode') bindMouse('DoubleClick', openTab) -- userMenu = {} table.insert(userMenu, {name='Close tab', action=closeTab}) table.insert(userMenu, {name='New tab name', action=function () setTabTitle('New tab name') end}) mi = {} mi.name = 'Zsh tab' mi.action = function () tabInfo = {} tabInfo.title = 'Zsh tab' tabInfo.command = 'zsh' tabInfo.encoding = 'UTF-8' tabInfo.workingDir = '/tmp' tabInfo.backspaceBinding = 'AsciiBksp' tabInfo.deleteBinding = 'EraseDel' openTab(tabInfo) end table.insert(userMenu, mi) table.insert(userMenu, {name='set red color', action=function () setTabForegroundColor('red') end}) table.insert(userMenu, {name='Reconfigure', action=reconfigure, accel='Ctrl-r'}) table.insert(userMenu, {name='Selection', action=function () print(selection()) end}) table.insert(userMenu, {name='dumpAllRows', action=function () forEachRow(print) end}) table.insert(userMenu, {name='dumpVisibleRowsToFile', action=function () termit.utils.dumpToFile(forEachVisibleRow, '/tmp/termit.dump') end}) table.insert(userMenu, {name='findNext', action=findNext, accel='Alt-n'}) table.insert(userMenu, {name='findPrev', action=findPrev, accel='Alt-p'}) table.insert(userMenu, {name='new colormap', action=function () setColormap(termit.colormaps.mikado) end}) table.insert(userMenu, {name='toggle menubar', action=function () toggleMenubar() end}) table.insert(userMenu, {name='toggle tabbar', action=function () toggleTabbar() end}) mi = {} mi.name = 'Get tab info' mi.action = function () tab = tabs[currentTabIndex()] if tab then termit.utils.printTable(tab, ' ') end end table.insert(userMenu, mi) function changeTabFontSize(delta) tab = tabs[currentTabIndex()] setTabFont(string.sub(tab.font, 1, string.find(tab.font, '%d+$') - 1)..(tab.fontSize + delta)) end table.insert(userMenu, {name='Increase font size', action=function () changeTabFontSize(1) end}) table.insert(userMenu, {name='Decrease font size', action=function () changeTabFontSize(-1) end}) table.insert(userMenu, {name='feed example', action=function () feed('example') end}) table.insert(userMenu, {name='feedChild example', action=function () feedChild('date\n') end}) table.insert(userMenu, {name='User quit', action=quit}) addMenu(userMenu, "User menu") addPopupMenu(userMenu, "User menu") addMenu(termit.utils.encMenu(), "Encodings") addPopupMenu(termit.utils.encMenu(), "Encodings") nonstop-termit-fd89f3b/doc/termit.1000066400000000000000000000207021176471573200173740ustar00rootroot00000000000000.\" Process this file with .\" groff -man -Tascii foo.1 .\" .TH TERMIT 1 "NOV 2008" Linux "User Manuals" .SH NAME termit \(hy lightweight terminal emulator .SH SYNOPSIS .B termit [\-option ...] .SH DESCRIPTION .B termit is a vte\(hybased lightweight terminal emulator. All configuration is done via Lua\(hyscripts. The only other dependencies are Gtk+ and Vte. .SH OPTIONS .BR \-h, .BR \-\-help .RS Print help .RE .BR \-v, .BR \-\-version .RS Print version number .RE .BR \-e, .BR \-\-execute = .I cmd .RS Use .I cmd as shell .RE .BR \-i, .BR \-\-init = .I file .RS Use .I file instead of default rc.lua .RE .BR \-n, .BR \-\-name = .I name .RS Use .I name in window name hint .RE .BR \-c, .BR \-\-class = .I class .RS Use .I class in window class hint .RE .BR \-r, .BR \-\-role = .I role .RS Use .I role in window role Gtk\(hyhint .RE .P termit \-\-execute=zsh \-\-init=session.lua \-\-name=TermitName \-\-class=TermitClass \-\-role=TermitRole .P .RE .SH FILES .I $HOME/.config/termit/rc.lua .RS Per user configuration file. See section .BR "TERMIT LUA API" for further details. .RE .I /usr/share/doc/termit/rc.lua.example .RS Example rc.lua file. Demonstrates usage of almost all available settings. .SH "TERMIT LUA API" .B "Functions:" .B activateTab ( .I tab_index ) Activates tab by index. tab_index \(hy index of tab to activate. Index of the first tab is 1. .P .B addMenu ( .I menu ) Adds menu in menubar. menu \(hy table of TermitMenuItem type. .P .B addPopupMenu ( .I menu ) Adds menu in popup menu, similar to addMenu. menu \(hy table of TermitMenuItem type. .P .B bindKey ( .I keys , .I luaFunction ) Sets new keybinding. If luaFunction is .I nil removes keybinding. keys \(hy string with keybinding. Available modifiers are Alt Ctrl Shift Meta Super Hyper. luaFunction \(hy callback function .P .B bindMouse ( .I event , .I luaFunction ) Sets new mouse\(hybinding. If luaFunction is .I nil removes mouse\(hybinding. event \(hy string with one of those values: DoubleClick luaFunction \(hy callback function .P .B closeTab () Closes active tab. .P .B copy () Copies selection into tab's buffer. .P .B currentTab () Returns current tab of TermitTabInfo. .P .B currentTabIndex () Returns current tab index. .P .B feed ( .I data ) Interprets data as if it were data received from a terminal process. .P .B feedChild ( .I data ) Sends a data to the terminal as if it were data entered by the user at the keyboard. .P .B findDlg () Opens search entry. (Enabled when build with vte version >= 0.26) .P .B findNext () Searches the next string matching search regex. (Enabled when build with vte version >= 0.26) .P .B findPrev () Searches the previous string matching search regex. (Enabled when build with vte version >= 0.26) .P .B forEachRow ( .I func ) For each terminal row in entire scrollback buffer executes function passing row as argument. func \(hy function to be called. .P .B forEachVisibleRow ( .I func ) For each visible terminal row executes function passing row as argument. func \(hy function to be called. .P .B loadSessionDlg () Displays "Load session" dialog. .P .B nextTab () Activates next tab. .P .B openTab ( .I tabInfo ) Opens new tab. tabinfo \(hy table of TermitTabInfo with tab settings. .P .B paste () Pastes tab's buffer. .P .B preferencesDlg () Displays "Preferences" dialog. .P .B prevTab () Activates previous tab. .P .B quit () Quit. .P .B reconfigure () Sets all configurable variables to defaults and forces rereading rc.lua. .P .B saveSessionDlg () Displays "Save session" dialog. .P .B selection () Returns selected text from current tab. .P .B setColormap ( .I colormap ) Changes colormap for active tab. colormap \(hy array with 8 or 16 or 24 colors. .P .B setEncoding ( .I encoding ) Changes encoding for active tab. encoding \(hy string with encoding name. .P .B setKbPolicy ( .I kb_policy ) Sets keyuboard policy for shortcuts. kb_policy \(hy string with one of those values: keycode \(hy use hardware keyboard codes (XkbLayout\(hyindependent) keysym \(hy use keysym values (XkbLayout\(hydependent) .P .B setOptions ( .I opts ) Changes default options. opts \(hy TermitOptions table with new options. .P .B setTabBackgroundColor ( .I color ) Changes background color for active tab. color \(hy string with new color. .P .B setTabFont ( .I font ) Changes font for active tab. font \(hy string with new font. .P .B setTabForegroundColor ( .I color ) Changes foreground (e.g. font) color for active tab. color \(hy string with new color. .P .B setTabTitle ( .I tabTitle ) Changes title for active tab. tabTitle \(hy string with new tab title. .P .B setTabTitleDlg () Displays "Set tab title" dialog. .P .B setWindowTitle ( .I title ) Changes termit window title. title \(hy string with new title. .P .B spawn ( .I command ) Spawns command (works via shell). command \(hy string with command and arguments. .P .B toggleMenubar () Displays or hides menubar. .P .P .B toggleTabbar () Displays or hides tabbar. .P .B "Types:" .B TermitEraseBinding \(hy one of those string value: Auto VTE_ERASE_AUTO AsciiBksp VTE_ERASE_ASCII_BACKSPACE AsciiDel VTE_ERASE_ASCII_DELETE EraseDel VTE_ERASE_DELETE_SEQUENCE EraseTty VTE_ERASE_TTY .P For detailed description look into Vte docs. .P .B TermitKeybindings \(hy table with predefined keybindings. closeTab 'Ctrl\(hyw' copy 'Ctrl\(hyInsert' nextTab 'Alt\(hyRight' openTab 'Ctrl\(hyt' paste 'Shift\(hyInsert' prevTab 'Alt\(hyLeft' .P .B TermitMatch \(hy table for matches. field name match regular expression field value lua callback for action on Left\(hyclick. .P .B TermitMenuItem \(hy table for menuitems. accel accelerator for menuitem. String with keybinding action lua function to execute when item activated name name for menuitem .P .B TermitOptions \(hy table with termit options. allowChangingTitle auto change title (similar to xterm) audibleBell enables audible bell backgroundColor background color backspaceBinding reaction on backspace key (one of TermitEraseBinding) colormap array with 8 or 16 or 24 colors deleteBinding reaction on delete key (one of TermitEraseBinding) encoding default encoding fillTabbar expand tabs' titles to fill whole tabbar font font name foregroundColor foreground color geometry cols x rows to start with getTabTitle lua function to generate new tab title getWindowTitle lua function to generate new window title hideMenubar hide menubar hideTabbar hide tabbar hideSingleTab hide menubar when only 1 tab present imageFile path to image to be set on the background matches table with items of TermitMatch type scrollbackLines the length of scrollback buffer setStatusbar lua function to generate new statusbar message showScrollbar display scrollbar tabName default tab name tabs table with items of TermitTabInfo type transparency use transparency level [0,1] visibleBell enables visible bell urgencyOnBell set WM\(hyhint 'urgent' on termit window when bell wordChars word characters (double click selects word) .P .B TermitTabInfo \(hy table with tab settings: command tab start command encoding current tab encoding font font string fontSize font size pid process id title tab title workingDir tab working dir .P .B "Globals:" .B tabs is the array with settings for all tabs. Access specific tab by index. .RS .SH EXAMPLES Look inside provided rc.lua.example. .SH BUGS After start sometimes there is black screen. Resizing termit window helps. .P In options table 'tabs' field should be the last one. When loading all settings are applied in the same order as they are set in options table. So if you set tabs and only then colormap, these tabs would have default colormap. .SH AUTHOR Evgeny Ratnikov .SH "SEE ALSO" .BR lua (1) nonstop-termit-fd89f3b/doc/termit.desktop000066400000000000000000000004511176471573200207040ustar00rootroot00000000000000[Desktop Entry] Name=Termit Name[ru]=Termit Type=Application Exec=termit Categories=Utility;TerminalEmulator;GTK Comment=Lightweight terminal emulator Comment[ru]=Эмулятор терминала GenericName=Terminal emulator GenericName[ru]=Эмулятор терминала Terminal=false nonstop-termit-fd89f3b/doc/termit.svg000066400000000000000000000024171176471573200200360ustar00rootroot00000000000000 2.0 TermIt terminal emulator nonstop-termit-fd89f3b/etc/000077500000000000000000000000001176471573200160135ustar00rootroot00000000000000nonstop-termit-fd89f3b/etc/CMakeLists.txt000066400000000000000000000013621176471573200205550ustar00rootroot00000000000000# Copyright (C) 2007-2010, Evgeny Ratnikov # # This file is part of termit. # termit is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 # as published by the Free Software Foundation. # termit 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 termit. If not, see . SET(TERMIT_ETC termit/rc.lua termit/colormaps.lua termit/utils.lua) INSTALL(FILES ${TERMIT_ETC} DESTINATION ${TERMIT_XDG_DIR}) nonstop-termit-fd89f3b/etc/termit/000077500000000000000000000000001176471573200173175ustar00rootroot00000000000000nonstop-termit-fd89f3b/etc/termit/colormaps.lua000066400000000000000000000026371176471573200220310ustar00rootroot00000000000000module('termit.colormaps') tango = {'#2e2e34343636', '#cccc00000000', '#4e4e9a9a0606', '#c4c4a0a00000', '#34346565a4a4', '#757550507b7b', '#060698209a9a', '#d3d3d7d7cfcf', '#555557575353', '#efef29292929', '#8a8ae2e23434', '#fcfce9e94f4f', '#72729f9fcfcf', '#adad7f7fa8a8', '#3434e2e2e2e2', '#eeeeeeeeecec'} zenburn = {'#1e2320', '#705050', '#60b48a', '#dfaf8f', '#b8c2cb', '#dc8cc3', '#486858', '#dcdccc', '#709080' ,'#dca3a3', '#c3bf9f', '#f0dfaf', '#94bff3', '#ec93d3', '#93e0e3', '#ffffff'} delicate = {'#2B2B2B', '#870000', '#5F875F', '#875F00', '#005FAF', '#5F5F87', '#008787', '#818181', '#414141', '#D70000', '#AFD7AF', '#D7AF00', '#00AFFF', '#AFAFD7', '#00D7D7', '#CECECE'} mikado = {'#322a2c', '#a04363', '#9b9329', '#bf7a29', '#6a8c8c', '#856774', '#757978', '#bcbcaf', '#46423b', '#ae837a', '#b4aa30', '#c7a551', '#74999e', '#9c818e', '#9fa590', '#c1c4bc'} parkerBrothers = {'#322a2c', '#79220E', '#344B1B', '#B45B00', '#434045', '#5C1E25', '#394745', '#AE8842', '#46423b', '#AA261F', '#76550F', '#B57F02', '#908862', '#624A35', '#393E38', '#A59058'} fishbone = {'#293b3b', '#bf5357', '#41a551', '#aea64f', '#416ea5', '#bf6053', '#714da5', '#876868', '#344040', '#bf6367', '#51a55f', '#aea75d', '#5177a5', '#bf6e63', '#7859a5', '#876f6f'} bright = {'#000000', '#CD0000', '#00CD00', '#CDCD00', '#0000CD', '#CD00CD', '#00CDCD', '#E5E5E5', '#4D4D4D', '#ff0000', '#00ff00', '#00ffff', '#0000ff', '#ff00ff', '#00ffff', '#ffffff'} nonstop-termit-fd89f3b/etc/termit/rc.lua000066400000000000000000000010201176471573200204170ustar00rootroot00000000000000defaults = {} defaults.windowTitle = 'Termit' defaults.tabName = 'Terminal' defaults.encoding = 'UTF-8' defaults.wordChars = '+-AA-Za-z0-9,./?%&#:_~' defaults.scrollbackLines = 4096 defaults.font = 'Monospace 10' defaults.geometry = '80x24' defaults.hideSingleTab = false defaults.showScrollbar = true defaults.fillTabbar = false defaults.hideMenubar = false defaults.allowChangingTitle = false defaults.visibleBell = false defaults.audibleBell = false defaults.urgencyOnBell = false setOptions(defaults) setKbPolicy('keysym') nonstop-termit-fd89f3b/etc/termit/utils.lua000066400000000000000000000022471176471573200211670ustar00rootroot00000000000000local io = io local pairs, print = pairs, print local table, tostring, type = table, tostring, type local setEncoding = setEncoding module('termit.utils') function encMenu () encodings = {'UTF-8', 'KOI8-R', 'CP1251', 'CP866'} menu = {} for k, v in pairs(encodings) do table.insert(menu, {name = v; action = function () setEncoding(v) end}) end return menu end function pairsByKeys(t, f) local a = {} for n in pairs(t) do table.insert(a, n) end table.sort(a, f) local i = 0 -- iterator variable local iter = function () -- iterator function i = i + 1 if a[i] == nil then return nil else return a[i], t[a[i]] end end return iter end function printTable(tbl, indent) for k, v in pairsByKeys(tbl) do if type(v) == 'table' then print(indent..k..':') local_indent = indent..' ' printTable(v, local_indent) else print(indent..tostring(k)..'='..tostring(v)) end end end function dumpToFile(func, file) io.output(io.open(file, 'w+')) callback = function (str) io.write(str..'\n') end func(callback) io.close() end nonstop-termit-fd89f3b/po/000077500000000000000000000000001176471573200156565ustar00rootroot00000000000000nonstop-termit-fd89f3b/po/CMakeLists.txt000066400000000000000000000044101176471573200204150ustar00rootroot00000000000000SET(PO_FILES de.po es.po fr.po hu.po ja.po ko.po pl.po ru.po zh_TW.po) SET(COPYRIGHT_HOLDER "Evgeny Ratnikov") SET(POT_FILE termit.pot) INCLUDE(${TERMIT_SOURCE_DIR}/src/Sources.cmake) FIND_PROGRAM(XGETTEXT_EXECUTABLE xgettext) FIND_PROGRAM(MSGFMT_EXECUTABLE msgfmt) FIND_PROGRAM(MSGMERGE_EXECUTABLE msgmerge) SET(ENABLE_NLS FALSE) IF(XGETTEXT_EXECUTABLE AND MSGFMT_EXECUTABLE AND MSGMERGE_EXECUTABLE) SET(ENABLE_NLS TRUE) ENDIF(XGETTEXT_EXECUTABLE AND MSGFMT_EXECUTABLE AND MSGMERGE_EXECUTABLE) IF(NOT ENABLE_NLS) MESSAGE(SEND_ERROR "gettext utils not found, disabling gettext") ELSE(NOT ENABLE_NLS) # Create PO Template file 'termit.pot' SET(PO_SOURCE_FILES) SET(PO_SOURCE_FILES_FULL_PATH) FOREACH(SRC_FILE ${TERMIT_SRCS}) SET(PO_SOURCE_FILES ${PO_SOURCE_FILES} src/${SRC_FILE}) SET(PO_SOURCE_FILES_FULL_PATH ${PO_SOURCE_FILES_FULL_PATH} ${TERMIT_SOURCE_DIR}/src/${SRC_FILE}) ENDFOREACH(SRC_FILE ${TERMIT_SRCS}) ADD_CUSTOM_COMMAND( OUTPUT ${POT_FILE} COMMAND ${XGETTEXT_EXECUTABLE} ARGS -o ${POT_FILE} -s --directory=${TERMIT_SOURCE_DIR} --omit-header --msgid-bugs-address=${TERMIT_PACKAGE_BUGREPORT} -c --keyword=_ --copyright-holder=${COPYRIGHT_HOLDER} ${PO_SOURCE_FILES} DEPENDS ${PO_SOURCE_FILES_FULL_PATH}) ADD_CUSTOM_TARGET(pot DEPENDS ${PO_SOURCE_FILES_FULL_PATH} ${POT_FILE}) # Update .po files and compile them into .gmo files SET(GMO_FILES) FOREACH(PO_FILE ${PO_FILES}) GET_FILENAME_COMPONENT(LANG ${PO_FILE} NAME_WE) SET(_gmofile ${CMAKE_CURRENT_BINARY_DIR}/${LANG}.gmo) ADD_CUSTOM_COMMAND( OUTPUT ${_gmofile} COMMAND ${MSGMERGE_EXECUTABLE} ARGS --quiet --update -s ${CMAKE_CURRENT_SOURCE_DIR}/${PO_FILE} ${POT_FILE} COMMAND ${MSGFMT_EXECUTABLE} ARGS -o ${_gmofile} ${CMAKE_CURRENT_SOURCE_DIR}/${PO_FILE} DEPENDS ${POT_FILE} ${CMAKE_CURRENT_SOURCE_DIR}/${PO_FILE} COMMENT "Language: ${LANG}") INSTALL(FILES ${_gmofile} DESTINATION ${TERMIT_LOCALE_DIR}/${LANG}/LC_MESSAGES RENAME termit.mo) SET(GMO_FILES ${GMO_FILES} ${_gmofile}) ENDFOREACH(PO_FILE ${PO_FILES}) ADD_CUSTOM_TARGET(gmo ALL DEPENDS ${GMO_FILES}) ADD_DEPENDENCIES(gmo pot) SET(TERMIT_DISTR_FILES "${POT_FILE} ${PO_FILES} CMakeLists.txt") SET(ENV{QQ} $ENV{QQ} ${TERMIT_DISTR_FILES}) ENDIF(NOT ENABLE_NLS) nonstop-termit-fd89f3b/po/da.po000066400000000000000000000035631176471573200166110ustar00rootroot00000000000000#: src/termit_preferences.c:299 msgid "Audible bell" msgstr "Hørbar klokke" #: src/termit_preferences.c:260 msgid "Background" msgstr "Baggrund" #: src/termit_preferences.c:276 msgid "Background image" msgstr "Baggrunds billede" #: src/termit_core_api.c:433 msgid "Cannot create a new tab" msgstr "Kan ikke oprette ny fane" #: src/termit_core_api.c:361 msgid "Cannot parse command. Creating tab with shell" msgstr "Kan ikke tolke kommando. Opretter fane med skal" #: src/termit.c:194 msgid "Edit" msgstr "Redigér" #: src/termit.c:177 msgid "File" msgstr "Fil" #: src/termit_preferences.c:242 msgid "Font" msgstr "Skrifttype" #: src/termit_preferences.c:251 msgid "Foreground" msgstr "Forgrund" #. g_signal_connect(btn_switch_image_file, "toggled", G_CALLBACK(dlg_switch_image_file), btn_image_file); #. TERMIT_PREFERENCE_ROW2(btn_switch_image_file, btn_image_file); #: src/termit_preferences.c:283 msgid "Image" msgstr "Billede" #: src/callbacks.c:383 msgid "Open session" msgstr "Åben session" #: src/callbacks.c:353 msgid "Save session" msgstr "Gem session" #: src/termit.c:234 msgid "Scrollbar" msgstr "Rullebjælke" #: src/termit.c:209 msgid "Sessions" msgstr "Sessioner" #. Edit menu #: src/termit.c:189 src/termit.c:229 msgid "Set tab name..." msgstr "Angiv fanenavn..." #: src/callbacks.c:37 msgid "" "Several tabs are opened.\n" "Close anyway?" msgstr "" "Adskillige faner åbne.\n" "Luk alligevel?" #: src/callbacks.c:262 src/callbacks.c:271 msgid "Tab name" msgstr "Fanenavn" #: src/termit_preferences.c:235 msgid "Title" msgstr "Titel" #: src/termit_preferences.c:291 msgid "Transparency" msgstr "Gennemsigtighed" #: src/sessions.c:90 #, c-format msgid "Unable to create directory '%s': %s" msgstr "Kan ikke oprette sti '%s': %s" #: src/termit_preferences.c:307 msgid "Visible bell" msgstr "Synlige klokke" #: src/termit_preferences.c:267 msgid "images" msgstr "billeder" nonstop-termit-fd89f3b/po/de.po000066400000000000000000000046661176471573200166220ustar00rootroot00000000000000# Termit translation file. # Copyright (C) 2007 # This file is distributed under the same license as the termit package. # Evgeny Ratnikov ratnikov.ev@gmail.com 2007. # msgid "" msgstr "" "Project-Id-Version: 1.0\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: \n" "PO-Revision-Date: 2011-12-19 21:23+0100\n" "Last-Translator: Dennis Ploeger \n" "Language-Team: de\n" "Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: src/termit_preferences.c:299 msgid "Audible bell" msgstr "Glocke" #: src/termit_preferences.c:260 msgid "Background" msgstr "Hintergrund" #: src/termit_preferences.c:276 msgid "Background image" msgstr "Hintergrundbild" #: src/termit_core_api.c:443 msgid "Cannot create a new tab" msgstr "Konnte keinen neuen Tab erzeugen" #: src/termit_core_api.c:371 msgid "Cannot parse command. Creating tab with shell" msgstr "" "Konnte Befehl nicht untersuchen. Erstelle einen Tab mit der Kommandozeile" #: src/termit.c:194 msgid "Edit" msgstr "Bearbeiten" #: src/termit.c:177 msgid "File" msgstr "Datei" #: src/termit_preferences.c:242 msgid "Font" msgstr "Schriftart" #: src/termit_preferences.c:251 msgid "Foreground" msgstr "Vordergrund" #. g_signal_connect(btn_switch_image_file, "toggled", G_CALLBACK(dlg_switch_image_file), btn_image_file); #. TERMIT_PREFERENCE_ROW2(btn_switch_image_file, btn_image_file); #: src/termit_preferences.c:283 msgid "Image" msgstr "Bild" #: src/callbacks.c:383 msgid "Open session" msgstr "Sitzung öffnen" #: src/callbacks.c:353 msgid "Save session" msgstr "Sitzung speichern" #: src/termit.c:234 msgid "Scrollbar" msgstr "Bildlaufleiste" #: src/termit.c:209 msgid "Sessions" msgstr "Sitzungen" #. Edit menu #: src/termit.c:189 src/termit.c:229 msgid "Set tab name..." msgstr "Tab-Namen setzen..." #: src/callbacks.c:37 msgid "" "Several tabs are opened.\n" "Close anyway?" msgstr "" "Mehrere Tabs sind geöffnet.\n" "Trotzdem schließen?" #: src/callbacks.c:262 src/callbacks.c:271 msgid "Tab name" msgstr "Tab-Name" #: src/termit_preferences.c:235 msgid "Title" msgstr "Titel" #: src/termit_preferences.c:291 msgid "Transparency" msgstr "Transparenz" #: src/sessions.c:90 #, c-format msgid "Unable to create directory '%s': %s" msgstr "Konnte Verzeichnis '%s' nicht erstellen: %s" #: src/termit_preferences.c:307 msgid "Visible bell" msgstr "Sichtbare Glocke" #: src/termit_preferences.c:267 msgid "images" msgstr "Bilder" nonstop-termit-fd89f3b/po/es.po000066400000000000000000000046261176471573200166350ustar00rootroot00000000000000# Termit translation file. # Copyright (C) 2007 # This file is distributed under the same license as the termit package. # Evgeny Ratnikov ratnikov.ev@gmail.com 2007. # msgid "" msgstr "" "Project-Id-Version: \n" "POT-Creation-Date: \n" "PO-Revision-Date: \n" "Last-Translator: Martintxo \n" "Language-Team: \n" "Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" #: src/termit_preferences.c:299 msgid "Audible bell" msgstr "Timbre audible" #: src/termit_preferences.c:260 msgid "Background" msgstr "Fondo" #: src/termit_preferences.c:276 msgid "Background image" msgstr "Imagen de fondo" #: src/termit_core_api.c:443 msgid "Cannot create a new tab" msgstr "No se puede crear una nueva pestaña" #: src/termit_core_api.c:371 msgid "Cannot parse command. Creating tab with shell" msgstr "El comando no se entiende. Creando una nueva pestaña con shell" #: src/termit.c:194 msgid "Edit" msgstr "Editar" #: src/termit.c:177 msgid "File" msgstr "Archivo" #: src/termit_preferences.c:242 msgid "Font" msgstr "Tipografía" #: src/termit_preferences.c:251 msgid "Foreground" msgstr "Frente" #. g_signal_connect(btn_switch_image_file, "toggled", G_CALLBACK(dlg_switch_image_file), btn_image_file); #. TERMIT_PREFERENCE_ROW2(btn_switch_image_file, btn_image_file); #: src/termit_preferences.c:283 msgid "Image" msgstr "Imagen" #: src/callbacks.c:383 msgid "Open session" msgstr "Abrir sesión" #: src/callbacks.c:353 msgid "Save session" msgstr "Guardar sesión" #: src/termit.c:234 msgid "Scrollbar" msgstr "Barra de desplazamiento" #: src/termit.c:209 msgid "Sessions" msgstr "Sesiones" #. Edit menu #: src/termit.c:189 src/termit.c:229 msgid "Set tab name..." msgstr "Establece el nombre de la pestaña" #: src/callbacks.c:37 msgid "" "Several tabs are opened.\n" "Close anyway?" msgstr "" "Hay varias pestañas abiertas.\n" "¿Cerrarlas todas?" #: src/callbacks.c:262 src/callbacks.c:271 msgid "Tab name" msgstr "Nombre de la pestaña" #: src/termit_preferences.c:235 msgid "Title" msgstr "Título" #: src/termit_preferences.c:291 msgid "Transparency" msgstr "Transparencia" #: src/sessions.c:90 #, c-format msgid "Unable to create directory '%s': %s" msgstr "No se puede crear el directorio '%s': %s." #: src/termit_preferences.c:307 msgid "Visible bell" msgstr "Timbre visible" #: src/termit_preferences.c:267 msgid "images" msgstr "imágenes" nonstop-termit-fd89f3b/po/fr.po000066400000000000000000000046001176471573200166250ustar00rootroot00000000000000msgid "" msgstr "" "Project-Id-Version: Termit 1.1.1\n" "POT-Creation-Date: \n" "PO-Revision-Date: 2008-01-22 11:12+0100\n" "Last-Translator: Mallory Mollo \n" "Language-Team: Mallory Mollo \n" "Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Poedit-Language: French\n" "X-Poedit-Country: FRANCE\n" #: src/termit_preferences.c:299 msgid "Audible bell" msgstr "" #: src/termit_preferences.c:260 msgid "Background" msgstr "" #: src/termit_preferences.c:276 msgid "Background image" msgstr "" #: src/termit_core_api.c:443 msgid "Cannot create a new tab" msgstr "Impossible de créer un nouvel onglet" #: src/termit_core_api.c:371 msgid "Cannot parse command. Creating tab with shell" msgstr "" #: src/termit.c:194 msgid "Edit" msgstr "Éditer" #: src/termit.c:177 msgid "File" msgstr "Fichier" #: src/termit_preferences.c:242 msgid "Font" msgstr "" #: src/termit_preferences.c:251 msgid "Foreground" msgstr "" #. g_signal_connect(btn_switch_image_file, "toggled", G_CALLBACK(dlg_switch_image_file), btn_image_file); #. TERMIT_PREFERENCE_ROW2(btn_switch_image_file, btn_image_file); #: src/termit_preferences.c:283 msgid "Image" msgstr "" #: src/callbacks.c:383 msgid "Open session" msgstr "Ouvrir une session" #: src/callbacks.c:353 msgid "Save session" msgstr "Enregistrer la session" #: src/termit.c:234 msgid "Scrollbar" msgstr "" #: src/termit.c:209 msgid "Sessions" msgstr "Sessions" #. Edit menu #: src/termit.c:189 src/termit.c:229 msgid "Set tab name..." msgstr "Définir le nom de l'onglet..." #: src/callbacks.c:37 msgid "" "Several tabs are opened.\n" "Close anyway?" msgstr "" "Vous êtes sur le point de fermer plusieurs onglets.\n" "Voulez-vous vraiment continuer ?" #: src/callbacks.c:262 src/callbacks.c:271 msgid "Tab name" msgstr "Nom de l'onglet" #: src/termit_preferences.c:235 #, fuzzy msgid "Title" msgstr "Fichier" #: src/termit_preferences.c:291 msgid "Transparency" msgstr "" #: src/sessions.c:90 #, c-format msgid "Unable to create directory '%s': %s" msgstr "Impossible de créer le dossier '%s': %s" #: src/termit_preferences.c:307 msgid "Visible bell" msgstr "" #: src/termit_preferences.c:267 msgid "images" msgstr "" #~ msgid "Bookmarks" #~ msgstr "Marques-page" #~ msgid "Encoding" #~ msgstr "Encodage" #~ msgid "Select font" #~ msgstr "Définir la police" nonstop-termit-fd89f3b/po/hu.po000066400000000000000000000047051176471573200166400ustar00rootroot00000000000000# Termit translation file. # Copyright (C) 2007 # This file is distributed under the same license as the termit package. # Evgeny Ratnikov ratnikov.ev@gmail.com 2007. # msgid "" msgstr "" "Project-Id-Version: 1.0\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: \n" "PO-Revision-Date: 2011-12-19 21:23+0100\n" "Last-Translator: Peter Polonkai \n" "Language-Team: hu\n" "Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: src/termit_preferences.c:299 msgid "Audible bell" msgstr "Hallható figyelmeztetés" #: src/termit_preferences.c:260 msgid "Background" msgstr "Háttér" #: src/termit_preferences.c:276 msgid "Background image" msgstr "Háttérkép" #: src/termit_core_api.c:443 msgid "Cannot create a new tab" msgstr "Nem sikerült új fület létrehozni" #: src/termit_core_api.c:371 msgid "Cannot parse command. Creating tab with shell" msgstr "" "Nem lehetséges a parancs értelmezése. Fül létrehozása shell segítségével" #: src/termit.c:194 msgid "Edit" msgstr "Szerkesztés" #: src/termit.c:177 msgid "File" msgstr "Fájl" #: src/termit_preferences.c:242 msgid "Font" msgstr "Betűtípus" #: src/termit_preferences.c:251 msgid "Foreground" msgstr "Előtér" #. g_signal_connect(btn_switch_image_file, "toggled", G_CALLBACK(dlg_switch_image_file), btn_image_file); #. TERMIT_PREFERENCE_ROW2(btn_switch_image_file, btn_image_file); #: src/termit_preferences.c:283 msgid "Image" msgstr "Kép" #: src/callbacks.c:383 msgid "Open session" msgstr "Megnyitás" #: src/callbacks.c:353 msgid "Save session" msgstr "Mentés" #: src/termit.c:234 msgid "Scrollbar" msgstr "Gördítősáv" #: src/termit.c:209 msgid "Sessions" msgstr "Munkamenetek" #. Edit menu #: src/termit.c:189 src/termit.c:229 msgid "Set tab name..." msgstr "Fül átnevezése..." #: src/callbacks.c:37 msgid "" "Several tabs are opened.\n" "Close anyway?" msgstr "" "Több fül is nyitva van.\n" "Bezárja mind?" #: src/callbacks.c:262 src/callbacks.c:271 msgid "Tab name" msgstr "Fül neve" #: src/termit_preferences.c:235 msgid "Title" msgstr "Cím" #: src/termit_preferences.c:291 msgid "Transparency" msgstr "Átlátszóság" #: src/sessions.c:90 #, c-format msgid "Unable to create directory '%s': %s" msgstr "A könyvtár létrehozása sikertelen '%s': %s" #: src/termit_preferences.c:307 msgid "Visible bell" msgstr "Látható figyelmeztetés" #: src/termit_preferences.c:267 msgid "images" msgstr "képek" nonstop-termit-fd89f3b/po/ja.po000066400000000000000000000046301176471573200166130ustar00rootroot00000000000000# Copyright (c) 2011 Nobuhiro Iwamatsu msgid "" msgstr "" "Project-Id-Version: termit japanese translate\n" "POT-Creation-Date: \n" "PO-Revision-Date: 2011-09-01 02:28+0900\n" "Last-Translator: Nobuhiro Iwamatsu \n" "Language-Team: \n" "Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Poedit-Language: Japanese\n" "X-Poedit-Country: JAPAN\n" #: src/termit_preferences.c:299 msgid "Audible bell" msgstr "可聴ベル" #: src/termit_preferences.c:260 msgid "Background" msgstr "背景" #: src/termit_preferences.c:276 msgid "Background image" msgstr "背景画像" #: src/termit_core_api.c:443 msgid "Cannot create a new tab" msgstr "新しいタブを作成できません" #: src/termit_core_api.c:371 msgid "Cannot parse command. Creating tab with shell" msgstr "コマンドを解析できません。シェル経由でタブを作成します" #: src/termit.c:194 msgid "Edit" msgstr "編集" #: src/termit.c:177 msgid "File" msgstr "ファイル" #: src/termit_preferences.c:242 msgid "Font" msgstr "フォント" #: src/termit_preferences.c:251 msgid "Foreground" msgstr "前景" #. g_signal_connect(btn_switch_image_file, "toggled", G_CALLBACK(dlg_switch_image_file), btn_image_file); #. TERMIT_PREFERENCE_ROW2(btn_switch_image_file, btn_image_file); #: src/termit_preferences.c:283 msgid "Image" msgstr "画像" #: src/callbacks.c:383 msgid "Open session" msgstr "セッションを開く" #: src/callbacks.c:353 msgid "Save session" msgstr "セッションを保存する" #: src/termit.c:234 msgid "Scrollbar" msgstr "スクロールバー" #: src/termit.c:209 msgid "Sessions" msgstr "セッション" #. Edit menu #: src/termit.c:189 src/termit.c:229 msgid "Set tab name..." msgstr "タブ名を設定する" #: src/callbacks.c:37 msgid "" "Several tabs are opened.\n" "Close anyway?" msgstr "終了しますか?" #: src/callbacks.c:262 src/callbacks.c:271 msgid "Tab name" msgstr "タブ名" #: src/termit_preferences.c:235 msgid "Title" msgstr "タイトル" #: src/termit_preferences.c:291 msgid "Transparency" msgstr "透過" #: src/sessions.c:90 #, c-format msgid "Unable to create directory '%s': %s" msgstr "ディレクトリ '%s' が生成できません: %s" #: src/termit_preferences.c:307 msgid "Visible bell" msgstr "可視ベル" #: src/termit_preferences.c:267 msgid "images" msgstr "画像" nonstop-termit-fd89f3b/po/ko.po000066400000000000000000000046411176471573200166340ustar00rootroot00000000000000msgid "" msgstr "" "Project-Id-Version: termit korean translate\n" "POT-Creation-Date: \n" "PO-Revision-Date: 2008-09-02 05:26+0900\n" "Last-Translator: SeonKon Choi \n" "Language-Team: \n" "Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Poedit-Language: Korean\n" "X-Poedit-Country: KOREA, REPUBLIC OF\n" #: src/termit_preferences.c:299 msgid "Audible bell" msgstr "" #: src/termit_preferences.c:260 msgid "Background" msgstr "" #: src/termit_preferences.c:276 msgid "Background image" msgstr "" #: src/termit_core_api.c:443 msgid "Cannot create a new tab" msgstr "새 탭을 만들 수 없습니다" #: src/termit_core_api.c:371 msgid "Cannot parse command. Creating tab with shell" msgstr "명령을 해석할 수 없습니다. 쉘을 이용한 새 탭을 만듭니다" #: src/termit.c:194 msgid "Edit" msgstr "편집" #: src/termit.c:177 msgid "File" msgstr "파일" #: src/termit_preferences.c:242 msgid "Font" msgstr "" #: src/termit_preferences.c:251 msgid "Foreground" msgstr "" #. g_signal_connect(btn_switch_image_file, "toggled", G_CALLBACK(dlg_switch_image_file), btn_image_file); #. TERMIT_PREFERENCE_ROW2(btn_switch_image_file, btn_image_file); #: src/termit_preferences.c:283 msgid "Image" msgstr "" #: src/callbacks.c:383 msgid "Open session" msgstr "세션 열기" #: src/callbacks.c:353 msgid "Save session" msgstr "세션 저장" #: src/termit.c:234 msgid "Scrollbar" msgstr "스크롤 바" #: src/termit.c:209 msgid "Sessions" msgstr "세션" #. Edit menu #: src/termit.c:189 src/termit.c:229 msgid "Set tab name..." msgstr "탭 이름 바꾸기" #: src/callbacks.c:37 msgid "" "Several tabs are opened.\n" "Close anyway?" msgstr "" "다른 탭들이 아직 열려 있습니다.\n" "전부 닫고 종료할까요 ?" #: src/callbacks.c:262 src/callbacks.c:271 msgid "Tab name" msgstr "탭 이름" #: src/termit_preferences.c:235 #, fuzzy msgid "Title" msgstr "파일" #: src/termit_preferences.c:291 msgid "Transparency" msgstr "" #: src/sessions.c:90 #, c-format msgid "Unable to create directory '%s': %s" msgstr "디렉토리를 만들 수 없습니다 '%s': %s" #: src/termit_preferences.c:307 msgid "Visible bell" msgstr "" #: src/termit_preferences.c:267 msgid "images" msgstr "" #~ msgid "Bookmarks" #~ msgstr "책갈피" #~ msgid "Encoding" #~ msgstr "문자집합" #~ msgid "Select font" #~ msgstr "글꼴 바꾸기" nonstop-termit-fd89f3b/po/pl.po000066400000000000000000000047771176471573200166500ustar00rootroot00000000000000# Polish translation of termit. # Copyright (C) 2007 # This file is distributed under the same license as the termit package. # Miś Uszatek , 2012 # msgid "" msgstr "" "Project-Id-Version: termit-2.9.3\n" "POT-Creation-Date: \n" "PO-Revision-Date: 2012-05-02 20:02+0100\n" "Last-Translator: Miś Uszatek \n" "Language-Team: Polish\n" "Language: pl\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 " "|| n%100>=20) ? 1 : 2);\n" #: src/termit_preferences.c:299 msgid "Audible bell" msgstr "Głośny dzwonek" #: src/termit_preferences.c:260 msgid "Background" msgstr "Tło" #: src/termit_preferences.c:276 msgid "Background image" msgstr "Obraz tła" #: src/termit_core_api.c:443 msgid "Cannot create a new tab" msgstr "Nie można utworzyć nowej karty" #: src/termit_core_api.c:371 msgid "Cannot parse command. Creating tab with shell" msgstr "Nie można przetworzyć polecenia. Tworzenia karty z powłoki" #: src/termit.c:194 msgid "Edit" msgstr "Edycja" #: src/termit.c:177 msgid "File" msgstr "Plik" #: src/termit_preferences.c:242 msgid "Font" msgstr "Czcionka" #: src/termit_preferences.c:251 msgid "Foreground" msgstr "Pierwszy plan" #. g_signal_connect(btn_switch_image_file, "toggled", G_CALLBACK(dlg_switch_image_file), btn_image_file); #. TERMIT_PREFERENCE_ROW2(btn_switch_image_file, btn_image_file); #: src/termit_preferences.c:283 msgid "Image" msgstr "Obraz" #: src/callbacks.c:383 msgid "Open session" msgstr "Otwórz sesje" #: src/callbacks.c:353 msgid "Save session" msgstr "Zapisz sesje " #: src/termit.c:234 msgid "Scrollbar" msgstr "Pasek przewijania" #: src/termit.c:209 msgid "Sessions" msgstr "Sesja" #. Edit menu #: src/termit.c:189 src/termit.c:229 msgid "Set tab name..." msgstr "Ustaw nazwe karty..." #: src/callbacks.c:37 msgid "" "Several tabs are opened.\n" "Close anyway?" msgstr "" "Kilka kart jest otwartych.\n" "Zamknąć pomimo to?" #: src/callbacks.c:262 src/callbacks.c:271 msgid "Tab name" msgstr "Nazwa Karty" #: src/termit_preferences.c:235 msgid "Title" msgstr "Tytuł" #: src/termit_preferences.c:291 msgid "Transparency" msgstr "Przezroczystość" #: src/sessions.c:90 #, c-format msgid "Unable to create directory '%s': %s" msgstr "Nie można utworzyć katalogu '%s': %s" #: src/termit_preferences.c:307 msgid "Visible bell" msgstr "Widoczny dzwonek" #: src/termit_preferences.c:267 msgid "images" msgstr "obrazy" nonstop-termit-fd89f3b/po/ru.po000066400000000000000000000051571176471573200166540ustar00rootroot00000000000000# Termit translation file. # Copyright (C) 2007 # This file is distributed under the same license as the termit package. # Evgeny Ratnikov ratnikov.ev@gmail.com 2007. # msgid "" msgstr "" "Project-Id-Version: 1.0\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2007-09-25 09:19+0400\n" "PO-Revision-Date: 2007-12-15 18:05+0400\n" "Last-Translator: Evgeny V. Ratnikov ratnikov.ev@gmail.com\n" "Language-Team: ru_RU\n" "Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: src/termit_preferences.c:299 msgid "Audible bell" msgstr "" #: src/termit_preferences.c:260 msgid "Background" msgstr "" #: src/termit_preferences.c:276 msgid "Background image" msgstr "" #: src/termit_core_api.c:443 msgid "Cannot create a new tab" msgstr "Ошибка открытия новой вкладки" #: src/termit_core_api.c:371 msgid "Cannot parse command. Creating tab with shell" msgstr "" #: src/termit.c:194 msgid "Edit" msgstr "Правка" #: src/termit.c:177 msgid "File" msgstr "Файл" #: src/termit_preferences.c:242 msgid "Font" msgstr "" #: src/termit_preferences.c:251 msgid "Foreground" msgstr "" #. g_signal_connect(btn_switch_image_file, "toggled", G_CALLBACK(dlg_switch_image_file), btn_image_file); #. TERMIT_PREFERENCE_ROW2(btn_switch_image_file, btn_image_file); #: src/termit_preferences.c:283 msgid "Image" msgstr "" #: src/callbacks.c:383 msgid "Open session" msgstr "Открыть сессию" #: src/callbacks.c:353 msgid "Save session" msgstr "Сохранить сессию" #: src/termit.c:234 msgid "Scrollbar" msgstr "Полоса прокрутки" #: src/termit.c:209 msgid "Sessions" msgstr "Сессии" #. Edit menu #: src/termit.c:189 src/termit.c:229 msgid "Set tab name..." msgstr "Заголовок вкладки" #: src/callbacks.c:37 msgid "" "Several tabs are opened.\n" "Close anyway?" msgstr "" "Открыто несколько вкладок.\n" "Закрыть?" #: src/callbacks.c:262 src/callbacks.c:271 msgid "Tab name" msgstr "Заголовок вкладки" #: src/termit_preferences.c:235 #, fuzzy msgid "Title" msgstr "Файл" #: src/termit_preferences.c:291 msgid "Transparency" msgstr "" #: src/sessions.c:90 #, c-format msgid "Unable to create directory '%s': %s" msgstr "Невозможно создать директорию '%s': %s" #: src/termit_preferences.c:307 msgid "Visible bell" msgstr "" #: src/termit_preferences.c:267 msgid "images" msgstr "" #~ msgid "Bookmarks" #~ msgstr "Закладки" #~ msgid "Encoding" #~ msgstr "Кодировка" #~ msgid "Select font" #~ msgstr "Выбор шрифта" nonstop-termit-fd89f3b/po/termit.pot000066400000000000000000000030471176471573200177120ustar00rootroot00000000000000#: src/termit_preferences.c:299 msgid "Audible bell" msgstr "" #: src/termit_preferences.c:260 msgid "Background" msgstr "" #: src/termit_preferences.c:276 msgid "Background image" msgstr "" #: src/termit_core_api.c:443 msgid "Cannot create a new tab" msgstr "" #: src/termit_core_api.c:371 msgid "Cannot parse command. Creating tab with shell" msgstr "" #: src/termit.c:194 msgid "Edit" msgstr "" #: src/termit.c:177 msgid "File" msgstr "" #: src/termit_preferences.c:242 msgid "Font" msgstr "" #: src/termit_preferences.c:251 msgid "Foreground" msgstr "" #. g_signal_connect(btn_switch_image_file, "toggled", G_CALLBACK(dlg_switch_image_file), btn_image_file); #. TERMIT_PREFERENCE_ROW2(btn_switch_image_file, btn_image_file); #: src/termit_preferences.c:283 msgid "Image" msgstr "" #: src/callbacks.c:383 msgid "Open session" msgstr "" #: src/callbacks.c:353 msgid "Save session" msgstr "" #: src/termit.c:234 msgid "Scrollbar" msgstr "" #: src/termit.c:209 msgid "Sessions" msgstr "" #. Edit menu #: src/termit.c:189 src/termit.c:229 msgid "Set tab name..." msgstr "" #: src/callbacks.c:37 msgid "" "Several tabs are opened.\n" "Close anyway?" msgstr "" #: src/callbacks.c:262 src/callbacks.c:271 msgid "Tab name" msgstr "" #: src/termit_preferences.c:235 msgid "Title" msgstr "" #: src/termit_preferences.c:291 msgid "Transparency" msgstr "" #: src/sessions.c:90 #, c-format msgid "Unable to create directory '%s': %s" msgstr "" #: src/termit_preferences.c:307 msgid "Visible bell" msgstr "" #: src/termit_preferences.c:267 msgid "images" msgstr "" nonstop-termit-fd89f3b/po/zh_TW.po000066400000000000000000000045121176471573200172530ustar00rootroot00000000000000# Traditional Chinese messages for termit. # Copyright (C) 2008 Tetralet . # This file is distributed under the same license as termit. # msgid "" msgstr "" "Project-Id-Version: termit\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2008-02-05 22:50+0000\n" "PO-Revision-Date: 2008-02-20 11:18+0800\n" "Last-Translator: Tetralet \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: src/termit_preferences.c:299 msgid "Audible bell" msgstr "" #: src/termit_preferences.c:260 msgid "Background" msgstr "" #: src/termit_preferences.c:276 msgid "Background image" msgstr "" #: src/termit_core_api.c:443 msgid "Cannot create a new tab" msgstr "無法建立新分頁" #: src/termit_core_api.c:371 msgid "Cannot parse command. Creating tab with shell" msgstr "" #: src/termit.c:194 msgid "Edit" msgstr "編輯" #: src/termit.c:177 msgid "File" msgstr "檔案" #: src/termit_preferences.c:242 msgid "Font" msgstr "" #: src/termit_preferences.c:251 msgid "Foreground" msgstr "" #. g_signal_connect(btn_switch_image_file, "toggled", G_CALLBACK(dlg_switch_image_file), btn_image_file); #. TERMIT_PREFERENCE_ROW2(btn_switch_image_file, btn_image_file); #: src/termit_preferences.c:283 msgid "Image" msgstr "" #: src/callbacks.c:383 msgid "Open session" msgstr "開啟作業階段" #: src/callbacks.c:353 msgid "Save session" msgstr "儲存作業階段" #: src/termit.c:234 msgid "Scrollbar" msgstr "" #: src/termit.c:209 msgid "Sessions" msgstr "作業階段" #. Edit menu #: src/termit.c:189 src/termit.c:229 msgid "Set tab name..." msgstr "設定分頁名稱..." #: src/callbacks.c:37 msgid "" "Several tabs are opened.\n" "Close anyway?" msgstr "已開啟數個分頁。是否關閉?" #: src/callbacks.c:262 src/callbacks.c:271 msgid "Tab name" msgstr "分頁名稱" #: src/termit_preferences.c:235 #, fuzzy msgid "Title" msgstr "檔案" #: src/termit_preferences.c:291 msgid "Transparency" msgstr "" #: src/sessions.c:90 #, c-format msgid "Unable to create directory '%s': %s" msgstr "無法建立目錄 '%s': %s" #: src/termit_preferences.c:307 msgid "Visible bell" msgstr "" #: src/termit_preferences.c:267 msgid "images" msgstr "" #~ msgid "Bookmarks" #~ msgstr "書籤" #~ msgid "Encoding" #~ msgstr "編碼" #~ msgid "Select font" #~ msgstr "選擇字型" nonstop-termit-fd89f3b/src/000077500000000000000000000000001176471573200160275ustar00rootroot00000000000000nonstop-termit-fd89f3b/src/CMakeLists.txt000066400000000000000000000043331176471573200205720ustar00rootroot00000000000000# Copyright (C) 2007-2010, Evgeny Ratnikov # # This file is part of termit. # termit is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 # as published by the Free Software Foundation. # termit 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 termit. If not, see . SET(TARGET "termit") INCLUDE_DIRECTORIES(${TERMIT_SOURCE_DIR}) INCLUDE (FindGTK) INCLUDE (FindPkgConfig) pkg_search_module(VTE REQUIRED libvte>=0.17 vte>=0.17) IF(NOT VTE_FOUND) message(FATAL_ERROR "vte library not found") ENDIF(NOT VTE_FOUND) SET(LUA_INCLUDE_DIR "/usr/include" CACHE STRING "Lua include dir") SET(LUA_LIBRARIES "/usr/lib/liblua.a" CACHE STRING "Lua libraries") IF(NOT LUA_INCLUDE_DIR OR NOT LUA_LIBRARIES) INCLUDE(FindLua51) IF(NOT LUA51_FOUND) message(FATAL_ERROR "lua 5.1 not found") ENDIF(NOT LUA51_FOUND) ENDIF(NOT LUA_INCLUDE_DIR OR NOT LUA_LIBRARIES) INCLUDE(Sources.cmake) SET(TERMIT_CFLAGS "-I${LUA_INCLUDE_DIR}") FOREACH(cflag ${VTE_CFLAGS} ${GTK_CFLAGS}) SET(TERMIT_CFLAGS "${TERMIT_CFLAGS} ${cflag}") ENDFOREACH(cflag) IF(NOT ${VTE_VERSION} LESS "0.26") SET(TERMIT_CFLAGS "${TERMIT_CFLAGS} -DTERMIT_ENABLE_SEARCH") ENDIF(NOT ${VTE_VERSION} LESS "0.26") IF(DEBUG) SET(EXTRA_CFLAGS "-Wall -Wextra -Wno-missing-field-initializers -Wno-unused-parameter") SET(TERMIT_CFLAGS "${TERMIT_CFLAGS} ${EXTRA_CFLAGS} -g -D DEBUG -DGTK_DISABLE_DEPRECATED -DGSEAL_ENABLE") ELSE(DEBUG) SET(TERMIT_CFLAGS "${TERMIT_CFLAGS} -O2") ENDIF(DEBUG) set(TERMIT_LDFLAGS ${VTE_LDFLAGS} ${GTK_LDFLAGS}) SET_SOURCE_FILES_PROPERTIES(${TERMIT_SRCS} PROPERTIES COMPILE_FLAGS "${TERMIT_CFLAGS}") ADD_EXECUTABLE(${TARGET} ${TERMIT_SRCS}) SET(TERMIT_LDFLAGS "-ldl") FOREACH(ldflag ${VTE_LDFLAGS} ${GTK_LDFLAGS}) LIST(APPEND TERMIT_LDFLAGS "${ldflag}") ENDFOREACH(ldflag) target_link_libraries(${TARGET} ${TERMIT_LDFLAGS} ${LUA_LIBRARIES}) INSTALL(TARGETS ${TARGET} DESTINATION ${CMAKE_INSTALL_PREFIX}/bin) nonstop-termit-fd89f3b/src/Sources.cmake000066400000000000000000000016161176471573200204600ustar00rootroot00000000000000# Copyright (C) 2007-2010, Evgeny Ratnikov # # This file is part of termit. # termit is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 # as published by the Free Software Foundation. # termit 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 termit. If not, see . SET( TERMIT_SRCS termit.c termit_core_api.c callbacks.c sessions.c keybindings.c lua_conf.c lua_api.c configs.c termit_style.c termit_preferences.c ) SET( TERMIT_HDRS termit_core_api.h callbacks.h configs.h sessions.h keybindings.h lua_api.h termit.h termit_style.h ) nonstop-termit-fd89f3b/src/callbacks.c000066400000000000000000000324201176471573200201130ustar00rootroot00000000000000/* Copyright (C) 2007-2010, Evgeny Ratnikov This file is part of termit. termit is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation. termit 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 termit. If not, see .*/ #include #include #include #include #include "termit.h" #include "configs.h" #include "sessions.h" #include "termit_core_api.h" #include "termit_style.h" #include "lua_api.h" #include "keybindings.h" #include "callbacks.h" static gboolean confirm_exit() { if (gtk_notebook_get_n_pages(GTK_NOTEBOOK(termit.notebook)) <= 1) return FALSE; GtkWidget *dlg = gtk_message_dialog_new( GTK_WINDOW(termit.main_window), GTK_DIALOG_MODAL, GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, _("Several tabs are opened.\nClose anyway?")); gint response = gtk_dialog_run(GTK_DIALOG(dlg)); gtk_widget_destroy(dlg); if (response == GTK_RESPONSE_YES) return FALSE; else return TRUE; } gboolean termit_on_delete_event(GtkWidget *widget, GdkEvent *event, gpointer data) { return confirm_exit(); } void termit_on_destroy(GtkWidget *widget, gpointer data) { termit_quit(); } void termit_on_tab_title_changed(VteTerminal *vte, gpointer user_data) { if (!configs.allow_changing_title) return; gint page = gtk_notebook_get_current_page(GTK_NOTEBOOK(termit.notebook)); TERMIT_GET_TAB_BY_INDEX(pTab, page); if (pTab->custom_tab_name) return; termit_tab_set_title(pTab, vte_terminal_get_window_title(VTE_TERMINAL(pTab->vte))); } #ifdef TERMIT_ENABLE_SEARCH gboolean termit_on_search_keypress(GtkWidget *widget, GdkEventKey *event, gpointer user_data) { switch (event->keyval) { case GDK_KEY_Return: { if (event->state == GDK_CONTROL_MASK) { termit_on_find_prev(NULL, NULL); } else { termit_on_find_next(NULL, NULL); } return TRUE; } case GDK_KEY_Escape: { gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(termit.b_toggle_search), FALSE); return TRUE; } default: return FALSE; } return FALSE; } static void termit_search_prepare_regex(const gchar* searchRegex) { gint page = gtk_notebook_get_current_page(GTK_NOTEBOOK(termit.notebook)); TERMIT_GET_TAB_BY_INDEX(pTab, page); if (strlen(searchRegex) == 0) { vte_terminal_search_set_gregex(VTE_TERMINAL(pTab->vte), NULL); } else { GRegex* currSearchRegex = vte_terminal_search_get_gregex(VTE_TERMINAL(pTab->vte)); if (!currSearchRegex || strcmp(searchRegex, g_regex_get_pattern(currSearchRegex)) != 0) { GError* err = NULL; GRegex* regex = g_regex_new(searchRegex, 0, 0, &err); if (err) { TRACE("failed to compile regex [%s]: skipping", searchRegex); return; } vte_terminal_search_set_gregex(VTE_TERMINAL(pTab->vte), regex); } } } void termit_on_find_next(GtkButton* btn, gpointer user_data) { termit_search_prepare_regex(gtk_entry_get_text(GTK_ENTRY(termit.search_entry))); termit_search_find_next(); } void termit_on_find_prev(GtkButton* btn, gpointer user_data) { termit_search_prepare_regex(gtk_entry_get_text(GTK_ENTRY(termit.search_entry))); termit_search_find_prev(); } void termit_on_toggle_search(GtkToggleButton* tb, gpointer user_data) { termit_toggle_search(); } #endif // TERMIT_ENABLE_SEARCH void termit_on_toggle_scrollbar() { TRACE_MSG(__FUNCTION__); gint page = gtk_notebook_get_current_page(GTK_NOTEBOOK(termit.notebook)); TERMIT_GET_TAB_BY_INDEX(pTab, page); if (pTab->scrollbar_is_shown) gtk_widget_hide(GTK_WIDGET(pTab->scrollbar)); else gtk_widget_show(GTK_WIDGET(pTab->scrollbar)); pTab->scrollbar_is_shown = !pTab->scrollbar_is_shown; } void termit_on_child_exited() { gint page = gtk_notebook_get_current_page(GTK_NOTEBOOK(termit.notebook)); TERMIT_GET_TAB_BY_INDEX(pTab, page); TRACE("waiting for pid %d", pTab->pid); int status = 0; waitpid(pTab->pid, &status, WNOHANG); /* TODO: check wait return */ termit_close_tab(); } static int termit_cursor_under_match(const GdkEventButton* ev, char** matchedText) { gint page = gtk_notebook_get_current_page(GTK_NOTEBOOK(termit.notebook)); TERMIT_GET_TAB_BY_INDEX2(pTab, page, -1); glong column = ((glong) (ev->x) / vte_terminal_get_char_width(VTE_TERMINAL(pTab->vte))); glong row = ((glong) (ev->y) / vte_terminal_get_char_height(VTE_TERMINAL(pTab->vte))); int tag = -1; *matchedText = vte_terminal_match_check(VTE_TERMINAL(pTab->vte), column, row, &tag); TRACE("column=%ld row=%ld matchedText=[%s] tag=%d", column, row, *matchedText, tag); return tag; } static struct Match* get_match_by_tag(GArray* matches, int tag) { guint i = 0; for (; ilen; ++i) { struct Match* match = &g_array_index(matches, struct Match, i); if (match->tag == tag) return match; } return NULL; } gboolean termit_on_popup(GtkWidget *widget, GdkEvent *event) { if (event->type != GDK_BUTTON_PRESS) return FALSE; GdkEventButton *event_button = (GdkEventButton *) event; if (event_button->button == 3) { GtkMenu *menu = GTK_MENU(termit.menu); gtk_menu_popup (menu, NULL, NULL, NULL, NULL, event_button->button, event_button->time); return TRUE; } else if (event_button->button == 1) { gint page = gtk_notebook_get_current_page(GTK_NOTEBOOK(termit.notebook)); TERMIT_GET_TAB_BY_INDEX2(pTab, page, FALSE); char* matchedText = NULL; int matchTag = termit_cursor_under_match(event_button, &matchedText); if (!matchedText) return FALSE; struct Match* match = get_match_by_tag(pTab->matches, matchTag); if (!match) { g_free(matchedText); return FALSE; } TRACE("tag=%d match=[%s]", matchTag, match->pattern); termit_lua_domatch(match->lua_callback, matchedText); g_free(matchedText); } return FALSE; } static gboolean dlg_key_press(GtkWidget *widget, GdkEventKey *event, gpointer user_data) { switch (event->keyval) { case GDK_KEY_Return: g_signal_emit_by_name(widget, "response", GTK_RESPONSE_ACCEPT, NULL); break; case GDK_KEY_Escape: g_signal_emit_by_name(widget, "response", GTK_RESPONSE_REJECT, NULL); break; default: return FALSE; } return TRUE; } void termit_on_beep(VteTerminal *vte, gpointer user_data) { struct TermitTab* pTab = (struct TermitTab*)user_data; if (!pTab) { ERROR("pTab is NULL"); return; } if (!gtk_window_has_toplevel_focus(GTK_WINDOW(termit.main_window))) { if (configs.urgency_on_bell) { gtk_window_set_urgency_hint(GTK_WINDOW(termit.main_window), TRUE); gchar* marked_title = g_strdup_printf("%s", gtk_label_get_text(GTK_LABEL(pTab->tab_name))); gtk_label_set_markup(GTK_LABEL(pTab->tab_name), marked_title); g_free(marked_title); } } } gboolean termit_on_focus(GtkWidget *widget, GtkDirectionType arg1, gpointer user_data) { struct TermitTab* pTab = (struct TermitTab*)user_data; if (!pTab) { ERROR("pTab is NULL"); return FALSE; } if (gtk_window_get_urgency_hint(GTK_WINDOW(termit.main_window))) { gtk_window_set_urgency_hint(GTK_WINDOW(termit.main_window), FALSE); gtk_label_set_markup(GTK_LABEL(pTab->tab_name), gtk_label_get_text(GTK_LABEL(pTab->tab_name))); gtk_label_set_use_markup(GTK_LABEL(pTab->tab_name), FALSE); } return FALSE; } void termit_on_set_tab_name() { GtkWidget *dlg = gtk_dialog_new_with_buttons( _("Tab name"), GTK_WINDOW(termit.main_window), GTK_DIALOG_MODAL, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL); gtk_dialog_set_default_response(GTK_DIALOG(dlg), GTK_RESPONSE_ACCEPT); gtk_window_set_modal(GTK_WINDOW(dlg), TRUE); gint page = gtk_notebook_get_current_page(GTK_NOTEBOOK(termit.notebook)); TERMIT_GET_TAB_BY_INDEX(pTab, page); GtkWidget *label = gtk_label_new(_("Tab name")); GtkWidget *entry = gtk_entry_new(); gtk_entry_set_text( GTK_ENTRY(entry), gtk_notebook_get_tab_label_text(GTK_NOTEBOOK(termit.notebook), pTab->hbox)); GtkWidget *hbox = gtk_hbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5); gtk_box_pack_start(GTK_BOX(hbox), entry, TRUE, FALSE, 5); g_signal_connect(G_OBJECT(dlg), "key-press-event", G_CALLBACK(dlg_key_press), dlg); gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dlg))), hbox, FALSE, FALSE, 10); gtk_widget_show_all(dlg); if (GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(dlg))) { termit_tab_set_title(pTab, gtk_entry_get_text(GTK_ENTRY(entry))); pTab->custom_tab_name = TRUE; } gtk_widget_destroy(dlg); } void termit_preferences_dialog(struct TermitTab *style); void termit_on_edit_preferences() { gint page = gtk_notebook_get_current_page(GTK_NOTEBOOK(termit.notebook)); TERMIT_GET_TAB_BY_INDEX(pTab, page); termit_preferences_dialog(pTab); } void termit_on_exit() { if (confirm_exit() == FALSE) termit_quit(); } void termit_on_switch_page(GtkNotebook *notebook, gpointer arg, guint page, gpointer user_data) { TERMIT_GET_TAB_BY_INDEX(pTab, page); TRACE("%s page=%d vte=%p", __FUNCTION__, page, pTab->vte); // it seems that set_active eventually calls toggle callback /*((GtkCheckMenuItem*)termit.mi_show_scrollbar)->active = pTab->scrollbar_is_shown;*/ gpointer pHandlerId = g_object_get_data(G_OBJECT(termit.mi_show_scrollbar), "handlerId"); if (pHandlerId) { g_signal_handler_disconnect(G_OBJECT(termit.mi_show_scrollbar), *((gulong*)pHandlerId)); } gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(termit.mi_show_scrollbar), pTab->scrollbar_is_shown); termit_set_show_scrollbar_signal(termit.mi_show_scrollbar, pHandlerId); termit_set_statusbar_message(page); if (configs.allow_changing_title) termit_set_window_title(pTab->title); } gint termit_on_double_click(GtkWidget *widget, GdkEventButton *event, gpointer func_data) { TRACE_MSG(__FUNCTION__); termit_mouse_event(event); return FALSE; } static gchar* termit_get_xdg_data_path() { gchar* fullPath = NULL; const gchar *dataHome = g_getenv("XDG_DATA_HOME"); if (dataHome) fullPath = g_strdup_printf("%s/termit", dataHome); else fullPath = g_strdup_printf("%s/.local/share/termit", g_getenv("HOME")); TRACE("XDG_DATA_PATH=%s", fullPath); return fullPath; } void termit_on_save_session() { /* // debug termit_save_session("tmpSess"); return; */ gchar* fullPath = termit_get_xdg_data_path(); GtkWidget* dlg = gtk_file_chooser_dialog_new( _("Save session"), GTK_WINDOW(termit.main_window), GTK_FILE_CHOOSER_ACTION_SAVE, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, NULL); gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(dlg), TRUE); gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dlg), fullPath); gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dlg), "New session"); if (gtk_dialog_run(GTK_DIALOG(dlg)) != GTK_RESPONSE_ACCEPT) { gtk_widget_destroy(dlg); g_free(fullPath); return; } gchar* filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dlg)); termit_save_session(filename); g_free(filename); gtk_widget_destroy(dlg); g_free(fullPath); } void termit_on_load_session() { gchar* fullPath = termit_get_xdg_data_path(); GtkWidget* dlg = gtk_file_chooser_dialog_new( _("Open session"), GTK_WINDOW(termit.main_window), GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL); gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(dlg), TRUE); gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dlg), fullPath); if (gtk_dialog_run(GTK_DIALOG(dlg)) != GTK_RESPONSE_ACCEPT) goto free_dlg; gchar* filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dlg)); termit_load_session(filename); g_free(filename); free_dlg: gtk_widget_destroy(dlg); g_free(fullPath); } void termit_on_menu_item_selected(GtkWidget *widget, void *data) { struct UserMenuItem* pMi = (struct UserMenuItem*)g_object_get_data(G_OBJECT(widget), TERMIT_USER_MENU_ITEM_DATA); if (pMi && pMi->lua_callback) { termit_lua_dofunction(pMi->lua_callback); } } gboolean termit_on_key_press(GtkWidget *widget, GdkEventKey *event, gpointer user_data) { return termit_key_event(event); } nonstop-termit-fd89f3b/src/callbacks.h000066400000000000000000000037461176471573200201310ustar00rootroot00000000000000/* Copyright (C) 2007-2010, Evgeny Ratnikov This file is part of termit. termit is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation. termit 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 termit. If not, see .*/ #ifndef CALLBACKS_H #define CALLBACKS_H gboolean termit_on_delete_event(GtkWidget *widget, GdkEvent *event, gpointer data); void termit_on_destroy(GtkWidget *widget, gpointer data); gboolean termit_on_popup(GtkWidget *, GdkEvent *); gboolean termit_on_key_press(GtkWidget *widget, GdkEventKey *event, gpointer user_data); gboolean termit_on_focus(GtkWidget *widget, GtkDirectionType arg1, gpointer user_data); void termit_on_beep(VteTerminal *vte, gpointer user_data); void termit_on_edit_preferences(); void termit_on_set_tab_name(); void termit_on_toggle_scrollbar(); void termit_on_child_exited(); void termit_on_exit(); void termit_on_switch_page(GtkNotebook *notebook, gpointer arg, guint page, gpointer user_data); void termit_on_menu_item_selected(GtkWidget *widget, void *data); void termit_on_del_tab(); gint termit_on_double_click(GtkWidget *widget, GdkEventButton *event, gpointer func_data); void termit_on_save_session(); void termit_on_load_session(); void termit_on_tab_title_changed(VteTerminal *vte, gpointer user_data); #ifdef TERMIT_ENABLE_SEARCH void termit_on_toggle_search(GtkToggleButton*, gpointer); void termit_on_find_next(GtkButton*, gpointer); void termit_on_find_prev(GtkButton*, gpointer); gboolean termit_on_search_keypress(GtkWidget *widget, GdkEventKey *event, gpointer user_data); #endif // TERMIT_ENABLE_SEARCH #endif /* CALLBACKS_H */ nonstop-termit-fd89f3b/src/configs.c000066400000000000000000000161041176471573200176250ustar00rootroot00000000000000/* Copyright (C) 2007-2010, Evgeny Ratnikov This file is part of termit. termit is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation. termit 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 termit. If not, see .*/ #include #include #include "termit.h" #include "keybindings.h" #include "configs.h" #include "lua_api.h" struct Configs configs = {}; static struct { const char* name; VteTerminalEraseBinding val; } erase_bindings[] = { {"Auto", VTE_ERASE_AUTO}, {"AsciiBksp", VTE_ERASE_ASCII_BACKSPACE}, {"AsciiDel", VTE_ERASE_ASCII_DELETE}, {"EraseDel", VTE_ERASE_DELETE_SEQUENCE}, {"EraseTty", VTE_ERASE_TTY} }; static guint EraseBindingsSz = sizeof(erase_bindings)/sizeof(erase_bindings[0]); const char* termit_erase_binding_to_string(VteTerminalEraseBinding val) { return erase_bindings[val].name; } VteTerminalEraseBinding termit_erase_binding_from_string(const char* str) { guint i = 0; for (; i < EraseBindingsSz; ++i) { if (strcmp(str, erase_bindings[i].name) == 0) { return erase_bindings[i].val; } } ERROR("not found binding for [%s], using Auto", str); return VTE_ERASE_AUTO; } void termit_config_trace() { #ifdef DEBUG TRACE_MSG(""); TRACE(" default_window_title = %s", configs.default_window_title); TRACE(" default_tab_name = %s", configs.default_tab_name); TRACE(" default_encoding = %s", configs.default_encoding); TRACE(" default_word_chars = %s", configs.default_word_chars); TRACE(" show_scrollbar = %d", configs.show_scrollbar); TRACE(" hide_menubar = %d", configs.hide_menubar); TRACE(" hide_tabbar = %d", configs.hide_tabbar); TRACE(" fill_tabbar = %d", configs.fill_tabbar); TRACE(" hide_single_tab = %d", configs.hide_single_tab); TRACE(" scrollback_lines = %d", configs.scrollback_lines); TRACE(" cols x rows = %d x %d", configs.cols, configs.rows); TRACE(" backspace = %s", termit_erase_binding_to_string(configs.default_bksp)); TRACE(" delete = %s", termit_erase_binding_to_string(configs.default_delete)); TRACE(" allow_changing_title = %d", configs.allow_changing_title); TRACE(" audible_bell = %d", configs.audible_bell); TRACE(" visible_bell = %d", configs.visible_bell); TRACE(" get_window_title_callback= %d", configs.get_window_title_callback); TRACE(" get_tab_title_callback = %d", configs.get_tab_title_callback); TRACE(" get_statusbar_callback = %d", configs.get_statusbar_callback); TRACE(" style:"); TRACE(" font_name = %s", configs.style.font_name); if (configs.style.foreground_color) { gchar* tmpStr = gdk_color_to_string(configs.style.foreground_color); TRACE(" foreground_color = %s", tmpStr); g_free(tmpStr); } if (configs.style.background_color) { gchar* tmpStr = gdk_color_to_string(configs.style.background_color); TRACE(" background_color = %s", tmpStr); g_free(tmpStr); } TRACE(" transparency = %f", configs.style.transparency); TRACE(" image_file = %s", configs.style.image_file); TRACE_MSG(""); #endif } void termit_configs_set_defaults() { configs.default_window_title = g_strdup("Termit"); configs.default_tab_name = g_strdup("Terminal"); termit_style_init(&configs.style); configs.default_command = g_strdup(g_getenv("SHELL")); configs.default_encoding = g_strdup("UTF-8"); configs.default_word_chars = g_strdup("-A-Za-z0-9,./?%&#_~"); configs.scrollback_lines = 4096; configs.cols = 80; configs.rows = 24; configs.default_bksp = VTE_ERASE_AUTO; configs.default_delete = VTE_ERASE_AUTO; configs.user_menus = g_array_new(FALSE, TRUE, sizeof(struct UserMenu)); configs.user_popup_menus = g_array_new(FALSE, TRUE, sizeof(struct UserMenu)); configs.key_bindings = g_array_new(FALSE, TRUE, sizeof(struct KeyBinding)); configs.mouse_bindings = g_array_new(FALSE, TRUE, sizeof(struct MouseBinding)); configs.matches = g_array_new(FALSE, TRUE, sizeof(struct Match)); configs.hide_single_tab = FALSE; configs.show_scrollbar = TRUE; configs.fill_tabbar = FALSE; configs.hide_menubar = FALSE; configs.hide_tabbar = FALSE; configs.allow_changing_title = FALSE; configs.visible_bell = FALSE; configs.audible_bell = FALSE; configs.urgency_on_bell = FALSE; configs.get_window_title_callback = 0; configs.get_tab_title_callback = 0; configs.get_statusbar_callback = 0; configs.kb_policy = TermitKbUseKeysym; } static void free_menu(GArray* menus) { guint i = 0; for (; ilen; ++i) { struct UserMenu* um = &g_array_index(menus, struct UserMenu, i); guint j = 0; for (; jitems->len; ++j) { struct UserMenuItem* umi = &g_array_index(um->items, struct UserMenuItem, j); g_free(umi->name); g_free(umi->accel); termit_lua_unref(&umi->lua_callback); } g_free(um->name); g_array_free(um->items, TRUE); } } void termit_config_deinit() { g_free(configs.default_window_title); g_free(configs.default_tab_name); termit_style_free(&configs.style); g_free(configs.default_command); g_free(configs.default_encoding); g_free(configs.default_word_chars); free_menu(configs.user_menus); g_array_free(configs.user_menus, TRUE); free_menu(configs.user_popup_menus); g_array_free(configs.user_popup_menus, TRUE); // name and default_binding are static (e.g. can be in readonly mempage) guint i = 0; for (; ilen; ++i) { struct KeyBinding* kb = &g_array_index(configs.key_bindings, struct KeyBinding, i); termit_lua_unref(&kb->lua_callback); } g_array_free(configs.key_bindings, TRUE); i = 0; for (; ilen; ++i) { struct MouseBinding* mb = &g_array_index(configs.mouse_bindings, struct MouseBinding, i); termit_lua_unref(&mb->lua_callback); } g_array_free(configs.mouse_bindings, TRUE); i = 0; for (; ilen; ++i) { struct Match* match = &g_array_index(configs.matches, struct Match, i); g_regex_unref(match->regex); g_free(match->pattern); } g_array_free(configs.matches, TRUE); termit_lua_unref(&configs.get_window_title_callback); termit_lua_unref(&configs.get_tab_title_callback); termit_lua_unref(&configs.get_statusbar_callback); } nonstop-termit-fd89f3b/src/configs.h000066400000000000000000000047731176471573200176430ustar00rootroot00000000000000/* Copyright (C) 2007-2010, Evgeny Ratnikov This file is part of termit. termit is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation. termit 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 termit. If not, see .*/ #ifndef CONFIGS_H #define CONFIGS_H #include #include #include "termit_style.h" enum TermitKbPolicy {TermitKbUseKeycode = 1, TermitKbUseKeysym = 2}; struct Configs { gchar* default_window_title; gchar* default_tab_name; gchar* default_command; gchar* default_encoding; gchar* default_word_chars; guint scrollback_lines; guint cols; guint rows; VteTerminalEraseBinding default_bksp; VteTerminalEraseBinding default_delete; GArray* user_menus; // UserMenu GArray* user_popup_menus; // UserMenu GArray* key_bindings; // KeyBinding GArray* mouse_bindings; // MouseBinding GArray* matches; // Match gboolean hide_single_tab; gboolean show_scrollbar; gboolean hide_menubar; gboolean hide_tabbar; gboolean fill_tabbar; gboolean urgency_on_bell; gboolean allow_changing_title; gboolean audible_bell; gboolean visible_bell; int get_window_title_callback; int get_tab_title_callback; int get_statusbar_callback; enum TermitKbPolicy kb_policy; struct TermitStyle style; GArray* default_tabs; // TabInfo }; struct Match { gchar* pattern; GRegex* regex; GRegexMatchFlags flags; int tag; int lua_callback; }; struct UserMenuItem { gchar* name; gchar* accel; int lua_callback; }; struct UserMenu { gchar* name; GArray* items; // UserMenuItem }; extern struct Configs configs; void termit_config_deinit(); void termit_configs_set_defaults(); void termit_config_load(); void termit_config_trace(); void termit_keys_trace(); const char* termit_erase_binding_to_string(VteTerminalEraseBinding val); VteTerminalEraseBinding termit_erase_binding_from_string(const char* str); #define TERMIT_USER_MENU_ITEM_DATA "termit.umi_data" #define TERMIT_TAB_DATA "termit.tab_data" #endif /* CONFIGS_H */ nonstop-termit-fd89f3b/src/keybindings.c000066400000000000000000000225201176471573200205020ustar00rootroot00000000000000/* Copyright (C) 2007-2010, Evgeny Ratnikov This file is part of termit. termit is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation. termit 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 termit. If not, see .*/ #include #include #include #include #include #include #include "termit.h" #include "configs.h" #include "termit_core_api.h" #include "lua_api.h" #include "keybindings.h" extern lua_State* L; static Display* disp; void termit_keys_trace() { #ifdef DEBUG guint i = 0; for (; ilen; ++i) { struct KeyBinding* kb = &g_array_index(configs.key_bindings, struct KeyBinding, i); TRACE("%s: %d, %d(%ld)", kb->name, kb->kws.state, kb->kws.keyval, kb->keycode); } #endif } #define ADD_DEFAULT_KEYBINDING(keybinding_, lua_callback_) \ { \ lua_getglobal(ls, lua_callback_); \ int func = luaL_ref(ls, LUA_REGISTRYINDEX); \ termit_keys_bind(keybinding_, func); \ } #define ADD_DEFAULT_MOUSEBINDING(mouse_event_, lua_callback_) \ { \ lua_getglobal(ls, lua_callback_); \ int func = luaL_ref(ls, LUA_REGISTRYINDEX); \ termit_mouse_bind(mouse_event_, func); \ } void termit_keys_set_defaults() { lua_State* ls = L; disp = XOpenDisplay(NULL); ADD_DEFAULT_KEYBINDING("Alt-Left", "prevTab"); ADD_DEFAULT_KEYBINDING("Alt-Right", "nextTab"); ADD_DEFAULT_KEYBINDING("Ctrl-t", "openTab"); ADD_DEFAULT_KEYBINDING("CtrlShift-w", "closeTab"); ADD_DEFAULT_KEYBINDING("Ctrl-Insert", "copy"); ADD_DEFAULT_KEYBINDING("Shift-Insert", "paste"); // push func to stack, get ref termit_keys_trace(); ADD_DEFAULT_MOUSEBINDING("DoubleClick", "openTab"); } struct TermitModifier { const gchar* name; guint state; }; struct TermitModifier termit_modifiers[] = { {"Alt", GDK_MOD1_MASK}, {"Ctrl", GDK_CONTROL_MASK}, {"Shift", GDK_SHIFT_MASK}, {"Meta", GDK_META_MASK}, {"Super", GDK_SUPER_MASK}, {"Hyper", GDK_HYPER_MASK} }; static guint TermitModsSz = sizeof(termit_modifiers)/sizeof(struct TermitModifier); static gint get_modifier_state(const gchar* token) { size_t modifier_len; size_t step; if (!token) return GDK_NOTHING; guint i = 0; guint state = 0; while (strlen(token) > 0) { step = 0; for (; ilen; ++i) { struct KeyBinding* kb = &g_array_index(configs.key_bindings, struct KeyBinding, i); if (!strcmp(kb->name, name)) return i; } return -1; } struct TermitMouseEvent { const gchar* name; GdkEventType type; }; struct TermitMouseEvent termit_mouse_events[] = { {"DoubleClick", GDK_2BUTTON_PRESS} }; static guint TermitMouseEventsSz = sizeof(termit_mouse_events)/sizeof(struct TermitMouseEvent); gint get_mouse_event_type(const gchar* event_name) { if (!event_name) return GDK_NOTHING; guint i = 0; for (; ilen; ++i) { struct MouseBinding* mb = &g_array_index(configs.mouse_bindings, struct MouseBinding, i); if (type == mb->type) return i; } return -1; } void termit_keys_unbind(const gchar* keybinding) { gint kb_index = get_kb_index(keybinding); if (kb_index < 0) { TRACE("keybinding [%s] not found - skipping", keybinding); return; } struct KeyBinding* kb = &g_array_index(configs.key_bindings, struct KeyBinding, kb_index); termit_lua_unref(&kb->lua_callback); g_free(kb->name); g_array_remove_index(configs.key_bindings, kb_index); } int termit_parse_keys_str(const gchar* keybinding, struct KeyWithState* kws) { gchar *modifier = NULL, *key = NULL; // token[0] - modifier. Only Alt, Ctrl or Shift allowed. gchar** tokens = g_strsplit(keybinding, "-", 2); if (!tokens[0]) { ERROR("failed to parse: [%s]", keybinding); return -1; } if (!tokens[1]) { key = tokens[0]; } else { modifier = tokens[0]; key = tokens[1]; } gint tmp_state = 0; if (modifier) { tmp_state = get_modifier_state(modifier); if (tmp_state == GDK_NOTHING) { TRACE("Bad modifier: %s", keybinding); return -1; } } guint tmp_keyval = gdk_keyval_from_name(key); if (tmp_keyval == GDK_KEY_VoidSymbol) { TRACE("Bad keyval: %s", keybinding); return -1; } g_strfreev(tokens); kws->state = tmp_state; kws->keyval = gdk_keyval_to_lower(tmp_keyval); return 0; } void termit_keys_bind(const gchar* keybinding, int lua_callback) { struct KeyWithState kws = {}; if (termit_parse_keys_str(keybinding, &kws) < 0) { ERROR("failed to parse keybinding: %s", keybinding); return; } gint kb_index = get_kb_index(keybinding); if (kb_index < 0) { struct KeyBinding kb = {}; kb.name = g_strdup(keybinding); kb.kws = kws; kb.keycode = XKeysymToKeycode(disp, kb.kws.keyval); kb.lua_callback = lua_callback; g_array_append_val(configs.key_bindings, kb); } else { struct KeyBinding* kb = &g_array_index(configs.key_bindings, struct KeyBinding, kb_index); kb->kws = kws; kb->keycode = XKeysymToKeycode(disp, kb->kws.keyval); termit_lua_unref(&kb->lua_callback); kb->lua_callback = lua_callback; } } void termit_mouse_bind(const gchar* mouse_event, int lua_callback) { GdkEventType type = get_mouse_event_type(mouse_event); if (type == GDK_NOTHING) { TRACE("unknown event: %s", mouse_event); return; } gint mb_index = get_mb_index(type); if (mb_index < 0) { struct MouseBinding mb = {}; mb.type = type; mb.lua_callback = lua_callback; g_array_append_val(configs.mouse_bindings, mb); } else { struct MouseBinding* mb = &g_array_index(configs.mouse_bindings, struct MouseBinding, mb_index); mb->type = type; termit_lua_unref(&mb->lua_callback); mb->lua_callback = lua_callback; } } void termit_mouse_unbind(const gchar* mouse_event) { GdkEventType type = get_mouse_event_type(mouse_event); if (type == GDK_NOTHING) { TRACE("unknown event: %s", mouse_event); return; } gint mb_index = get_mb_index(type); if (mb_index < 0) { TRACE("mouse event [%d] not found - skipping", type); return; } struct MouseBinding* mb = &g_array_index(configs.mouse_bindings, struct MouseBinding, mb_index); termit_lua_unref(&mb->lua_callback); g_array_remove_index(configs.mouse_bindings, mb_index); } static gboolean termit_key_press_use_keycode(GdkEventKey *event) { guint i = 0; for (; ilen; ++i) { struct KeyBinding* kb = &g_array_index(configs.key_bindings, struct KeyBinding, i); if (kb && (event->state & kb->kws.state) == kb->kws.state) { if (event->hardware_keycode == kb->keycode) { termit_lua_dofunction(kb->lua_callback); return TRUE; } } } return FALSE; } static gboolean termit_key_press_use_keysym(GdkEventKey *event) { guint i = 0; for (; ilen; ++i) { struct KeyBinding* kb = &g_array_index(configs.key_bindings, struct KeyBinding, i); if (kb && (event->state & kb->kws.state) == kb->kws.state) if (gdk_keyval_to_lower(event->keyval) == kb->kws.keyval) { termit_lua_dofunction(kb->lua_callback); return TRUE; } } return FALSE; } gboolean termit_key_event(GdkEventKey* event) { switch(configs.kb_policy) { case TermitKbUseKeycode: return termit_key_press_use_keycode(event); break; case TermitKbUseKeysym: return termit_key_press_use_keysym(event); break; default: ERROR("unknown kb_policy: %d", configs.kb_policy); } return FALSE; } gboolean termit_mouse_event(GdkEventButton* event) { guint i = 0; for (; ilen; ++i) { struct MouseBinding* kb = &g_array_index(configs.mouse_bindings, struct MouseBinding, i); if (kb && (event->type & kb->type)) termit_lua_dofunction(kb->lua_callback); } return FALSE; } nonstop-termit-fd89f3b/src/keybindings.h000066400000000000000000000027401176471573200205110ustar00rootroot00000000000000/* Copyright (C) 2007-2010, Evgeny Ratnikov This file is part of termit. termit is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation. termit 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 termit. If not, see .*/ #ifndef KEYBINDINGS_H #define KEYBINDINGS_H #include #include struct KeyWithState { guint state; guint keyval; }; typedef void(*BindingCallback)(); struct KeyBinding { gchar* name; struct KeyWithState kws; KeySym keycode; int lua_callback; }; struct MouseBinding { GdkEventType type; int lua_callback; }; //void termit_load_keys(); int termit_parse_keys_str(const gchar* keybinding, struct KeyWithState* kws); void termit_keys_bind(const gchar* keys, int lua_callback); void termit_keys_unbind(const gchar* keys); void termit_mouse_bind(const gchar* mouse_event, int lua_callback); void termit_mouse_unbind(const gchar* mouse_event); void termit_keys_set_defaults(); gboolean termit_key_event(GdkEventKey* event); gboolean termit_mouse_event(GdkEventButton* event); #endif /* KEYBINDINGS_H */ nonstop-termit-fd89f3b/src/lua_api.c000066400000000000000000000504431176471573200176130ustar00rootroot00000000000000/* Copyright (C) 2007-2010, Evgeny Ratnikov This file is part of termit. termit is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation. termit 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 termit. If not, see .*/ #include #include #include #include #include "termit.h" #include "termit_core_api.h" #include "keybindings.h" #include "configs.h" #include "callbacks.h" #include "lua_api.h" extern lua_State* L; TermitLuaTableLoaderResult termit_lua_load_table(lua_State* ls, TermitLuaTableLoaderFunc func, const int tableIndex, void* data) { if (!lua_istable(ls, tableIndex)) { ERROR("not a table"); return TERMIT_LUA_TABLE_LOADER_FAILED; } lua_pushnil(ls); while (lua_next(ls, tableIndex) != 0) { if (lua_isnumber(ls, tableIndex + 1)) { func("0", ls, tableIndex + 2, data); } else if (lua_isstring(ls, tableIndex + 1)) { const char* name = lua_tostring(ls, tableIndex + 1); func(name, ls, tableIndex + 2, data); } else { ERROR("neither number nor string value found - skipping"); lua_pop(ls, 1); } lua_pop(ls, 1); } return TERMIT_LUA_TABLE_LOADER_OK; } void termit_lua_execute(const gchar* cmd) { TRACE("executing script: %s", cmd); int s = luaL_dostring(L, cmd); termit_lua_report_error(__FILE__, __LINE__, s); } void termit_lua_report_error(const char* file, int line, int status) { if (status == 0) return; TRACE_MSG("lua error:"); g_fprintf(stderr, "%s:%d %s\n", file, line, lua_tostring(L, -1)); lua_pop(L, 1); } static int termit_lua_setOptions(lua_State* ls) { TRACE_MSG(__FUNCTION__); termit_lua_load_table(ls, termit_lua_options_loader, 1, &configs); if (configs.default_tabs) { guint i = 0; for (; i < configs.default_tabs->len; ++i) { struct TabInfo* ti = &g_array_index(configs.default_tabs, struct TabInfo, i); termit_append_tab_with_details(ti); g_free(ti->name); g_free(ti->command); g_free(ti->encoding); g_free(ti->working_dir); } g_array_free(configs.default_tabs, TRUE); configs.default_tabs = NULL; } return 0; } int termit_lua_dofunction(int f) { lua_State* ls = L; if(f != LUA_REFNIL) { lua_rawgeti(ls, LUA_REGISTRYINDEX, f); if (lua_pcall(ls, 0, 0, 0)) { TRACE("error running function (%d): %s", f, lua_tostring(ls, -1)); lua_pop(ls, 1); return 0; } return 1; } return 0; } int termit_lua_dofunction2(int f, const char* arg1) { lua_State* ls = L; if(f != LUA_REFNIL) { lua_rawgeti(ls, LUA_REGISTRYINDEX, f); lua_pushstring(ls, arg1); if (lua_pcall(ls, 1, 0, 0)) { TRACE("error running function (%d): %s", f, lua_tostring(ls, -1)); lua_pop(ls, 1); return 0; } return 1; } return 0; } int termit_lua_domatch(int f, const gchar* matchedText) { lua_State* ls = L; if(f != LUA_REFNIL) { lua_rawgeti(ls, LUA_REGISTRYINDEX, f); lua_pushstring(ls, matchedText); if (lua_pcall(ls, 1, 0, 0)) { TRACE("error running function (%d: %s): %s", f, matchedText, lua_tostring(ls, -1)); lua_pop(ls, 1); return 0; } return 1; } return 0; } void termit_lua_unref(int* lua_callback) { if (*lua_callback) { luaL_unref(L, LUA_REGISTRYINDEX, *lua_callback); *lua_callback = 0; } } gchar* termit_lua_getStatusbarCallback(int f, guint page) { lua_State* ls = L; if(f != LUA_REFNIL) { lua_rawgeti(ls, LUA_REGISTRYINDEX, f); lua_pushnumber(ls, page); if (lua_pcall(ls, 1, 1, 0)) { TRACE("error running function: %s", lua_tostring(ls, -1)); lua_pop(ls, 1); return NULL; } if (lua_isstring(ls, -1)) return g_strdup(lua_tostring(ls, -1)); } return NULL; } gchar* termit_lua_getTitleCallback(int f, const gchar* title) { lua_State* ls = L; if(f != LUA_REFNIL) { lua_rawgeti(ls, LUA_REGISTRYINDEX, f); lua_pushstring(ls, title); if (lua_pcall(ls, 1, 1, 0)) { TRACE("error running function: %s", lua_tostring(ls, -1)); lua_pop(ls, 1); return NULL; } if (lua_isstring(ls, -1)) return g_strdup(lua_tostring(ls, -1)); } return NULL; } static int termit_lua_bindKey(lua_State* ls) { TRACE_MSG(__FUNCTION__); if (lua_isnil(ls, 1)) { TRACE_MSG("nil args: skipping"); } else if (!lua_isstring(ls, 1)) { TRACE_MSG("bad args: skipping"); } else if (lua_isnil(ls, 2)) { const char* keybinding = lua_tostring(ls, 1); termit_keys_unbind(keybinding); TRACE("unbindKey: %s", keybinding); } else if (lua_isfunction(ls, 2)) { const char* keybinding = lua_tostring(ls, 1); int func = luaL_ref(ls, LUA_REGISTRYINDEX); termit_keys_bind(keybinding, func); TRACE("bindKey: %s - %d", keybinding, func); } return 0; } static int termit_lua_bindMouse(lua_State* ls) { if (lua_isnil(ls, 1)) { TRACE_MSG("nil args: skipping"); } else if (!lua_isstring(ls, 1)) { TRACE_MSG("bad args: skipping"); } else if (lua_isnil(ls, 2)) { const char* mousebinding = lua_tostring(ls, 1); termit_mouse_unbind(mousebinding); TRACE("unbindMouse: %s", mousebinding); } else if (lua_isfunction(ls, 2)) { const char* mousebinding = lua_tostring(ls, 1); int func = luaL_ref(ls, LUA_REGISTRYINDEX); termit_mouse_bind(mousebinding, func); TRACE("bindMouse: %s - %d", mousebinding, func); } return 0; } static int termit_lua_toggleMenubar(lua_State* ls) { termit_toggle_menubar(); return 0; } static int termit_lua_toggleTabbar(lua_State* ls) { termit_toggle_tabbar(); return 0; } void termit_lua_tab_loader(const gchar* name, lua_State* ls, int index, void* data) { struct TabInfo* ti = (struct TabInfo*)data; if (strcmp(name, "title") == 0) { termit_config_get_string(&ti->name, ls, index); } else if (strcmp(name, "command") == 0) { termit_config_get_string(&ti->command, ls, index); } else if (strcmp(name, "encoding") == 0) { termit_config_get_string(&ti->encoding, ls, index); } else if (strcmp(name, "backspaceBinding") == 0) { termit_config_get_erase_binding(&ti->bksp_binding, ls, index); } else if (strcmp(name, "deleteBinding") == 0) { termit_config_get_erase_binding(&ti->delete_binding, ls, index); } else if (strcmp(name, "workingDir") == 0) { termit_config_get_string(&ti->working_dir, ls, index); } } static int termit_lua_nextTab(lua_State* ls) { TRACE_MSG(__FUNCTION__); termit_next_tab(); return 0; } static int termit_lua_prevTab(lua_State* ls) { TRACE_MSG(__FUNCTION__); termit_prev_tab(); return 0; } static int termit_lua_copy(lua_State* ls) { TRACE_MSG(__FUNCTION__); termit_copy(); return 0; } static int termit_lua_paste(lua_State* ls) { TRACE_MSG(__FUNCTION__); termit_paste(); return 0; } static int termit_lua_openTab(lua_State* ls) { TRACE_MSG(__FUNCTION__); if (lua_istable(ls, 1)) { struct TabInfo ti = {}; if (termit_lua_load_table(ls, termit_lua_tab_loader, 1, &ti) != TERMIT_LUA_TABLE_LOADER_OK) { ERROR("openTab failed"); return 0; } termit_append_tab_with_details(&ti); g_free(ti.name); g_free(ti.command); g_free(ti.encoding); g_free(ti.working_dir); } else { termit_append_tab(); } return 0; } static int termit_lua_closeTab(lua_State* ls) { termit_close_tab(); TRACE_FUNC; return 0; } static int termit_lua_setKbPolicy(lua_State* ls) { if (lua_isnil(ls, 1)) { TRACE_MSG("no kbPolicy defined: skipping"); return 0; } else if (!lua_isstring(ls, 1)) { TRACE_MSG("kbPolicy is not string: skipping"); return 0; } const gchar* val = lua_tostring(ls, 1); TRACE("setKbPolicy: %s", val); if (!strcmp(val, "keycode")) termit_set_kb_policy(TermitKbUseKeycode); else if (!strcmp(val, "keysym")) termit_set_kb_policy(TermitKbUseKeysym); else { ERROR("unknown kbPolicy: %s", val); } return 0; } static void menuItemLoader(const gchar* name, lua_State* ls, int index, void* data) { struct UserMenuItem* umi = (struct UserMenuItem*)data; if (!strcmp(name, "name") && lua_isstring(ls, index)) { const gchar* value = lua_tostring(ls, index); umi->name = g_strdup(value); } else if (!strcmp(name, "action") && lua_isfunction(ls, index)) { umi->lua_callback = luaL_ref(ls, LUA_REGISTRYINDEX); lua_pushnil(ls); // luaL_ref pops value so we restore stack size } else if (!strcmp(name, "accel") && lua_isstring(ls, index)) { const gchar* value = lua_tostring(ls, index); umi->accel = g_strdup(value); } } static void menuLoader(const gchar* name, lua_State* ls, int index, void* data) { struct UserMenu* um = (struct UserMenu*)data; if (lua_istable(ls, index)) { struct UserMenuItem umi = {}; if (termit_lua_load_table(ls, menuItemLoader, index, &umi) == TERMIT_LUA_TABLE_LOADER_OK) { g_array_append_val(um->items, umi); } else { ERROR("failed to load item: %s.%s", name, lua_tostring(ls, 3)); } } else { ERROR("unknown type instead if menu table: skipping"); lua_pop(ls, 1); } } static int loadMenu(lua_State* ls, GArray* menus) { if (lua_isnil(ls, 1) || lua_isnil(ls, 2)) { TRACE_MSG("menu not defined: skipping"); return -1; } else if (!lua_istable(ls, 1) || !lua_isstring(ls, 2)) { TRACE_MSG("menu is not table: skipping"); return -1; } struct UserMenu um = {}; um.name = g_strdup(lua_tostring(ls, 2)); lua_pop(ls, 1); um.items = g_array_new(FALSE, TRUE, sizeof(struct UserMenuItem)); if (termit_lua_load_table(ls, menuLoader, 1, &um) != TERMIT_LUA_TABLE_LOADER_OK) { ERROR("addMenu failed"); } if (um.items->len > 0) { g_array_append_val(menus, um); } else { g_free(um.name); g_array_free(um.items, TRUE); } return 0; } static int termit_lua_addMenu(lua_State* ls) { if (loadMenu(ls, configs.user_menus) < 0) { ERROR("addMenu failed"); } return 0; } static int termit_lua_addPopupMenu(lua_State* ls) { if (loadMenu(ls, configs.user_popup_menus) < 0) { ERROR("addMenu failed"); } return 0; } static int termit_lua_setColormap(lua_State* ls) { const gint page = gtk_notebook_get_current_page(GTK_NOTEBOOK(termit.notebook)); TERMIT_GET_TAB_BY_INDEX2(pTab, page, 0); termit_lua_load_colormap(ls, 1, &pTab->style.colors, &pTab->style.colors_size); termit_tab_apply_colors(pTab); return 0; } static int termit_lua_setEncoding(lua_State* ls) { if (lua_isnil(ls, 1)) { TRACE_MSG("no encoding defined: skipping"); return 0; } else if (!lua_isstring(ls, 1)) { TRACE_MSG("encoding is not string: skipping"); return 0; } const gchar* val = lua_tostring(ls, 1); termit_set_encoding(val); return 0; } static int termit_lua_activateTab(lua_State* ls) { if (lua_isnil(ls, 1)) { TRACE_MSG("no tabNum defined: skipping"); return 0; } else if (!lua_isnumber(ls, 1)) { TRACE_MSG("tabNum is not number: skipping"); return 0; } int tab_index = lua_tointeger(ls, 1); termit_activate_tab(tab_index - 1); return 0; } static int termit_lua_currentTab(lua_State* ls) { return termit_lua_fill_tab(termit_get_current_tab_index(), ls); } static int termit_lua_currentTabIndex(lua_State* ls) { lua_pushinteger(ls, termit_get_current_tab_index()); return 1; } static int termit_lua_loadSessionDialog(lua_State* ls) { termit_on_load_session(); return 0; } static int termit_lua_saveSessionDialog(lua_State* ls) { termit_on_save_session(); return 0; } static int termit_lua_preferencesDialog(lua_State* ls) { termit_on_edit_preferences(); return 0; } static int termit_lua_setTabTitleDialog(lua_State* ls) { termit_on_set_tab_name(); return 0; } static int termit_lua_setTabTitle(lua_State* ls) { if (lua_isnil(ls, 1)) { TRACE_MSG("no tabName defined: skipping"); return 0; } else if (!lua_isstring(ls, 1)) { TRACE_MSG("tabName is not string: skipping"); return 0; } const gchar* val = lua_tostring(ls, 1); gint page = gtk_notebook_get_current_page(GTK_NOTEBOOK(termit.notebook)); TERMIT_GET_TAB_BY_INDEX2(pTab, page, 0); termit_tab_set_title(pTab, val); pTab->custom_tab_name = TRUE; return 0; } static int termit_lua_setWindowTitle(lua_State* ls) { if (lua_isnil(ls, 1)) { TRACE_MSG("no title defined: skipping"); return 0; } else if (!lua_isstring(ls, 1)) { TRACE_MSG("title is not string: skipping"); return 0; } const gchar* val = lua_tostring(ls, 1); termit_set_window_title(val); return 0; } static int termit_lua_setTabColor__(lua_State* ls, void (*callback)(gint, const GdkColor*)) { if (lua_isnil(ls, 1)) { TRACE_MSG("no color defined: skipping"); return 0; } else if (!lua_isstring(ls, 1)) { TRACE_MSG("color is not string: skipping"); return 0; } const gchar* val = lua_tostring(ls, 1); GdkColor color; if (gdk_color_parse(val, &color) == TRUE) callback(-1, &color); return 0; } static int termit_lua_setTabForegroundColor(lua_State* ls) { return termit_lua_setTabColor__(ls, &termit_tab_set_color_foreground_by_index); } static int termit_lua_setTabBackgroundColor(lua_State* ls) { return termit_lua_setTabColor__(ls, &termit_tab_set_color_background_by_index); } static int termit_lua_setTabFont(lua_State* ls) { if (lua_isnil(ls, 1)) { TRACE_MSG("no font defined: skipping"); return 0; } else if (!lua_isstring(ls, 1)) { TRACE_MSG("font is not string: skipping"); return 0; } const gchar* val = lua_tostring(ls, 1); termit_tab_set_font_by_index(-1, val); return 0; } static int termit_lua_spawn(lua_State* ls) { if (lua_isnil(ls, 1)) { TRACE_MSG("no command defined: skipping"); return 0; } else if (!lua_isstring(ls, 1)) { TRACE_MSG("command is not string: skipping"); return 0; } GError *err = NULL; const gchar* val = lua_tostring(ls, 1); g_spawn_command_line_async(val, &err); return 0; } static int termit_lua_forEachRow(lua_State* ls) { if (lua_isnil(ls, 1)) { TRACE_MSG("no function defined: skipping"); return 0; } else if (!lua_isfunction(ls, 1)) { TRACE_MSG("1 arg is not function: skipping"); return 0; } int func = luaL_ref(ls, LUA_REGISTRYINDEX); termit_for_each_row(func); termit_lua_unref(&func); return 0; } static int termit_lua_forEachVisibleRow(lua_State* ls) { if (lua_isnil(ls, 1)) { TRACE_MSG("no function defined: skipping"); return 0; } else if (!lua_isfunction(ls, 1)) { TRACE_MSG("1 arg is not function: skipping"); return 0; } int func = luaL_ref(ls, LUA_REGISTRYINDEX); termit_for_each_visible_row(func); termit_lua_unref(&func); return 0; } static int termit_lua_feed(lua_State* ls) { if (lua_isnil(ls, 1)) { TRACE_MSG("no data defined: skipping"); return 0; } else if (!lua_isstring(ls, 1)) { TRACE_MSG("data is not string: skipping"); return 0; } const gchar* val = lua_tostring(ls, 1); gint page = gtk_notebook_get_current_page(GTK_NOTEBOOK(termit.notebook)); TERMIT_GET_TAB_BY_INDEX2(pTab, page, 0); termit_tab_feed(pTab, val); return 0; } static int termit_lua_feedChild(lua_State* ls) { if (lua_isnil(ls, 1)) { TRACE_MSG("no data defined: skipping"); return 0; } else if (!lua_isstring(ls, 1)) { TRACE_MSG("data is not string: skipping"); return 0; } const gchar* val = lua_tostring(ls, 1); gint page = gtk_notebook_get_current_page(GTK_NOTEBOOK(termit.notebook)); TERMIT_GET_TAB_BY_INDEX2(pTab, page, 0); termit_tab_feed_child(pTab, val); return 0; } #ifdef TERMIT_ENABLE_SEARCH static int termit_lua_findNext(lua_State* ls) { termit_search_find_next(); return 0; } static int termit_lua_findPrev(lua_State* ls) { termit_search_find_prev(); return 0; } static int termit_lua_findDlg(lua_State* ls) { gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(termit.b_toggle_search), TRUE); return 0; } #endif // TERMIT_ENABLE_SEARCH static int termit_lua_selection(lua_State* ls) { gchar* buff = termit_get_selection(); if (!buff) return 0; lua_pushstring(ls, buff); g_free(buff); return 1; } static int termit_lua_reconfigure(lua_State* ls) { termit_reconfigure(); termit_config_trace(); return 0; } static int termit_lua_quit(lua_State* ls) { termit_on_exit(); return 0; } struct TermitLuaFunction { const char* lua_func_name; lua_CFunction c_func; int lua_func; } functions[] = { {"activateTab", termit_lua_activateTab, 0}, {"addMenu", termit_lua_addMenu, 0}, {"addPopupMenu", termit_lua_addPopupMenu, 0}, {"bindKey", termit_lua_bindKey, 0}, {"bindMouse", termit_lua_bindMouse, 0}, {"closeTab", termit_lua_closeTab, 0}, {"copy", termit_lua_copy, 0}, {"currentTab", termit_lua_currentTab, 0}, {"currentTabIndex", termit_lua_currentTabIndex, 0}, {"feed", termit_lua_feed, 0}, {"feedChild", termit_lua_feedChild, 0}, #ifdef TERMIT_ENABLE_SEARCH {"findDlg", termit_lua_findDlg, 0}, {"findNext", termit_lua_findNext, 0}, {"findPrev", termit_lua_findPrev, 0}, #endif // TERMIT_ENABLE_SEARCH {"forEachRow", termit_lua_forEachRow, 0}, {"forEachVisibleRow", termit_lua_forEachVisibleRow, 0}, {"loadSessionDlg", termit_lua_loadSessionDialog, 0}, {"nextTab", termit_lua_nextTab, 0}, {"openTab", termit_lua_openTab, 0}, {"paste", termit_lua_paste, 0}, {"preferencesDlg", termit_lua_preferencesDialog, 0}, {"prevTab", termit_lua_prevTab, 0}, {"quit", termit_lua_quit, 0}, {"reconfigure", termit_lua_reconfigure, 0}, {"saveSessionDlg", termit_lua_saveSessionDialog, 0}, {"selection", termit_lua_selection, 0}, {"setColormap", termit_lua_setColormap, 0}, {"setEncoding", termit_lua_setEncoding, 0}, {"setKbPolicy", termit_lua_setKbPolicy, 0}, {"setOptions", termit_lua_setOptions, 0}, {"setTabBackgroundColor", termit_lua_setTabBackgroundColor, 0}, {"setTabFont", termit_lua_setTabFont, 0}, {"setTabForegroundColor", termit_lua_setTabForegroundColor, 0}, {"setTabTitle", termit_lua_setTabTitle, 0}, {"setTabTitleDlg", termit_lua_setTabTitleDialog, 0}, {"setWindowTitle", termit_lua_setWindowTitle, 0}, {"spawn", termit_lua_spawn, 0}, {"toggleMenubar", termit_lua_toggleMenubar, 0}, {"toggleTabbar", termit_lua_toggleTabbar, 0} }; int termit_get_lua_func(const char* name) { unsigned short i = 0; for (; i < sizeof(functions)/sizeof(functions[0]); ++i) { if (strcmp(name, functions[i].lua_func_name) == 0) { return functions[i].lua_func; } } ERROR("not found lua function by name [%s]", name); return 0; } void termit_lua_init_api() { unsigned short i = 0; for (; i < sizeof(functions)/sizeof(functions[0]); ++i) { lua_pushcfunction(L, functions[i].c_func); functions[i].lua_func = luaL_ref(L, LUA_REGISTRYINDEX); lua_rawgeti(L, LUA_REGISTRYINDEX, functions[i].lua_func); lua_setglobal(L, functions[i].lua_func_name); TRACE("%s [%d]", functions[i].lua_func_name, functions[i].lua_func); } } nonstop-termit-fd89f3b/src/lua_api.h000066400000000000000000000065331176471573200176210ustar00rootroot00000000000000/* Copyright (C) 2007-2010, Evgeny Ratnikov This file is part of termit. termit is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation. termit 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 termit. If not, see .*/ #ifndef TERMIT_LUA_API_H #define TERMIT_LUA_API_H struct lua_State; void termit_lua_init_api(); void termit_lua_close(); void termit_lua_report_error(const char* file, int line, int status); void termit_lua_init(const gchar* initFile); void termit_lua_load_config(); void termit_lua_execute(const gchar* cmd); int termit_lua_dofunction(int f); int termit_lua_dofunction2(int f, const char* arg1); int termit_lua_domatch(int f, const gchar* matchedText); void termit_lua_unref(int* lua_callback); gchar* termit_lua_getTitleCallback(int f, const gchar* title); gchar* termit_lua_getStatusbarCallback(int f, guint page); int termit_get_lua_func(const char* name); typedef enum {TERMIT_LUA_TABLE_LOADER_OK, TERMIT_LUA_TABLE_LOADER_FAILED} TermitLuaTableLoaderResult; typedef void (*TermitLuaTableLoaderFunc)(const gchar*, struct lua_State*, int, void*); TermitLuaTableLoaderResult termit_lua_load_table(struct lua_State* ls, TermitLuaTableLoaderFunc func, const int tableIndex, void* data); int termit_lua_fill_tab(int tab_index, struct lua_State* ls); /** * Loaders * */ void termit_lua_options_loader(const gchar* name, struct lua_State* ls, int index, void* data); void termit_lua_keys_loader(const gchar* name, struct lua_State* ls, int index, void* data); void termit_lua_tab_loader(const gchar* name, struct lua_State* ls, int index, void* data); void termit_lua_load_colormap(struct lua_State* ls, int index, GdkColor** colors, glong* sz); void termit_config_get_string(gchar** opt, struct lua_State* ls, int index); void termit_config_get_double(double* opt, struct lua_State* ls, int index); void termit_config_getuint(guint* opt, struct lua_State* ls, int index); void termit_config_get_boolean(gboolean* opt, struct lua_State* ls, int index); void termit_config_get_function(int* opt, struct lua_State* ls, int index); void termit_config_get_color(GdkColor** opt, struct lua_State* ls, int index); void termit_config_get_erase_binding(VteTerminalEraseBinding* opt, struct lua_State* ls, int index); #define TERMIT_TAB_ADD_NUMBER(name, value) {\ lua_pushstring(ls, name); \ lua_pushnumber(ls, value); \ lua_rawset(ls, -3); \ } #define TERMIT_TAB_ADD_STRING(name, value) {\ lua_pushstring(ls, name); \ lua_pushstring(ls, value); \ lua_rawset(ls, -3); \ } #define TERMIT_TAB_ADD_VOID(name, value) {\ lua_pushstring(ls, name); \ lua_pushlightuserdata(ls, value); \ lua_rawset(ls, -3); \ } #define TERMIT_TAB_ADD_BOOLEAN(name, value) {\ lua_pushstring(ls, name); \ lua_pushboolean(ls, value); \ lua_rawset(ls, -3); \ } #define TERMIT_TAB_ADD_CALLBACK(name, value) {\ lua_pushstring(ls, name); \ lua_rawgeti(ls, LUA_REGISTRYINDEX, value); \ lua_rawset(ls, -3); \ } #endif /* TERMIT_LUA_API_H */ nonstop-termit-fd89f3b/src/lua_conf.c000066400000000000000000000354031176471573200177660ustar00rootroot00000000000000/* Copyright (C) 2007-2010, Evgeny Ratnikov This file is part of termit. termit is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation. termit 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 termit. If not, see .*/ #include #include // XParseGeometry #include #include #include #include #include "termit.h" #include "termit_core_api.h" #include "configs.h" #include "keybindings.h" #include "lua_api.h" extern struct TermitData termit; extern struct Configs configs; lua_State* L = NULL; void termit_lua_close() { lua_close(L); } static void trace_menus(GArray* menus) { #ifdef DEBUG guint i = 0; for (; ilen; ++i) { struct UserMenu* um = &g_array_index(menus, struct UserMenu, i); TRACE("%s items %d", um->name, um->items->len); guint j = 0; for (; jitems->len; ++j) { struct UserMenuItem* umi = &g_array_index(um->items, struct UserMenuItem, j); TRACE(" %s: (%d) [%s]", umi->name, umi->lua_callback, umi->accel); } } #endif } void termit_config_get_string(gchar** opt, lua_State* ls, int index) { if (!lua_isnil(ls, index) && lua_isstring(ls, index)) { if (*opt) g_free(*opt); *opt = g_strdup(lua_tostring(ls, index)); } } void termit_config_get_double(double* opt, lua_State* ls, int index) { if (!lua_isnil(ls, index) && lua_isnumber(ls, index)) *opt = lua_tonumber(ls, index); } void termit_config_getuint(guint* opt, lua_State* ls, int index) { if (!lua_isnil(ls, index) && lua_isnumber(ls, index)) *opt = lua_tointeger(ls, index); } void termit_config_get_boolean(gboolean* opt, lua_State* ls, int index) { if (!lua_isnil(ls, index) && lua_isboolean(ls, index)) *opt = lua_toboolean(ls, index); } void termit_config_get_function(int* opt, lua_State* ls, int index) { if (!lua_isnil(ls, index) && lua_isfunction(ls, index)) { *opt = luaL_ref(ls, LUA_REGISTRYINDEX); // luaL_ref pops value so we restore stack size lua_pushnil(ls); } } void termit_config_get_color(GdkColor** opt, lua_State* ls, int index) { gchar* color_str = NULL; termit_config_get_string(&color_str, ls, index); if (color_str) { GdkColor color = {}; if (gdk_color_parse(color_str, &color) == TRUE) { *opt = gdk_color_copy(&color); TRACE("color_str=%s", color_str); } } g_free(color_str); } void termit_config_get_erase_binding(VteTerminalEraseBinding* opt, lua_State* ls, int index) { gchar* str = NULL; termit_config_get_string(&str, ls, index); *opt = termit_erase_binding_from_string(str); g_free(str); } static void matchesLoader(const gchar* pattern, struct lua_State* ls, int index, void* data) { TRACE("pattern=%s index=%d data=%p", pattern, index, data); if (!lua_isfunction(ls, index)) { ERROR("match [%s] without function: skipping", pattern); return; } GArray* matches = (GArray*)data; struct Match match = {}; GError* err = NULL; match.regex = g_regex_new(pattern, 0, 0, &err); if (err) { TRACE("failed to compile regex [%s]: skipping", pattern); return; } match.flags = 0; match.pattern = g_strdup(pattern); termit_config_get_function(&match.lua_callback, ls, index); g_array_append_val(matches, match); } struct ColormapHelper { GdkColor* colors; int idx; }; static void colormapLoader(const gchar* name, lua_State* ls, int index, void* data) { struct ColormapHelper* ch = (struct ColormapHelper*)data; if (!lua_isnil(ls, index) && lua_isstring(ls, index)) { const gchar* colorStr = lua_tostring(ls, index); if (!gdk_color_parse(colorStr, &(ch->colors[ch->idx]))) { ERROR("failed to parse color: %s %d - %s", name, ch->idx, colorStr); } } else { ERROR("invalid type in colormap: skipping"); } ++ch->idx; } static void tabsLoader(const gchar* name, lua_State* ls, int index, void* data) { if (lua_istable(ls, index)) { GArray* tabs = (GArray*)data; struct TabInfo ti = {}; if (termit_lua_load_table(ls, termit_lua_tab_loader, index, &ti) != TERMIT_LUA_TABLE_LOADER_OK) { ERROR("failed to load tab: %s %s", name, lua_tostring(ls, 3)); } else { g_array_append_val(tabs, ti); } } else { ERROR("unknown type instead if tab table: skipping"); lua_pop(ls, 1); } } void termit_lua_load_colormap(lua_State* ls, int index, GdkColor** colors, glong* sz) { if (lua_isnil(ls, index) || !lua_istable(ls, index)) { ERROR("invalid colormap type"); return; } #if LUA_VERSION_NUM > 501 const int size = lua_rawlen(ls, index); #else const int size = lua_objlen(ls, index); #endif // LUA_VERSION_NUM if ((size != 8) && (size != 16) && (size != 24)) { ERROR("bad colormap length: %d", size); return; } struct ColormapHelper ch = {}; ch.colors = g_malloc0(size * sizeof(GdkColor)); if (termit_lua_load_table(ls, colormapLoader, index, &ch) == TERMIT_LUA_TABLE_LOADER_OK) { if (*colors) { g_free(*colors); } *colors = ch.colors; *sz = size; } else { ERROR("failed to load colormap"); return; } TRACE("colormap loaded: size=%ld", *sz); } void termit_lua_options_loader(const gchar* name, lua_State* ls, int index, void* data) { struct Configs* p_cfg = (struct Configs*)data; if (!strcmp(name, "tabName")) termit_config_get_string(&(p_cfg->default_tab_name), ls, index); else if (!strcmp(name, "windowTitle")) termit_config_get_string(&(p_cfg->default_window_title), ls, index); else if (!strcmp(name, "encoding")) termit_config_get_string(&(p_cfg->default_encoding), ls, index); else if (!strcmp(name, "wordChars")) termit_config_get_string(&(p_cfg->default_word_chars), ls, index); else if (!strcmp(name, "font")) termit_config_get_string(&(p_cfg->style.font_name), ls, index); else if (!strcmp(name, "foregroundColor")) termit_config_get_color(&p_cfg->style.foreground_color, ls, index); else if (!strcmp(name, "backgroundColor")) termit_config_get_color(&p_cfg->style.background_color, ls, index); else if (!strcmp(name, "showScrollbar")) termit_config_get_boolean(&(p_cfg->show_scrollbar), ls, index); else if (!strcmp(name, "transparency")) termit_config_get_double(&(p_cfg->style.transparency), ls, index); else if (!strcmp(name, "imageFile")) termit_config_get_string(&(p_cfg->style.image_file), ls, index); else if (!strcmp(name, "fillTabbar")) termit_config_get_boolean(&(p_cfg->fill_tabbar), ls, index); else if (!strcmp(name, "hideSingleTab")) termit_config_get_boolean(&(p_cfg->hide_single_tab), ls, index); else if (!strcmp(name, "hideMenubar")) termit_config_get_boolean(&(p_cfg->hide_menubar), ls, index); else if (!strcmp(name, "hideTabbar")) termit_config_get_boolean(&(p_cfg->hide_tabbar), ls, index); else if (!strcmp(name, "scrollbackLines")) termit_config_getuint(&(p_cfg->scrollback_lines), ls, index); else if (!strcmp(name, "allowChangingTitle")) termit_config_get_boolean(&(p_cfg->allow_changing_title), ls, index); else if (!strcmp(name, "audibleBell")) termit_config_get_boolean(&(p_cfg->audible_bell), ls, index); else if (!strcmp(name, "visibleBell")) termit_config_get_boolean(&(p_cfg->visible_bell), ls, index); else if (!strcmp(name, "urgencyOnBell")) termit_config_get_boolean(&(p_cfg->urgency_on_bell), ls, index); else if (!strcmp(name, "getWindowTitle")) termit_config_get_function(&(p_cfg->get_window_title_callback), ls, index); else if (!strcmp(name, "getTabTitle")) termit_config_get_function(&(p_cfg->get_tab_title_callback), ls, index); else if (!strcmp(name, "setStatusbar")) termit_config_get_function(&(p_cfg->get_statusbar_callback), ls, index); else if (!strcmp(name, "backspaceBinding")) termit_config_get_erase_binding(&(p_cfg->default_bksp), ls, index); else if (!strcmp(name, "deleteBinding")) termit_config_get_erase_binding(&(p_cfg->default_delete), ls, index); else if (!strcmp(name, "colormap")) { termit_lua_load_colormap(ls, index, &configs.style.colors, &configs.style.colors_size); } else if (!strcmp(name, "matches")) { if (termit_lua_load_table(ls, matchesLoader, index, configs.matches) != TERMIT_LUA_TABLE_LOADER_OK) { ERROR("failed to load matches"); } } else if (!strcmp(name, "geometry")) { gchar* geometry_str = NULL; termit_config_get_string(&geometry_str, ls, index); if (geometry_str) { unsigned int cols = 0, rows = 0; int tmp1 = 0, tmp2 = 0; XParseGeometry(geometry_str, &tmp1, &tmp2, &cols, &rows); if ((cols != 0) && (rows != 0)) { p_cfg->cols = cols; p_cfg->rows = rows; } } g_free(geometry_str); } else if (!strcmp(name, "tabs")) { if (lua_istable(ls, index)) { if (!configs.default_tabs) { configs.default_tabs = g_array_new(FALSE, TRUE, sizeof(struct TabInfo)); } TRACE("tabs at index: %d tabs.size=%zd", index, configs.default_tabs->len); if (termit_lua_load_table(ls, tabsLoader, index, configs.default_tabs) != TERMIT_LUA_TABLE_LOADER_OK) { ERROR("openTab failed"); } } else { ERROR("expecting table"); } } } static void termit_lua_add_package_path(const gchar* path) { gchar* luaCmd = g_strdup_printf("package.path = package.path .. \";%s/?.lua\"", path); int s = luaL_dostring(L, luaCmd); termit_lua_report_error(__FILE__, __LINE__, s); g_free(luaCmd); } static gchar** termit_system_path() { const gchar *configSystem = g_getenv("XDG_CONFIG_DIRS"); gchar* xdgConfigDirs = NULL; if (configSystem) { xdgConfigDirs = g_strdup_printf("%s:/etc/xdg", configSystem); } else { xdgConfigDirs = g_strdup("/etc/xdg"); } gchar** systemPaths = g_strsplit(xdgConfigDirs, ":", 0); g_free(xdgConfigDirs); return systemPaths; } static gchar* termit_user_path() { const gchar *configHome = g_getenv("XDG_CONFIG_HOME"); if (configHome) return g_strdup(configHome); else return g_strdup_printf("%s/.config", g_getenv("HOME")); } static void load_init(const gchar* initFile) { const gchar *configFile = "rc.lua"; gchar** systemPaths = termit_system_path(); guint i = 0; gchar* systemPath = systemPaths[i]; while (systemPath) { if (g_file_test(systemPath, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR) == TRUE) { termit_lua_add_package_path(systemPath); } systemPath = systemPaths[++i]; } gchar* userPath = termit_user_path(); termit_lua_add_package_path(userPath); gchar* fullPath = NULL; if (initFile) { fullPath = g_strdup(initFile); } else { fullPath = g_strdup_printf("%s/termit/%s", userPath, configFile); if (g_file_test(fullPath, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR) == FALSE) { TRACE("%s not found", fullPath); g_free(fullPath); i = 0; gchar* systemPath = systemPaths[i]; while (systemPath) { fullPath = g_strdup_printf("%s/termit/%s", systemPath, configFile); if (g_file_test(fullPath, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR) == FALSE) { TRACE("%s not found", fullPath); g_free(fullPath); fullPath = NULL; } else { break; } systemPath = systemPaths[++i]; } } } g_strfreev(systemPaths); g_free(userPath); if (fullPath) { TRACE("using config: %s", fullPath); int s = luaL_loadfile(L, fullPath); termit_lua_report_error(__FILE__, __LINE__, s); g_free(fullPath); s = lua_pcall(L, 0, LUA_MULTRET, 0); termit_lua_report_error(__FILE__, __LINE__, s); } else { ERROR("config file %s not found", configFile); } } int termit_lua_fill_tab(int tab_index, lua_State* ls) { TERMIT_GET_TAB_BY_INDEX2(pTab, tab_index, 0); lua_newtable(ls); TERMIT_TAB_ADD_STRING("title", pTab->title); TERMIT_TAB_ADD_STRING("command", pTab->command); TERMIT_TAB_ADD_STRING("encoding", pTab->encoding); gchar* working_dir = termit_get_pid_dir(pTab->pid); TERMIT_TAB_ADD_STRING("workingDir", working_dir); g_free(working_dir); TERMIT_TAB_ADD_NUMBER("pid", pTab->pid); TERMIT_TAB_ADD_STRING("font", pTab->style.font_name); TERMIT_TAB_ADD_NUMBER("fontSize", pango_font_description_get_size(pTab->style.font)/PANGO_SCALE); TERMIT_TAB_ADD_STRING("backspaceBinding", termit_erase_binding_to_string(pTab->bksp_binding)); TERMIT_TAB_ADD_STRING("deleteBinding", termit_erase_binding_to_string(pTab->delete_binding)); return 1; } static int termit_lua_tabs_index(lua_State* ls) { if (lua_isnumber(ls, 1)) { TRACE_MSG("index is not number: skipping"); return 0; } int tab_index = lua_tointeger(ls, -1); TRACE("tab_index:%d", tab_index); return termit_lua_fill_tab(tab_index, ls); } static int termit_lua_tabs_newindex(lua_State* ls) { ERROR("'tabs' is read-only variable"); return 0; } static void termit_lua_init_tabs() { lua_newtable(L); luaL_newmetatable(L, "tabs_meta"); lua_pushcfunction(L, termit_lua_tabs_index); lua_setfield(L, -2, "__index"); lua_pushcfunction(L, termit_lua_tabs_newindex); lua_setfield(L, -2, "__newindex"); lua_setmetatable(L, -2); lua_setglobal(L, "tabs"); } static const gchar* termit_init_file = NULL; void termit_lua_load_config() { load_init(termit_init_file); termit_config_trace(); trace_menus(configs.user_menus); trace_menus(configs.user_popup_menus); } void termit_lua_init(const gchar* initFile) { L = luaL_newstate(); luaL_openlibs(L); if (!termit_init_file) termit_init_file = g_strdup(initFile); termit_lua_init_tabs(); termit_lua_init_api(); termit_keys_set_defaults(); termit_lua_load_config(); } nonstop-termit-fd89f3b/src/sessions.c000066400000000000000000000107041176471573200200430ustar00rootroot00000000000000/* Copyright (C) 2007-2010, Evgeny Ratnikov This file is part of termit. termit is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation. termit 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 termit. If not, see .*/ #include #include #include #include #include #include #include #include #include #include #include #include "termit.h" #include "termit_core_api.h" #include "configs.h" #include "callbacks.h" #include "lua_api.h" #include "sessions.h" extern lua_State* L; // from Openbox static gboolean parse_mkdir(const gchar *path, gint mode) { gboolean ret = TRUE; g_return_val_if_fail(path != NULL, FALSE); g_return_val_if_fail(path[0] != '\0', FALSE); if (!g_file_test(path, G_FILE_TEST_IS_DIR)) if (mkdir(path, mode) == -1) ret = FALSE; return ret; } // from Openbox static gboolean parse_mkdir_path(const gchar *path, gint mode) { gboolean ret = TRUE; g_return_val_if_fail(path != NULL, FALSE); g_return_val_if_fail(path[0] == '/', FALSE); if (!g_file_test(path, G_FILE_TEST_IS_DIR)) { gchar *c, *e; c = g_strdup(path); e = c; while ((e = strchr(e + 1, '/'))) { *e = '\0'; if (!(ret = parse_mkdir(c, mode))) goto parse_mkdir_path_end; *e = '/'; } ret = parse_mkdir(c, mode); parse_mkdir_path_end: g_free(c); } return ret; } void termit_init_sessions() { gchar *fullPath; const gchar *dataHome = g_getenv("XDG_DATA_HOME"); if (dataHome) fullPath = g_strdup_printf("%s/termit", dataHome); else fullPath = g_strdup_printf("%s/.local/share/termit", g_getenv("HOME")); TRACE("%s %s", __FUNCTION__, fullPath); if (!parse_mkdir_path(fullPath, 0700)) g_message(_("Unable to create directory '%s': %s"), fullPath, g_strerror(errno)); g_free(fullPath); } void termit_load_session(const gchar* sessionFile) { TRACE("loading sesions from %s", sessionFile); int s = luaL_dofile(L, sessionFile); termit_lua_report_error(__FILE__, __LINE__, s); } /** * saves session as lua-script * */ void termit_save_session(const gchar* sessionFile) { TRACE("saving session to file %s", sessionFile); FILE* fd = g_fopen(sessionFile, "w"); if ((intptr_t)fd == -1) { TRACE("failed savimg to %s", sessionFile); return; } guint pages = gtk_notebook_get_n_pages(GTK_NOTEBOOK(termit.notebook)); guint i = 0; for (; i < pages; ++i) { TERMIT_GET_TAB_BY_INDEX(pTab, i); gchar* working_dir = termit_get_pid_dir(pTab->pid); gchar* groupName = g_strdup_printf("tab%d", i); g_fprintf(fd, "%s = {}\n", groupName); g_fprintf(fd, "%s.title = \"%s\"\n", groupName, gtk_label_get_text(GTK_LABEL(pTab->tab_name))); g_fprintf(fd, "%s.workingDir = \"%s\"\n", groupName, working_dir); g_fprintf(fd, "%s.command = \"%s\"\n", groupName, pTab->command); g_fprintf(fd, "%s.encoding = \"%s\"\n", groupName, pTab->encoding); GValue val = {}; g_value_init(&val, g_type_from_name("VteTerminalEraseBinding")); g_object_get_property(G_OBJECT(pTab->vte), "backspace-binding", &val); VteTerminalEraseBinding eb = g_value_get_enum(&val); if (eb != VTE_ERASE_AUTO) { g_fprintf(fd, "%s.backspaceBinding = \"%s\"\n", groupName, termit_erase_binding_to_string(eb)); } g_value_unset(&val); g_value_init(&val, g_type_from_name("VteTerminalEraseBinding")); g_object_get_property(G_OBJECT(pTab->vte), "delete-binding", &val); eb = g_value_get_enum(&val); if (eb != VTE_ERASE_AUTO) { g_fprintf(fd, "%s.deleteBinding = \"%s\"\n", groupName, termit_erase_binding_to_string(eb)); } g_value_unset(&val); g_fprintf(fd, "openTab(%s)\n\n", groupName); g_free(groupName); g_free(working_dir); } // g_fprintf(fd, data); fclose(fd); } nonstop-termit-fd89f3b/src/sessions.h000066400000000000000000000015161176471573200200510ustar00rootroot00000000000000/* Copyright (C) 2007-2010, Evgeny Ratnikov This file is part of termit. termit is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation. termit 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 termit. If not, see .*/ #ifndef SESSIONS_H #define SESSIONS_H void termit_init_sessions(); void termit_load_session(const gchar* sessionFile); void termit_save_session(const gchar* sessionFile); #endif /* SESSIONS_H */ nonstop-termit-fd89f3b/src/termit.c000066400000000000000000000423051176471573200175030ustar00rootroot00000000000000/* Copyright (C) 2007-2010, Evgeny Ratnikov This file is part of termit. termit is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation. termit 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 termit. If not, see .*/ #include #include #include #include #include #include "config.h" #include "termit_core_api.h" #include "lua_api.h" #include "callbacks.h" #include "sessions.h" #include "keybindings.h" #include "configs.h" #include "termit.h" struct TermitData termit = {}; struct TermitTab* termit_get_tab_by_index(guint index) { GtkWidget* tabWidget = gtk_notebook_get_nth_page(GTK_NOTEBOOK(termit.notebook), index); if (!tabWidget) { ERROR("tabWidget at %zd is NULL", index); return NULL; } struct TermitTab* pTab = (struct TermitTab*)g_object_get_data(G_OBJECT(tabWidget), TERMIT_TAB_DATA); return pTab; } static GtkWidget* create_statusbar() { GtkWidget* statusbar = gtk_statusbar_new(); return statusbar; } static void create_search(struct TermitData* termit) { #ifdef TERMIT_ENABLE_SEARCH termit->b_toggle_search = gtk_toggle_button_new(); gtk_button_set_image(GTK_BUTTON(termit->b_toggle_search), gtk_image_new_from_stock(GTK_STOCK_FIND, GTK_ICON_SIZE_BUTTON)); g_signal_connect(G_OBJECT(termit->b_toggle_search), "toggled", G_CALLBACK(termit_on_toggle_search), NULL); termit->b_find_next = gtk_button_new(); gtk_button_set_image(GTK_BUTTON(termit->b_find_next), gtk_image_new_from_stock(GTK_STOCK_GO_FORWARD, GTK_ICON_SIZE_BUTTON)); g_signal_connect(G_OBJECT(termit->b_find_next), "clicked", G_CALLBACK(termit_on_find_next), NULL); termit->b_find_prev = gtk_button_new(); gtk_button_set_image(GTK_BUTTON(termit->b_find_prev), gtk_image_new_from_stock(GTK_STOCK_GO_BACK, GTK_ICON_SIZE_BUTTON)); g_signal_connect(G_OBJECT(termit->b_find_prev), "clicked", G_CALLBACK(termit_on_find_prev), NULL); termit->search_entry = gtk_entry_new(); g_signal_connect(G_OBJECT(termit->search_entry), "key-press-event", G_CALLBACK(termit_on_search_keypress), NULL); #endif // TERMIT_ENABLE_SEARCH } static void pack_widgets() { GtkWidget *vbox = gtk_vbox_new(FALSE, 0); termit.hbox = gtk_hbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(termit.hbox), termit.menu_bar, FALSE, 0, 0); #ifdef TERMIT_ENABLE_SEARCH gtk_box_pack_start(GTK_BOX(termit.hbox), termit.b_toggle_search, FALSE, 0, 0); gtk_box_pack_start(GTK_BOX(termit.hbox), termit.search_entry, FALSE, 0, 0); gtk_box_pack_start(GTK_BOX(termit.hbox), termit.b_find_prev, FALSE, 0, 0); gtk_box_pack_start(GTK_BOX(termit.hbox), termit.b_find_next, FALSE, 0, 0); #endif // TERMIT_ENABLE_SEARCH gtk_box_pack_start(GTK_BOX(termit.hbox), termit.statusbar, TRUE, 1, 0); gtk_box_pack_start(GTK_BOX(vbox), termit.notebook, TRUE, 1, 0); gtk_box_pack_start(GTK_BOX(vbox), termit.hbox, FALSE, 1, 0); gtk_container_add(GTK_CONTAINER(termit.main_window), vbox); if (!gtk_notebook_get_n_pages(GTK_NOTEBOOK(termit.notebook))) termit_append_tab(); g_signal_connect(G_OBJECT(termit.notebook), "switch-page", G_CALLBACK(termit_on_switch_page), NULL); g_signal_connect(G_OBJECT(termit.main_window), "button-press-event", G_CALLBACK(termit_on_double_click), NULL); } static void menu_item_set_accel(GtkMenuItem* mi, const gchar* parentName, const gchar* itemName, const gchar* accel) { struct KeyWithState kws = {}; if (termit_parse_keys_str(accel, &kws) < 0) { ERROR("failed to parse keybinding: %s", accel); return; } gchar* path = NULL; path = g_strdup_printf("/%s/%s", parentName, itemName); gtk_menu_item_set_accel_path(GTK_MENU_ITEM(mi), path); gtk_accel_map_add_entry(path, kws.keyval, kws.state); g_free(path); } static void termit_create_menus(GtkWidget* menu_bar, GtkAccelGroup* accel, GArray* menus) { TRACE("menus->len=%d", menus->len); guint j = 0; for (; jlen; ++j) { struct UserMenu* um = &g_array_index(menus, struct UserMenu, j); GtkWidget *mi_menu = gtk_menu_item_new_with_label(um->name); GtkWidget *menu = gtk_menu_new(); gtk_menu_item_set_submenu(GTK_MENU_ITEM(mi_menu), menu); gtk_menu_set_accel_group(GTK_MENU(menu), accel); TRACE("%s items->len=%d", um->name, um->items->len); guint i = 0; gtk_menu_set_accel_group(GTK_MENU(menu), accel); for (; iitems->len; ++i) { struct UserMenuItem* umi = &g_array_index(um->items, struct UserMenuItem, i); GtkWidget *mi_tmp = gtk_menu_item_new_with_label(umi->name); g_object_set_data(G_OBJECT(mi_tmp), TERMIT_USER_MENU_ITEM_DATA, umi); g_signal_connect(G_OBJECT(mi_tmp), "activate", G_CALLBACK(termit_on_menu_item_selected), NULL); if (umi->accel) { menu_item_set_accel(GTK_MENU_ITEM(mi_tmp), um->name, umi->name, umi->accel); } gtk_menu_shell_append(GTK_MENU_SHELL(menu), mi_tmp); } gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), mi_menu); } } static GtkWidget* termit_lua_menu_item_from_stock(const gchar* stock_id, const char* luaFunc) { GtkWidget *mi = gtk_image_menu_item_new_from_stock(stock_id, NULL); g_signal_connect(G_OBJECT(mi), "activate", G_CALLBACK(termit_on_menu_item_selected), NULL); struct UserMenuItem* umi = (struct UserMenuItem*)malloc(sizeof(struct UserMenuItem)); umi->name = g_strdup(gtk_menu_item_get_label(GTK_MENU_ITEM(mi))); umi->accel = NULL; umi->lua_callback = termit_get_lua_func(luaFunc); g_object_set_data(G_OBJECT(mi), TERMIT_USER_MENU_ITEM_DATA, umi); return mi; } static GtkWidget* termit_lua_menu_item_from_string(const gchar* label, const char* luaFunc) { GtkWidget *mi = gtk_menu_item_new_with_label(label); g_signal_connect(G_OBJECT(mi), "activate", G_CALLBACK(termit_on_menu_item_selected), NULL); struct UserMenuItem* umi = (struct UserMenuItem*)malloc(sizeof(struct UserMenuItem)); umi->name = g_strdup(gtk_menu_item_get_label(GTK_MENU_ITEM(mi))); umi->accel = NULL; umi->lua_callback = termit_get_lua_func(luaFunc); g_object_set_data(G_OBJECT(mi), TERMIT_USER_MENU_ITEM_DATA, umi); return mi; } void termit_create_menubar() { GtkAccelGroup *accel = gtk_accel_group_new(); gtk_window_add_accel_group(GTK_WINDOW(termit.main_window), accel); GtkWidget* menu_bar = gtk_menu_bar_new(); // File menu GtkWidget *mi_new_tab = termit_lua_menu_item_from_stock(GTK_STOCK_ADD, "openTab"); GtkWidget *mi_close_tab = termit_lua_menu_item_from_stock(GTK_STOCK_DELETE, "closeTab"); GtkWidget *mi_exit = termit_lua_menu_item_from_stock(GTK_STOCK_QUIT, "quit"); GtkWidget *mi_file = gtk_menu_item_new_with_label(_("File")); GtkWidget *file_menu = gtk_menu_new(); gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), mi_new_tab); gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), mi_close_tab); gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), gtk_separator_menu_item_new()); gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), mi_exit); gtk_menu_item_set_submenu(GTK_MENU_ITEM(mi_file), file_menu); gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), mi_file); // Edit menu GtkWidget *mi_set_tab_name = termit_lua_menu_item_from_string(_("Set tab name..."), "setTabTitleDlg"); GtkWidget *mi_edit_preferences = termit_lua_menu_item_from_stock(GTK_STOCK_PREFERENCES, "preferencesDlg"); GtkWidget *mi_copy = termit_lua_menu_item_from_stock(GTK_STOCK_COPY, "copy"); GtkWidget *mi_paste = termit_lua_menu_item_from_stock(GTK_STOCK_PASTE, "paste"); GtkWidget *mi_edit = gtk_menu_item_new_with_label(_("Edit")); GtkWidget *edit_menu = gtk_menu_new(); gtk_menu_shell_append(GTK_MENU_SHELL(edit_menu), mi_copy); gtk_menu_shell_append(GTK_MENU_SHELL(edit_menu), mi_paste); gtk_menu_shell_append(GTK_MENU_SHELL(edit_menu), gtk_separator_menu_item_new()); gtk_menu_shell_append(GTK_MENU_SHELL(edit_menu), mi_set_tab_name); gtk_menu_shell_append(GTK_MENU_SHELL(edit_menu), mi_edit_preferences); gtk_menu_item_set_submenu(GTK_MENU_ITEM(mi_edit), edit_menu); gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), mi_edit); // Sessions menu GtkWidget *mi_load_session = termit_lua_menu_item_from_stock(GTK_STOCK_OPEN, "loadSessionDlg"); GtkWidget *mi_save_session = termit_lua_menu_item_from_stock(GTK_STOCK_SAVE, "saveSessionDlg"); GtkWidget *mi_sessions = gtk_menu_item_new_with_label(_("Sessions")); GtkWidget *sessions_menu = gtk_menu_new(); gtk_menu_shell_append(GTK_MENU_SHELL(sessions_menu), mi_load_session); gtk_menu_shell_append(GTK_MENU_SHELL(sessions_menu), mi_save_session); gtk_menu_item_set_submenu(GTK_MENU_ITEM(mi_sessions), sessions_menu); gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), mi_sessions); // User menus termit_create_menus(menu_bar, accel, configs.user_menus); termit.menu_bar = menu_bar; } void termit_create_popup_menu() { termit.menu = gtk_menu_new(); GtkWidget *mi_new_tab = termit_lua_menu_item_from_stock(GTK_STOCK_ADD, "openTab"); GtkWidget *mi_close_tab = termit_lua_menu_item_from_stock(GTK_STOCK_DELETE, "closeTab"); GtkWidget *mi_set_tab_name = termit_lua_menu_item_from_string(_("Set tab name..."), "setTabTitleDlg"); GtkWidget *mi_edit_preferences = termit_lua_menu_item_from_stock(GTK_STOCK_PREFERENCES, "preferencesDlg"); GtkWidget *mi_copy = termit_lua_menu_item_from_stock(GTK_STOCK_COPY, "copy"); GtkWidget *mi_paste = termit_lua_menu_item_from_stock(GTK_STOCK_PASTE, "paste"); GtkWidget *mi_exit = termit_lua_menu_item_from_stock(GTK_STOCK_QUIT, "quit"); termit.mi_show_scrollbar = gtk_check_menu_item_new_with_label(_("Scrollbar")); gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(termit.mi_show_scrollbar), configs.show_scrollbar); termit_set_show_scrollbar_signal(termit.mi_show_scrollbar, NULL); gtk_menu_shell_append(GTK_MENU_SHELL(termit.menu), mi_new_tab); gtk_menu_shell_append(GTK_MENU_SHELL(termit.menu), mi_close_tab); gtk_menu_shell_append(GTK_MENU_SHELL(termit.menu), gtk_separator_menu_item_new()); gtk_menu_shell_append(GTK_MENU_SHELL(termit.menu), mi_set_tab_name); gtk_menu_shell_append(GTK_MENU_SHELL(termit.menu), termit.mi_show_scrollbar); gtk_menu_shell_append(GTK_MENU_SHELL(termit.menu), mi_edit_preferences); gtk_menu_shell_append(GTK_MENU_SHELL(termit.menu), gtk_separator_menu_item_new()); gtk_menu_shell_append(GTK_MENU_SHELL(termit.menu), mi_copy); gtk_menu_shell_append(GTK_MENU_SHELL(termit.menu), mi_paste); gtk_menu_shell_append(GTK_MENU_SHELL(termit.menu), gtk_separator_menu_item_new()); gtk_menu_shell_append(GTK_MENU_SHELL(termit.menu), mi_exit); // User popup menus TRACE("user_popup_menus->len=%zd", configs.user_popup_menus->len); guint j = 0; for (; jlen; ++j) { struct UserMenu* um = &g_array_index(configs.user_popup_menus, struct UserMenu, j); GtkWidget *mi_util = gtk_menu_item_new_with_label(um->name); GtkWidget *utils_menu = gtk_menu_new(); gtk_menu_item_set_submenu(GTK_MENU_ITEM(mi_util), utils_menu); TRACE("%s items->len=%zd", um->name, um->items->len); guint i = 0; for (; iitems->len; i++) { struct UserMenuItem* umi = &g_array_index(um->items, struct UserMenuItem, i); GtkWidget *mi_tmp = gtk_menu_item_new_with_label(umi->name); g_object_set_data(G_OBJECT(mi_tmp), TERMIT_USER_MENU_ITEM_DATA, umi); gtk_menu_shell_append(GTK_MENU_SHELL(utils_menu), mi_tmp); g_signal_connect(G_OBJECT(mi_tmp), "activate", G_CALLBACK(termit_on_menu_item_selected), NULL); } gtk_menu_shell_insert(GTK_MENU_SHELL(termit.menu), mi_util, 6); } gtk_widget_show_all(termit.menu); } static void termit_init(const gchar* initFile, const gchar* command) { termit_init_sessions(); termit_configs_set_defaults(); termit.tab_max_number = 1; termit.main_window = gtk_window_new(GTK_WINDOW_TOPLEVEL); termit.statusbar = create_statusbar(); create_search(&termit); termit.notebook = gtk_notebook_new(); gtk_notebook_set_show_tabs(GTK_NOTEBOOK(termit.notebook), TRUE); termit_lua_init(initFile); if (command) { TRACE("using command: %s", command); termit_append_tab_with_command(command); } termit_create_menubar(); pack_widgets(); termit_create_popup_menu(); if (!configs.allow_changing_title) termit_set_window_title(configs.default_window_title); } enum { TERMIT_GETOPT_HELP = 'h', TERMIT_GETOPT_VERSION = 'v', TERMIT_GETOPT_EXEC = 'e', TERMIT_GETOPT_INIT = 'i', TERMIT_GETOPT_NAME = 'n', TERMIT_GETOPT_CLASS = 'c', TERMIT_GETOPT_ROLE = 'r' }; static void termit_print_usage() { g_print( "termit %s - terminal emulator\n" "\n" "This program comes with NO WARRANTY, to the extent permitted by law.\n" "You may redistribute copies of this program\n" "under the terms of the GNU General Public License.\n" "For more information about these matters, see the file named COPYING.\n" "\n" "Options:\n" " -h, --help - print this help message\n" " -v, --version - print version number\n" " -e, --execute - execute command\n" " -i, --init=init_file - use init_file instead of standard rc.lua\n" " -n, --name=name - set window name hint\n" " -c, --class=class - set window class hint\n" " -r, --role=role - set window role (Gtk hint)\n" "", PACKAGE_VERSION); } int main(int argc, char **argv) { gchar* initFile = NULL; gchar* command = NULL; gchar *windowName = NULL, *windowClass = NULL, *windowRole = NULL; while (1) { static struct option long_options[] = { {"help", no_argument, 0, TERMIT_GETOPT_HELP}, {"version", no_argument, 0, TERMIT_GETOPT_VERSION}, {"execute", required_argument, 0, TERMIT_GETOPT_EXEC}, {"init", required_argument, 0, TERMIT_GETOPT_INIT}, {"name", required_argument, 0, TERMIT_GETOPT_NAME}, {"class", required_argument, 0, TERMIT_GETOPT_CLASS}, {"role", required_argument, 0, TERMIT_GETOPT_ROLE}, {0, 0, 0, 0} }; /* getopt_long stores the option index here. */ int option_index = 0; int flag = getopt_long(argc, argv, "hvi:e:n:c:r:", long_options, &option_index); /* Detect the end of the options. */ if (flag == -1) break; switch (flag) { case TERMIT_GETOPT_HELP: termit_print_usage(); return 0; case TERMIT_GETOPT_VERSION: g_printf(PACKAGE_VERSION); g_printf("\n"); return 0; case TERMIT_GETOPT_EXEC: command = g_strdup(optarg); break; case TERMIT_GETOPT_INIT: initFile = g_strdup(optarg); break; case TERMIT_GETOPT_NAME: windowName = g_strdup(optarg); break; case TERMIT_GETOPT_CLASS: windowClass = g_strdup(optarg); break; case TERMIT_GETOPT_ROLE: windowRole = g_strdup(optarg); break; case '?': break; /* getopt_long already printed an error message. */ default: break; } } bind_textdomain_codeset(PACKAGE, "UTF-8"); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); gtk_init(&argc, &argv); #ifdef __linux__ signal(SIGCHLD, SIG_IGN); #endif /* LINUX */ termit_init(initFile, command); g_free(command); g_free(initFile); /** * dirty hack from gnome-terminal ;-) * F10 is used in many console apps, so we change global Gtk setting for termit * */ gtk_settings_set_string_property(gtk_settings_get_default(), "gtk-menu-bar-accel", "F10", "termit"); g_signal_connect(G_OBJECT (termit.main_window), "delete_event", G_CALLBACK (termit_on_delete_event), NULL); g_signal_connect(G_OBJECT (termit.main_window), "destroy", G_CALLBACK (termit_on_destroy), NULL); g_signal_connect(G_OBJECT (termit.main_window), "key-press-event", G_CALLBACK(termit_on_key_press), NULL); TRACE("windowName=%s windowClass=%s windowRole=%s", windowName, windowClass, windowRole); if (windowName || windowClass) { gtk_window_set_wmclass(GTK_WINDOW(termit.main_window), windowName, windowClass); g_free(windowName); g_free(windowClass); } if (windowRole) { gtk_window_set_role(GTK_WINDOW(termit.main_window), windowRole); g_free(windowRole); } /* Show the application window */ gtk_widget_show_all(termit.main_window); // actions after display termit_after_show_all(); gtk_main(); termit_config_deinit(); termit_lua_close(); return 0; } nonstop-termit-fd89f3b/src/termit.h000066400000000000000000000060201176471573200175020ustar00rootroot00000000000000/* Copyright (C) 2007-2010, Evgeny Ratnikov This file is part of termit. termit is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation. termit 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 termit. If not, see .*/ #ifndef TERMIT_H #define TERMIT_H #include #include #include #include #include #define _(String) gettext(String) #include "termit_style.h" struct TermitData { GtkWidget *main_window; GtkWidget *notebook; GtkWidget *statusbar; #ifdef TERMIT_ENABLE_SEARCH GtkWidget *b_toggle_search; GtkWidget *b_find_next; GtkWidget *b_find_prev; GtkWidget *search_entry; #endif // TERMIT_ENABLE_SEARCH GtkWidget *cb_bookmarks; GtkWidget *menu; GtkWidget *mi_show_scrollbar; GtkWidget *hbox; GtkWidget *menu_bar; gint tab_max_number; }; extern struct TermitData termit; struct TermitTab { GtkWidget *tab_name; GtkWidget *hbox; GtkWidget *vte; GtkWidget *scrollbar; gboolean scrollbar_is_shown; gboolean custom_tab_name; gboolean audible_bell; gboolean visible_bell; VteTerminalEraseBinding bksp_binding; VteTerminalEraseBinding delete_binding; gchar *encoding; gchar *command; gchar *title; GArray* matches; struct TermitStyle style; pid_t pid; }; struct TabInfo { gchar* name; gchar* command; gchar* working_dir; gchar* encoding; VteTerminalEraseBinding bksp_binding; VteTerminalEraseBinding delete_binding; }; struct TermitTab* termit_get_tab_by_index(guint index); #define TERMIT_GET_TAB_BY_INDEX(pTab, ind) \ struct TermitTab* pTab = termit_get_tab_by_index(ind); \ if (!pTab) \ { g_fprintf(stderr, "%s:%d error: %s is null\n", __FILE__, __LINE__, #pTab); return; } #define TERMIT_GET_TAB_BY_INDEX2(pTab, ind, retCode) \ struct TermitTab* pTab = termit_get_tab_by_index(ind); \ if (!pTab) \ { g_fprintf(stderr, "%s:%d error: %s is null\n", __FILE__, __LINE__, #pTab); return retCode; } //#define ERROR(x) g_fprintf(stderr, "%s:%d error: %s\n", __FILE__, __LINE__, x) #define ERROR(format, ...) g_fprintf(stderr, "%s:%d " format "\n", __FILE__, __LINE__, ## __VA_ARGS__) #ifdef DEBUG #define STDFMT "%s:%d " #define STD __FILE__, __LINE__ #define TRACE(format, ...) g_fprintf(stderr, STDFMT # format, STD, ## __VA_ARGS__); g_fprintf(stderr, "\n") #define TRACE_MSG(x) g_fprintf(stderr, "%s:%d %s\n", __FILE__, __LINE__, x) #define TRACE_FUNC g_fprintf(stderr, "%s:%d %s\n", __FILE__, __LINE__, __FUNCTION__) #else #define TRACE(format, ...) #define TRACE_MSG(x) #define TRACE_FUNC #endif #endif /* TERMIT_H */ nonstop-termit-fd89f3b/src/termit_core_api.c000066400000000000000000000625571176471573200213570ustar00rootroot00000000000000/* Copyright (C) 2007-2010, Evgeny Ratnikov This file is part of termit. termit is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation. termit 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 termit. If not, see .*/ #include #include #include #include "termit.h" #include "configs.h" #include "callbacks.h" #include "lua_api.h" #include "keybindings.h" #include "termit_core_api.h" #include "termit_style.h" void termit_create_popup_menu(); void termit_create_menubar(); static void termit_hide_scrollbars() { gint page_num = gtk_notebook_get_n_pages(GTK_NOTEBOOK(termit.notebook)); gint i=0; for (; iscrollbar_is_shown) gtk_widget_hide(pTab->scrollbar); } } void termit_tab_set_color_foreground(struct TermitTab* pTab, const GdkColor* p_color) { if (p_color) { pTab->style.foreground_color = gdk_color_copy(p_color); vte_terminal_set_color_foreground(VTE_TERMINAL(pTab->vte), pTab->style.foreground_color); if (pTab->style.foreground_color) { vte_terminal_set_color_bold(VTE_TERMINAL(pTab->vte), pTab->style.foreground_color); } } } void termit_tab_set_color_background(struct TermitTab* pTab, const GdkColor* p_color) { if (p_color) { pTab->style.background_color = gdk_color_copy(p_color); vte_terminal_set_color_background(VTE_TERMINAL(pTab->vte), pTab->style.background_color); } } void termit_tab_apply_colors(struct TermitTab* pTab) { if (pTab->style.colors) { vte_terminal_set_colors(VTE_TERMINAL(pTab->vte), NULL, NULL, pTab->style.colors, pTab->style.colors_size); if (pTab->style.foreground_color) { vte_terminal_set_color_bold(VTE_TERMINAL(pTab->vte), pTab->style.foreground_color); } } if (pTab->style.foreground_color) { vte_terminal_set_color_foreground(VTE_TERMINAL(pTab->vte), pTab->style.foreground_color); } if (pTab->style.background_color) { vte_terminal_set_color_background(VTE_TERMINAL(pTab->vte), pTab->style.background_color); } } void termit_tab_feed(struct TermitTab* pTab, const gchar* data) { vte_terminal_feed(VTE_TERMINAL(pTab->vte), data, strlen(data)); } void termit_tab_feed_child(struct TermitTab* pTab, const gchar* data) { vte_terminal_feed_child(VTE_TERMINAL(pTab->vte), data, strlen(data)); } static void termit_set_colors() { gint page_num = gtk_notebook_get_n_pages(GTK_NOTEBOOK(termit.notebook)); gint i=0; for (; ivte), pTab->style.font); GtkBorder* border; gtk_widget_style_get(GTK_WIDGET(pTab->vte), "inner-border", &border, NULL); gint w = vte_terminal_get_char_width(VTE_TERMINAL(pTab->vte)) * configs.cols + border->left + border->right; if (w > minWidth) minWidth = w; gint h = vte_terminal_get_char_height(VTE_TERMINAL(pTab->vte)) * configs.rows + border->top + border->bottom; if (h > minHeight) minHeight = h; } gint oldWidth, oldHeight; gtk_window_get_size(GTK_WINDOW(termit.main_window), &oldWidth, &oldHeight); gint width = (minWidth > oldWidth) ? minWidth : oldWidth; gint height = (minHeight > oldHeight) ? minHeight : oldHeight; gtk_window_resize(GTK_WINDOW(termit.main_window), width, height); GdkGeometry geom; geom.min_width = minWidth; geom.min_height = minHeight; gtk_window_set_geometry_hints(GTK_WINDOW(termit.main_window), termit.main_window, &geom, GDK_HINT_MIN_SIZE); } gchar* termit_get_pid_dir(pid_t pid) { gchar* file = g_strdup_printf("/proc/%d/cwd", pid); gchar* link = g_file_read_link(file, NULL); g_free(file); return link; } void termit_toggle_menubar() { if (configs.hide_menubar) { gtk_widget_hide(GTK_WIDGET(termit.hbox)); } else { gtk_widget_show(GTK_WIDGET(termit.hbox)); } configs.hide_menubar = !configs.hide_menubar; } static void termit_check_single_tab() { if (configs.hide_single_tab && !configs.hide_tabbar) { if (gtk_notebook_get_n_pages(GTK_NOTEBOOK(termit.notebook)) == 1) gtk_notebook_set_show_tabs(GTK_NOTEBOOK(termit.notebook), FALSE); else gtk_notebook_set_show_tabs(GTK_NOTEBOOK(termit.notebook), TRUE); } } void termit_toggle_tabbar() { if (configs.hide_tabbar) { gtk_notebook_set_show_tabs(GTK_NOTEBOOK(termit.notebook), FALSE); } else { gtk_notebook_set_show_tabs(GTK_NOTEBOOK(termit.notebook), TRUE); termit_check_single_tab(); } configs.hide_tabbar = !configs.hide_tabbar; } void termit_toggle_search() { #ifdef TERMIT_ENABLE_SEARCH if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(termit.b_toggle_search))) { gtk_widget_show(termit.search_entry); gtk_widget_show(termit.b_find_prev); gtk_widget_show(termit.b_find_next); gtk_window_set_focus(GTK_WINDOW(termit.main_window), termit.search_entry); } else { gtk_widget_hide(termit.search_entry); gtk_widget_hide(termit.b_find_prev); gtk_widget_hide(termit.b_find_next); gint page = gtk_notebook_get_current_page(GTK_NOTEBOOK(termit.notebook)); TERMIT_GET_TAB_BY_INDEX(pTab, page); gtk_window_set_focus(GTK_WINDOW(termit.main_window), pTab->vte); } #endif // TERMIT_ENABLE_SEARCH } void termit_after_show_all() { termit_set_fonts(); termit_hide_scrollbars(); termit_set_colors(); termit_toggle_menubar(); termit_toggle_tabbar(); termit_toggle_search(); } void termit_reconfigure() { gtk_widget_destroy(termit.menu); gtk_container_remove(GTK_CONTAINER(termit.hbox), termit.menu_bar); termit_config_deinit(); termit_configs_set_defaults(); termit_keys_set_defaults(); termit_lua_load_config(); termit_create_popup_menu(); termit_create_menubar(); gtk_box_pack_start(GTK_BOX(termit.hbox), termit.menu_bar, FALSE, 0, 0); gtk_box_reorder_child(GTK_BOX(termit.hbox), termit.menu_bar, 0); gtk_widget_show_all(termit.main_window); termit_after_show_all(); } void termit_set_statusbar_message(guint page) { TERMIT_GET_TAB_BY_INDEX(pTab, page); TRACE("%s page=%d get_statusbar_callback=%d", __FUNCTION__, page, configs.get_statusbar_callback); if (configs.get_statusbar_callback) { gchar* statusbarMessage = termit_lua_getStatusbarCallback(configs.get_statusbar_callback, page); TRACE("statusbarMessage=[%s]", statusbarMessage); gtk_statusbar_push(GTK_STATUSBAR(termit.statusbar), 0, statusbarMessage); g_free(statusbarMessage); } else { gtk_statusbar_push(GTK_STATUSBAR(termit.statusbar), 0, vte_terminal_get_encoding(VTE_TERMINAL(pTab->vte))); } } static void termit_del_tab() { gint page = gtk_notebook_get_current_page(GTK_NOTEBOOK(termit.notebook)); TERMIT_GET_TAB_BY_INDEX(pTab, page); TRACE("%s pid=%d", __FUNCTION__, pTab->pid); g_array_free(pTab->matches, TRUE); g_free(pTab->encoding); g_free(pTab->command); g_free(pTab->title); termit_style_free(&pTab->style); g_free(pTab); gtk_notebook_remove_page(GTK_NOTEBOOK(termit.notebook), page); termit_check_single_tab(); } static void termit_tab_add_matches(struct TermitTab* pTab, GArray* matches) { guint i = 0; for (; ilen; ++i) { struct Match* match = &g_array_index(matches, struct Match, i); struct Match tabMatch = {}; tabMatch.lua_callback = match->lua_callback; tabMatch.pattern = match->pattern; tabMatch.tag = vte_terminal_match_add_gregex(VTE_TERMINAL(pTab->vte), match->regex, match->flags); vte_terminal_match_set_cursor_type(VTE_TERMINAL(pTab->vte), tabMatch.tag, GDK_HAND2); g_array_append_val(pTab->matches, tabMatch); } } #ifdef TERMIT_ENABLE_SEARCH void termit_search_find_next() { gint page = gtk_notebook_get_current_page(GTK_NOTEBOOK(termit.notebook)); TERMIT_GET_TAB_BY_INDEX(pTab, page); TRACE("%s tab=%p page=%d", __FUNCTION__, pTab, page); vte_terminal_search_find_next(VTE_TERMINAL(pTab->vte)); } void termit_search_find_prev() { gint page = gtk_notebook_get_current_page(GTK_NOTEBOOK(termit.notebook)); TERMIT_GET_TAB_BY_INDEX(pTab, page); TRACE("%s tab=%p page=%d", __FUNCTION__, pTab, page); vte_terminal_search_find_previous(VTE_TERMINAL(pTab->vte)); } #endif // TERMIT_ENABLE_SEARCH void termit_tab_set_transparency(struct TermitTab* pTab, gdouble transparency) { pTab->style.transparency = transparency; if (transparency) { if (pTab->style.image_file == NULL) { vte_terminal_set_background_transparent(VTE_TERMINAL(pTab->vte), TRUE); } else { vte_terminal_set_background_transparent(VTE_TERMINAL(pTab->vte), FALSE); } vte_terminal_set_background_saturation(VTE_TERMINAL(pTab->vte), pTab->style.transparency); } else { vte_terminal_set_background_saturation(VTE_TERMINAL(pTab->vte), pTab->style.transparency); vte_terminal_set_background_transparent(VTE_TERMINAL(pTab->vte), FALSE); } } static void termit_for_each_row_execute(struct TermitTab* pTab, glong row_start, glong row_end, int lua_callback) { glong i = row_start; for (; i < row_end; ++i) { char* str = vte_terminal_get_text_range(VTE_TERMINAL(pTab->vte), i, 0, i, 500, NULL, &lua_callback, NULL); str[strlen(str) - 1] = '\0'; termit_lua_dofunction2(lua_callback, str); free(str); } } void termit_for_each_row(int lua_callback) { TRACE("%s lua_callback=%d", __FUNCTION__, lua_callback); gint page = gtk_notebook_get_current_page(GTK_NOTEBOOK(termit.notebook)); TERMIT_GET_TAB_BY_INDEX(pTab, page); GtkAdjustment* adj = gtk_range_get_adjustment(GTK_RANGE(pTab->scrollbar)); const glong rows_total = gtk_adjustment_get_upper(adj); termit_for_each_row_execute(pTab, 0, rows_total, lua_callback); } void termit_for_each_visible_row(int lua_callback) { TRACE("%s lua_callback=%d", __FUNCTION__, lua_callback); gint page = gtk_notebook_get_current_page(GTK_NOTEBOOK(termit.notebook)); TERMIT_GET_TAB_BY_INDEX(pTab, page); GtkAdjustment* adj = gtk_range_get_adjustment(GTK_RANGE(pTab->scrollbar)); const glong row_start = ceil(gtk_adjustment_get_value(adj)); const glong page_size = vte_terminal_get_row_count(VTE_TERMINAL(pTab->vte)); termit_for_each_row_execute(pTab, row_start, row_start + page_size, lua_callback); } void termit_tab_set_audible_bell(struct TermitTab* pTab, gboolean audible_bell) { pTab->audible_bell = audible_bell; vte_terminal_set_audible_bell(VTE_TERMINAL(pTab->vte), audible_bell); } void termit_tab_set_visible_bell(struct TermitTab* pTab, gboolean visible_bell) { pTab->visible_bell = visible_bell; vte_terminal_set_visible_bell(VTE_TERMINAL(pTab->vte), visible_bell); } void termit_append_tab_with_details(const struct TabInfo* ti) { struct TermitTab* pTab = g_malloc0(sizeof(struct TermitTab)); termit_style_copy(&pTab->style, &configs.style); if (ti->name) { pTab->tab_name = gtk_label_new(ti->name); pTab->custom_tab_name = TRUE; } else { gchar* label_text = g_strdup_printf("%s %d", configs.default_tab_name, termit.tab_max_number++); pTab->tab_name = gtk_label_new(label_text); g_free(label_text); pTab->custom_tab_name = FALSE; } pTab->encoding = (ti->encoding) ? g_strdup(ti->encoding) : g_strdup(configs.default_encoding); pTab->bksp_binding = ti->bksp_binding; pTab->delete_binding = ti->delete_binding; pTab->hbox = gtk_hbox_new(FALSE, 0); pTab->vte = vte_terminal_new(); vte_terminal_set_scrollback_lines(VTE_TERMINAL(pTab->vte), configs.scrollback_lines); if (configs.default_word_chars) vte_terminal_set_word_chars(VTE_TERMINAL(pTab->vte), configs.default_word_chars); vte_terminal_set_mouse_autohide(VTE_TERMINAL(pTab->vte), TRUE); vte_terminal_set_backspace_binding(VTE_TERMINAL(pTab->vte), pTab->bksp_binding); vte_terminal_set_delete_binding(VTE_TERMINAL(pTab->vte), pTab->delete_binding); #ifdef TERMIT_ENABLE_SEARCH vte_terminal_search_set_wrap_around(VTE_TERMINAL(pTab->vte), TRUE); #endif // TERMIT_ENABLE_SEARCH /* parse command */ gchar **cmd_argv; GError *cmd_err = NULL; gchar *cmd_path = NULL; gchar *cmd_file = NULL; pTab->command = (ti->command) ? g_strdup(ti->command) : g_strdup(configs.default_command); if (!g_shell_parse_argv(pTab->command, NULL, &cmd_argv, &cmd_err)) { ERROR("%s", _("Cannot parse command. Creating tab with shell")); g_error_free(cmd_err); } else { cmd_path = g_find_program_in_path(cmd_argv[0]); cmd_file = g_path_get_basename(cmd_argv[0]); } TRACE("command=%s cmd_path=%s cmd_file=%s", pTab->command, cmd_path, cmd_file); if (cmd_path && cmd_file) { g_free(cmd_argv[0]); cmd_argv[0] = g_strdup(cmd_path); #if VTE_CHECK_VERSION(0, 26, 0) > 0 if (vte_terminal_fork_command_full(VTE_TERMINAL(pTab->vte), VTE_PTY_DEFAULT, ti->working_dir, cmd_argv, NULL, 0, NULL, NULL, &pTab->pid, &cmd_err) != TRUE) { ERROR("failed to open tab: %s", cmd_err->message); g_error_free(cmd_err); } #else pTab->pid = vte_terminal_fork_command(VTE_TERMINAL(pTab->vte), cmd_path, cmd_argv, NULL, ti->working_dir, TRUE, TRUE, TRUE); #endif // version >= 0.26 } else { g_free(pTab->command); pTab->command = g_strdup(configs.default_command); gchar* argv[] = {pTab->command, NULL}; TRACE("defaults: cmd=%s working_dir=%s", pTab->command, ti->working_dir); /* default tab */ #if VTE_CHECK_VERSION(0, 26, 0) > 0 if (vte_terminal_fork_command_full(VTE_TERMINAL(pTab->vte), VTE_PTY_DEFAULT, ti->working_dir, argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, &pTab->pid, &cmd_err) != TRUE) { ERROR("failed to open tab: %s", cmd_err->message); g_error_free(cmd_err); } #else pTab->pid = vte_terminal_fork_command(VTE_TERMINAL(pTab->vte), pTab->command, NULL, NULL, ti->working_dir, TRUE, TRUE, TRUE); #endif // version >= 0.26 } g_strfreev(cmd_argv); g_free(cmd_path); g_free(cmd_file); g_signal_connect(G_OBJECT(pTab->vte), "beep", G_CALLBACK(termit_on_beep), pTab); g_signal_connect(G_OBJECT(pTab->vte), "focus-in-event", G_CALLBACK(termit_on_focus), pTab); g_signal_connect(G_OBJECT(pTab->vte), "window-title-changed", G_CALLBACK(termit_on_tab_title_changed), NULL); g_signal_connect(G_OBJECT(pTab->vte), "child-exited", G_CALLBACK(termit_on_child_exited), NULL); // g_signal_connect(G_OBJECT(pTab->vte), "eof", G_CALLBACK(termit_eof), NULL); g_signal_connect_swapped(G_OBJECT(pTab->vte), "button-press-event", G_CALLBACK(termit_on_popup), NULL); vte_terminal_set_encoding(VTE_TERMINAL(pTab->vte), pTab->encoding); pTab->matches = g_array_new(FALSE, TRUE, sizeof(struct Match)); termit_tab_add_matches(pTab, configs.matches); termit_tab_set_transparency(pTab, pTab->style.transparency); vte_terminal_set_font(VTE_TERMINAL(pTab->vte), pTab->style.font); gint index = gtk_notebook_append_page(GTK_NOTEBOOK(termit.notebook), pTab->hbox, pTab->tab_name); if (index == -1) { ERROR("%s", _("Cannot create a new tab")); return; } if (configs.fill_tabbar) { GValue val = {}; g_value_init(&val, G_TYPE_BOOLEAN); g_value_set_boolean(&val, TRUE); gtk_container_child_set_property(GTK_CONTAINER(termit.notebook), pTab->hbox, "tab-expand", &val); gtk_container_child_set_property(GTK_CONTAINER(termit.notebook), pTab->hbox, "tab-fill", &val); } termit_tab_set_audible_bell(pTab, configs.audible_bell); termit_tab_set_visible_bell(pTab, configs.visible_bell); pTab->scrollbar = gtk_vscrollbar_new(vte_terminal_get_adjustment(VTE_TERMINAL(pTab->vte))); gtk_box_pack_start(GTK_BOX(pTab->hbox), pTab->vte, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(pTab->hbox), pTab->scrollbar, FALSE, FALSE, 0); GtkWidget* tabWidget = gtk_notebook_get_nth_page(GTK_NOTEBOOK(termit.notebook), index); if (!tabWidget) { ERROR("tabWidget is NULL"); return; } g_object_set_data(G_OBJECT(tabWidget), TERMIT_TAB_DATA, pTab); if (index == 0) { // there is no "switch-page" signal on the first page termit_set_statusbar_message(index); } pTab->scrollbar_is_shown = configs.show_scrollbar; gtk_widget_show_all(termit.notebook); if (pTab->style.image_file == NULL) { vte_terminal_set_background_image(VTE_TERMINAL(pTab->vte), NULL); } else { vte_terminal_set_background_image_file(VTE_TERMINAL(pTab->vte), pTab->style.image_file); } termit_tab_apply_colors(pTab); gtk_notebook_set_current_page(GTK_NOTEBOOK(termit.notebook), index); gtk_notebook_set_tab_reorderable(GTK_NOTEBOOK(termit.notebook), pTab->hbox, TRUE); gtk_window_set_focus(GTK_WINDOW(termit.main_window), pTab->vte); termit_check_single_tab(); termit_hide_scrollbars(); } void termit_append_tab_with_command(const gchar* command) { struct TabInfo ti = {}; ti.bksp_binding = configs.default_bksp; ti.delete_binding = configs.default_delete; ti.command = g_strdup(command); termit_append_tab_with_details(&ti); g_free(ti.command); } void termit_append_tab() { termit_append_tab_with_command(configs.default_command); } void termit_set_encoding(const gchar* encoding) { gint page = gtk_notebook_get_current_page(GTK_NOTEBOOK(termit.notebook)); TERMIT_GET_TAB_BY_INDEX(pTab, page); TRACE("%s tab=%p page=%d encoding=%s", __FUNCTION__, pTab, page, encoding); vte_terminal_set_encoding(VTE_TERMINAL(pTab->vte), encoding); g_free(pTab->encoding); pTab->encoding = g_strdup(encoding); termit_set_statusbar_message(page); } void termit_tab_set_title(struct TermitTab* pTab, const gchar* title) { gchar* tmp_title = g_strdup(title); if (configs.get_tab_title_callback) { gchar* lua_title = termit_lua_getTitleCallback(configs.get_tab_title_callback, title); if (!lua_title) { ERROR("termit_lua_getTitleCallback(%s) failed", title); g_free(tmp_title); return; } g_free(tmp_title); tmp_title = lua_title; } if (pTab->title) g_free(pTab->title); pTab->title = tmp_title; gtk_label_set_text(GTK_LABEL(pTab->tab_name), pTab->title); termit_set_window_title(title); } void termit_set_default_colors() { gint page_num = gtk_notebook_get_n_pages(GTK_NOTEBOOK(termit.notebook)); gint i=0; for (; ivte)); } } void termit_tab_set_font(struct TermitTab* pTab, const gchar* font_name) { if (pTab->style.font_name) { g_free(pTab->style.font_name); } pTab->style.font_name = g_strdup(font_name); if (pTab->style.font) { pango_font_description_free(pTab->style.font); } pTab->style.font = pango_font_description_from_string(font_name); vte_terminal_set_font(VTE_TERMINAL(pTab->vte), pTab->style.font); } void termit_tab_set_font_by_index(gint tab_index, const gchar* font_name) { TRACE("%s: tab_index=%d font=%s", __FUNCTION__, tab_index, font_name); if (tab_index < 0) { tab_index = gtk_notebook_get_current_page(GTK_NOTEBOOK(termit.notebook)); } TERMIT_GET_TAB_BY_INDEX(pTab, tab_index); termit_tab_set_font(pTab, font_name); } void termit_tab_set_background_image(struct TermitTab* pTab, const gchar* image_file) { TRACE("pTab->image_file=%s image_file=%s", pTab->style.image_file, image_file); if (pTab->style.image_file) { g_free(pTab->style.image_file); } if (image_file == NULL) { pTab->style.image_file = NULL; vte_terminal_set_background_transparent(VTE_TERMINAL(pTab->vte), TRUE); vte_terminal_set_background_image(VTE_TERMINAL(pTab->vte), NULL); } else { pTab->style.image_file = g_strdup(image_file); vte_terminal_set_background_transparent(VTE_TERMINAL(pTab->vte), FALSE); vte_terminal_set_background_image_file(VTE_TERMINAL(pTab->vte), pTab->style.image_file); } } static void termit_set_color__(gint tab_index, const GdkColor* p_color, void (*callback)(struct TermitTab*, const GdkColor*)) { TRACE("%s: tab_index=%d color=%p", __FUNCTION__, tab_index, p_color); if (!p_color) { TRACE_MSG("p_color is NULL"); return; } if (tab_index < 0) { tab_index = gtk_notebook_get_current_page(GTK_NOTEBOOK(termit.notebook)); } TERMIT_GET_TAB_BY_INDEX(pTab, tab_index); callback(pTab, p_color); } void termit_tab_set_color_foreground_by_index(gint tab_index, const GdkColor* p_color) { termit_set_color__(tab_index, p_color, termit_tab_set_color_foreground); } void termit_tab_set_color_background_by_index(gint tab_index, const GdkColor* p_color) { termit_set_color__(tab_index, p_color, termit_tab_set_color_background); } void termit_paste() { gint page = gtk_notebook_get_current_page(GTK_NOTEBOOK(termit.notebook)); TERMIT_GET_TAB_BY_INDEX(pTab, page); vte_terminal_paste_clipboard(VTE_TERMINAL(pTab->vte)); } void termit_copy() { gint page = gtk_notebook_get_current_page(GTK_NOTEBOOK(termit.notebook)); TERMIT_GET_TAB_BY_INDEX(pTab, page); vte_terminal_copy_clipboard(VTE_TERMINAL(pTab->vte)); } static void clipboard_received_text(GtkClipboard *clipboard, const gchar *text, gpointer data) { if (text) { gchar** d = (gchar**)data; *d = g_strdup(text); } } gchar* termit_get_selection() { gint page = gtk_notebook_get_current_page(GTK_NOTEBOOK(termit.notebook)); TERMIT_GET_TAB_BY_INDEX2(pTab, page, NULL); if (vte_terminal_get_has_selection(VTE_TERMINAL(pTab->vte)) == FALSE) { return NULL; } GtkClipboard* clip = gtk_clipboard_get(GDK_SELECTION_PRIMARY); gchar* text = NULL; gtk_clipboard_request_text(clip, clipboard_received_text, &text); if (!text) return NULL; return text; } void termit_close_tab() { termit_del_tab(); if (gtk_notebook_get_n_pages(GTK_NOTEBOOK(termit.notebook)) == 0) termit_quit(); } void termit_activate_tab(gint tab_index) { if (tab_index < 0) { TRACE("tab_index(%d) < 0: skipping", tab_index); return; } if (tab_index >= gtk_notebook_get_n_pages(GTK_NOTEBOOK(termit.notebook))) { TRACE("tab_index(%d) > n_pages: skipping", tab_index); return; } gtk_notebook_set_current_page(GTK_NOTEBOOK(termit.notebook), tab_index); } void termit_prev_tab() { gint index = gtk_notebook_get_current_page(GTK_NOTEBOOK(termit.notebook)); index = (index) ? index - 1 : gtk_notebook_get_n_pages(GTK_NOTEBOOK(termit.notebook)) - 1; termit_activate_tab(index); } void termit_next_tab() { gint index = gtk_notebook_get_current_page(GTK_NOTEBOOK(termit.notebook)); index = (index == gtk_notebook_get_n_pages(GTK_NOTEBOOK(termit.notebook)) - 1) ? 0 : index + 1; termit_activate_tab(index); } void termit_quit() { while (gtk_notebook_get_n_pages(GTK_NOTEBOOK(termit.notebook)) > 0) termit_del_tab(); gtk_main_quit(); } int termit_get_current_tab_index() { return gtk_notebook_get_current_page(GTK_NOTEBOOK(termit.notebook)); } void termit_set_kb_policy(enum TermitKbPolicy kbp) { configs.kb_policy = kbp; } void termit_set_window_title(const gchar* title) { if (!title) return; if (!configs.get_window_title_callback) { gchar* window_title = g_strdup_printf("%s: %s", configs.default_window_title, title); gtk_window_set_title(GTK_WINDOW(termit.main_window), window_title); g_free(window_title); } else { gchar* window_title = termit_lua_getTitleCallback(configs.get_window_title_callback, title); if (!window_title) { ERROR("termit_lua_getTitleCallback(%s) failed", title); return; } gtk_window_set_title(GTK_WINDOW(termit.main_window), window_title); g_free(window_title); } } void termit_set_show_scrollbar_signal(GtkWidget* menuItem, gpointer pHandlerId) { gulong handlerId = g_signal_connect(G_OBJECT(menuItem), "toggled", G_CALLBACK(termit_on_toggle_scrollbar), NULL); if (pHandlerId == NULL) { pHandlerId = g_malloc(sizeof(handlerId)); } memcpy(pHandlerId, &handlerId, sizeof(handlerId)); g_object_set_data(G_OBJECT(menuItem), "handlerId", pHandlerId); } nonstop-termit-fd89f3b/src/termit_core_api.h000066400000000000000000000060531176471573200213510ustar00rootroot00000000000000/* Copyright (C) 2007-2010, Evgeny Ratnikov This file is part of termit. termit is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation. termit 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 termit. If not, see .*/ #ifndef TERMIT_CORE_API_H #define TERMIT_CORE_API_H #include "termit.h" #include "configs.h" void termit_reconfigure(); void termit_after_show_all(); void termit_append_tab(); void termit_append_tab_with_command(const gchar* command); void termit_append_tab_with_details(const struct TabInfo*); void termit_activate_tab(gint tab_index); void termit_prev_tab(); void termit_next_tab(); void termit_paste(); void termit_copy(); gchar* termit_get_selection(); #ifdef TERMIT_ENABLE_SEARCH void termit_search_find_next(); void termit_search_find_prev(); #endif // TERMIT_ENABLE_SEARCH void termit_for_each_row(int lua_callback); void termit_for_each_visible_row(int lua_callback); void termit_close_tab(); void termit_toggle_menubar(); void termit_toggle_tabbar(); void termit_toggle_search(); void termit_set_window_title(const gchar* title); void termit_set_statusbar_message(guint page); void termit_set_encoding(const gchar* encoding); void termit_quit(); void termit_tab_feed(struct TermitTab* pTab, const gchar* data); void termit_tab_feed_child(struct TermitTab* pTab, const gchar* data); void termit_tab_set_font(struct TermitTab* pTab, const gchar* font_name); void termit_tab_set_font_by_index(gint tab_index, const gchar* font_name); void termit_tab_set_transparency(struct TermitTab* pTab, gdouble transparency); void termit_tab_set_style(gint tab_index, const struct TermitStyle*); void termit_tab_apply_colors(struct TermitTab* pTab); void termit_tab_set_color_foreground(struct TermitTab* pTab, const GdkColor* p_color); void termit_tab_set_color_background(struct TermitTab* pTab, const GdkColor* p_color); void termit_tab_set_color_foreground_by_index(gint tab_index, const GdkColor*); void termit_tab_set_color_background_by_index(gint tab_index, const GdkColor*); void termit_tab_set_background_image(struct TermitTab* pTab, const gchar* image_file); void termit_tab_set_title(struct TermitTab* pTab, const gchar* title); void termit_tab_set_audible_bell(struct TermitTab* pTab, gboolean audible_bell); void termit_tab_set_visible_bell(struct TermitTab* pTab, gboolean visible_bell); int termit_get_current_tab_index(); gchar* termit_get_pid_dir(pid_t pid); /** * function to switch key processing policy * keycodes - kb layout independent * keysyms - kb layout dependent * */ void termit_set_kb_policy(enum TermitKbPolicy kbp); void termit_set_show_scrollbar_signal(GtkWidget* menuItem, gpointer pHanderId); #endif /* TERMIT_CORE_API_H */ nonstop-termit-fd89f3b/src/termit_preferences.c000066400000000000000000000312411176471573200220610ustar00rootroot00000000000000/* Copyright (C) 2007-2010, Evgeny Ratnikov This file is part of termit. termit is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation. termit 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 termit. If not, see .*/ #include #include #include #include #include "termit.h" #include "termit_style.h" #include "termit_core_api.h" static gboolean dlg_key_press(GtkWidget *widget, GdkEventKey *event, gpointer user_data) { switch (event->keyval) { case GDK_KEY_Return: g_signal_emit_by_name(widget, "response", GTK_RESPONSE_OK, NULL); break; case GDK_KEY_Escape: g_signal_emit_by_name(widget, "response", GTK_RESPONSE_NONE, NULL); break; default: return FALSE; } return TRUE; } static void dlg_set_tab_color__(GtkColorButton *widget, gpointer user_data, void (*callback)(struct TermitTab*, const GdkColor*)) { if (!user_data) { ERROR("user_data is NULL"); return; } struct TermitTab* pTab = (struct TermitTab*)user_data; GdkColor color = {}; gtk_color_button_get_color(widget, &color); callback(pTab, &color); } static void dlg_set_foreground(GtkColorButton *widget, gpointer user_data) { return dlg_set_tab_color__(widget, user_data, termit_tab_set_color_foreground); } static void dlg_set_background(GtkColorButton *widget, gpointer user_data) { return dlg_set_tab_color__(widget, user_data, termit_tab_set_color_background); } static void dlg_set_font(GtkFontButton *widget, gpointer user_data) { if (!user_data) { ERROR("user_data is NULL"); return; } struct TermitTab* pTab = (struct TermitTab*)user_data; termit_tab_set_font(pTab, gtk_font_button_get_font_name(widget)); } static gboolean dlg_set_transparency(GtkSpinButton *btn, gpointer user_data) { if (!user_data) { ERROR("user_data is NULL"); return FALSE; } struct TermitTab* pTab = (struct TermitTab*)user_data; gdouble value = gtk_spin_button_get_value(btn); termit_tab_set_transparency(pTab, value); return FALSE; } static gboolean dlg_set_audible_bell(GtkToggleButton *btn, gpointer user_data) { if (!user_data) { ERROR("user_data is NULL"); return FALSE; } struct TermitTab* pTab = (struct TermitTab*)user_data; gboolean value = gtk_toggle_button_get_active(btn); termit_tab_set_audible_bell(pTab, value); return FALSE; } static gboolean dlg_set_visible_bell(GtkToggleButton *btn, gpointer user_data) { if (!user_data) { ERROR("user_data is NULL"); return FALSE; } struct TermitTab* pTab = (struct TermitTab*)user_data; gboolean value = gtk_toggle_button_get_active(btn); termit_tab_set_visible_bell(pTab, value); return FALSE; } struct TermitDlgHelper { struct TermitTab* pTab; gchar* tab_title; gboolean handmade_tab_title; struct TermitStyle style; gboolean au_bell; gboolean vi_bell; // widgets with values GtkWidget* dialog; GtkWidget* entry_title; GtkWidget* btn_font; GtkWidget* btn_foreground; GtkWidget* btn_background; GtkWidget* btn_image_file; GtkWidget* scale_transparency; GtkWidget* audible_bell; GtkWidget* visible_bell; }; static struct TermitDlgHelper* termit_dlg_helper_new(struct TermitTab* pTab) { struct TermitDlgHelper* hlp = g_malloc0(sizeof(struct TermitDlgHelper)); hlp->pTab = pTab; if (pTab->title) { hlp->handmade_tab_title = TRUE; hlp->tab_title = g_strdup(pTab->title); } else { hlp->tab_title = g_strdup(gtk_label_get_text(GTK_LABEL(pTab->tab_name))); } termit_style_copy(&hlp->style, &pTab->style); hlp->au_bell = pTab->audible_bell; hlp->vi_bell = pTab->visible_bell; return hlp; } static void termit_dlg_helper_free(struct TermitDlgHelper* hlp) { g_free(hlp->tab_title); termit_style_free(&hlp->style); g_free(hlp); } static void dlg_set_tab_default_values(struct TermitTab* pTab, struct TermitDlgHelper* hlp) { if (hlp->tab_title) termit_tab_set_title(pTab, hlp->tab_title); vte_terminal_set_default_colors(VTE_TERMINAL(pTab->vte)); termit_tab_set_font(pTab, hlp->style.font_name); termit_tab_set_background_image(pTab, hlp->style.image_file); termit_tab_set_color_foreground(pTab, hlp->style.foreground_color); termit_tab_set_color_background(pTab, hlp->style.background_color); termit_tab_set_transparency(pTab, hlp->style.transparency); termit_tab_set_audible_bell(pTab, hlp->au_bell); termit_tab_set_visible_bell(pTab, hlp->vi_bell); if (hlp->style.image_file) { gtk_file_chooser_select_filename(GTK_FILE_CHOOSER(hlp->btn_image_file), hlp->style.image_file); } } static void dlg_set_default_values(struct TermitDlgHelper* hlp) { gtk_entry_set_text(GTK_ENTRY(hlp->entry_title), hlp->tab_title); gtk_font_button_set_font_name(GTK_FONT_BUTTON(hlp->btn_font), hlp->style.font_name); if (hlp->style.foreground_color) { gtk_color_button_set_color(GTK_COLOR_BUTTON(hlp->btn_foreground), hlp->style.foreground_color); } if (hlp->style.background_color) { gtk_color_button_set_color(GTK_COLOR_BUTTON(hlp->btn_background), hlp->style.background_color); } gtk_spin_button_set_value(GTK_SPIN_BUTTON(hlp->scale_transparency), hlp->style.transparency); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(hlp->audible_bell), hlp->au_bell); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(hlp->visible_bell), hlp->vi_bell); if (hlp->style.image_file) { gtk_file_chooser_select_filename(GTK_FILE_CHOOSER(hlp->btn_image_file), hlp->style.image_file); } else { gtk_file_chooser_unselect_all(GTK_FILE_CHOOSER(hlp->btn_image_file)); } } static void dlg_restore_defaults(GtkButton *button, gpointer user_data) { struct TermitDlgHelper* hlp = (struct TermitDlgHelper*)user_data; dlg_set_default_values(hlp); dlg_set_tab_default_values(hlp->pTab, hlp); } static void dlg_set_image_file(GtkFileChooserButton *widget, gpointer user_data) { struct TermitTab* pTab = (struct TermitTab*)user_data; termit_tab_set_background_image(pTab, gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(widget))); } static gboolean dlg_clear_image_file(GtkWidget* widget, GdkEventKey* event, gpointer user_data) { struct TermitTab* pTab = (struct TermitTab*)user_data; if (event->keyval == GDK_KEY_Delete) { if (pTab->style.image_file) { gtk_file_chooser_unselect_all(GTK_FILE_CHOOSER(widget)); termit_tab_set_background_image(pTab, NULL); } } return FALSE; } void termit_preferences_dialog(struct TermitTab *pTab) { // store font_name, foreground, background struct TermitDlgHelper* hlp = termit_dlg_helper_new(pTab); GtkStockItem item = {}; gtk_stock_lookup(GTK_STOCK_PREFERENCES, &item); // may be memory leak inside GtkWidget* dialog = gtk_dialog_new_with_buttons(item.label, GTK_WINDOW_TOPLEVEL, GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL, GTK_STOCK_CANCEL, GTK_RESPONSE_NONE, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); g_signal_connect(G_OBJECT(dialog), "key-press-event", G_CALLBACK(dlg_key_press), dialog); GtkWidget* dlg_table = gtk_table_new(5, 2, FALSE); #define TERMIT_PREFERENCE_ROW(pref_name, widget) \ gtk_table_attach(GTK_TABLE(dlg_table), gtk_label_new(pref_name), 0, 1, row, row + 1, 0, 0, 0, 0); \ gtk_table_attach_defaults(GTK_TABLE(dlg_table), widget, 1, 2, row, row + 1); \ hlp->widget = widget; \ row++; #define TERMIT_PREFERENCE_ROW2(pref_widget, widget) \ gtk_table_attach(GTK_TABLE(dlg_table), pref_widget, 0, 1, row, row + 1, 0, 0, 0, 0); \ gtk_table_attach_defaults(GTK_TABLE(dlg_table), widget, 1, 2, row, row + 1); \ hlp->widget = widget; \ row++; GtkWidget* entry_title = gtk_entry_new(); guint row = 0; { // tab title gtk_entry_set_text(GTK_ENTRY(entry_title), hlp->tab_title); TERMIT_PREFERENCE_ROW(_("Title"), entry_title); } { // font selection GtkWidget* btn_font = gtk_font_button_new_with_font(pTab->style.font_name); g_signal_connect(btn_font, "font-set", G_CALLBACK(dlg_set_font), pTab); TERMIT_PREFERENCE_ROW(_("Font"), btn_font); } { // foreground GtkWidget* btn_foreground = (pTab->style.foreground_color) ? gtk_color_button_new_with_color(pTab->style.foreground_color) : gtk_color_button_new(); g_signal_connect(btn_foreground, "color-set", G_CALLBACK(dlg_set_foreground), pTab); TERMIT_PREFERENCE_ROW(_("Foreground"), btn_foreground); } { // background GtkWidget* btn_background = (pTab->style.background_color) ? gtk_color_button_new_with_color(pTab->style.background_color) : gtk_color_button_new(); g_signal_connect(btn_background, "color-set", G_CALLBACK(dlg_set_background), pTab); TERMIT_PREFERENCE_ROW(_("Background"), btn_background); } { // background image GtkWidget* btn_image_file = gtk_file_chooser_button_new(pTab->style.image_file, GTK_FILE_CHOOSER_ACTION_OPEN); GtkFileFilter* filter = gtk_file_filter_new(); gtk_file_filter_set_name(filter, _("images")); gtk_file_filter_add_mime_type(filter, "image/*"); if (pTab->style.image_file) { gtk_file_chooser_select_filename(GTK_FILE_CHOOSER(btn_image_file), pTab->style.image_file); } gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(btn_image_file), filter); g_signal_connect(btn_image_file, "file-set", G_CALLBACK(dlg_set_image_file), pTab); g_signal_connect(btn_image_file, "key-press-event", G_CALLBACK(dlg_clear_image_file), pTab); GtkWidget* btn_switch_image_file = gtk_check_button_new_with_label(_("Background image")); if (pTab->style.image_file) { gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(btn_switch_image_file), TRUE); } /*g_signal_connect(btn_switch_image_file, "toggled", G_CALLBACK(dlg_switch_image_file), btn_image_file);*/ /*TERMIT_PREFERENCE_ROW2(btn_switch_image_file, btn_image_file);*/ TERMIT_PREFERENCE_ROW(_("Image"), btn_image_file); } { // transparency GtkWidget* scale_transparency = gtk_spin_button_new_with_range(0, 1, 0.05); gtk_spin_button_set_value(GTK_SPIN_BUTTON(scale_transparency), pTab->style.transparency); g_signal_connect(scale_transparency, "value-changed", G_CALLBACK(dlg_set_transparency), pTab); TERMIT_PREFERENCE_ROW(_("Transparency"), scale_transparency); } { // audible_bell GtkWidget* audible_bell = gtk_check_button_new(); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(audible_bell), pTab->audible_bell); g_signal_connect(audible_bell, "toggled", G_CALLBACK(dlg_set_audible_bell), pTab); TERMIT_PREFERENCE_ROW(_("Audible bell"), audible_bell); } { // visible_bell GtkWidget* visible_bell = gtk_check_button_new(); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(visible_bell), pTab->visible_bell); g_signal_connect(visible_bell, "toggled", G_CALLBACK(dlg_set_visible_bell), pTab); TERMIT_PREFERENCE_ROW(_("Visible bell"), visible_bell); } { GtkWidget* btn_restore = gtk_button_new_from_stock(GTK_STOCK_REVERT_TO_SAVED); g_signal_connect(G_OBJECT(btn_restore), "clicked", G_CALLBACK(dlg_restore_defaults), hlp); gtk_table_attach(GTK_TABLE(dlg_table), btn_restore, 1, 2, row, row + 1, 0, 0, 0, 0); } gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), dlg_table); // TODO: apply to all tabs // TODO: color palette // TODO: save style - choose from saved (murphy, delek, etc.) gtk_widget_show_all(dialog); if (gtk_dialog_run(GTK_DIALOG(dialog)) != GTK_RESPONSE_OK) { dlg_set_tab_default_values(pTab, hlp); } else { // insane title flag if (pTab->title || (!pTab->title && strcmp(gtk_label_get_text(GTK_LABEL(pTab->tab_name)), gtk_entry_get_text(GTK_ENTRY(entry_title))) != 0)) { termit_tab_set_title(pTab, gtk_entry_get_text(GTK_ENTRY(entry_title))); } } termit_dlg_helper_free(hlp); gtk_widget_destroy(dialog); } nonstop-termit-fd89f3b/src/termit_style.c000066400000000000000000000046271176471573200207300ustar00rootroot00000000000000/* Copyright (C) 2007-2010, Evgeny Ratnikov This file is part of termit. termit is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation. termit 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 termit. If not, see .*/ #include #include #include #include "termit_style.h" void termit_style_init(struct TermitStyle* style) { style->font_name = g_strdup("Monospace 10"); style->font = pango_font_description_from_string(style->font_name); style->foreground_color = NULL; style->background_color = NULL; style->colors = NULL; style->image_file = NULL; style->colors_size = 0; style->transparency = 0; } void termit_style_free(struct TermitStyle* style) { g_free(style->font_name); pango_font_description_free(style->font); if (style->colors) { g_free(style->colors); } if (style->image_file) { g_free(style->image_file); } if (style->background_color) { gdk_color_free(style->background_color); } if (style->foreground_color) { gdk_color_free(style->foreground_color); } struct TermitStyle tmp = {}; *style = tmp; } void termit_style_copy(struct TermitStyle* dest, const struct TermitStyle* src) { dest->font_name = g_strdup(src->font_name); dest->font = pango_font_description_from_string(src->font_name); if (src->background_color) { dest->background_color = gdk_color_copy(src->background_color); } else { dest->background_color = NULL; } if (src->foreground_color) { dest->foreground_color = gdk_color_copy(src->foreground_color); } else { dest->foreground_color = NULL; } dest->transparency = src->transparency; dest->image_file = g_strdup(src->image_file); if (src->colors_size) { dest->colors = g_memdup(src->colors, src->colors_size * sizeof(GdkColor)); dest->colors_size = src->colors_size; } else { dest->colors = NULL; dest->colors_size = 0; } } nonstop-termit-fd89f3b/src/termit_style.h000066400000000000000000000022711176471573200207260ustar00rootroot00000000000000/* Copyright (C) 2007-2010, Evgeny Ratnikov This file is part of termit. termit is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation. termit 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 termit. If not, see .*/ #ifndef TERMIT_STYLE_H #define TERMIT_STYLE_H #include #include #include struct TermitStyle { gchar* font_name; PangoFontDescription* font; GdkColor* foreground_color; GdkColor* background_color; gchar *image_file; GdkColor* colors; glong colors_size; gdouble transparency; }; void termit_style_init(struct TermitStyle* style); void termit_style_copy(struct TermitStyle* dest, const struct TermitStyle* src); void termit_style_free(struct TermitStyle* style); #endif /* TERMIT_STYLE_H */ nonstop-termit-fd89f3b/utils/000077500000000000000000000000001176471573200164005ustar00rootroot00000000000000nonstop-termit-fd89f3b/utils/CMakeLists.txt000066400000000000000000000016661176471573200211510ustar00rootroot00000000000000# Copyright (C) 2007-2010, Evgeny Ratnikov # # This file is part of termit. # termit is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 # as published by the Free Software Foundation. # termit 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 termit. If not, see . # Slackware SlackBuild CONFIGURE_FILE(termit.SlackBuild.in ${TERMIT_SOURCE_DIR}/utils/termit.SlackBuild @ONLY) # Gentoo ebuild CONFIGURE_FILE(termit.ebuild ${TERMIT_SOURCE_DIR}/utils/termit-${TERMIT_PACKAGE_VERSION}.ebuild COPY_ONLY) # Fedora spec CONFIGURE_FILE(termit.spec.in ${TERMIT_SOURCE_DIR}/utils/termit.spec @ONLY) nonstop-termit-fd89f3b/utils/slack-desc000066400000000000000000000005531176471573200203370ustar00rootroot00000000000000 |-----handy-ruler------------------------------------------------------| termit: termit (terminal emulator) termit: termit: Small terminal emulator configurable via Lua. termit: Other dependencies are Vte and Gtk2 libs. termit: Termit supports multiple tabs, encoding switching and sessions. termit: termit: http://wiki.github.com/nonstop/termit/ termit: nonstop-termit-fd89f3b/utils/termit.SlackBuild.in000066400000000000000000000032041176471573200222470ustar00rootroot00000000000000#!/bin/sh # Slackware build script for termit # Written by Evgeny Ratnikov (ratnikov dot ev at gmail dot com) PRGNAM=termit VERSION=${VERSION:-"@TERMIT_PACKAGE_VERSION@"} ARCH=${ARCH:-i686} BUILD=${BUILD:-1} TAG=${TAG:-_SBo} CWD=$(pwd) TMP=${TMP:-/tmp/$TAG} PKG=$TMP/package-$PRGNAM OUTPUT=${OUTPUT:-/tmp} if [ "$ARCH" = "i486" ]; then SLKCFLAGS="-O2 -march=i486 -mtune=i686" elif [ "$ARCH" = "i686" ]; then SLKCFLAGS="-O2 -march=i686 -mtune=i686" elif [ "$ARCH" = "x86_64" ]; then SLKCFLAGS="-O2 -fPIC" fi set -e rm -rf $PKG mkdir -p $TMP $PKG $OUTPUT cd $TMP rm -rf $PRGNAM-$VERSION tar xvf $CWD/$PRGNAM-$VERSION.tar.bz2 cd $PRGNAM-$VERSION find . \ \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \ -exec chmod 755 {} \; -o \ \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \ -exec chmod 644 {} \; CFLAGS="$SLKCFLAGS" CXXFLAGS="$SLKCFLAGS" cmake -DCMAKE_INSTALL_PREFIX=/usr . make make install DESTDIR=$PKG ( cd $PKG find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true ) mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION cp -a ChangeLog INSTALL COPYING TODO $PKG/usr/doc/$PRGNAM-$VERSION cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild cat $CWD/slack-desc > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.slack-desc mkdir -p $PKG/install cat $CWD/slack-desc > $PKG/install/slack-desc cd $PKG chown -R root:root . /sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.tgz nonstop-termit-fd89f3b/utils/termit.ebuild000066400000000000000000000015021176471573200210700ustar00rootroot00000000000000# Copyright 1999-2008 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: $ inherit cmake-utils SRC_URI="http://github.com/downloads/nonstop/termit/${P}.tar.bz2" HOMEPAGE="http://wiki.github.com/nonstop/termit/" DESCRIPTION="Simple terminal emulator based on vte library with Lua scripting" RDEPEND="x11-libs/vte >=x11-libs/gtk+-2.10 >=dev-lang/lua-5.1" DEPEND="${RDEPEND} >=dev-util/cmake-2.4" SLOT="0" LICENSE="GPL-2" KEYWORDS="~x86" IUSE="" DOCS="README ChangeLog doc/rc.lua.example doc/lua_api.txt" CMAKE_IN_SOURCE_BUILD="yes" pkg_postinst() { einfo einfo "There is a example of configfile in " einfo " /usr/share/doc/termit/rc.lua.example " einfo "copy this file to " einfo " \$HOME/.config/termit/rc.lua" einfo "and modify to fit your needs " einfo } nonstop-termit-fd89f3b/utils/termit.spec.in000066400000000000000000000027511176471573200211720ustar00rootroot00000000000000Summary: termit (terminal emulator) Name: termit Version: @TERMIT_PACKAGE_VERSION@ Release: 1%{?dist} License: GPLv2 URL: http://wiki.github.com/nonstop/termit/ Group: System Environment/Base Source: %{name}-%{version}.tar.bz2 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: gtk2-devel BuildRequires: vte-devel >= 0.17.4 BuildRequires: lua-devel >= 5.1 BuildRequires: cmake desktop-file-utils gettext %description Small terminal emulator. The only dependencies are Vte and Gtk2 libs. Termit supports tabs, bookmarks, encoding switching and sessions. %prep %setup -q %build find . -type f -name CMakeCache.txt -exec rm -rf {} \; %cmake DCMAKE_INSTALL_DOCDIR=%{_docdir} . make VERBOSE=1 %{?_smp_mflags} %install rm -rf $RPM_BUILD_ROOT make install DESTDIR=$RPM_BUILD_ROOT desktop-file-install \ --delete-original \ --remove-category=Utility \ --add-category=System \ --dir=${RPM_BUILD_ROOT}%{_datadir}/applications \ ${RPM_BUILD_ROOT}%{_datadir}/applications/%{name}.desktop %find_lang %{name} rm -rf ${RPM_BUILD_ROOT}%{_datadir}/doc/termit/ %clean rm -rf $RPM_BUILD_ROOT %files -f %{name}.lang %defattr(-,root,root,-) %doc ChangeLog COPYING TODO %doc doc/README doc/rc.lua.example doc/lua_api.txt doc/termit.svg %{_bindir}/%{name} %{_datadir}/applications/%{name}.desktop %{_mandir}/man1/%{name}.1.*