1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-21 18:36:39 +02:00

Compare commits

...

208 Commits

Author SHA1 Message Date
Sebastien Helleu d13e2328b1 Version 0.1.9 2006-05-24 22:57:33 +00:00
Sebastien Helleu 1838637f24 Fixed /squery command (message sent to server, now ok with # args > 2) 2006-05-24 21:39:39 +00:00
Sebastien Helleu 6beb0f1cb0 Fixed typo when weechat log file is locked 2006-05-22 14:35:23 +00:00
Sebastien Helleu b0260b6494 Fixed typos 2006-05-22 07:31:51 +00:00
Sebastien Helleu fe2bb8516b Fixed /alias command (now ok with an alias name: display content) 2006-05-21 15:10:36 +00:00
Sebastien Helleu 9eb6643f63 Replaced "window close" by "window merge" for default alias "wc" 2006-05-21 15:04:44 +00:00
Sebastien Helleu d2f855b7ee Changed default alias "wc" (now /window close instead of /part) 2006-05-21 14:59:34 +00:00
Sebastien Helleu 586e89b191 Fixed bug with keyboard on GNU/Hurd: use only one select(), waiting for better solution 2006-05-21 14:15:24 +00:00
Emmanuel Bouthenot f6bb78a3b2 make possible to disable flock support 2006-05-21 12:57:24 +00:00
Sebastien Helleu 1c9456f2a7 Added include of time.h 2006-05-21 10:41:15 +00:00
Emmanuel Bouthenot 545fa4c332 Fix some compile erros on OpenBSD and NetBSD 2006-05-20 18:48:13 +00:00
Sebastien Helleu ec9da8cc85 Improved lua plugin detection (bug #16574) 2006-05-20 14:43:49 +00:00
Sebastien Helleu 2322eb0625 Automatically rename log file when crashing, added backtrace to log file 2006-05-20 13:42:08 +00:00
Sebastien Helleu 0eea93bba3 Moved content of src/common/log.c to src/gui/gui-log.c, log.c is now used for WeeChat log file 2006-05-20 09:45:02 +00:00
Sebastien Helleu 1bc71392c4 Use of "which" to find path to executables with addr2line (for backtrace) 2006-05-20 09:43:30 +00:00
Emmanuel Bouthenot 94a5c72590 improve lua checking (libs) in configure 2006-05-19 23:04:06 +00:00
Sebastien Helleu 15f75d157c Added backtrace when WeeChat crashes 2006-05-19 22:49:24 +00:00
Julien Louis 7e802070ca Remove uneeded weechat-curses.links 2006-05-19 19:41:21 +00:00
Emmanuel Bouthenot c2dd7e4ffb check return value in weechat_ruby_exec() to be a valid value and fix crash when called function return nothing 2006-05-17 12:41:58 +00:00
Emmanuel Bouthenot 524fbba036 fix bug in end function calls for plugins/scripts 2006-05-17 09:59:19 +00:00
Emmanuel Bouthenot 87aa03b2cf fix number of args in end function call 2006-05-17 08:58:56 +00:00
Sebastien Helleu a47e4a9567 Updated translations 2006-05-16 13:57:02 +00:00
Sebastien Helleu 88fd88373d Added lock for log file (~/.weechat/weechat.log), only one WeeChat process can use this file (bug #16382) 2006-05-16 13:53:34 +00:00
Sebastien Helleu ed5f70aa6a Updated spanish translations 2006-05-16 08:53:33 +00:00
Sebastien Helleu 8659d94965 Updated translations 2006-05-15 20:24:06 +00:00
Sebastien Helleu 949c4f72e0 Added missing status bar refresh when connecting to server 2006-05-15 17:27:10 +00:00
Sebastien Helleu a4650a7f92 Fixed typos 2006-05-14 20:10:22 +00:00
Sebastien Helleu 127edfb0fe Fixed crash with ncurses color when too many colors defined in ncurses (bug #16556) 2006-05-14 12:42:46 +00:00
Sebastien Helleu 631eab3c66 Fixed 2 crashs: with malformed UTF-8 strings and with ncurses color when too many colors defined in ncurses 2006-05-14 11:06:16 +00:00
Sebastien Helleu 1418897108 Fixed typo 2006-05-14 09:25:55 +00:00
Sebastien Helleu f4ab9dcc33 Updated translations 2006-05-14 09:24:57 +00:00
Sebastien Helleu d88ad92c72 Added missing IRC commands (006, 007, 310, 379) 2006-05-14 08:45:55 +00:00
Sebastien Helleu 01aa8472c0 Added charset encoding for some command arguments (like /me, /msg, /query, ..) 2006-05-13 21:04:27 +00:00
Sebastien Helleu c1ce18e2f6 Updated doc 2006-05-13 17:57:50 +00:00
Sebastien Helleu bdaaa6182f Fixed typos in doc 2006-05-13 17:56:06 +00:00
Julien Louis c7a8d68f70 Sync debian packaging stuff with official packages 2006-05-13 08:45:19 +00:00
Sebastien Helleu 78ca78855e Added new key to find previous completion (shift-tab by default) 2006-05-13 00:06:18 +00:00
Sebastien Helleu 293bf5988b Removed unused prefix 2006-05-13 00:04:45 +00:00
Sebastien Helleu 65b4c157d1 Fixed savannah bugs URL 2006-05-12 15:56:09 +00:00
Sebastien Helleu e36b53bf74 Fixed "hostname" option for servers (now really used to set hostname/IP for choosing local interface (ipv4 or ipv6)) 2006-05-12 14:24:23 +00:00
Sebastien Helleu 59cddf7a40 Updated translations 2006-05-10 14:18:36 +00:00
Sebastien Helleu dce5e4fa18 Fixed bug with long outgoing IRC messages (> 512 bytes) (bug #16358) 2006-05-08 22:45:01 +00:00
Emmanuel Bouthenot 5d08d5e27c - fix a crash in ruby when a function return nothing (close bug #16552)
- add a warning when a function return nothing (python, ruby)
2006-05-08 20:22:42 +00:00
Sebastien Helleu 93e69f5b3e Fixed UTF-8 display bug with chars using more than one cell on screen (bug #16356) 2006-05-08 13:26:08 +00:00
Sebastien Helleu beb846884c Added date in doc 2006-05-08 00:44:07 +00:00
Sebastien Helleu 343e7fe59d Added contributors 2006-05-07 23:31:11 +00:00
Sebastien Helleu 057cffe9f0 Fixed display bug with DCC file size when > 1 Gb 2006-05-07 16:21:42 +00:00
Sebastien Helleu 86c2fb3031 Added russian translator name in doc 2006-05-07 14:01:19 +00:00
Sebastien Helleu b7ba64c744 Added some panel structures and functions 2006-05-07 11:40:19 +00:00
Sebastien Helleu 7d944ceca4 Fixed typo in setup option help 2006-05-07 11:35:35 +00:00
Sebastien Helleu 6172338bb7 Fixed refresh bug (deadlock in curses) when terminal is resized (bug #16542) 2006-05-07 11:31:11 +00:00
Emmanuel Bouthenot 27f45cdc6a update email and jabber address 2006-05-05 18:08:44 +00:00
Sebastien Helleu 9761177a2c Fixed nicklist sort bug 2006-05-05 12:59:16 +00:00
Sebastien Helleu 3352658af4 Added russian translations 2006-04-30 14:42:09 +00:00
Sebastien Helleu b314ee0f43 Added german doc 2006-04-30 12:35:58 +00:00
Sebastien Helleu 758f7f0103 Added colors in doc CSS 2006-04-25 17:09:18 +00:00
Sebastien Helleu b33e8c6482 Added IRC commands 290, 292, 437, 974 2006-04-23 16:01:01 +00:00
Sebastien Helleu 23f3622f2c Fixed bug #16369: fixed crash when multiple pv have same name: now it's forbidden and pv buffer is not renamed (when a nick changes) if another exists with same name 2006-04-23 09:22:53 +00:00
Sebastien Helleu 6021ee85cb Fixed bug #16416 (crash when purging old DCC chats) 2006-04-23 08:19:06 +00:00
Sebastien Helleu bcee678a56 Nick modes are now saved with /upgrade 2006-04-22 21:33:49 +00:00
Sebastien Helleu 40ffeb9e0c Splited GUI sources 2006-04-22 21:18:02 +00:00
Sebastien Helleu fb0e3a4e95 Splited gui-display.c into many sources 2006-04-22 21:09:59 +00:00
Sebastien Helleu daf2087164 Command /clear [-all] now clears hotlist 2006-04-21 13:02:50 +00:00
Sebastien Helleu a17a5337dc Removed known bugs, added URL to Savannah bugs page 2006-04-19 13:01:56 +00:00
Sebastien Helleu a56d65a7c0 Fixed crash after /upgrade if a line in history is empty 2006-04-19 12:35:30 +00:00
Sebastien Helleu 5af8e4f6e7 Fixed bug in logs with nick for names lines (nicks on channel when joining new channel) 2006-04-18 13:30:29 +00:00
Sebastien Helleu a065de071c Fixed typo in /window command help 2006-04-16 12:18:53 +00:00
Sebastien Helleu 22d8c1017b Fixed typo in /window command help 2006-04-16 11:56:34 +00:00
Sebastien Helleu 9481ec0c9c Changed default nick prefix/suffix 2006-04-16 10:27:48 +00:00
Sebastien Helleu f80489f469 Added option "look_align_size_max", nick alignment to right is now set by default with size 14 (max 20) 2006-04-16 09:46:23 +00:00
Sebastien Helleu 2fd53dcc37 Fixed many crashes with DCC chat 2006-04-15 16:47:43 +00:00
Sebastien Helleu b34bb801dc Added german translation 2006-04-14 07:21:47 +00:00
Sebastien Helleu 14fdcc5157 Fixed typos 2006-04-13 21:57:12 +00:00
Sebastien Helleu 0b523df418 Fixed typos in doc 2006-04-13 16:13:57 +00:00
Sebastien Helleu b81b747b96 Added more help for input prompt format 2006-04-13 12:04:14 +00:00
Sebastien Helleu 0da4487a11 Added --auto option, to remove wait for Return key (useful for automatic CVS build scripts) 2006-04-12 16:32:24 +00:00
Emmanuel Bouthenot f2258884d9 fix minor bug with ruby 1.9 and stdout/stderr redirections 2006-04-12 15:29:28 +00:00
Sebastien Helleu 1bee0ba0b2 Added new option to customize input prompt, added nick modes, fixed commands 332, 333 (/topic now ok when channel is not opened) 2006-04-12 13:34:33 +00:00
Sebastien Helleu 69730a21dd Removed charset conversion for commands (only allowed in text sent to channel/private) 2006-04-11 09:55:40 +00:00
Sebastien Helleu d6459aa638 Removed color encoding in commands (only allowed in text sent to channel/private) 2006-04-10 15:53:14 +00:00
Sebastien Helleu 58a1fc72db Added nick host in doc (for get_nick_info API function) 2006-04-09 08:51:21 +00:00
Emmanuel Bouthenot 1bc997b238 Fix possible minor bug in getting hostnames in plugins/scripts 2006-04-08 21:37:26 +00:00
Emmanuel Bouthenot 1f03444a6b Added hostnames associeted to nicks in plugins/scripts 2006-04-08 21:03:31 +00:00
Sebastien Helleu c525b231e4 Added hostnames associeted to nicks (available for /ban completion) 2006-04-08 18:38:00 +00:00
Emmanuel Bouthenot 6963ca7b65 make gcc-2.95 happy 2006-04-07 08:00:27 +00:00
Sebastien Helleu 99d86d64ab Added "+p" mode for channels, fixed mode display in status bar 2006-04-04 17:47:31 +00:00
Sebastien Helleu 94face39a6 Updated czech translations 2006-04-04 07:30:20 +00:00
Sebastien Helleu 2a34684bc1 Added alignment for local away message 2006-04-03 21:12:01 +00:00
Sebastien Helleu 5068f4d365 Added nick alignment in DCC chat, /query and /msg, fixed DCC chat bug when closing buffer 2006-04-03 16:01:10 +00:00
Sebastien Helleu 212ec7a76d Added nick alignment in private buffers 2006-04-03 09:35:08 +00:00
Sebastien Helleu 08b0272a9b Fixed typos in doc 2006-04-02 22:03:47 +00:00
Sebastien Helleu d01081241a Added nick alignment options 2006-04-02 21:53:41 +00:00
Sebastien Helleu 8ef6192b49 Fixed string explosion bug (should return 0 with empty string) 2006-04-02 11:37:22 +00:00
Sebastien Helleu f98d66a842 Fixed /buffer close bug with part message 2006-04-02 10:45:29 +00:00
Emmanuel Bouthenot 6175a89580 add regular expression support for /list command 2006-04-01 19:33:02 +00:00
Sebastien Helleu 23bfafed6a Fixed /names command: now displays result when not on a channel 2006-04-01 14:39:51 +00:00
Sebastien Helleu fccefcdf04 Fixed display but with input command line (when text is longer than window size) 2006-04-01 10:03:09 +00:00
Sebastien Helleu d86af240fa Fixed plugin command handler call when no argument is given 2006-04-01 07:43:51 +00:00
Sebastien Helleu c803419616 Fixed nicklist display bugs when on top or bottom of chat window, fixed refresh bug (too many refresh) when terminal is resized 2006-03-31 13:49:58 +00:00
Sebastien Helleu cc324abb75 Fixed bug with /alias and /unalias commands when alias begins with '/' 2006-03-30 17:08:23 +00:00
Sebastien Helleu 8c8a4104f0 Added nick completion for /userhost command 2006-03-30 15:20:28 +00:00
Sebastien Helleu 83bdd97916 Added keyboard handler to plugin API 2006-03-30 12:08:55 +00:00
Sebastien Helleu 56af0e3284 Improved script plugin loader 2006-03-26 09:46:30 +00:00
Sebastien Helleu 9abddbb7e9 Fixed bug with /set string value completion 2006-03-25 11:53:00 +00:00
Sebastien Helleu c0b6a23959 Fixed typo 2006-03-25 11:43:39 +00:00
Sebastien Helleu 173c7f7f2e Fixed typo 2006-03-25 11:32:31 +00:00
Sebastien Helleu eaa33bfb8e Added hostname/IP option for connection to server 2006-03-25 11:20:37 +00:00
Sebastien Helleu fcd3809326 Updated doc 2006-03-24 22:22:30 +00:00
Sebastien Helleu 8d4497a764 Fixed --disable-plugins option in configure script 2006-03-24 09:57:22 +00:00
Sebastien Helleu d9c032fee3 Added /setp command (set plugin options) 2006-03-24 09:38:54 +00:00
Sebastien Helleu 9fb1176b1b Completed /set command help 2006-03-21 14:17:29 +00:00
Sebastien Helleu 9ed873ed94 Fixed high CPU usage when running under a screen that has been killed 2006-03-21 13:27:51 +00:00
Sebastien Helleu 27fd4beca7 Aliases are executed before WeeChat/IRC commands, /builtin command added 2006-03-21 11:41:02 +00:00
Sebastien Helleu 6a55ee4f79 Immediately refresh nick (input window) during server connection process 2006-03-19 16:05:37 +00:00
Sebastien Helleu 4a13abcc9b Updated doc 2006-03-19 12:51:17 +00:00
Sebastien Helleu e499c1cb32 Added /cycle command, /part command does close buffer any more 2006-03-19 12:15:27 +00:00
Julien Louis 12b0742668 Sync Debian packaging stuff with official package 2006-03-18 12:07:14 +00:00
Sebastien Helleu 04e9677405 Fixed bug on ppc 2006-03-18 10:51:53 +00:00
Sebastien Helleu 3ff8d488e7 Version 0.1.9-cvs 2006-03-18 10:51:18 +00:00
Sebastien Helleu a4ee390737 Version 0.1.8 2006-03-18 09:46:07 +00:00
Sebastien Helleu 2b99338176 Version 0.1.8 2006-03-18 09:25:50 +00:00
Sebastien Helleu 1314c8e78e Version 0.1.8 2006-03-18 09:03:14 +00:00
Sebastien Helleu 0277a1eb62 Ruby changes forgotten in ChangeLog 2006-03-17 14:09:34 +00:00
Sebastien Helleu c4bafd3eef Fixed translations 2006-03-16 11:57:10 +00:00
Sebastien Helleu d006811b8e Fixed typos 2006-03-16 10:36:27 +00:00
Sebastien Helleu 2c894b89e7 Fixed /set command when internal server name contains one or many dots 2006-03-14 13:06:48 +00:00
Sebastien Helleu 02d4287ad0 Added missing IRC command "378" 2006-03-14 12:44:42 +00:00
Sebastien Helleu 7fa3dcbb2e Fixed plugin get_info bug when no server at all is opened 2006-03-14 12:43:02 +00:00
Sebastien Helleu 031fab21b0 Fixed display bug when top of buffer is displayed and first line is removed
(according to "history_max_lines" setting)
2006-03-11 07:33:54 +00:00
Sebastien Helleu ea06fca69c Fixed "+I" mode output 2006-03-10 23:19:11 +00:00
Sebastien Helleu 4181fa3f74 Fixed /mode command output 2006-03-10 22:44:21 +00:00
Julien Louis b9e247794e Fix typo in french translation 2006-03-10 20:11:41 +00:00
Sebastien Helleu d6e562ed7e Fixed completion for /away and /nick commands 2006-03-10 09:04:29 +00:00
Sebastien Helleu 227c05447f Improved alias completion (now uses target command for completion) 2006-03-08 15:31:26 +00:00
Sebastien Helleu 1005890db2 Fixed completion bug with commands in pv (nick completion, for example with /me) 2006-03-06 21:09:09 +00:00
Sebastien Helleu 8f714033ac Fixed chmod on home (now chmod is not executed when a directory is user's home) 2006-03-06 20:58:08 +00:00
Sebastien Helleu 1a510e1598 Added missing IRC command "487" 2006-03-04 23:20:41 +00:00
Sebastien Helleu 650805f204 Using new default value for DCC download dir (created at startup), fixed logs dir creation 2006-03-04 15:37:20 +00:00
Sebastien Helleu 919800c37c Added inactivity time, available for plugins via get_info("inactivity") 2006-03-04 14:27:14 +00:00
Sebastien Helleu 92db79989e Keys alt-{home|end} to scroll top/bottom, alt-{f11-f12} to scroll nicklist top/bottom 2006-03-03 10:40:43 +00:00
Sebastien Helleu 5d32ac0d57 Added special names for plugin message handlers: weechat_pv, weechat_highlight, weechat_ctcp, weechat_dcc 2006-03-02 21:54:33 +00:00
Sebastien Helleu bd1685a8fe Updated TODO 2006-03-02 21:54:00 +00:00
Sebastien Helleu 312ad619ae Fixed bug with dl library detection (for FreeBSD and maybe other systems) 2006-03-02 15:58:10 +00:00
Sebastien Helleu e4cc182105 Script plugins now load scripts in WeeChat system share directory 2006-02-28 21:11:34 +00:00
Sebastien Helleu 8c662f69f9 /msg command does not open any buffer any more 2006-02-28 15:59:33 +00:00
Sebastien Helleu 5c29def9d9 Fixed crash when using global history (when older entry is removed) 2006-02-26 11:27:43 +00:00
Sebastien Helleu c0a1673060 Added IRC raw data buffer 2006-02-22 11:58:11 +00:00
Emmanuel Bouthenot 3a79e32dbb fix minor bug and improve backtrace display on errors 2006-02-21 22:43:48 +00:00
Sebastien Helleu 349d9d1028 Fixed display bugs with /kill command 2006-02-21 10:23:35 +00:00
Sebastien Helleu 13ddcc3adc Added infobar_remove in C plugin API 2006-02-20 21:55:51 +00:00
Sebastien Helleu 9373a7a47e Added new plugin API function: remove_infobar 2006-02-20 17:01:18 +00:00
Sebastien Helleu e0c97562a5 Fixed bug in /lua command for timer handlers 2006-02-19 11:17:14 +00:00
Sebastien Helleu 3a213f38ec Added timer handler for plugins 2006-02-19 10:43:47 +00:00
Sebastien Helleu 484274d65f Plugin messages handlers now called when message is ignored; new behaviour for
messages ignored by a message handler: now WeeChat executes standard handler,
treating message as "ignored"
2006-02-18 13:35:06 +00:00
Sebastien Helleu 4f81254e40 Fixed message displayed when a command handler failed (now "failed" instead of
"command not found")
2006-02-18 12:50:55 +00:00
Sebastien Helleu da3f8ade08 Fixed Ruby function "log" (argument count) 2006-02-18 12:50:03 +00:00
Sebastien Helleu 271d1c905f Fixed scripts examples with server/channel/nick info 2006-02-17 15:00:00 +00:00
Sebastien Helleu ae0e17cfe2 Commands allowed when not connected to any server, fixed get_config: now needs exact option name to return value 2006-02-17 14:59:07 +00:00
Sebastien Helleu d69c634d2f Fixed typos 2006-02-17 14:58:01 +00:00
Emmanuel Bouthenot 14c9afb990 fix typo in parsing args for weechat_python_add_command_handler 2006-02-16 21:14:36 +00:00
Sebastien Helleu c491b39388 Updated doc, renamed functions in plugins API 2006-02-16 20:27:28 +00:00
Emmanuel Bouthenot 8855d39f44 make possible to log with plugins / scripts 2006-02-16 16:10:25 +00:00
Sebastien Helleu 91af3fe728 Updated translations 2006-02-16 10:19:07 +00:00
Emmanuel Bouthenot a62a002522 clean code while parsing commands in server_command and make possible to run many (irc or weechat) commands with alias 2006-02-16 09:51:08 +00:00
Sebastien Helleu f79653db8e Updated czech translations 2006-02-14 08:02:47 +00:00
Sebastien Helleu 0538215157 Updated doc for server_command setting 2006-02-12 22:12:05 +00:00
Emmanuel Bouthenot fa02f128ec make possible to run more than one command when connecting to server 2006-02-12 21:50:31 +00:00
Emmanuel Bouthenot 06ecdfdd35 fix some crash (unprotected code execution) and display some kind of backtrace when errors occurs 2006-02-12 01:33:36 +00:00
Emmanuel Bouthenot 00eef1c1bc clean some code 2006-02-12 01:31:35 +00:00
Sebastien Helleu e7fd1a0cb7 Auto-detect all components, and compile if found by default 2006-02-11 10:11:10 +00:00
Sebastien Helleu 321a8a65ad Added Lua 2006-02-11 10:10:26 +00:00
Sebastien Helleu e7f730387f Enable plugins compilation if Lua is enabled (like Perl/Python/Ruby) 2006-02-11 10:09:59 +00:00
Emmanuel Bouthenot e4eeaaf1dd clean code to avoid warning and errors when compiling with gcc-2.95 2006-02-10 12:44:10 +00:00
Sebastien Helleu 4c34ac5d8f Added Lua script plugin 2006-02-09 20:47:16 +00:00
Emmanuel Bouthenot 73990d8caa fix weechat_lua_remove_handler : now really use function args 2006-02-09 10:50:46 +00:00
Emmanuel Bouthenot d4e755a641 fix weechat_lua_add_message_handler : now really use function args 2006-02-09 10:33:48 +00:00
Sebastien Helleu 4a4daf6931 Added lua script plugin, new functions in plugins API 2006-02-08 21:37:17 +00:00
Emmanuel Bouthenot 8ddc5afb21 adding lua plugin/scripts support 2006-02-08 13:14:23 +00:00
Emmanuel Bouthenot a5cef6abde lua plugin/scripts support 2006-02-08 12:06:24 +00:00
Emmanuel Bouthenot 13a6d5b833 adding lua plugin/script 2006-02-08 11:49:04 +00:00
Sebastien Helleu 47b7b1d578 Added new API functions for scripts (list of servers, channels, nicks) 2006-02-08 11:13:49 +00:00
Sebastien Helleu c0a7e4445c Added hungarian translation (thanks to voroskoi) 2006-02-08 10:27:10 +00:00
Sebastien Helleu 80d6b1d952 Fixed XML typos 2006-02-07 21:10:11 +00:00
Sebastien Helleu 75eb47ee9e Added new plugins API functions (get_server_info, free_server_info, get_channel_info, free_channel_info, get_nick_info, free_nick_info) 2006-02-05 20:57:42 +00:00
Sebastien Helleu 6013e43292 Minor changes on server/channel/nick info API functions 2006-02-04 15:25:18 +00:00
Emmanuel Bouthenot 9150cff430 fix minor bugs while detecting lua 2006-02-03 08:31:15 +00:00
Sebastien Helleu 480974b8de Gtk GUI changes, now compile is ok 2006-02-03 00:36:03 +00:00
Emmanuel Bouthenot abeb5a2f48 Move previous GNU/hurd fix
Add lua script/plugin (detect libs and headers)
2006-02-03 00:29:38 +00:00
Emmanuel Bouthenot 4aac135244 fix a missing link in GNU/Hurd by force linking with pthread 2006-02-01 07:33:34 +00:00
Emmanuel Bouthenot f222a6ad7a extending plugins/scripts API by adding get_server_info, get_channel_info and get_nick_info 2006-01-31 13:54:27 +00:00
Sebastien Helleu fe5731dc84 Added options "look_open_near_server" and "look_nick_complete_first" (patch from Gwenn) 2006-01-30 20:42:53 +00:00
Sebastien Helleu 70ad116c0f Added options "look_open_near_server" and "look_nick_complete_first" (patch from Gwenn) 2006-01-30 20:22:40 +00:00
Sebastien Helleu 99a3434733 Fixed bug with elapsed time when away if computer clock was changed (displays 0 if elapsed time is negative) 2006-01-26 16:49:21 +00:00
Sebastien Helleu 0e91f0c208 Fixed bug with /upgrade when servers buffer (with one buffer for all servers) is moved to buffer # > 1 2006-01-26 13:57:27 +00:00
Sebastien Helleu 7711d548c0 Fixed typos 2006-01-26 11:18:59 +00:00
Sebastien Helleu a7479272f0 Fixed bug with "get_dcc_info" plugin interface function 2006-01-26 10:18:50 +00:00
Sebastien Helleu 2e1c6023d7 Fixed bug with option "irc_away_check_max_nicks" (now channels are refreshed when nicks count changed) 2006-01-26 10:04:57 +00:00
Sebastien Helleu 464fc8abdf Added new scroll keys for a few lines up/down (default: meta-pgup/pgdn) (patch from Pistos) 2006-01-25 17:52:11 +00:00
Sebastien Helleu 1e4c1a7073 Fixed compilation problem with debug messages 2006-01-25 17:09:24 +00:00
Sebastien Helleu 1607c44e75 Added new option "irc_away_check_max_nicks" to disable away check on channels with high number of nicks (patch from Gwenn) 2006-01-25 10:31:22 +00:00
Sebastien Helleu 364d774ded Added new command line argument for setting WeeChat homedir (-d or --dir) (patch from Gwenn) 2006-01-25 08:55:24 +00:00
Sebastien Helleu 6972b057d9 Fixed bug with charset in infobar highlights 2006-01-24 15:08:03 +00:00
Sebastien Helleu 8cd8410448 Fixed bugs: buffer detection in plugins/scripts commands, and /history command 2006-01-22 21:30:19 +00:00
Julien Louis 1cbdbffa40 Update debian packaging 2006-01-22 18:34:32 +00:00
Sebastien Helleu 3c16d49d2d Added some info for commands and options help 2006-01-21 21:26:24 +00:00
Sebastien Helleu 083ede73fd Added command line section in doc 2006-01-21 16:49:25 +00:00
Sebastien Helleu 5aeb7921fe Added option "irc_show_away_once", to show away message only once in pv 2006-01-21 11:56:58 +00:00
Sebastien Helleu e907b3b7a5 Version 0.1.8-cvs 2006-01-14 13:05:25 +00:00
272 changed files with 119092 additions and 31492 deletions
+11 -7
View File
@@ -16,10 +16,10 @@ Developers:
* Scripts plugins
Kolter <kolter@free.fr>
Kolter <kolter@openics.org>
Web : http://kolter.free.fr
IRC : nick is "kolter" @ irc.freenode.net
Jabber: kolter@jabber.org
Jabber: kolter@im.openics.org
Debian packager:
@@ -33,11 +33,15 @@ Julien Louis <ptitlouis@sysif.net>
Contributors:
------------
Rudolf Polzer <rpolzer-rp@durchnull.de> (IRC: "divVerent")
Jiri Golembiovsky <golemj@gmail.com> (IRC: "GolemJ")
Jim Ramsay <i.am@jimramsay.com> (IRC: "lack")
Odin <odin@dtdm.org> (IRC: "[Odin]")
Pistos (IRC: "pistos")
Rudolf Polzer <rpolzer-rp@durchnull.de>, IRC: "divVerent"
Jiri Golembiovsky <golemj@gmail.com>, IRC: "GolemJ"
Jim Ramsay <i.am@jimramsay.com>, IRC: "lack"
Odin <odin@dtdm.org>, IRC: "Odin"
Pistos, IRC: "pistos"
Gwenn, IRC: "gwenn"
Voroskoi, IRC: "voroskoi"
Frank Zacharias
Pavel Shevchuk, IRC: "Stalwart"
=====
+2 -12
View File
@@ -1,15 +1,5 @@
WeeChat - Wee Enhanced Environment for Chat
===========================================
WeeChat known bugs, 2006-01-14
- display bugs with UTF-8 chars coded on more than 2 bytes
- divide long messages (> 512 bytes) into more messages so IRC server can
parse them correctly
- some refresh bugs with splited windows
- command name for /server can not contain spaces
- when many WeeChat are launched, log file is not properly written
(cleared by each WeeChat at startup)
- WeeChat may crash if too much nicks in nicklist when position is top
or bottom
- ./configure does not check that Gtk 2.0 libraries are installed
WeeChat known bugs:
please look at https://savannah.nongnu.org/bugs/?group=weechat
+105 -11
View File
@@ -1,8 +1,102 @@
WeeChat - Wee Enhanced Environment for Chat
===========================================
ChangeLog - 2006-01-14
ChangeLog - 2006-05-25
Version 0.1.9 (2006-05-25):
* fixed /squery command (message sent to server, now ok with # args > 2)
* fixed /alias command (with an alias name, display content)
* improved lua plugin detection (bug #16574)
* added backtrace when WeeChat crashes, log file automatically renamed
* added lock for log file (~/.weechat/weechat.log), only one WeeChat
process can use this file (bug #16382)
* fixed crash with malformed UTF-8 strings
* fixed crash with ncurses color when too many colors defined in ncurses
(bug #16556)
* added new key to find previous completion (shift-tab by default)
* fixed bug with long outgoing IRC messages (> 512 bytes) (bug #16358)
* fixed Ruby crash when handler does not return OK or KO (bug #16552)
* fixed UTF-8 display bug with chars using more than one cell on screen
(bug #16356)
* fixed display bug with DCC file size when > 1 Gb
* fixed refresh bug (deadlock in curses) when terminal is resized
(bug #16542)
* fixed nicklist sort bug
* added russian translations (thanks to Pavel Shevchuk)
* added german doc (thanks to Frank Zacharias)
* added missing IRC commands (006, 007, 290, 292, 310, 379, 437, 974)
* fixed crash when multiple pv have same name: now it's forbidden
and pv buffer is not renamed (when a nick changes) if another
exists with same name (bug #16369)
* command /clear [-all] now clears hotlist
* fixed crash after /upgrade if a line in history is empty (bug #16379)
* fixed many crashes with DCC chat (bug #16416)
* added new option to customize input prompt
* added nick modes
* fixed commands 332, 333 (/topic now ok when channel is not opened)
* removed color encoding and charset conversion for commands (only
allowed in text sent to channel/private)
* added hostnames associeted to nicks (available for /ban completion)
* added "+p" mode for channels, fixed mode display in status bar
* added nick alignment options
* fixed /names command: now displays result when not on a channel
* fixed refresh bug (too many refresh) when terminal is resized
* fixed nicklist display bugs when on top or bottom of chat window
* added keyboard handler to plugin API
* improved script plugin loader
* added hostname/IP option for connection to server
* fixed --disable-plugins option in configure script
* added /setp command (set plugin options)
* fixed high CPU usage when running under a screen that has been killed
* aliases are executed before WeeChat/IRC commands, /builtin command added
* added /cycle command, /part command does close buffer any more (use
/buffer close (or alias /close) to part and close buffer
Version 0.1.8 (2006-03-18):
* improved Ruby plugin
* fixed /set command when internal server name contains one or many dots
* fixed get_info plugin API function when no server at all is opened
* fixed display bug when top of buffer is displayed and first line is
removed (according to "history_max_lines" setting)
* fixed /mode command output
* improved alias completion (now uses target command for completion)
* fixed completion problem in private with nicks
* added missing IRC command (487)
* added inactivity time, available for plugins via get_info("inactivity")
* keys alt-{home|end} to scroll top/bottom, alt-{f11-f12} to scroll
nicklist top/bottom
* added special names for plugin message handlers: weechat_pv,
weechat_highlight, weechat_ctcp, weechat_dcc
* script plugins now load scripts in WeeChat system share directory
* /msg command does not open any buffer any more
* fixed crash when using global history (when older entry is removed)
* added IRC raw data buffer (new key: alt-J + alt-R)
* fixed display bug with /kill command
* added new plugins functions: add_timer_handler, remove_timer_handler,
remove_infobar
* plugin messages handlers now called when message is ignored (by /ignore)
* new behaviour for messages ignored by a message handler: now WeeChat
executes standard handler, treating message as "ignored"
* many commands allowed for aliases
* many commands allowed when connecting to server
* added Lua script plugin
* added functions in plugins API: get_server_info, free_server_info,
get_channel_info, free_channel_info, get_nick_info, free_nick_info
* added option "look_nick_complete_first" (patch from Gwenn)
* added option "look_open_near_server" (patch from Gwenn)
* fixed bug with /upgrade and servers buffer
* fixed bug with "get_dcc_info" plugin interface function
* added new scroll keys for a few lines up/down (default: meta-pgup/pgdn)
(patch from Pistos)
* added new option "irc_away_check_max_nicks" to disable away check on
channels with high number of nicks (patch from Gwenn)
* added new command line argument for setting WeeChat homedir (-d or --dir)
(patch from Gwenn)
* fixed bug with charset in infobar highlights
* fixed bug with buffer detection in plugins/scripts commands
* fixed bug with /history command
* added option "irc_show_away_once", to show away message only once in pv
* added partial hungarian translation
Version 0.1.7 (2006-01-14):
* fixed msg command (now allowed in private buffer with "*" as target)
@@ -22,7 +116,7 @@ Version 0.1.7 (2006-01-14):
* added server/channel arg to /buffer command for jumping to buffer
* fixed display bug in chat window when a message length equals to window
width
* added new keys for switching to other windows: alt-w followed by
* added new keys for switching to other windows: alt-W followed by
alt-{arrow}
* added new keys for scrolling to previous/next highlight: alt-P / alt-N
* added "read marker": an indicator for first unread line in a
@@ -97,7 +191,7 @@ Version 0.1.4 (2005-07-30):
* topic completion now decodes UTF-8 string
* fixed bug with IRC URL on command line (irc://)
* new keyboard management: keys are setup in config file, new command
/key was added and some new default keys were added, alt-k key is
/key was added and some new default keys were added, alt-K key is
used to grab key (useful for /key command)
* added seconds in infobar time (optional thanks to new setting)
* fixed some curses refreshs
@@ -123,14 +217,14 @@ Version 0.1.3 (2005-07-02):
* fixed plugins "print" and "prnt" functions: now ok for writing on server
buffers
* fixed color problem with new libcurses version
* fixed crash when using Alt-S or Alt-X on DCC buffer (Alt-D)
* fixed crash when using alt-S or alt-X on DCC buffer (alt-D)
* fixed startup crash when config file (~/.weechat/weechat.rc) is not found
* improved Perl/Python libs detection for ./configure script
Version 0.1.2 (2005-05-21):
* added Python plugin support, improved Perl interface (and now Perl/Python
libraries are checked by configure script)
* added nicklist scroll keys (Alt+{home/end/pgup/pgdn} or F11/F12)
* added nicklist scroll keys (alt+{home/end/pgup/pgdn} or F11/F12)
* added transfer rate for DCC files
* added "-all" option for /nick command
* buffers timestamp can now be changed (new option in config file)
@@ -199,8 +293,8 @@ Version 0.0.9 (2005-01-01):
* fixed display of nick mode changes
* new command "/buffer close" (close any server/channel/private buffer)
* /notice command fixed (and display when received from server)
* new keys: Ctrl+A (=home), Ctrl+E (=end), Ctrl+W (=Ctrl+Backspace),
Alt-S (switch to server buffer), Alt-X (switch to first channel of next
* new keys: ctrl+A (=home), ctrl+E (=end), ctrl+W (= ctrl+Backspace),
alt-S (switch to server buffer), alt-X (switch to first channel of next
server)
* added new config option: "server_command_delay" (delay in seconds after
startup command for each server)
@@ -217,15 +311,15 @@ Version 0.0.8 (2004-10-30):
to enable/disable this feature
* Fixed crash when resizing terminal to very small size
* "-MORE-" message is now erased when switching to another buffer
* DCC file receive ok (Alt-D for DCC view)
* DCC file receive ok (alt-D for DCC view)
* /query command now reopens private buffer if already opened
* added key for redrawing terminal (Ctrl-L)
* added key for clearing hotlist (Alt-R)
* added key for redrawing terminal (ctrl-L)
* added key for clearing hotlist (alt-R)
Version 0.0.7 (2004-08-08):
* new "col_status_delimiters" config option
* /buffer command added, buffers ordered by number, auto-jump to active
buffers (alt-a), jump to buffers by number (alt-number)
buffers (alt-A), jump to buffers by number (alt-number)
* /window command added, split terminal horizontally/vertically
* unique color for each nick (based on nickname)
* action messages are now considered as messages, not crappy joins/parts
+21 -6
View File
@@ -1,4 +1,4 @@
WeeChat FAQ, 2006-01-14
WeeChat FAQ, 2006-05-25
=======================
Intended audience:
@@ -53,7 +53,7 @@ A: Because WeeChat is very light and has new features.
* many GUI (Curses, Gtk, wxWidgets, Qt)
* available in many languages
* nicklist available in all GUI
* extensible with scripts (Perl, Python, Ruby)
* extensible with plugins (C, Perl, Python, Ruby, Lua)
* horizontal and vertical window split
* infobar highlight
* FIFO pipe for remote control
@@ -95,42 +95,57 @@ A: Key bindings are customizable with /key command.
2.5
================================================================================
Q: How can I load Perl scripts?
Are Perl scripts compatible with X-chat or/and Irssi ?
Are Perl scripts compatible with other IRC clients ?
A: You can use /perl command to load scripts (default path is
~/.weechat/perl).
Note that scripts in ~/.weechat/perl/autoload are automatically loaded
when WeeChat is starting up.
Perl scripts are not compatible with other IRC clients.
2.6
================================================================================
Q: How can I load Python scripts?
Are Python scripts compatible with X-chat or/and Irssi ?
Are Python scripts compatible with other IRC clients ?
A: You can use /python command to load scripts (default path is
~/.weechat/python).
Note that scripts in ~/.weechat/python/autoload are automatically loaded
when WeeChat is starting up.
Python scripts are not compatible with other IRC clients.
2.7
================================================================================
Q: How can I load Ruby scripts?
Are Ruby scripts compatible with other IRC clients ?
A: You can use /ruby command to load scripts (default path is
~/.weechat/ruby).
Note that scripts in ~/.weechat/ruby/autoload are automatically loaded
when WeeChat is starting up.
Ruby scripts are not compatible with other IRC clients.
2.8
================================================================================
Q: How can I load Lua scripts?
Are Lua scripts compatible with other IRC clients ?
A: You can use /lua command to load scripts (default path is
~/.weechat/lua).
Note that scripts in ~/.weechat/lua/autoload are automatically loaded
when WeeChat is starting up.
Lua scripts are not compatible with other IRC clients.
3.1
================================================================================
Q: How should I report bugs?
A: There is 3 ways to report bugs:
1. you can join us on IRC: irc.freenode.net, channel #weechat
2. you can submit your bug at this url:
2. you can submit your bug at this URL:
http://savannah.nongnu.org/bugs/?func=addbug&group=weechat
3. you can mail your problem, look at support page for developer's mails:
http://weechat.flashtux.org/support.php
@@ -143,7 +158,7 @@ Q: How should I submit patches?
A: There is 3 ways to submit patches:
1. you can join us on IRC: irc.freenode.net, channel #weechat
2. you can submit your patch at this url:
2. you can submit your patch at this URL:
http://savannah.nongnu.org/patch/?func=addpatch&group=weechat
3. you can mail your patch, look at support page for developer's mails:
http://weechat.flashtux.org/support.php
+21 -5
View File
@@ -1,4 +1,4 @@
WeeChat FAQ, 2006-01-14
WeeChat FAQ, 2006-05-25
=======================
Public concerné :
@@ -56,7 +56,7 @@ R: Parce que WeeChat est tr
* plusieurs interfaces (Curses, Gtk, wxWidgets, Qt)
* disponible en plusieurs langues
* liste des pseudos disponible dans toutes les interfaces
* extensible par des scripts (Perl, Python, Ruby)
* extensible par des extensions (C, Perl, Python, Ruby, Lua)
* découpage de la fenêtre horizontalement et verticalement
* highlight dans la barre d'infos
* tube FIFO pour contrĂ´le Ă  distance
@@ -100,33 +100,49 @@ R: Les raccourcis clavier sont modifiables avec la commande /key.
2.5
================================================================================
Q: Comment puis-je charger des scripts Perl ?
Les scripts Perl sont-ils compatibles avec X-chat et/ou Irssi ?
Les scripts Perl sont-ils compatibles avec d'autres clients IRC ?
R: La commande /perl permet de charger les scripts Perl (le chemin par défaut
est ~/.weechat/perl).
Notez que les scripts dans ~/.weechat/perl/autoload sont automatiquement
chargés par WeeChat lorsqu'il démarre.
Les scripts Perl ne sont pas compatibles avec d'autres clients IRC.
2.6
================================================================================
Q: Comment puis-je charger les scripts Python ?
Les scripts Python sont-ils compatibles avec X-chat et/ou Irssi ?
Les scripts Python sont-ils compatibles avec d'autres clients IRC ?
R: La commande /python permet de charger les scripts Python (le chemin par
défaut est ~/.weechat/python).
Notez que les scripts dans ~/.weechat/python/autoload sont automatiquement
chargés par WeeChat lorsqu'il démarre.
Les scripts Python ne sont pas compatibles avec d'autres clients IRC.
2.7
================================================================================
Q: Comment puis-je charger des scripts Ruby ?
Les scripts Ruby sont-ils compatibles avec d'autres clients IRC ?
R: La commande /ruby permet de charger les scripts Ruby (le chemin par
défaut est ~/.weechat/ruby).
Notez que les scripts dans ~/.weechat/ruby/autoload sont automatiquement
chargés par WeeChat lorsqu'il démarre.
Les scripts Ruby ne sont pas compatibles avec d'autres clients IRC.
2.8
================================================================================
Q: Comment puis-je charger des scripts Lua ?
Les scripts Lua sont-ils compatibles avec d'autres clients IRC ?
R: La commande /lua permet de charger les scripts Lua (le chemin par
défaut est ~/.weechat/lua).
Notez que les scripts dans ~/.weechat/lua/autoload sont automatiquement
chargés par WeeChat lorsqu'il démarre.
Les scripts Lua ne sont pas compatibles avec d'autres clients IRC.
3.1
@@ -137,7 +153,7 @@ R: Il y a 3 mani
1. vous pouvez nous joindre sur IRC: irc.freenode.net, canal #weechat
2. vous pouvez soumettre votre bug Ă  cette adresse :
http://savannah.nongnu.org/bugs/?func=addbug&group=weechat
3. vous pouvez envoyer votre problem par mail, consultez la page
3. vous pouvez envoyer votre problème par mail, consultez la page
support pour les mails des développeurs :
http://weechat.flashtux.org/support.php
(vous pouvez souscrire et envoyer Ă  la liste de diffusion
+2 -6
View File
@@ -2,11 +2,7 @@ WeeChat - Installation instructions
===================================
1) Run './configure'
options: --enable-perl : enable Perl scripts
--disable-curses : do not build Curses interface
--enable-gtk : build Gtk+ interface (under development!)
--enable-qt : build Qt interface (not developed!)
--with-debug=X : X=1 for debug compilation, 2 for debug messages
(./configure --help so see options)
2) Run 'make'
@@ -14,4 +10,4 @@ WeeChat - Installation instructions
4) Enjoy ! :-)
See AUTHORS for support, feel free to contact us for any problem ;)
See AUTHORS for support, feel free to contact us for any problem.
+32
View File
@@ -1,6 +1,38 @@
WeeChat - Wee Enhanced Environment for Chat
===========================================
* FlashCode, 2006-05-25
WeeChat 0.1.9 released.
Important release notes:
- please close all DCC chat buffers before using /upgrade command,
otherwise you may experience problems with DCC chats.
- some changes in script API: now timer handlers functions takes exactly
0 (zero) argument (in version 0.1.8, two arguments were mandatory but
not used: server and args)
* FlashCode, 2006-03-18
WeeChat 0.1.8 released.
Important release notes:
- it is recommended for users of version 0.1.7 (or any older), to
replace values in setup file (~/.weechat/weechat.rc) :
- option: log_path: replace "~/.weechat/logs" by "%h/logs"
- option: plugins_path: replace "~/.weechat/plugins" by "%h/plugins"
"%h" is replaced by WeeChat home (default: ~/.weechat, may be overriden
by new command line arg --dir)
- after installing 0.1.8 (or with /upgrade), issue both commands (if you
didn't redefined these keys (alt-home/end):
/key unbind meta-meta2-1~
/key unbind meta-meta2-4~
then launch again WeeChat (or issue /upgrade).
Alt-home/end were used for nicklist scroll, they're now replaced by
Alt-F11/F12.
* FlashCode, 2006-01-14
WeeChat 0.1.7 released.
+3 -4
View File
@@ -12,10 +12,10 @@ Features
* IRC chat client with multi-server connection
* many GUI (curses, Gtk, Qt) (1)
* small, fast and very light
* customizable and extensible with plugins (scripts Perl, Python, Ruby) (2)
* customizable and extensible with plugins (C, Perl, Python, Ruby, Lua)
* compliant with RFC 1459,2810,2811,2812,2813
* developed from scratch
* multi-platform (GNU/Linux, *BSD, Mac OS X, QNX, Windows & other) (3)
* multi-platform (GNU/Linux, *BSD, Mac OS X, QNX, Windows & other) (2)
* 100% GPL & free
@@ -44,5 +44,4 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
---
(1) only Curses interface is available today
(2) only Perl and Python plugins are available today
(3) Windows is under construction
(2) Windows version is under construction
+2 -90
View File
@@ -1,93 +1,5 @@
WeeChat - Wee Enhanced Environment for Chat
===========================================
TODO - 2006-01-14
Legend:
# done
+ currently in development
- pending
? is this really necessary?
* General:
+ Windows version
# Solaris version
* Interface:
+ Gtk GUI
? Qt GUI
+ internationalization (traduce WeeChat in many languages)
- add dark colors (demi intensity)
# color for nicks (except own nick) when nick colors are disabled
# allow decode/encode charsets for servers or chan (not globally)
- understand incomplete commands if unambigous (for example: /he for /help is ok)
- interpret 'old-school' special chars in messages: *bold* _underline_ /italic/
- minimal width of nick in text area
- display number of highlights since last buffer read (pink square)
- add "*" on the side of message buffer when alt-j or other meta modifier is on
- completion with tab key for all words starting with "#" by opened chans names
- completion when input line is empty should add last nick that wrote to me
- open new channels near server (not at the end of buffers)
- add filename completion (for example with /dcc send)
* WeeChat commands
- be able to bind a key on more than one command
- be able to make an alias running more than one command
- host with "*" possible with /ignore command
- "/completion" command: do shortcuts (for example when we type "u"
in the text bar it send it to the server as "you")
- "/last": command to look for text in previous messages
# completion system for scripts arguments
# "/upgrade" command: reload WeeChat himself without disconnecting from server
- get help on config settings with /help option instead of /set option (since
many options can be displayed and help is not displayed in this case)
- "/cycle": do a /part then /join on current channel
- be able to save the current buffer with a single command
(/buffer dump /path/to/file), or to make it possible to write a script
that does so (see plugins)
- "/reconnect": reconnect to all servers, without waiting for auto-reconnect delay after disconnection
* IRC protocol:
# customizable CTCP version reply (possible by plugin script)
- complete "/list" command: add regexp search, display only channels that
match regexp
- when we're away, WeeChat should log all the lines begenning by our nick.
When we come back from our away it should print it to the current window
- "/notify" and "/unnotify" command to be warn by WeeChat when a given
nick/host connect to the given irc network
- display one time away message of remote user in private (optional)
- add max number of nicks for away check (do not check away nicks on channels with high number of nicks)
- add anti-flood mechanism, when pasting more than N lines
- add mask for /ban command, and ban types (host, nick)
* Configuration:
- be able to launch more than one command when connecting to server
- use ~/.weechat/dcc by default for DCC incoming files (and create
directory at startup if not found)
- add global username/realname, used if server values are not filled
- add command line arg (--dir ?) to choose weechat home dir
(~/.weechat by default)
- be able to set more than one server address for network
- save buffer numbers (order) to config file and restore them when
opened, or make it possible by script
* Plugins:
- allow print function to write on all buffers or all channels of a server
- Ruby plugin
- "/ruby load" and "/ruby unload" commands to (un)load Ruby scripts
- add "outgoing" message event so scripts can edit user-input text before
it is sent to the channel
- add a timer function so scripts can do things like timeouts, delayed
processing, etc.
- allow print function to write on all buffers or all channels of a server
- allow plugins to perform actions on "highlight" messages
- get_servers(), get_channels(server), get_nicks(server,channel)
- Lua plugin
- Tcl plugin
- Php plugin (maybe if possible)
? "fish" plugin (cf http://fish.sekure.us/)
- script plugins (perl, python, ruby, ..) should load scripts in system dir,
not only ~/.weechat/xxxx/autoload/
- allow plugins to get the contents of a specified (or at least the
"current") buffer.
WeeChat TODO:
please look at https://savannah.nongnu.org/task/?group=weechat
+9 -5
View File
@@ -3,14 +3,18 @@
# gettextize updates Makefile.am, configure.in
cp configure.in configure.in.old
cp Makefile.am Makefile.am.old
gettextize --copy --force --intl --no-changelog &&
if test "$1" = "--auto" ; then
grep -v 'read dummy < /dev/tty' $(which gettextize) | /bin/sh -s -- --copy --force --intl --no-changelog
else
gettextize --copy --force --intl --no-changelog
fi
mv Makefile.am.old Makefile.am
mv configure.in.old configure.in
libtoolize --automake --force --copy &&
aclocal &&
libtoolize --automake --force --copy
aclocal
# autoheader creates config.h.in needed by autoconf
autoheader &&
autoheader
# autoconf creates configure
autoconf &&
autoconf
# automake creates Makefile.in
automake --add-missing --copy --gnu
+377 -146
View File
@@ -19,10 +19,10 @@
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.56)
AC_INIT(WeeChat, 0.1.7, flashcode@flashtux.org)
AC_INIT(WeeChat, 0.1.9, flashcode@flashtux.org)
AC_CONFIG_SRCDIR([src/common/weechat.c])
AM_CONFIG_HEADER(config.h)
AM_INIT_AUTOMAKE([weechat], [0.1.7])
AM_INIT_AUTOMAKE([weechat], [0.1.9])
# Checks for programs
AC_PROG_CC
@@ -32,6 +32,7 @@ AM_PROG_LIBTOOL
# Add some flags for some OS
case "$host_os" in
freebsd* | openbsd*)
CFLAGS="$CFLAGS -I/usr/local/include"
LDFLAGS="$LDFLAGS -L/usr/local/lib"
;;
netbsd*)
@@ -46,7 +47,7 @@ solaris*)
esac
# Gettext
ALL_LINGUAS="fr es cs"
ALL_LINGUAS="fr es cs hu de ru"
AM_GNU_GETTEXT
# Checks for libraries
@@ -55,7 +56,12 @@ AC_CHECK_LIB(ncursesw, initscr, LIBNCURSESW_FOUND=1, LIBNCURSESW_FOUND=0)
# Checks for header files
AC_HEADER_STDC
AC_CHECK_HEADERS([arpa/inet.h libintl.h limits.h locale.h netdb.h netinet/in.h stdlib.h string.h sys/socket.h sys/time.h sys/types.h unistd.h pwd.h errno.h])
AC_CHECK_HEADERS([arpa/inet.h libintl.h limits.h locale.h netdb.h netinet/in.h stdlib.h string.h sys/socket.h sys/time.h sys/types.h unistd.h pwd.h errno.h regex.h wchar.h sys/file.h])
if echo "$host_os" | grep "^openbsd" 1>/dev/null 2>&1 ; then
AC_CHECK_HEADER(utf8/wchar.h, LDFLAGS="$LDFLAGS -lutf8", [AC_MSG_ERROR([
*** on OpenBSD systems, package libutf8 must be installed to compile WeeChat])])
fi
# Checks for typedefs, structures, and compiler characteristics
AC_HEADER_TIME
@@ -78,7 +84,7 @@ AC_MSG_RESULT($ac_cv_type_socklen_t)
# Checks for library functions.
AC_FUNC_SELECT_ARGTYPES
AC_TYPE_SIGNAL
AC_CHECK_FUNCS([gethostbyname gethostname getsockname gettimeofday inet_ntoa memset mkdir select setlocale socket strcasecmp strchr strdup strncasecmp strpbrk strrchr strstr uname])
AC_CHECK_FUNCS([gethostbyname gethostname getsockname gettimeofday inet_ntoa memset mkdir select setlocale socket strcasecmp strchr strdup strncasecmp strpbrk strrchr strstr uname regexec])
# Variables in config.h
@@ -89,31 +95,29 @@ AH_VERBATIM([PLUGINS], [#undef PLUGINS])
AH_VERBATIM([PLUGIN_PERL], [#undef PLUGIN_PERL])
AH_VERBATIM([PLUGIN_PYTHON], [#undef PLUGIN_PYTHON])
AH_VERBATIM([PLUGIN_RUBY], [#undef PLUGIN_RUBY])
AH_VERBATIM([PLUGIN_LUA], [#undef PLUGIN_LUA])
AH_VERBATIM([HAVE_GNUTLS], [#undef HAVE_GNUTLS])
AH_VERBATIM([HAVE_FLOCK], [#undef HAVE_FLOCK])
AH_VERBATIM([DEBUG], [#undef DEBUG])
# Arguments for ./configure
AC_ARG_ENABLE(ncurses, [ --disable-ncurses Turn off ncurses interface (default=compiled if found)],enable_ncurses=$enableval,enable_ncurses=yes)
AC_ARG_ENABLE(wxwidgets, [ --enable-wxwidgets Turn on WxWidgets interface (default=no wxwidgets)],enable_wxwidgets=$enableval,enable_wxwidgets=no)
AC_ARG_ENABLE(gtk, [ --enable-gtk Turn on Gtk+ interface (default=no Gtk+)],enable_gtk=$enableval,enable_gtk=no)
AC_ARG_ENABLE(gtk, [ --enable-gtk Turn on Gtk interface (default=no Gtk)],enable_gtk=$enableval,enable_gtk=no)
AC_ARG_ENABLE(qt, [ --enable-qt Turn on Qt interface (default=no Qt)],enable_qt=$enableval,enable_qt=no)
AC_ARG_ENABLE(plugins, [ --disable-plugins Turn off plugins support (default=plugins enabled)],enable_plugins=$enableval,enable_plugins=yes)
AC_ARG_ENABLE(perl, [ --enable-perl Turn on Perl script plugin (default=no Perl plugin)],enable_perl=$enableval,enable_perl=no)
AC_ARG_ENABLE(python, [ --enable-python Turn on Python script plugin (default=no Python plugin)],enable_python=$enableval,enable_python=no)
AC_ARG_ENABLE(ruby, [ --enable-ruby Turn on Ruby script plugin (default=no Ruby script)],enable_ruby=$enableval,enable_ruby=no)
AC_ARG_ENABLE(perl, [ --disable-perl Turn off Perl script plugin (default=compiled if found)],enable_perl=$enableval,enable_perl=yes)
AC_ARG_ENABLE(python, [ --disable-python Turn off Python script plugin (default=compiled if found)],enable_python=$enableval,enable_python=yes)
AC_ARG_ENABLE(ruby, [ --disable-ruby Turn off Ruby script plugin (default=compiled if found)],enable_ruby=$enableval,enable_ruby=yes)
AC_ARG_ENABLE(lua, [ --disable-lua Turn off Lua script plugin (default=compiled if found)],enable_lua=$enableval,enable_lua=yes)
AC_ARG_WITH(lua-inc, [ --with-lua-inc=DIR, Lua include files are in DIR (default=autodetect)],lua_inc=$withval,lua_inc='')
AC_ARG_WITH(lua-lib, [ --with-lua-lib=DIR, Lua library files are in DIR (default=autodetect)],lua_lib=$withval,lua_lib='')
AC_ARG_WITH(lua-suffix, [ --with-lua-suffix=ARG Lua is suffixed with ARG (default=autodetect)],lua_suffix=$withval,lua_suffix='')
AC_ARG_ENABLE(gnutls, [ --disable-gnutls Turn off gnutls support (default=compiled if found)],enable_gnutls=$enableval,enable_gnutls=yes)
AC_ARG_WITH(debug, [ --with-debug Debugging: 0=no debug, 1=debug compilation, 2=debug compilation + verbose msgs (default=1)],debug=$withval,debug=1)
AM_CONDITIONAL(GUI_NCURSES, test "$enable_ncurses" = "yes")
AM_CONDITIONAL(GUI_WXWIDGETS, test "$enable_wxwidgets" = "yes")
AM_CONDITIONAL(GUI_GTK, test "$enable_gtk" = "yes")
AM_CONDITIONAL(GUI_QT, test "$enable_qt" = "yes")
AM_CONDITIONAL(PLUGINS, test "$enable_plugins" = "yes")
AM_CONDITIONAL(PLUGIN_PERL, test "$enable_perl" = "yes")
AM_CONDITIONAL(PLUGIN_PYTHON, test "$enable_python" = "yes")
AM_CONDITIONAL(PLUGIN_RUBY, test "$enable_ruby" = "yes")
AM_CONDITIONAL(HAVE_GNUTLS, test "$enable_gnutls" = "yes")
not_found=""
# ------------------------------------------------------------------------------
# GUI
@@ -122,14 +126,17 @@ AM_CONDITIONAL(HAVE_GNUTLS, test "$enable_gnutls" = "yes")
if test "x$enable_ncurses" = "xyes" ; then
if test "$LIBNCURSESW_FOUND" = "0" ; then
if test "$LIBNCURSES_FOUND" = "0" ; then
AC_MSG_ERROR([
AC_MSG_WARN([
*** ncurses library not found!
*** Please install ncurses library or run ./configure with --disable-ncurses parameter.])
fi
AC_MSG_WARN([
*** WeeChat will be built without ncurses support.])
enable_ncurses="no"
not_found="$not_found ncurses"
else
AC_MSG_WARN([
*** ncursesw library not found! Falling back to "ncurses"
*** Be careful, UTF-8 display may not work properly if your locale is UTF-8.])
NCURSES_LIBS="-lncurses"
NCURSES_LIBS="-lncurses"
fi
else
NCURSES_LIBS="-lncursesw"
AC_CHECK_HEADERS(ncursesw/curses.h)
@@ -163,13 +170,19 @@ fi
#fi
if test "x$enable_gtk" = "xyes" ; then
#if test "$LIBGTK_FOUND" = "0" ; then
# AC_MSG_ERROR([Gtk+ library not found! Install Gtk+ (2.0 or higher) library or run ./configure without --enable-gtk parameter.])
#fi
GTK_CFLAGS=`pkg-config --cflags gtk+-2.0`
GTK_LIBS=`pkg-config --libs gtk+-2.0`
AC_SUBST(GTK_CFLAGS)
AC_SUBST(GTK_LIBS)
AM_PATH_GTK_2_0(2.4.0, LIBGTK_FOUND=1, LIBGTK_FOUND=0)
if test "$LIBGTK_FOUND" = "0" ; then
AC_MSG_WARN([
*** Gtk library not found!
*** WeeChat will be built without Gtk support.])
enable_gtk="no"
not_found="$not_found gtk"
else
GTK_CFLAGS=`pkg-config --cflags gtk+-2.0`
GTK_LIBS=`pkg-config --libs gtk+-2.0`
AC_SUBST(GTK_CFLAGS)
AC_SUBST(GTK_LIBS)
fi
fi
# ------------------------------------------------------------------------------
@@ -178,148 +191,293 @@ fi
PLUGINS_LIBS=
if test "x$enable_plugins" != "xyes" ; then
enable_plugins="no"
enable_perl="no"
enable_python="no"
enable_ruby="no"
enable_lua="no"
fi
# ---------------------------------- perl --------------------------------------
if test "x$enable_perl" = "xyes" ; then
enable_plugins="yes"
AC_PATH_PROGS(PERL, perl perl5)
if test -z $PERL ; then
AC_MSG_ERROR([
*** Perl must be installed on your system
*** but perl interpreter couldn't be found in path.
Please check that perl is in path, or install
it with your software package manager.])
fi
AC_MSG_CHECKING(for Perl headers files)
PERL_HEADER_TEST=`PT=perltest.c ; echo "#include <EXTERN.h>" > $PT; echo "#include <perl.h>" >> $PT; echo "#include <XSUB.h>" >> $PT ; echo "int main() { return 0; }" >> $PT ; $CC -Wall $PT -o $PT.out $($PERL -MExtUtils::Embed -e ccopts) 1>/dev/null 2>&1; echo $?; rm -f $PT $PT.out 1>/dev/null 2>&1`
if test "x$PERL_HEADER_TEST" = "x0" ; then
PERL_CFLAGS=`$PERL -MExtUtils::Embed -e ccopts`
AC_MSG_WARN([
*** Perl must be installed on your system but perl interpreter couldn't be found in path.
*** Please check that perl is in path, or install it with your software package manager.
*** WeeChat will be built without Perl support.])
enable_perl="no"
not_found="$not_found perl"
else
AC_MSG_ERROR([
*** Perl headers couldn't be found in your system.
*** Try to install it with your software package manager.])
fi
AC_MSG_RESULT(found)
AC_MSG_CHECKING(for Perl library)
PERL_LIB_TEST=`PT=perltest.c ; echo "int main() { return 0; }" > $PT ; $CC -Wall $PT -o $PT.out $($PERL -MExtUtils::Embed -e ldopts) 1>/dev/null 2>&1; echo $?; rm -f $PT $PT.out 1>/dev/null 2>&1`
if test "x$PERL_LIB_TEST" = "x0" ; then
PERL_LFLAGS=`$PERL -MExtUtils::Embed -e ldopts`
else
AC_MSG_ERROR([
AC_MSG_CHECKING(for Perl headers files)
PERL_HEADER_TEST=`PT=perltest.c ; echo "#include <EXTERN.h>" > $PT; echo "#include <perl.h>" >> $PT; echo "#include <XSUB.h>" >> $PT ; echo "int main() { return 0; }" >> $PT ; $CC -Wall $PT -o $PT.out $($PERL -MExtUtils::Embed -e ccopts) 1>/dev/null 2>&1; echo $?; rm -f $PT $PT.out 1>/dev/null 2>&1`
if test "x$PERL_HEADER_TEST" = "x0" ; then
PERL_CFLAGS=`$PERL -MExtUtils::Embed -e ccopts`
AC_MSG_RESULT(found)
AC_MSG_CHECKING(for Perl library)
PERL_LIB_TEST=`PT=perltest.c ; echo "int main() { return 0; }" > $PT ; $CC -Wall $PT -o $PT.out $($PERL -MExtUtils::Embed -e ldopts) 1>/dev/null 2>&1; echo $?; rm -f $PT $PT.out 1>/dev/null 2>&1`
if test "x$PERL_LIB_TEST" = "x0" ; then
PERL_LFLAGS=`$PERL -MExtUtils::Embed -e ldopts`
AC_MSG_RESULT(found)
else
AC_MSG_WARN([
*** Perl library couldn't be found in your system.
*** Try to install it with your software package manager.])
*** Try to install it with your software package manager.
*** WeeChat will be built without Perl support.])
enable_perl="no"
not_found="$not_found perl"
fi
else
AC_MSG_WARN([
*** Perl headers couldn't be found in your system.
*** Try to install it with your software package manager.
*** WeeChat will be built without Perl support.])
enable_perl="no"
not_found="$not_found perl"
fi
fi
AC_MSG_RESULT(found)
fi
if test "x$enable_perl" = "xyes" ; then
AC_SUBST(PERL_CFLAGS)
AC_SUBST(PERL_LFLAGS)
AC_DEFINE(PLUGIN_PERL)
fi
# --------------------------------- python -------------------------------------
if test "x$enable_python" = "xyes" ; then
enable_plugins="yes"
AC_PATH_PROGS(PYTHON, python python2.4 python2.3 python2.2)
if test -z $PYTHON ; then
AC_MSG_ERROR([
*** Python must be installed on your system
*** but python interpreter couldn't be found in path.
*** Please check that python is in path, or install
*** it with your software package manager.])
fi
PYTHON_SYSPREFIX=`$PYTHON -c 'import sys; print "%s" % sys.prefix'`
PYTHON_VERSION=`$PYTHON -c 'import sys ; print sys.version[[:3]]'`
PYTHON_INCLUDE=`$PYTHON -c "import distutils.sysconfig,string; print distutils.sysconfig.get_config_var('CONFINCLUDEPY')"`
AC_MSG_CHECKING(for Python header files)
if test -r "$PYTHON_INCLUDE/Python.h"; then
PYTHON_CFLAGS="-I$PYTHON_INCLUDE"
AC_MSG_WARN([
*** Python must be installed on your system but python interpreter couldn't be found in path.
*** Please check that python is in path, or install it with your software package manager.
*** WeeChat will be built without Python support.])
enable_python="no"
not_found="$not_found python"
else
AC_MSG_ERROR([
*** Python header files couldn't be found in your system.
*** Try to install them with your software package manager.])
fi
AC_MSG_RESULT(found)
PYTHON_LIB=`$PYTHON -c "import distutils.sysconfig; print distutils.sysconfig.get_config_var('LIBPL')"`
PYTHON_LFLAGS="-lpython$PYTHON_VERSION "`$PYTHON -c "import distutils.sysconfig; print distutils.sysconfig.get_config_var('LIBS')+' '+distutils.sysconfig.get_config_var('SYSLIBS')+' '+distutils.sysconfig.get_config_var('LINKFORSHARED')"`
AC_MSG_CHECKING(for Python library)
if test -r "$PYTHON_LIB/libpython$PYTHON_VERSION.so"; then
PYTHON_LFLAGS="-L$PYTHON_LIB $PYTHON_LFLAGS"
elif test -r "$PYTHON_LIB/libpython$PYTHON_VERSION.a"; then
PYTHON_LFLAGS="-L$PYTHON_LIB $PYTHON_LFLAGS"
elif test -r "$PYTHON_SYSPREFIX/lib/libpython$PYTHON_VERSION.so"; then
PYTHON_LFLAGS="-L$PYTHON_SYSPREFIX/lib/ $PYTHON_LFLAGS"
else
AC_MSG_ERROR([
PYTHON_SYSPREFIX=`$PYTHON -c 'import sys; print "%s" % sys.prefix'`
PYTHON_VERSION=`$PYTHON -c 'import sys ; print sys.version[[:3]]'`
PYTHON_INCLUDE=`$PYTHON -c "import distutils.sysconfig,string; print distutils.sysconfig.get_config_var('CONFINCLUDEPY')"`
AC_MSG_CHECKING(for Python header files)
if test -r "$PYTHON_INCLUDE/Python.h"; then
PYTHON_CFLAGS="-I$PYTHON_INCLUDE"
AC_MSG_RESULT(found)
PYTHON_LIB=`$PYTHON -c "import distutils.sysconfig; print distutils.sysconfig.get_config_var('LIBPL')"`
PYTHON_LFLAGS="-lpython$PYTHON_VERSION "`$PYTHON -c "import distutils.sysconfig; print distutils.sysconfig.get_config_var('LIBS')+' '+distutils.sysconfig.get_config_var('SYSLIBS')+' '+distutils.sysconfig.get_config_var('LINKFORSHARED')"`
AC_MSG_CHECKING(for Python library)
if test -r "$PYTHON_LIB/libpython$PYTHON_VERSION.so"; then
PYTHON_LFLAGS="-L$PYTHON_LIB $PYTHON_LFLAGS"
AC_MSG_RESULT(found)
elif test -r "$PYTHON_LIB/libpython$PYTHON_VERSION.a"; then
PYTHON_LFLAGS="-L$PYTHON_LIB $PYTHON_LFLAGS"
AC_MSG_RESULT(found)
elif test -r "$PYTHON_SYSPREFIX/lib/libpython$PYTHON_VERSION.so"; then
PYTHON_LFLAGS="-L$PYTHON_SYSPREFIX/lib/ $PYTHON_LFLAGS"
AC_MSG_RESULT(found)
else
AC_MSG_WARN([
*** Python library couldn't be found in your system.
*** Try to install it with your software package manager.])
*** Try to install it with your software package manager.
*** WeeChat will be built without Python support.])
enable_python="no"
not_found="$not_found python"
fi
else
AC_MSG_WARN([
*** Python header files couldn't be found in your system.
*** Try to install them with your software package manager.
*** WeeChat will be built without Python support.])
enable_python="no"
not_found="$not_found python"
fi
fi
AC_MSG_RESULT(found)
fi
if test "x$enable_python" = "xyes" ; then
AC_SUBST(PYTHON_CFLAGS)
AC_SUBST(PYTHON_LFLAGS)
AC_DEFINE(PLUGIN_PYTHON)
fi
# ---------------------------------- ruby --------------------------------------
if test "x$enable_ruby" = "xyes" ; then
enable_plugins="yes"
AC_PATH_PROGS(RUBY, ruby ruby1.8 ruby1.9)
if test -z $RUBY ; then
AC_MSG_ERROR([
*** Ruby must be installed on your system
*** but ruby interpreter couldn't be found in path.
*** Please check that ruby is in path, or install
*** it with your software package manager.])
fi
RUBY_INCLUDE=`$RUBY -rrbconfig -e "puts Config::CONFIG[['archdir']]"`
AC_MSG_CHECKING(for Ruby header files)
if test -r "$RUBY_INCLUDE/ruby.h"; then
RUBY_CFLAGS="-I$RUBY_INCLUDE"
AC_MSG_WARN([
*** Ruby must be installed on your system but ruby interpreter couldn't be found in path.
*** Please check that ruby is in path, or install it with your software package manager.
*** WeeChat will be built without Ruby support.])
enable_ruby="no"
not_found="$not_found ruby"
else
AC_MSG_ERROR([
RUBY_INCLUDE=`$RUBY -rrbconfig -e "puts Config::CONFIG[['archdir']]"`
AC_MSG_CHECKING(for Ruby header files)
if test -r "$RUBY_INCLUDE/ruby.h"; then
RUBY_CFLAGS="-I$RUBY_INCLUDE"
else
AC_MSG_WARN([
*** Ruby header files couldn't be found in your system.
*** Try to install them with your software package manager.])
*** Try to install them with your software package manager.
*** WeeChat will be built without Ruby support.])
enable_ruby="no"
not_found="$not_found ruby"
fi
AC_MSG_RESULT(found)
RUBY_LFLAGS=`$RUBY -rrbconfig -e "puts Config::CONFIG[['LIBRUBYARG_SHARED']]"`
fi
AC_MSG_RESULT(found)
RUBY_LFLAGS=`$RUBY -rrbconfig -e "puts Config::CONFIG[['LIBRUBYARG_SHARED']]"`
fi
if test "x$enable_ruby" = "xyes" ; then
AC_SUBST(RUBY_CFLAGS)
AC_SUBST(RUBY_LFLAGS)
AC_DEFINE(PLUGIN_RUBY)
fi
# ---------------------------------- lua --------------------------------------
if test "x$enable_lua" = "xyes" ; then
enable_plugins="yes"
ac_save_CPPFLAGS="$CPPFLAGS"
ac_save_CFLAGS="$CFLAGS"
ac_save_LDFLAGS="$LDFLAGS"
LUA_CFLAGS=""
LUA_LFLAGS=""
if test -n "$lua_inc"; then
CFLAGS="$CFLAGS -I$lua_inc"
CPPFLAGS="$CPPFLAGS -I$lua_inc"
fi
if test -n "$lua_lib"; then
LDFLAGS="$LDFLAGS -L$lua_lib"
fi
if test "x$LUA_CFLAGS" = "x" -o "x$LUA_LFLAGS" = "x" ; then
PKGCONFIG=""
AC_CHECK_PROGS(PKGCONFIG, pkg-config)
if test "x$PKGCONFIG" != "x"; then
AC_MSG_CHECKING(for Lua headers and librairies with pkg-config)
echo
for l in "$lua_suffix" "" "50" "5.0" "51" "5.1" ; do
pkgconfig_lua_found=`$PKGCONFIG --exists lua$l 2>/dev/null && $PKGCONFIG --exists lualib$l 2>/dev/null`
if test "x$?" = "x0" ; then
LUA_CFLAGS="$LUA_CFLAGS "`$PKGCONFIG --cflags lua$l`
LUA_CFLAGS="$LUA_CFLAGS "`$PKGCONFIG --cflags lualib$l`
LUA_LFLAGS="$LUA_LFLAGS "`$PKGCONFIG --libs lua$l`
LUA_LFLAGS="$LUA_LFLAGS "`$PKGCONFIG --libs lualib$l`
break
fi
done
fi
fi
if test "x$LUA_CFLAGS" = "x" -o "x$LUA_LFLAGS" = "x" ; then
LUACONFIG=""
AC_CHECK_PROGS(LUACONFIG, lua-config lua-config50 lua-config5.0 lua-config51 lua-config5.1)
if test "x$LUACONFIG" != "x" ; then
AC_MSG_CHECKING(for Lua headers and librairies with lua-config)
echo
LUA_CFLAGS=`$LUACONFIG --include`
LUA_LFLAGS=`$LUACONFIG --libs`
fi
fi
if test "x$LUA_CFLAGS" = "x" -o "x$LUA_LFLAGS" = "x" ; then
AC_MSG_CHECKING(for Lua headers and librairies)
echo
AC_CHECK_HEADER(lua.h,ac_found_lua_header="yes",ac_found_lua_header="no")
AC_CHECK_HEADER(lualib.h,ac_found_liblua_header="yes",ac_found_liblua_header="no")
if test "x$ac_found_lua_header" = "xyes" -a "x$ac_found_liblua_header" = "xyes"; then
LUA_CFLAGS="$CFLAGS"
fi
for l in "$lua_suffix" "" "50" "5.0" "51" "5.1" ; do
AC_CHECK_LIB(lua$l,lua_call,ac_found_lua_lib="yes",ac_found_lua_lib="no")
if test "x$ac_found_lua_lib" = "xyes" ; then
LUA_LFLAGS="$LDFLAGS -llua$l -lm"
ac2_save_LDFLAGS="$LDFLAGS"
LDFLAGS="$LDFLAGS -llua$l -lm"
if echo "$host_os" | grep "^linux" 1>/dev/null 2>&1 ; then
LDFLAGS="$LDFLAGS -ldl"
fi
AC_CHECK_LIB(lualib$l,luaL_openlib,ac_found_liblua_lib="yes",ac_found_liblua_lib="no")
if test "x$ac_found_liblua_lib" = "xyes" ; then
LUA_LFLAGS="$LUA_LFLAGS -llualib$l"
if echo "$host_os" | grep "^linux" 1>/dev/null 2>&1 ; then
LUA_LFLAGS="$LUA_LFLAGS -ldl"
fi
fi
LDFLAGS="$ac2_save_LDFLAGS"
break
fi
done
fi
AC_MSG_CHECKING(for Lua compiling and linking)
LUA_TEST=`LT=luatest.c ; echo "#include <lua.h>" > $LT; echo "#include <lualib.h>" >> $LT; echo "int main() { luaopen_base((lua_State *)lua_open()); return 0; }" >> $LT ; $CC -Wall $LT -o $LT.out $LUA_CFLAGS $LUA_LFLAGS $CFLAGS $LDFLAGS 1>/dev/null 2>&1 ; echo $?; rm -f $LT $LT.out 1>/dev/null 2>&1`
if test "x$LUA_TEST" != "x0" ; then
AC_MSG_RESULT(no)
AC_MSG_WARN([
*** Lua (>=5.0) headers and/or librairies couldn't be found in your system.
*** Try to install liblua, liblualib and liblua-dev with your software package manager.
*** WeeChat will be built without Lua support.])
enable_lua="no"
not_found="$not_found lua"
else
AC_MSG_RESULT(yes)
fi
CFLAGS="$ac_save_CFLAGS"
CPPFLAGS="$ac_save_CPPFLAGS"
LDFLAGS="$ac_save_LDFLAGS"
fi
if test "x$enable_lua" = "xyes" ; then
AC_SUBST(LUA_CFLAGS)
AC_SUBST(LUA_LFLAGS)
AC_DEFINE(PLUGIN_LUA)
fi
if test "x$enable_plugins" = "xyes" ; then
AC_CHECK_FUNCS(dlopen, LIBDL_FOUND=yes, LIBDL_FOUND=no)
if test "$LIBDL_FOUND" != "yes"; then
AC_CHECK_LIB(dl, dlopen, LIBDL_FOUND=yes, LIBDL_FOUND=no)
if test "$LIBDL_FOUND" = "yes"; then
PLUGINS_LIBS="-ldl"
else
AC_MSG_ERROR([
*** "dl" library (dynamic library loader) couldn't be found in your system.
*** Try to install it with your software package manager or disable plugins.])
fi
AC_CHECK_LIB(dl, dlopen, [LIBDL_FOUND=yes; PLUGINS_LIBS=-ldl], LIBDL_FOUND=no)
fi
if test "$LIBDL_FOUND" = "yes"; then
AC_DEFINE(PLUGINS)
AC_SUBST(PLUGINS_LIBS)
else
AC_MSG_WARN([
*** "dl" library (dynamic library loader) couldn't be found in your system.
*** Try to install it with your software package manager or disable plugins.
*** WeeChat will be built without any plugin.])
enable_plugins="no"
enable_perl="no"
enable_python="no"
enable_ruby="no"
enable_lua="no"
not_found="$not_found plugins"
fi
AC_DEFINE(PLUGINS)
fi
AC_SUBST(PLUGINS_LIBS)
# ------------------------------------------------------------------------------
# gnutls
# ------------------------------------------------------------------------------
@@ -327,17 +485,54 @@ AC_SUBST(PLUGINS_LIBS)
if test "x$enable_gnutls" = "xyes" ; then
found_gnutls="no"
AM_PATH_LIBGNUTLS( 1.0.0, found_gnutls=yes, AC_MSG_WARN([[
*** libgnutls was not found. You may want to get it from
*** ftp://ftp.gnutls.org/pub/gnutls/
*** libgnutls was not found. You may want to get it from ftp://ftp.gnutls.org/pub/gnutls/
*** WeeChat will be built without GnuTLS support.]]))
if test "x$found_gnutls" = "xyes" ; then
GNUTLS_CFLAGS=`libgnutls-config --cflags`
GNUTLS_LFLAGS=`libgnutls-config --libs`
AC_SUBST(GNUTLS_CFLAGS)
AC_SUBST(GNUTLS_LFLAGS)
AC_DEFINE(HAVE_GNUTLS)
GNUTLS_CFLAGS=`libgnutls-config --cflags`
GNUTLS_LFLAGS=`libgnutls-config --libs`
AC_SUBST(GNUTLS_CFLAGS)
AC_SUBST(GNUTLS_LFLAGS)
AC_DEFINE(HAVE_GNUTLS)
else
enable_gnutls="no"
not_found="$not_found gnutls"
fi
fi
# ------------------------------------------------------------------------------
# flock
# ------------------------------------------------------------------------------
enable_flock="no"
AC_CACHE_CHECK([for flock() support], ac_have_flock, [
AC_TRY_COMPILE(
[ #include <sys/file.h>
],
[ flock(0, LOCK_SH); ],
[ ac_have_flock="yes" ],
[ ac_have_flock="no" ])])
if test "x$ac_have_flock" = "xyes"; then
enable_flock="yes"
AC_DEFINE(HAVE_FLOCK)
fi
# ------------------------------------------------------------------------------
# backtrace
# ------------------------------------------------------------------------------
enable_backtrace="no"
if test "x$debug" != "x0" ; then
AC_CACHE_CHECK([for execinfo.h and backtrace], ac_have_backtrace, [
AC_TRY_COMPILE(
[ #include <execinfo.h>
],
[ void *trace[128]; int n = backtrace(trace, 128); ],
[ ac_have_backtrace="yes" ],
[ ac_have_backtrace="no" ])])
if test "x$ac_have_backtrace" = "xyes"; then
enable_backtrace="yes"
AC_DEFINE(HAVE_BACKTRACE,1,[glibc backtrace function])
fi
fi
@@ -381,7 +576,7 @@ fi
LIBS="$LIBS $INTLLIBS"
case "$host_os" in
freebsd* | netbsd*)
freebsd*)
if test "x$enable_perl" = "xyes" -o "x$enable_python" = "xyes" ; then
CFLAGS="$CFLAGS -pthread"
fi
@@ -392,6 +587,19 @@ openbsd*)
CFLAGS="$CFLAGS -pthread"
fi
;;
netbsd*)
if test "x$enable_perl" = "xyes" -o "x$enable_python" = "xyes" ; then
CFLAGS="$CFLAGS -pthread"
fi
CFLAGS="$CFLAGS $CPPFLAGS"
# bad hack
LDFLAGS="$LDFLAGS -liconv"
;;
gnu*)
if test "x$enable_plugins" = "xyes" ; then
LDFLAGS="$LDFLAGS -lpthread"
fi
;;
*)
;;
esac
@@ -400,10 +608,23 @@ esac
# output Makefiles
# ------------------------------------------------------------------------------
AM_CONDITIONAL(GUI_NCURSES, test "$enable_ncurses" = "yes")
AM_CONDITIONAL(GUI_WXWIDGETS, test "$enable_wxwidgets" = "yes")
AM_CONDITIONAL(GUI_GTK, test "$enable_gtk" = "yes")
AM_CONDITIONAL(GUI_QT, test "$enable_qt" = "yes")
AM_CONDITIONAL(PLUGINS, test "$enable_plugins" = "yes")
AM_CONDITIONAL(PLUGIN_PERL, test "$enable_perl" = "yes")
AM_CONDITIONAL(PLUGIN_PYTHON, test "$enable_python" = "yes")
AM_CONDITIONAL(PLUGIN_RUBY, test "$enable_ruby" = "yes")
AM_CONDITIONAL(PLUGIN_LUA, test "$enable_lua" = "yes")
AM_CONDITIONAL(HAVE_GNUTLS, test "$enable_gnutls" = "yes")
AM_CONDITIONAL(HAVE_FLOCK, test "$enable_flock" = "yes")
AC_OUTPUT([Makefile
doc/Makefile
doc/fr/Makefile
doc/en/Makefile
doc/fr/Makefile
doc/de/Makefile
src/Makefile
src/common/Makefile
src/irc/Makefile
@@ -412,6 +633,7 @@ AC_OUTPUT([Makefile
src/plugins/scripts/perl/Makefile
src/plugins/scripts/python/Makefile
src/plugins/scripts/ruby/Makefile
src/plugins/scripts/lua/Makefile
src/gui/Makefile
src/gui/curses/Makefile
src/gui/wxwidgets/Makefile
@@ -424,7 +646,7 @@ AC_OUTPUT([Makefile
# end message
# ------------------------------------------------------------------------------
listgui=
listgui=""
if test "x$enable_ncurses" = "xyes" ; then
listgui="$listgui ncurses"
fi
@@ -432,7 +654,7 @@ if test "x$enable_wxwidgets" = "xyes"; then
listgui="$listgui WxWidgets"
fi
if test "x$enable_gtk" = "xyes" ; then
listgui="$listgui Gtk+"
listgui="$listgui Gtk"
fi
if test "x$enable_qt" = "xyes" ; then
listgui="$listgui Qt"
@@ -441,7 +663,13 @@ fi
if test "x$listgui" = "x" ; then
AC_MSG_ERROR([
*** No interface specified...
*** Please specify at least ncurses, WxWidgets, Gtk or Qt.])
*** Please enable at least ncurses, WxWidgets, Gtk or Qt.])
fi
if test "x$not_found" != "x" ; then
echo ""
echo "Following components were asked but not found, they will not be built:"
echo "$not_found"
fi
msg_debug_compiler="no"
@@ -454,14 +682,17 @@ if test "x$debug" = "x2" ; then
fi
echo ""
echo "Interfaces.................................... :$listgui"
echo "Build with GNUtls support..................... : $enable_gnutls"
echo "Build with Plugin support..................... : $enable_plugins"
echo " Perl plugin..................... : $enable_perl"
echo " Python plugin................... : $enable_python"
echo " Ruby plugin..................... : $enable_ruby"
echo "Compile with debug info....................... : $msg_debug_compiler"
echo "Print debugging messages...................... : $msg_debug_verbose"
echo "Interfaces........................ :$listgui"
echo "Build with GNUtls support......... : $enable_gnutls"
echo "Build with flock support.......... : $enable_flock"
echo "Build with Plugin support......... : $enable_plugins"
echo " Perl plugin......... : $enable_perl"
echo " Python plugin....... : $enable_python"
echo " Ruby plugin......... : $enable_ruby"
echo " Lua plugin.......... : $enable_lua"
echo "Compile with debug info........... : $msg_debug_compiler"
echo " Backtrace........... : $enable_backtrace"
echo "Print debugging messages.......... : $msg_debug_verbose"
echo ""
eval echo "WeeChat will be installed in $bindir."
echo ""
+29
View File
@@ -1,3 +1,32 @@
weechat (0.1.8-2) unstable; urgency=low
* Switch to cdbs
* update debhelper compatibility to 5
* update Build-Depends
* update debian/copyright
* Bump Standards-Version, no changes needed
-- Julien Louis <ptitlouis@sysif.net> Fri, 21 Apr 2006 22:39:00 +0200
weechat (0.1.8-1) unstable; urgency=low
* New upstream release
* Add liblualib50-dev and docbook-xml to Build-Depends
-- Julien Louis <ptitlouis@sysif.net> Sat, 18 Mar 2006 11:32:52 +0100
weechat (0.1.7-2) unstable; urgency=low
* force linking against libpthread on GNU/Hurd (Closes: #350487)
-- Julien Louis <ptitlouis@sysif.net> Sun, 5 Feb 2006 18:23:24 +0100
weechat (0.1.7-1) unstable; urgency=low
* New upstream release
-- Julien Louis <ptitlouis@sysif.net> Sat, 14 Jan 2006 14:14:29 +0100
weechat (0.1.6-2) unstable; urgency=low
* Apply path to fix segfault when removing server.
+1 -1
View File
@@ -1 +1 @@
4
5
+2 -2
View File
@@ -3,8 +3,8 @@ Section: net
Priority: optional
Maintainer: Sebastien Helleu <flashcode@flashtux.org>
Uploaders: Julien Louis <ptitlouis@sysif.net>
Build-Depends: debhelper (>> 4.0.0), libncursesw5-dev (>= 5.2.20020112a-7), ruby1.8-dev, libperl-dev, python-dev, libgnutls-dev, libtool, texinfo
Standards-Version: 3.6.2
Build-Depends: cdbs, debhelper (>= 5), libncursesw5-dev, ruby, ruby1.8-dev, libperl-dev, python-dev, liblualib50-dev, libgnutls-dev, libtool, xsltproc, docbook-xsl, docbook-xml
Standards-Version: 3.7.2
Package: weechat
Architecture: all
+3 -1
View File
@@ -3,7 +3,9 @@ Sat, 21 May 2005 08:00:00 +0200.
It was downloaded from http://weechat.flashtux.org/download
Upstream Author: FlashCode <flashcode@flashtux.org>
Upstream Authors:
- FlashCode <flashcode@flashtux.org>
- kolter <kolter@free.fr>
Copyright:
+22 -73
View File
@@ -1,85 +1,34 @@
#!/usr/bin/make -f
# Sample debian/rules that uses cdbs. Originaly written by Robert Millan.
# This file is public domain.
#export DH_VERBOSE=1
DEB_AUTO_CLEANUP_RCS := yes
# Add here any variable or target overrides you need
DEB_CONFIGURE_USER_FLAGS := --with-debug=0
DEB_STRIP_EXCLUDE := libperl.a
DEB_DH_INSTALL_SOURCEDIR := $(CURDIR)/debian/tmp
DEB_INSTALL_DOCS_weechat-common := FAQ FAQ.fr
DEB_DH_MAKESHLIBS_ARGS_weechat-plugins := -n
DEB_HOST_ARCH_OS := $(shell dpkg-architecture -qDEB_HOST_ARCH_OS)
ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
CFLAGS += -O0
CFLAGS += -O0
else
CFLAGS += -O2
CFLAGS += -O2
endif
ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
INSTALL_PROGRAM += -s
INSTALL_PROGRAM += -s
endif
configure: configure-stamp
configure-stamp:
dh_testdir
./configure --prefix=/usr --sysconfdir=/etc --mandir=\$${prefix}/share/man \
--infodir=\$${prefix}/share/info --enable-perl --enable-python --enable-ruby \
--with-debug=0
touch configure-stamp
ifeq ($(DEB_HOST_ARCH_OS),hurd)
DEB_CONFIGURE_SCRIPT_ENV += LDFLAGS="-lpthread"
endif
include /usr/share/cdbs/1/class/autotools.mk
include /usr/share/cdbs/1/rules/debhelper.mk
build: build-stamp
build-stamp: configure-stamp
dh_testdir
$(MAKE)
touch build-stamp
clean:
dh_testdir
dh_testroot
rm -f build-stamp configure-stamp
-$(MAKE) distclean
dh_clean
install: build
dh_testdir
dh_testroot
dh_clean -k
dh_installdirs
$(MAKE) install DESTDIR=$(CURDIR)/debian/tmp
dh_install
# install -o root -g root -m 755 src/gui/curses/weechat-curses $(CURDIR)/debian/weechat-curses/usr/bin
# install -o root -g root -m 755 src/gui/gtk/weechat-gtk $(CURDIR)/debian/weechat-gtk/usr/bin
install/weechat-common::
install -D -o root -g root -m 644 weechat_icon_32.png $(CURDIR)/debian/weechat-common/usr/share/pixmaps/weechat_icon_32.png
# Build architecture-independent files here.
binary-indep: build install
dh_testdir -pweechat-common -pweechat
dh_testroot -pweechat-common -pweechat
dh_installchangelogs ChangeLog -pweechat-common
dh_installdocs -pweechat-common
dh_installinfo -pweechat-common
dh_installexamples -pweechat-common
dh_compress -pweechat-common -pweechat
dh_link -pweechat usr/share/doc/weechat-common usr/share/doc/weechat
dh_fixperms -pweechat-common -pweechat
dh_installdeb -pweechat-common -pweechat
dh_shlibdeps -pweechat-common -pweechat
dh_gencontrol -pweechat-common -pweechat
dh_md5sums -pweechat-common -pweechat
dh_builddeb -pweechat-common -pweechat
# Build architecture-dependent files here.
binary-arch: build install
dh_testdir -a -pweechat-curses -pweechat-plugins
dh_testroot -a -pweechat-curses -pweechat-plugins
dh_installchangelogs ChangeLog -pweechat-plugins
dh_installdocs -pweechat-plugins
dh_installman doc/weechat-curses.1 -pweechat-curses
dh_link -pweechat-curses usr/share/doc/weechat-common usr/share/doc/weechat-curses
dh_installmenu -pweechat-curses
dh_strip -a -pweechat-curses -pweechat-plugins --exclude=libperl.a
dh_compress -a -pweechat-curses -p weechat-plugins
dh_fixperms -a -pweechat-curses -pweechat-plugins
dh_installdeb -a -pweechat-curses -pweechat-plugins
dh_shlibdeps -a -pweechat-curses -pweechat-plugins
dh_gencontrol -a -pweechat-curses -pweechat-plugins
dh_md5sums -a -pweechat-curses -pweechat-plugins
dh_builddeb -a -pweechat-curses -pweechat-plugins
binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install configure
+2 -1
View File
@@ -1 +1,2 @@
debian/tmp/usr/share/locale/
usr/share/locale/
usr/share/doc/weechat/html usr/share/doc/weechat-common
+1 -1
View File
@@ -1 +1 @@
debian/tmp/usr/bin/weechat-curses
usr/bin/weechat-curses
-1
View File
@@ -1 +0,0 @@
usr/share/doc/weechat-common usr/share/doc/weechat-curses
+1 -1
View File
@@ -1 +1 @@
debian/tmp/usr/lib
usr/lib/weechat/plugins/*so*
+1 -1
View File
@@ -15,7 +15,7 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
SUBDIRS = fr en
SUBDIRS = en fr de
man_MANS = weechat-curses.1
+29 -9
View File
@@ -22,21 +22,29 @@
# with weechat-curses command
#
@all_lang = ("fr_FR", "en_US");
@all_lang = ("fr_FR", "en_US", "de_DE");
%all_encodings = ("fr_FR" => "iso-8859-1",
"en_US" => "iso-8859-1");
"en_US" => "iso-8859-1",
"de_DE" => "iso-8859-1");
%all_types = ("fr_FR" => "type",
"en_US" => "type",
"de_DE" => "Typ",
"es_ES" => "tipo");
%all_values = ("fr_FR" => "valeurs",
"en_US" => "values",
"de_DE" => "Werte",
"es_ES" => "valores");
%all_default = ("fr_FR" => "valeur par défaut",
"en_US" => "default values",
"en_US" => "default value",
"de_DE" => "Standardwert",
"es_ES" => "valor por defecto");
%all_desc = ("fr_FR" => "description",
"en_US" => "description",
"de_DE" => "Beschreibung",
"es_ES" => "descripciĂłn");
$warning_do_not_edit = "\n<!-- ********* WARNING! *********\n\n"
." This file is automatically built with a Perl script. DO NOT EDIT!\n"
."-->\n\n";
foreach $lng (@all_lang)
{
@@ -51,6 +59,15 @@ foreach $lng (@all_lang)
print "\n";
}
sub toxml
{
$_ = $_[0];
$_ =~ s/&/&amp;/g;
$_ =~ s/</&lt;/g;
$_ =~ s/>/&gt;/g;
return $_;
}
sub create_commands
{
$lang = $_[0];
@@ -61,6 +78,7 @@ sub create_commands
print "Creating $lang2/$file.xml ($lang)...\n";
open XML, ">$lang2/$file.xml" or die "Error: can't write file!";
print XML "<?xml version=\"1.0\" encoding=\"$encoding\"?>\n";
print XML $warning_do_not_edit;
$started = 0;
$ENV{"LANG"} = $lang;
@@ -70,13 +88,13 @@ sub create_commands
{
print XML "</programlisting>\n" if ($started == 1);
$started = 1;
print XML "<command>$1</command>\n";
print XML "<command>".toxml($1)."</command>\n";
print XML "<programlisting>";
}
else
{
chomp ($_);
print XML "$_\n";
print XML toxml($_)."\n";
}
}
print XML "</programlisting>\n";
@@ -94,6 +112,7 @@ sub create_key_func
print "Creating $lang2/$file.xml ($lang)...\n";
open XML, ">$lang2/$file.xml" or die "Error: can't write file!";
print XML "<?xml version=\"1.0\" encoding=\"$encoding\"?>\n";
print XML $warning_do_not_edit;
$ENV{"LANG"} = $lang;
foreach (`$command`)
@@ -120,6 +139,7 @@ sub create_config
print "Creating $lang2/$file.xml ($lang)...\n";
open XML, ">$lang2/$file.xml" or die "Error: can't write file!";
print XML "<?xml version=\"1.0\" encoding=\"$encoding\"?>\n";
print XML $warning_do_not_edit;
$type = "";
$values = "";
$default = "";
@@ -150,10 +170,10 @@ sub create_config
$_ = $1;
s/(.*)/\u$1/;
$desc = $_;
print XML " <entry>".$type."</entry>\n";
print XML " <entry>".$values."</entry>\n";
print XML " <entry>".$default."</entry>\n";
print XML " <entry>".$desc."</entry>\n";
print XML " <entry>".toxml($type)."</entry>\n";
print XML " <entry>".toxml($values)."</entry>\n";
print XML " <entry>".toxml($default)."</entry>\n";
print XML " <entry>".toxml($desc)."</entry>\n";
print XML "</row>\n";
}
}
+61
View File
@@ -0,0 +1,61 @@
# Copyright (c) 2003-2006 FlashCode <flashcode@flashtux.org>
#
# 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 St, Fifth Floor, Boston, MA 02110-1301 USA
#
LANGCODE = de
BOOK = weechat.$(LANGCODE)
BOOK_INCLUDE = weechat_commands.xml irc_commands.xml key_functions.xml config.xml
EXTRA_DIST = $(BOOK).xml $(BOOK_INCLUDE)
docdir = $(datadir)/doc/$(PACKAGE)
all-local: html-stamp
# HTML output with chunks (many pages)
html: html-stamp
html-stamp: $(BOOK).xml $(BOOK_INCLUDE) ../weechat-html.xsl ../weechat-doc.css
echo "<pubdate>`date -R`</pubdate>" >date.xml
mkdir -p html/
xsltproc -o html/ ../weechat-html.xsl $(BOOK).xml || true
cp ../weechat-doc.css html/
touch html-stamp
# HTML output, all in one page
html1: html1-stamp
html1-stamp: $(BOOK).xml $(BOOK_INCLUDE) ../weechat-html-one.xsl ../weechat-doc.css
echo "<pubdate>`date -R`</pubdate>" >date.xml
mkdir -p html1/
xsltproc -o html1/$(BOOK).html ../weechat-html-one.xsl $(BOOK).xml || true
cp ../weechat-doc.css html1/
touch html1-stamp
# install docs
install-data-hook:
$(mkinstalldirs) $(DESTDIR)$(docdir)/html/$(LANGCODE)/
$(INSTALL_DATA) html/* $(DESTDIR)$(docdir)/html/$(LANGCODE)/
# clean
clean-local:
-rm -f *.html *.pdf *.txt date.xml
-rm -rf html/ html1/
-rm -f html-stamp html1-stamp
+1246
View File
File diff suppressed because it is too large Load Diff
+443
View File
@@ -0,0 +1,443 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- ********* WARNING! *********
This file is automatically built with a Perl script. DO NOT EDIT!
-->
<command>admin [Ziel]</command>
<programlisting>
Information ĂĽber den Server-Administrator abfragen
Ziel: Server
</programlisting>
<command>ame Nachricht</command>
<programlisting>
Nachricht an alle Channels aller verbundenen Server schicken
zu sendende Nachricht
</programlisting>
<command>amsg Text</command>
<programlisting>
Nachricht an alle Channels aller verbundener Server schicken
Text: zu sendender Text
</programlisting>
<command>away [-all] [Nachricht]</command>
<programlisting>
Abwesenheitsnachricht ein/ausschalten
-all: Abwesenheitszustand auf allen Servern ändern
Nachricht: Abwesenheitsnachricht (bzw. keine, um den Abwesenheitszustand zu deaktivieren)
</programlisting>
<command>ban [Channel] [Nickname [Nickname ...]]</command>
<programlisting>
Nicknames oder Hosts sperren/verbannen
Channel: Channel fĂĽr die Sperre
Nickname: zu sperrender User oder Host
</programlisting>
<command>ctcp Nickname Typ [Argumente]</command>
<programlisting>
CTCP-Nachricht verschicken
Nickname: User, an den die CTCP-Nachricht geschickt werden soll
Typ: Typ der CTCP-Nachricht (z.B. "version", "ping", ...)
Argumente: Argumente fĂĽr CTCP
</programlisting>
<command>cycle [Channel[,Channel]] [Abschiedsnachricht]</command>
<programlisting>
einen Channel verlassen und wieder betreten
Channel: zu verlassender Channel
Abschiedsnachricht: Abschiedsnachricht (die den anderen Usern angezeigt wird)
</programlisting>
<command>dehalfop Nickname [Nickname]</command>
<programlisting>
Halb-Operatorstatus aberkennen
</programlisting>
<command>deop Nickname [Nickname]</command>
<programlisting>
Operatorstatus aberkennen
</programlisting>
<command>devoice Nickname [Nickname]</command>
<programlisting>
Voice wegnehmen
</programlisting>
<command>die</command>
<programlisting>
Server herunterfahren
</programlisting>
<command>halfop Nickname [Nickname]</command>
<programlisting>
Halb-Operatorstatus verleihen
</programlisting>
<command>info [Ziel]</command>
<programlisting>
Information ĂĽber den Server abfragen
Ziel: Servername
</programlisting>
<command>invite Nickname Channel</command>
<programlisting>
jemanden in einen Channel einladen
Nickname: Chatname des Einzuladenden
Channel: Channel, in den er eingeladen werden soll
</programlisting>
<command>ison Nickname [Nickname ...]</command>
<programlisting>
ĂĽberprĂĽfen, ob jemand zur Zeit im IRC ist
Nickname: Nickname
</programlisting>
<command>join Channel[,Channel] [Passwort[,Passwort]]</command>
<programlisting>
einen Channel betreten
Channel: zu betretender Channel
Passwort: Channelpasswort (+k-Mode)
</programlisting>
<command>kick [Channel] Nickname [Kommentar]</command>
<programlisting>
einen User aus einem Channel herauskicken
Channel: Channel des Benutzers
Nickname: Nickname des Benutzers
Kommentar: BegrĂĽndung fĂĽr den Kick
</programlisting>
<command>kickban [Channel] Nickname [Kommentar]</command>
<programlisting>
kickt und verbannt jemanden von einem Channel
Channel: Channel des Benutzers
Nickname: Nickname des Benutzers
Kommentar: BegrĂĽndung fĂĽr den Kickban
</programlisting>
<command>kill Nickname Kommentar</command>
<programlisting>
Jemanden vom Server werfen
Nickname: Chatname
Kommentar: BegrĂĽndung
</programlisting>
<command>links [[Server] Servermaske]</command>
<programlisting>
Alle dem antwortenden Server bekannten Servernamen auflisten
Server: dieser Server soll die Anfrage beantworten
Servermaske: die aufzulistenden Server sollen diesem Muster entsprechen
</programlisting>
<command>list [Channel[,Channel] [Server]]</command>
<programlisting>
Channels mit ihren Topics auflisten
Channel: aufzulistender Channel (reguläre Ausdrücke sind möglich)
Server: Servername
</programlisting>
<command>lusers [Maske [Ziel]]</command>
<programlisting>
Statistik über die Größe dieses IRC-Netzwerks abfragen
Maske: Nur Server, die diesem Muster entsprechen
Ziel: Server, der die Anfrage weiterleiten soll
</programlisting>
<command>me Nachricht</command>
<programlisting>
eine CTCP ACTION an den aktuellen Channel senden
zu sendende Nachricht
</programlisting>
<command>mode { Channel {[+|-]|o|p|s|i|t|n|b|v} [Limit] [User] [Bannmaske] } | {Nickname {[+|-]|i|w|s|o} }</command>
<programlisting>
Channel- oder Usermode ändern
Channelmodi:
Channel: zu ändernder Channel
o: gib/nimm Operatorstatus
p: privater Channel
s: geheimer Channel
i: geschlossener Channel (Zutritt nur mit Einladung)
t: nur Operatoren dĂĽrfen das Topic setzen
n: keine Channelnachrichten von auĂźerhalb des Channels
m: moderierter Channel (schreiben nur mit Voice)
l: maximale Anzahl an Usern im Channel festlegen
b: Bannmaske fĂĽr zu sperrende User (in nick!ident@host-Form)
e: lege Ausnahmemaske fest
v: gib/nimm Voice (d.h. Schreibrecht bei moderierten Channels)
k: Channelkey/Channelpasswort festlegen
Usermodi:
Nickname: zu ändernder Nickname
i: User als unsichtbar kennzeichnen
s: User empfängt Server-Nachrichten
w: User empfängt WALLOPS
o: User ist Channeloperator
</programlisting>
<command>motd [Ziel]</command>
<programlisting>
die "Nachricht von heute" abfragen
Ziel: Servername
</programlisting>
<command>msg Empfänger[,Empfänger] Text</command>
<programlisting>
Nachricht an Nick/Channel verschicken
Empfänger: Nick/Channel (darf eine Maske sein, '*' = aktueller Channel)
Text: zu sendender Text
</programlisting>
<command>names [Channel[,Channel]]</command>
<programlisting>
Nicknames in Channels auflisten
Channel: Channelname
</programlisting>
<command>nick [-all] Nickname</command>
<programlisting>
aktuellen Nickname wechseln
-all: Nickname auf allen verbundenen Servern ändern
Nickname: neuer Nickname
</programlisting>
<command>notice Nickname Text</command>
<programlisting>
NOTICE an einen User verschicken
Nickname: Empfänger der Nachricht
Text: zu sendender Text
</programlisting>
<command>op Nickname [Nickname]</command>
<programlisting>
Channeloperatorstatus verleihen
</programlisting>
<command>oper Benutzername Passwort</command>
<programlisting>
Serveroperatorprivilegien anfordern
Benutzername/Passwort: Account im IRC-Server
</programlisting>
<command>part [Channel[,Channel]] [Abschiedsnachricht]</command>
<programlisting>
einen Channel verlassen
Channel: zu verlassender Channel
Abschiedsnachricht: Abschiedsnachricht, die den anderen Usern angezeigt wird
</programlisting>
<command>ping Server1 [Server2]</command>
<programlisting>
Server anpingen
Server1: Anzupingender Server
Server2: Ping an diesen Server weiterleiten
</programlisting>
<command>pong Daemon [Daemon2]</command>
<programlisting>
auf Ping antworten
Daemon: Daemon, der auf die Ping-Nachricht geantwortet hat
Daemon2: Nachricht an diesen Daemon weiterleiten
</programlisting>
<command>query Nickname [Text]</command>
<programlisting>
private Nachricht an jemanden schicken
Nickname: Nickname fĂĽr privaten Chat
Text: zu sendender Text
</programlisting>
<command>quit [Abschiedsnachricht]</command>
<programlisting>
alle Verbindungen trennen und Programm beenden
Abschiednachricht: anderen Usern zu zeigende Nachricht
</programlisting>
<command>quote Daten</command>
<programlisting>
Daten direkt an Server senden (siehe RFC 2812)
Daten: zu sendende Rohdaten
</programlisting>
<command>rehash</command>
<programlisting>
den Server dazu bringen, seine Konfigurationsdatei neu zu laden
</programlisting>
<command>restart</command>
<programlisting>
den Server dazu bringen, sich selbst neu zu starten
</programlisting>
<command>service Nickname reserviert Distribution Typ reserviert Info</command>
<programlisting>
einen neuen Service eintragen
Distribution: Sichtbarkeit des Services
Typ: für spätere Verwendung reserviert
</programlisting>
<command>servlist [Maske [Typ]]</command>
<programlisting>
zur Zeit verbundene Services auflisten
Maske: nur zutreffende Services auflisten
Typ: nur Services von diesem Typ auflisten
</programlisting>
<command>squery Service Text</command>
<programlisting>
Nachricht an einen Service senden
Service: Name des Service
Text: zu sendender Text
</programlisting>
<command>squit Server Kommentar</command>
<programlisting>
Serververbindungen trennen
Server: Servername
Kommentar: Trennungsgrund
</programlisting>
<command>stats [Anfrage [Server]]</command>
<programlisting>
Serverstatistik abfragen
Anfrage: c/h/i/k/l/m/o/y/u (siehe RFC1459)
Server: zu befragender Server
</programlisting>
<command>summon User [Ziel [Channel]]</command>
<programlisting>
Nutzer, die auf dem IRC-Server arbeiten, darum bitten, auf den IRC-Server zu kommen
User: Benutzername
Ziel: Servername
Channel: Channelname
</programlisting>
<command>time [Ziel]</command>
<programlisting>
Ortszeit des Servers abfragen
Ziel: der zu fragende Server
</programlisting>
<command>topic [Channel] [Topic]</command>
<programlisting>
Channeltopic abfragen/setzen
Channel: Channelname
Topic: neues Topic (oder "-delete" zum Entfernen des Topics)
</programlisting>
<command>trace [Ziel]</command>
<programlisting>
Route zum angegebenen Server ermitteln
Ziel: Server
</programlisting>
<command>unban [Channel] nickname [nickname ...]</command>
<programlisting>
Bann aufheben
Channel: Channel, in dem der Bann aufzuheben ist
Nickname: User, fĂĽr den der Bann aufzuheben ist
</programlisting>
<command>userhost Nickname [Nickname ...]</command>
<programlisting>
liste von Nickname-Informationen ermitteln
Nickname: Nickname
</programlisting>
<command>users [Ziel]</command>
<programlisting>
auf dem Server eingeloggte User auflisten
Ziel: Server
</programlisting>
<command>version [Server | Nickname]</command>
<programlisting>
Versionsinformationen von Nickname oder Server ermitteln
Server: Servername
Nickname: Nickname
</programlisting>
<command>voice Nickname [Nickname]</command>
<programlisting>
Voice vergeben
</programlisting>
<command>wallops Text</command>
<programlisting>
Nachricht an alle User schicken, die den 'w'-Mode gesetzt haben
zu sendender Text
</programlisting>
<command>who [Maske ["o"]]</command>
<programlisting>
erweiterte Nicknameliste
Maske: nur Information ĂĽber betreffende Nicknames abfragen
o: nur Operatoren ausgeben, die dem Filter entsprechen
</programlisting>
<command>whois [Server] Nickname[,Nickname]</command>
<programlisting>
Information ĂĽber User abfragen
Server: Servername
Nickname: Nickname (oder eine Maske)
</programlisting>
<command>whowas Nickname [,Nickname [,Nickname ...]] [Anzahl [Ziel]]</command>
<programlisting>
Information ĂĽber die Vergangenheit eines Nicknames erfragen
Nickname: abzufragende Nicknames
Anzahl: maximale Anzahl an Antworten (negative Zahl für eine vollständige Liste)
Ziel: zu suchende Hostmaske
</programlisting>
+191
View File
@@ -0,0 +1,191 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- ********* WARNING! *********
This file is automatically built with a Perl script. DO NOT EDIT!
-->
<row>
<entry><literal>return</literal></entry>
<entry>Zeile terminieren</entry>
</row>
<row>
<entry><literal>tab</literal></entry>
<entry>Wort vervollständigen</entry>
</row>
<row>
<entry><literal>tab_previous</literal></entry>
<entry>finde letzte Wortvervollständigung</entry>
</row>
<row>
<entry><literal>backspace</literal></entry>
<entry>vorheriges Zeichen löschen</entry>
</row>
<row>
<entry><literal>delete</literal></entry>
<entry>nächstes Zeichen löschen</entry>
</row>
<row>
<entry><literal>delete_end_line</literal></entry>
<entry>bis zum Zeilenende löschen</entry>
</row>
<row>
<entry><literal>delete_beginning_line</literal></entry>
<entry>bis zum Zeilenanfang löschen</entry>
</row>
<row>
<entry><literal>delete_line</literal></entry>
<entry>ganze Zeile löschen</entry>
</row>
<row>
<entry><literal>delete_previous_word</literal></entry>
<entry>vorheriges Wort löschen</entry>
</row>
<row>
<entry><literal>delete_next_word</literal></entry>
<entry>nächstes Wort löschen</entry>
</row>
<row>
<entry><literal>clipboard_paste</literal></entry>
<entry>einfĂĽgen</entry>
</row>
<row>
<entry><literal>transpose_chars</literal></entry>
<entry>Zeichen vertauschen</entry>
</row>
<row>
<entry><literal>home</literal></entry>
<entry>zum Zeilenanfang gehen</entry>
</row>
<row>
<entry><literal>end</literal></entry>
<entry>zum Zeilenende gehen</entry>
</row>
<row>
<entry><literal>left</literal></entry>
<entry>ein Zeichen nach links gehen</entry>
</row>
<row>
<entry><literal>previous_word</literal></entry>
<entry>ein Wort nach links gehen</entry>
</row>
<row>
<entry><literal>right</literal></entry>
<entry>ein Zeichen nach rechts gehen</entry>
</row>
<row>
<entry><literal>next_word</literal></entry>
<entry>ein Wort nach rechts gehen</entry>
</row>
<row>
<entry><literal>up</literal></entry>
<entry>vorherigen Befehl aus dem Verlauf abfragen</entry>
</row>
<row>
<entry><literal>up_global</literal></entry>
<entry>vorherigen Befehl aus dem globalen Verlauf abfragen</entry>
</row>
<row>
<entry><literal>down</literal></entry>
<entry>nächsten Befehl aus dem Verlauf abfragen</entry>
</row>
<row>
<entry><literal>down_global</literal></entry>
<entry>nächsten Befehl aus dem globalen Verlauf abfragen</entry>
</row>
<row>
<entry><literal>page_up</literal></entry>
<entry>eine Seite hochscrollen</entry>
</row>
<row>
<entry><literal>page_down</literal></entry>
<entry>eine Seite herunterscrollen</entry>
</row>
<row>
<entry><literal>scroll_up</literal></entry>
<entry>einige Zeilen hochscrollen</entry>
</row>
<row>
<entry><literal>scroll_down</literal></entry>
<entry>einige Zeilen herunterscrollen</entry>
</row>
<row>
<entry><literal>scroll_top</literal></entry>
<entry>nach ganz oben scrollen</entry>
</row>
<row>
<entry><literal>scroll_bottom</literal></entry>
<entry>nach ganz unten scrollen</entry>
</row>
<row>
<entry><literal>nick_beginning</literal></entry>
<entry>zum Anfang der Nicklist gehen</entry>
</row>
<row>
<entry><literal>nick_end</literal></entry>
<entry>zum Ende der Nicklist gehen</entry>
</row>
<row>
<entry><literal>nick_page_up</literal></entry>
<entry>Nickliste eine Seite hochscrollen</entry>
</row>
<row>
<entry><literal>nick_page_down</literal></entry>
<entry>Nickliste eine Seite herunterscrollen</entry>
</row>
<row>
<entry><literal>jump_smart</literal></entry>
<entry>zu nächstem aktiven Puffer springen</entry>
</row>
<row>
<entry><literal>jump_dcc</literal></entry>
<entry>zum DCC-Puffer springen</entry>
</row>
<row>
<entry><literal>jump_raw_data</literal></entry>
<entry>gehe zum IRC-Rohdaten-Puffer</entry>
</row>
<row>
<entry><literal>jump_last_buffer</literal></entry>
<entry>zum letzten Puffer springen</entry>
</row>
<row>
<entry><literal>jump_server</literal></entry>
<entry>zum Serverpuffer springen</entry>
</row>
<row>
<entry><literal>jump_next_server</literal></entry>
<entry>zum nächsten Server springen</entry>
</row>
<row>
<entry><literal>switch_server</literal></entry>
<entry>wechsel den aktiven Server im Server-Puffer</entry>
</row>
<row>
<entry><literal>scroll_previous_highlight</literal></entry>
<entry>scrolle zur vorherigen hervorhebung im Puffer</entry>
</row>
<row>
<entry><literal>scroll_next_highlight</literal></entry>
<entry>scrolle zur nächsten Hervorhebung im Puffer</entry>
</row>
<row>
<entry><literal>scroll_unread</literal></entry>
<entry>scrolle zur ersten, ungelesenen Zeile im Puffer</entry>
</row>
<row>
<entry><literal>hotlist_clear</literal></entry>
<entry>Hotlist leeren</entry>
</row>
<row>
<entry><literal>infobar_clear</literal></entry>
<entry>Infobar leeren</entry>
</row>
<row>
<entry><literal>refresh</literal></entry>
<entry>Bild neu aufbauen</entry>
</row>
<row>
<entry><literal>grab_key</literal></entry>
<entry>Tastencode ermitteln und einfĂĽgen</entry>
</row>
File diff suppressed because it is too large Load Diff
+235
View File
@@ -0,0 +1,235 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- ********* WARNING! *********
This file is automatically built with a Perl script. DO NOT EDIT!
-->
<command>alias [Aliasname [Befehl [Argumente]]]</command>
<programlisting>
einen Alias fĂĽr einen Befehl anlegen
Aliasname: Name des Alias
Befehl: Befehlsname (WeeChat- oder IRC-Befehl ohne führenden '/', mehrere Befehle können durch Semikola getrennt werden)
Argumente: Argumente fĂĽr den Befehl
</programlisting>
<command>buffer [Aktion [Argumente] | Nummer | [[Server] [Channel]]]</command>
<programlisting>
Puffer verwalten
Aktion: Pufferaktion:
move: Puffer in der Liste bewegen (kann auch relativ sein, wie -1)
close: Puffer schlieĂźen (und Channel ohne Meldung verlassen)
list: alle offenen Puffer auflisten (Standardaktion)
notify: Notify-Level fĂĽr Puffer festlegen (0=nie, 1=highlighten, 2=1+Nachricht, 3=2+join/part)
Server
Channel: gehe zum Puffer mit Servernamen oder Channelnamen
Nummer: gehe zu Puffer mit dieser Nummer
</programlisting>
<command>builtin Befehl</command>
<programlisting>
starte eingebauten WeeChat/IRC-Befehl (ohne Plugin-Handler oder Aliase)
Befehl: auszufĂĽhrender Befehl (falls nicht vorhanden wird automatisch ein '/' vorangestellt)
</programlisting>
<command>charset [(decode_iso | decode_utf | encode) Zeichensatz]</command>
<programlisting>
ändere Zeichensatz für den Server oder Channel
decode_iso: Zeichensatz um ISO zu decoden
decode_utf: Zeichensatz um UTF zu decoden
encode: der zum encoden benutzte Zeichensatz
Zeichensatz: Zeichensatz, der benutzt werden soll (zum Beispiel: ISO-8859-15, UTF-8,..)
</programlisting>
<command>clear [-all]</command>
<programlisting>
Fenster leeren
-all: alle Fenster leeren
</programlisting>
<command>connect [Servername]</command>
<programlisting>
mit einem Server verbinden
Servername: Zielserver
</programlisting>
<command>disconnect [Servername]</command>
<programlisting>
Serververbindung trennen
Servername: Name des zu trennenden Servers
</programlisting>
<command>dcc Aktion [Nickname [Datei]]</command>
<programlisting>
DCC (Filetransfer oder Chat) starten oder Chat beenden
Aktion: 'send' (Datei) oder 'chat' oder 'close' (Chat)
Nickname: Empfänger der Datei bzw. Chatpartner
Datei: zu versendende (lokal vorliegende) Datei
</programlisting>
<command>debug dump | windows</command>
<programlisting>
Debugging-Nachricht ausgeben
dump: Speicherabbild im WeeChat-Logfile ablegen (wie nach einem Programmabsturz)
windows: zeigt Fensterdaten an
</programlisting>
<command>help [Befehl]</command>
<programlisting>
Hilfe zu Befehlen abfragen
Befehl: Name eines WeeChat- oder IRC-Befehls
</programlisting>
<command>history [clear | Anzahl]</command>
<programlisting>
zeigt Befehlsverlauf des Puffers
clear: Löscht Verlauf
Anzahl: zeigt die gewünschte Anzahl an Verlaufseinträgen
</programlisting>
<command>ignore [Maske [[Typ | Befehl] [Channel [Server]]]]</command>
<programlisting>
IRC-Nachrichten und/oder Hosts ignorieren
Nummer: Nummer des zu entfernenden Eintrags (siehe Liste)
Maske: Nickname oder Hostmaske, die ignoriert werden soll
Typ: Typ der Nachrichten, die ignoriert werden sollen (action, ctcp, dcc, pv)
Befehl: IRC-Befehl
Channel: Channel, in dem ignoriert werden soll
Server: Server, auf dem ignoriert werden soll
Bei jedem Argument steht '*' fĂĽr 'alle'.
Ohne Argumente listet /ignore alle definierten /ignore-Regeln auf.
</programlisting>
<command>key [Taste Funktion/Befehl] [unbind Taste] [functions] [reset -yes]</command>
<programlisting>
belegen/freigeben von Tasten
Taste: diese Taste mit einer internen Funktion oder einem Befehl, beginnend mit "/", belegen
unbind: Tastenbelegung aufheben
functions: interne Funktionen fĂĽr Tastenbelegungen auflisten
reset: Standardbelegung wiederherstellen und entferne alle eigenen Belegungen (Vorsicht!)
</programlisting>
<command>plugin [load Dateiname] | [autoload] | [reload] | [unload]</command>
<programlisting>
auflisten/laden/entladen von Plugins
Dateiname: zu ladendes Plugin
Ohne Argumente werden alle geladenen Plugins aufgelistet.
</programlisting>
<command>server [Servername] | [Servername Hostname Port [-auto | -noauto] [-ipv6] [-ssl] [-pwd Passwort] [-nicks Nick1 Nick2 Nick3] [-username Benutzername] [-realname Name] [-command Befehl] [-autojoin Channel[,Channel]] ] | [del Servername]</command>
<programlisting>
Auflisten, HinzufĂĽgen oder Entfernen von Servern
Servername: anzuzeigender Servername
Hostname: Name oder IP-Adresse des Servers
Port: Port des Servers
ipv6: IPv6 benutzen
ssl: SSL benutzen
Passwort: Serverpasswort
Nick1: erster Nickname
Nick2: zweiter Nickname
Nick3: dritter Nicname
Benutzername: Benutzername
Realname: voller Name des Benutzers
</programlisting>
<command>save [Datei]</command>
<programlisting>
Konfiguration abspeichern
Datei: Name der zu speichernden Konfigurationsdatei
</programlisting>
<command>set [Option [ = Wert]]</command>
<programlisting>
Konfigurationsparameter setzen
Option: Name einer Option (wenn der Name vorhanden ist, aber kein Wert, dann wird eine Hilfe zur Option ausgegeben
Wert: Wert der Option
Option kann Servername.server_xxx lauten, wobei "Servername" der interne Servername ist und "xxx" eine Option fĂĽr diesen Server.
</programlisting>
<command>setp [Option [ = Wert]]</command>
<programlisting>
Konfigurationsparameter fĂĽr Plugin setzen
Option: Name einer Plugin-Option
Wert: Wert fĂĽr Option
Option wird wie folgt formatiert: Plugin.Option, z.B. perl.myscript.item1
</programlisting>
<command>unalias Aliasname</command>
<programlisting>
einen Alias entfernen
Aliasname: Name des zu löschenden Aliases
</programlisting>
<command>unignore [Nummer | [Maske [[Typ | Befehl] [Channel [Server]]]]</command>
<programlisting>
/ignore-Regel entfernen
Nummer: Nummer des zu entfernenden Eintrags (siehe Liste)
Maske: Nickname oder Hostmaske, die ignoriert werden soll
Typ: Typ der Nachrichten, die ignoriert werden sollen (action, ctcp, dcc, pv)
Befehl: IRC-Befehl
Channel: Channel, in dem ignoriert werden soll
Server: Server, auf dem ignoriert werden soll
Bei jedem Argument steht '*' fĂĽr 'alle'.
Ohne Argumente listet /unignore alle definierten /ignore-Regeln auf.
</programlisting>
<command>upgrade</command>
<programlisting>
aktualisiert WeeChat ohne die Verbindung zum Server zu trennen
Dieser Befehl wird auf dem Weechat-Binary ausgefĂĽhrt, daher sollte dieses kompiliert oder mit einem Paketmanager installiert sein, bevor der Befehl ausgefĂĽhrt wird.
</programlisting>
<command>uptime [-o]</command>
<programlisting>
zeigt die Uptime von Weechat an
-o: sendet die Weechat-Uptime als IRC-Nachricht in den aktuellen Channel
</programlisting>
<command>window [list | -1 | +1 | b# | up | down | left | right | splith [pct] | splitv [pct] | resize pct | merge [all]]</command>
<programlisting>
Fenster verwalten
list: listet die geöffneten Fenster (Default, kann auch weggelassen werden)
-1: springt zum vorherigen Fenster
+1: springt zum nächsten Fenster
b#: springt zum nächsten Fenster, dass Puffer Nummer # anzeigt
up: wechselt zum Fenster ĂĽber dem aktuellen
down: wechselt zum Fenster unter dem aktuellen
left: wechselt zum linken Fenster
right: wechselt zum rechten Fenster
splith: teilt das aktuelle Fenster horizontal
splitv: teilt das aktuelle Fenster vertikal
resize: verändert die Größe des aktuellen Fensters, die neue Größe wird in Prozent des Elternfensters angegeben
merge: vereinigt Fenster miteinander (all = alle Fenster vereinigen)
Bei splith und splitv gibt pct die neue Größe des Fensters im verhältnis zur aktuellen Größe an. Zum Beispiel würde 25 bedeuten, dass das neue Fenster nur noch ein Viertel der Größe des alten Fensters hätte.
</programlisting>
+3 -1
View File
@@ -30,6 +30,7 @@ all-local: html-stamp
html: html-stamp
html-stamp: $(BOOK).xml $(BOOK_INCLUDE) ../weechat-html.xsl ../weechat-doc.css
echo "<pubdate>`date -R`</pubdate>" >date.xml
mkdir -p html/
xsltproc -o html/ ../weechat-html.xsl $(BOOK).xml || true
cp ../weechat-doc.css html/
@@ -40,6 +41,7 @@ html-stamp: $(BOOK).xml $(BOOK_INCLUDE) ../weechat-html.xsl ../weechat-doc.css
html1: html1-stamp
html1-stamp: $(BOOK).xml $(BOOK_INCLUDE) ../weechat-html-one.xsl ../weechat-doc.css
echo "<pubdate>`date -R`</pubdate>" >date.xml
mkdir -p html1/
xsltproc -o html1/$(BOOK).html ../weechat-html-one.xsl $(BOOK).xml || true
cp ../weechat-doc.css html1/
@@ -54,6 +56,6 @@ install-data-hook:
# clean
clean-local:
-rm -f *.html *.pdf *.txt
-rm -f *.html *.pdf *.txt date.xml
-rm -rf html/ html1/
-rm -f html-stamp html1-stamp
+275 -171
View File
File diff suppressed because it is too large Load Diff
+11 -6
View File
@@ -1,4 +1,10 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- ********* WARNING! *********
This file is automatically built with a Perl script. DO NOT EDIT!
-->
<command>admin [target]</command>
<programlisting>
find information about the administrator of the server
@@ -45,13 +51,12 @@ send a CTCP message (Client-To-Client Protocol)
arguments: arguments for CTCP
</programlisting>
<command>dcc action [nickname [file]]</command>
<command>cycle [channel[,channel]] [part_message]</command>
<programlisting>
starts DCC (file or chat) or close chat
leave and rejoin a channel
action: 'send' (file) or 'chat' or 'close' (chat)
nickname: nickname to send file or chat
file: filename (on local host)
channel: channel name for cycle
part_message: part message (displayed to other users)
</programlisting>
<command>dehalfop [nickname [nickname]]</command>
@@ -147,7 +152,7 @@ server_mask: list of servers must match this mask
<programlisting>
list channels and their topic
channel: channel to list
channel: channel to list (a regexp is allowed)
server: server name
</programlisting>
+30
View File
@@ -1,4 +1,10 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- ********* WARNING! *********
This file is automatically built with a Perl script. DO NOT EDIT!
-->
<row>
<entry><literal>return</literal></entry>
<entry>terminate line</entry>
@@ -7,6 +13,10 @@
<entry><literal>tab</literal></entry>
<entry>complete word</entry>
</row>
<row>
<entry><literal>tab_previous</literal></entry>
<entry>find previous completion for word</entry>
</row>
<row>
<entry><literal>backspace</literal></entry>
<entry>delete previous char</entry>
@@ -91,6 +101,22 @@
<entry><literal>page_down</literal></entry>
<entry>scroll one page down</entry>
</row>
<row>
<entry><literal>scroll_up</literal></entry>
<entry>scroll a few lines up</entry>
</row>
<row>
<entry><literal>scroll_down</literal></entry>
<entry>scroll a few lines down</entry>
</row>
<row>
<entry><literal>scroll_top</literal></entry>
<entry>scroll to top of buffer</entry>
</row>
<row>
<entry><literal>scroll_bottom</literal></entry>
<entry>scroll to bottom of buffer</entry>
</row>
<row>
<entry><literal>nick_beginning</literal></entry>
<entry>display beginning of nicklist</entry>
@@ -115,6 +141,10 @@
<entry><literal>jump_dcc</literal></entry>
<entry>jump to DCC buffer</entry>
</row>
<row>
<entry><literal>jump_raw_data</literal></entry>
<entry>jump to raw IRC data buffer</entry>
</row>
<row>
<entry><literal>jump_last_buffer</literal></entry>
<entry>jump to last buffer</entry>
+2520 -169
View File
File diff suppressed because it is too large Load Diff
+44 -7
View File
@@ -1,26 +1,40 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<command>alias [alias_name [command [arguments]]</command>
<!-- ********* WARNING! *********
This file is automatically built with a Perl script. DO NOT EDIT!
-->
<command>alias [alias_name [command [arguments]]]</command>
<programlisting>
create an alias for a command
alias_name: name of alias
command: command name (WeeChat or IRC command, without first '/')
command: command name (WeeChat or IRC command, many commands can be separated by semicolons)
arguments: arguments for command
</programlisting>
<command>buffer [action | number | [[server] [channel]]]</command>
<command>buffer [action [args] | number | [[server] [channel]]]</command>
<programlisting>
manage buffers
action: action to do:
move: move buffer in the list (may be relative, for example -1)
close: close buffer (for channel: same as /part without part message)
close: close buffer (optional arg is part message, for a channel)
list: list opened buffers (no parameter implies this list)
notify: set notify level for buffer (0=never, 1=highlight, 2=1+msg, 3=2+join/part)
server
channel: jump to buffer by server and/or channel name
number: jump to buffer by number
</programlisting>
<command>builtin command</command>
<programlisting>
launch WeeChat/IRC builtin command (do not look at plugins handlers or aliases)
command: command to execute (a '/' is automatically added if not found at beginning of command)
</programlisting>
<command>charset [(decode_iso | decode_utf | encode) charset]</command>
<programlisting>
@@ -52,6 +66,15 @@ disconnect from a server
servername: server name to disconnect
</programlisting>
<command>dcc action [nickname [file]]</command>
<programlisting>
starts DCC (file or chat) or close chat
action: 'send' (file) or 'chat' or 'close' (chat)
nickname: nickname to send file or chat
file: filename (on local host)
</programlisting>
<command>debug dump | windows</command>
<programlisting>
@@ -135,10 +158,22 @@ file: filename for writing config
</programlisting>
<command>set [option [ = value]]</command>
<programlisting>
set config parameters
set config options
option: name of an option (if name is full and no value is given, then help is displayed on option)
value: value for option
value: value for option
Option may be: servername.server_xxx where "servername" is an internal server name and "xxx" an option for this server.
</programlisting>
<command>setp [option [ = value]]</command>
<programlisting>
set plugin config options
option: name of a plugin option
value: value for option
Option is format: plugin.option, example: perl.myscript.item1
</programlisting>
<command>unalias alias_name</command>
@@ -167,6 +202,8 @@ Without argument, /unignore command lists all defined ignore.
<programlisting>
upgrade WeeChat without disconnecting from servers
This command run again WeeChat binary, so it should have been compiled or installed with a package manager before running this command.
</programlisting>
<command>uptime [-o]</command>
<programlisting>
@@ -189,7 +226,7 @@ manage windows
right: switch to window on the right
splith: split current window horizontally
splitv: split current window vertically
resize: resize window size, new size is pct%% of parent window
resize: resize window size, new size is &lt;pct&gt; pourcentage of parent window
merge: merge window with another (all = keep only one window)
For splith and splitv, pct is a pourcentage which represents size of new window, computed with current window as size reference. For example 25 means create a new window with size = current_size / 4
+3 -1
View File
@@ -30,6 +30,7 @@ all-local: html-stamp
html: html-stamp
html-stamp: $(BOOK).xml $(BOOK_INCLUDE) ../weechat-html.xsl ../weechat-doc.css
echo "<pubdate>`date -R`</pubdate>" >date.xml
mkdir -p html/
xsltproc -o html/ ../weechat-html.xsl $(BOOK).xml || true
cp ../weechat-doc.css html/
@@ -40,6 +41,7 @@ html-stamp: $(BOOK).xml $(BOOK_INCLUDE) ../weechat-html.xsl ../weechat-doc.css
html1: html1-stamp
html1-stamp: $(BOOK).xml $(BOOK_INCLUDE) ../weechat-html-one.xsl ../weechat-doc.css
echo "<pubdate>`date -R`</pubdate>" >date.xml
mkdir -p html1/
xsltproc -o html1/$(BOOK).html ../weechat-html-one.xsl $(BOOK).xml || true
cp ../weechat-doc.css html1/
@@ -54,6 +56,6 @@ install-data-hook:
# clean
clean-local:
-rm -f *.html *.pdf *.txt
-rm -f *.html *.pdf *.txt date.xml
-rm -rf html/ html1/
-rm -f html-stamp html1-stamp
+114 -10
View File
@@ -1,4 +1,10 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- ********* WARNING! *********
This file is automatically built with a Perl script. DO NOT EDIT!
-->
<row>
<entry><option>look_set_title</option></entry>
<entry>booléen</entry>
@@ -46,7 +52,7 @@
<entry>chaîne</entry>
<entry>toute chaîne</entry>
<entry>''</entry>
<entry>Jeu de caractères pour encoder les messages envoyés au serveur, exemples: UFT-8, ISO-8859-1 (si non renseigné, les messages ne sont pas convertis)</entry>
<entry>Jeu de caractères pour encoder les messages envoyés au serveur, exemples: UTF-8, ISO-8859-1 (si non renseigné, les messages ne sont pas convertis)</entry>
</row>
<row>
<entry><option>look_charset_internal</option></entry>
@@ -62,6 +68,20 @@
<entry>'off'</entry>
<entry>Utiliser le mĂŞme tampon pour tous les serveurs</entry>
</row>
<row>
<entry><option>look_open_near_server</option></entry>
<entry>booléen</entry>
<entry>'on' ou 'off'</entry>
<entry>'off'</entry>
<entry>Ouvrir les nouveaux canaux/privés près du serveur</entry>
</row>
<row>
<entry><option>look_scroll_amount</option></entry>
<entry>entier</entry>
<entry>entre 1 et 2147483647</entry>
<entry>3</entry>
<entry>Nombre de lignes pour le défilement avec scroll_up et scroll_down</entry>
</row>
<row>
<entry><option>look_buffer_timestamp</option></entry>
<entry>chaîne</entry>
@@ -109,7 +129,7 @@
<entry>entier</entry>
<entry>entre 0 et 100</entry>
<entry>0</entry>
<entry>Taille maximum pour la fenĂŞtre d'utilisateurs (largeur ou hauteur, selon look_nicklist_position (0 = pas de taille maximum; si min == max et > 0, alors la taille est fixe))</entry>
<entry>Taille maximum pour la fenĂŞtre d'utilisateurs (largeur ou hauteur, selon look_nicklist_position (0 = pas de taille maximum; si min == max et &gt; 0, alors la taille est fixe))</entry>
</row>
<row>
<entry><option>look_no_nickname</option></entry>
@@ -132,6 +152,48 @@
<entry>'off'</entry>
<entry>Afficher un espace si le mode utilisateur n'est pas (half)op/voice</entry>
</row>
<row>
<entry><option>look_nick_prefix</option></entry>
<entry>chaîne</entry>
<entry>toute chaîne</entry>
<entry>''</entry>
<entry>Texte Ă  afficher avant le pseudo dans la fenĂŞtre de discussion</entry>
</row>
<row>
<entry><option>look_nick_suffix</option></entry>
<entry>chaîne</entry>
<entry>toute chaîne</entry>
<entry>' |'</entry>
<entry>Texte à afficher après le pseudo dans la fenêtre de discussion</entry>
</row>
<row>
<entry><option>look_align_nick</option></entry>
<entry>chaîne</entry>
<entry>'none', 'left', 'right'</entry>
<entry>'right'</entry>
<entry>Alignement des pseudos (taille fixe pour les pseudos dans la fenĂŞtre de discussion (none, left, right))</entry>
</row>
<row>
<entry><option>look_align_other</option></entry>
<entry>booléen</entry>
<entry>'on' ou 'off'</entry>
<entry>'on'</entry>
<entry>Alignement pour les autres messages (ne commençant pas par un pseudo)</entry>
</row>
<row>
<entry><option>look_align_size</option></entry>
<entry>entier</entry>
<entry>entre 8 et 64</entry>
<entry>14</entry>
<entry>Taille pour l'alignement des pseudos et autres messages</entry>
</row>
<row>
<entry><option>look_align_size_max</option></entry>
<entry>entier</entry>
<entry>entre 8 et 64</entry>
<entry>20</entry>
<entry>Taille maximum pour l'alignement des pseudos et autres messages (doit ĂŞtre &gt;= Ă  look_align_size)</entry>
</row>
<row>
<entry><option>look_nick_completor</option></entry>
<entry>chaîne</entry>
@@ -146,6 +208,13 @@
<entry>'[]-^'</entry>
<entry>Caractères à ignorer pour la complétion des pseudos</entry>
</row>
<row>
<entry><option>look_nick_complete_first</option></entry>
<entry>booléen</entry>
<entry>'on' ou 'off'</entry>
<entry>'off'</entry>
<entry>Compléter seulement avec le premier pseudo trouvé</entry>
</row>
<row>
<entry><option>look_infobar</option></entry>
<entry>booléen</entry>
@@ -216,6 +285,13 @@
<entry>' '</entry>
<entry>Utiliser un marqueur sur les serveurs/canaux pour montrer la première ligne non lue</entry>
</row>
<row>
<entry><option>look_input_format</option></entry>
<entry>chaîne</entry>
<entry>toute chaîne</entry>
<entry>'[%n(%m)] '</entry>
<entry>Format pour l'invite de la zone de saisie ('%c' est remplacé par le canal ou serveur, '%n' par le pseudo et '%m' par les modes du pseudo)</entry>
</row>
<row>
<entry><option>col_real_white</option></entry>
<entry>booléen</entry>
@@ -454,6 +530,13 @@
<entry>'default'</entry>
<entry>Couleur pour le texte saisi</entry>
</row>
<row>
<entry><option>col_input_server</option></entry>
<entry>couleur</entry>
<entry>couleur Curses ou Gtk</entry>
<entry>'brown'</entry>
<entry>Couleur pour le texte saisi (nom du serveur)</entry>
</row>
<row>
<entry><option>col_input_channel</option></entry>
<entry>couleur</entry>
@@ -738,8 +821,8 @@
<entry><option>log_path</option></entry>
<entry>chaîne</entry>
<entry>toute chaîne</entry>
<entry>'~/.weechat/logs/'</entry>
<entry>Chemin pour les conversations sauvegardées par WeeChat</entry>
<entry>'%h/logs/'</entry>
<entry>Chemin pour les conversations sauvegardées par WeeChat ('%h' sera remplacé par le répertoire de base WeeChat, par défaut: ~/.weechat)</entry>
</row>
<row>
<entry><option>log_timestamp</option></entry>
@@ -762,12 +845,19 @@
<entry>'off'</entry>
<entry>Affiche un message pour l'absence/le retour</entry>
</row>
<row>
<entry><option>irc_show_away_once</option></entry>
<entry>booléen</entry>
<entry>'on' ou 'off'</entry>
<entry>'on'</entry>
<entry>Voir le message d'absence distant une seule fois en privé</entry>
</row>
<row>
<entry><option>irc_default_msg_part</option></entry>
<entry>chaîne</entry>
<entry>toute chaîne</entry>
<entry>'WeeChat %v'</entry>
<entry>Message par défaut pour le part (quitte un canal)</entry>
<entry>Message par défaut pour le part (quitte un canal) ('%v' sera remplacé par la version de WeeChat dans la chaîne)</entry>
</row>
<row>
<entry><option>irc_default_msg_quit</option></entry>
@@ -788,7 +878,14 @@
<entry>entier</entry>
<entry>entre 0 et 2147483647</entry>
<entry>0</entry>
<entry>Intervalle entre deux vérifications des absences (en minutes, 0 = ne jemais vérifier)</entry>
<entry>Intervalle entre deux vérifications des absences (en minutes, 0 = ne jamais vérifier)</entry>
</row>
<row>
<entry><option>irc_away_check_max_nicks</option></entry>
<entry>entier</entry>
<entry>entre 0 et 2147483647</entry>
<entry>0</entry>
<entry>Ne pas vérifier les pseudos absents lorsqu'il y a un nombre important de pseudos (0 = pas de limite)</entry>
</row>
<row>
<entry><option>irc_lag_check</option></entry>
@@ -885,7 +982,7 @@
<entry><option>dcc_download_path</option></entry>
<entry>chaîne</entry>
<entry>toute chaîne</entry>
<entry>'~'</entry>
<entry>'%h/dcc'</entry>
<entry>Chemin pour écrire les fichiers reçus par dcc (par défaut: répertoire de l'utilisateur)</entry>
</row>
<row>
@@ -969,8 +1066,8 @@
<entry><option>plugins_path</option></entry>
<entry>chaîne</entry>
<entry>toute chaîne</entry>
<entry>'~/.weechat/plugins'</entry>
<entry>Chemin de recherche des extensions</entry>
<entry>'%h/plugins'</entry>
<entry>Chemin de recherche des extensions ('%h' sera remplacé par le répertoire de base WeeChat, par défaut: ~/.weechat)</entry>
</row>
<row>
<entry><option>plugins_autoload</option></entry>
@@ -1084,12 +1181,19 @@
<entry>''</entry>
<entry>Nom réel pour le serveur IRC</entry>
</row>
<row>
<entry><option>server_hostname</option></entry>
<entry>chaîne</entry>
<entry>toute chaîne</entry>
<entry>''</entry>
<entry>Nom de machine/IP personnalisé pour le serveur (optionnel, si non renseigné, le nom de machine local est utilisé)</entry>
</row>
<row>
<entry><option>server_command</option></entry>
<entry>chaîne</entry>
<entry>toute chaîne</entry>
<entry>''</entry>
<entry>Commande à exécuter en premier lorsque connecté au serveur</entry>
<entry>Commande(s) à exécuter lorsque connecté au serveur (plusieurs commandes doivent être séparées par ';', utilisez '\;' pour un point-virgule)</entry>
</row>
<row>
<entry><option>server_command_delay</option></entry>
+13 -8
View File
@@ -1,4 +1,10 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- ********* WARNING! *********
This file is automatically built with a Perl script. DO NOT EDIT!
-->
<command>admin [cible]</command>
<programlisting>
trouver les informations sur l'administrateur du serveur
@@ -45,13 +51,12 @@ envoyer un message CTCP (Client-To-Client Protocol)
arguments: arguments pour le CTCP
</programlisting>
<command>dcc action [pseudo [fichier]]</command>
<command>cycle [canal[,canal]] [message_de_fin]</command>
<programlisting>
démarre le DCC (fichier ou discussion) ou ferme une discussion
quitter et rejoindre un canal
action: 'send' (envoi de fichier) ou 'chat' (discussion) ou 'close' (fermeture discussion)
pseudo: pseudo pour envoyer le fichier ou discuter
fichier: nom du fichier (sur la machine locale)
canal: canal pour le cycle
message_de_fin: message de fin (affiché aux autres utilisateurs)
</programlisting>
<command>dehalfop [pseudo [pseudo]]</command>
@@ -143,11 +148,11 @@ lister tous les noms de serveurs connus du serveur qui r
masque_serveur: liste des serveurs correspondant au masque
</programlisting>
<command>list [canal[,canall] [serveur]]</command>
<command>list [canal[,canal] [serveur]]</command>
<programlisting>
lister les canaux et leur sujet
canal: canal Ă  lister
canal: canal à lister (une expression régulière est acceptée)
serveur: nom du serveur
</programlisting>
@@ -242,7 +247,7 @@ obtenir le statut d'op
utilisateur/mot_de_passe: utilisé pour obtenir les privilèges sur le serveur IRC courant
</programlisting>
<command>part [canal[,canall] [message_de_fin]</command>
<command>part [canal[,canal]] [message_de_fin]</command>
<programlisting>
quitter un canal
+30
View File
@@ -1,4 +1,10 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- ********* WARNING! *********
This file is automatically built with a Perl script. DO NOT EDIT!
-->
<row>
<entry><literal>return</literal></entry>
<entry>terminer la ligne</entry>
@@ -7,6 +13,10 @@
<entry><literal>tab</literal></entry>
<entry>compléter le mot</entry>
</row>
<row>
<entry><literal>tab_previous</literal></entry>
<entry>trouver le mot complété précédent</entry>
</row>
<row>
<entry><literal>backspace</literal></entry>
<entry>effacer le caractère précédent</entry>
@@ -91,6 +101,22 @@
<entry><literal>page_down</literal></entry>
<entry>faire défiler d'une page vers le bas</entry>
</row>
<row>
<entry><literal>scroll_up</literal></entry>
<entry>faire défiler de quelques lignes vers le haut</entry>
</row>
<row>
<entry><literal>scroll_down</literal></entry>
<entry>faire défiler de quelques lignes vers le bas</entry>
</row>
<row>
<entry><literal>scroll_top</literal></entry>
<entry>faire défiler jusqu'au début du tampon</entry>
</row>
<row>
<entry><literal>scroll_bottom</literal></entry>
<entry>faire défiler jusqu'à la fin du tampon</entry>
</row>
<row>
<entry><literal>nick_beginning</literal></entry>
<entry>afficher le début de la liste des pseudos</entry>
@@ -115,6 +141,10 @@
<entry><literal>jump_dcc</literal></entry>
<entry>sauter au tampon DCC</entry>
</row>
<row>
<entry><literal>jump_raw_data</literal></entry>
<entry>sauter au tampon IRC brut</entry>
</row>
<row>
<entry><literal>jump_last_buffer</literal></entry>
<entry>sauter au dernier tampon</entry>
+2544 -149
View File
File diff suppressed because it is too large Load Diff
+43 -6
View File
@@ -1,26 +1,40 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<command>alias [nom_alias [commande [paramètres]]</command>
<!-- ********* WARNING! *********
This file is automatically built with a Perl script. DO NOT EDIT!
-->
<command>alias [nom_alias [commande [paramètres]]]</command>
<programlisting>
créer un alias pour une commande
nom_alias: nom de l'alias
commande: nom de la commande (commande WeeChat ou IRC, sans le premier '/')
commande: nom de la commande (commande WeeChat ou IRC, plusieurs commandes peuvent être séparées par des point-virgules)
paramètres: paramètres pour la commande
</programlisting>
<command>buffer [action | nombre | [[serveur] [canal]]]</command>
<command>buffer [action [args] | nombre | [[serveur] [canal]]]</command>
<programlisting>
gestion des tampons
action: action Ă  effectuer:
move: déplacer le tampon dans la liste (peut être relatif, par exemple -1)
close: fermer le tampon (pour un canal: équivalent à /part sans message de fin)
close: fermer le tampon (le paramètre optionnel est le message de fin, pour un canal)
list: liste les tampons ouverts (pas de paramètre affiche cette liste)
notify: fixer le niveau de notification (0=jamais, 1=highlight, 2=1+msg, 3=2+join/part)
serveur
canal: sauter au tampon par serveur et/ou nom de canal
nombre: sauter au tampon qui a ce numéro
</programlisting>
<command>builtin commande</command>
<programlisting>
lance une commande WeeChat/IRC interne (sans regarder les gestionnaires de commandes et les alias)
commande: commande à exécuter (un '/' est automatiquement ajouté s'il n'est pas trouvé au début de la commande)
</programlisting>
<command>charset [(decode_iso | decode_utf | encode) charset]</command>
<programlisting>
@@ -52,6 +66,15 @@ se d
nom_serveur: nom du serveur pour se déconnecter
</programlisting>
<command>dcc action [pseudo [fichier]]</command>
<programlisting>
démarre le DCC (fichier ou discussion) ou ferme une discussion
action: 'send' (envoi de fichier) ou 'chat' (discussion) ou 'close' (fermeture discussion)
pseudo: pseudo pour envoyer le fichier ou discuter
fichier: nom du fichier (sur la machine locale)
</programlisting>
<command>debug dump | windows</command>
<programlisting>
@@ -135,11 +158,23 @@ fichier: fichier pour sauvegarder la configuration
</programlisting>
<command>set [option [ = valeur]]</command>
<programlisting>
modifier des paramètres de configuration
modifier des options de configuration
option: nom de l'option (si le nom est complet et qu'aucune valeur n'est donnée, alors l'aide sur l'option est affichée)
valeur: valeur pour l'option
L'option peut ĂŞtre: nomserveur.server_xxx oĂą "nomserveur" est le nom interne d'un serveur et "xxx" une option pour ce serveur.
</programlisting>
<command>setp [option [ = valeur]]</command>
<programlisting>
modifier des options de configuration des extensions
option: nom d'une option d'extension
valeur: valeur pour l'option
L'option est au format: extension.option, par exemple: perl.monscript.variable1
</programlisting>
<command>unalias nom_alias</command>
<programlisting>
@@ -167,6 +202,8 @@ Sans param
<programlisting>
mettre à jour WeeChat sans se déconnecter des serveurs
Cette commande lance à nouveau le binaire WeeChat, il doit donc avoir été compilé ou installé via un gestionnaire de paquet avant de lancer cette commande.
</programlisting>
<command>uptime [-o]</command>
<programlisting>
@@ -189,7 +226,7 @@ gestion des fen
right: saute Ă  la fenĂŞtre Ă  droite
splith: éclate la fenêtre en deux horizontalement
splitv: éclate la fenêtre en deux verticalement
resize: redimensionne une fenĂŞtre, la nouvelle taille est pct%% de la fenĂŞtre parent
resize: redimensionne une fenĂŞtre, la nouvelle taille est &lt;pct&gt; pourcentage de la fenĂŞtre parent
merge: fusionne la fenĂŞtre avec une autre
Pour splith et splitv, pct est un pourcentage qui représente la taille de la nouvelle fenêtre, calculée par rapport à la taille de la fenêtre courante. Par exemple 25 signifie créer une fenêtre qui a pour taille: taille_courante / 4
+5 -1
View File
@@ -1,4 +1,4 @@
.TH WEECHAT 1 "January 2006" "FlashCode"
.TH WEECHAT 1 "May 2006" "FlashCode"
.SH NAME
weechat-curses \- Wee Enhanced Environment for Chat (Curses version)
@@ -27,6 +27,10 @@ disable auto-connect to servers at startup
.br
display config file help (list of options)
.TP
.B \-d, \-\-dir <dir>
.br
set WeeChat home dir
.TP
.B \-f, \-\-key\-functions
.br
display internal functions for keys
+36
View File
@@ -12,6 +12,42 @@ table {
font-size: 12px;
}
a {
color: #000099;
}
a:visited {
color: #770077;
}
a:hover {
background-color: #FFCCCC;
}
.navheader {
background-color: #E8E8FF;
border: solid 1px #B5B5CC;
}
.navheader hr {
display: none;
}
.navfooter {
background-color: #E8E8FF;
border: solid 1px #B5B5CC;
}
.navfooter hr {
display: none;
}
.title {
background-color: #E5FFE5;
border: solid 1px #CCDDCC;
padding: 3px;
}
.informaltable table {
font-size: 11px;
font-family: Verdana;
+33 -4
View File
@@ -14,14 +14,43 @@
./src/plugins/plugins-config.h
./src/plugins/plugins-interface.c
./src/plugins/weechat-plugin.h
./src/gui/curses/gui-input.c
./src/gui/curses/gui-display.c
./src/gui/gtk/gui-display.c
./src/gui/gtk/gui-input.c
./src/gui/curses/gui-curses-chat.c
./src/gui/curses/gui-curses-color.c
./src/gui/curses/gui-curses-infobar.c
./src/gui/curses/gui-curses-input.c
./src/gui/curses/gui-curses-keyboard.c
./src/gui/curses/gui-curses-main.c
./src/gui/curses/gui-curses-nicklist.c
./src/gui/curses/gui-curses-panel.c
./src/gui/curses/gui-curses-status.c
./src/gui/curses/gui-curses-window.c
./src/gui/curses/gui-curses.h
./src/gui/gtk/gui-gtk-chat.c
./src/gui/gtk/gui-gtk-color.c
./src/gui/gtk/gui-gtk-infobar.c
./src/gui/gtk/gui-gtk-input.c
./src/gui/gtk/gui-gtk-keyboard.c
./src/gui/gtk/gui-gtk-main.c
./src/gui/gtk/gui-gtk-nicklist.c
./src/gui/gtk/gui-gtk-panel.c
./src/gui/gtk/gui-gtk-status.c
./src/gui/gtk/gui-gtk-window.c
./src/gui/gtk/gui-gtk.h
./src/gui/gui-action.c
./src/gui/gui-buffer.c
./src/gui/gui-common.c
./src/gui/gui-keyboard.c
./src/gui/gui-log.c
./src/gui/gui-panel.c
./src/gui/gui-window.c
./src/gui/gui.h
./src/gui/gui-buffer.h
./src/gui/gui-color.h
./src/gui/gui-keyboard.h
./src/gui/gui-panel.h
./src/gui/gui-window.h
./src/common/backtrace.c
./src/common/backtrace.h
./src/common/command.c
./src/common/command.h
./src/common/completion.c
+1674 -1272
View File
File diff suppressed because it is too large Load Diff
+5691
View File
File diff suppressed because it is too large Load Diff
+1696 -1271
View File
File diff suppressed because it is too large Load Diff
+1696 -1263
View File
File diff suppressed because it is too large Load Diff
+5611
View File
File diff suppressed because it is too large Load Diff
+5643
View File
File diff suppressed because it is too large Load Diff
+1631 -1252
View File
File diff suppressed because it is too large Load Diff
+2
View File
@@ -21,6 +21,8 @@ noinst_LIBRARIES = lib_weechat_main.a
lib_weechat_main_a_SOURCES = weechat.c \
weechat.h \
backtrace.c \
backtrace.h \
command.c \
command.h \
completion.c \
+163
View File
@@ -0,0 +1,163 @@
/*
* Copyright (c) 2003-2006 by FlashCode <flashcode@flashtux.org>
* See README for License detail, AUTHORS for developers list.
*
* 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 St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/* backtrace.c: display backtrace after a segfault */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#define __USE_GNU
#include <dlfcn.h>
#ifdef HAVE_BACKTRACE
#include <execinfo.h>
#endif
#include "weechat.h"
#include "backtrace.h"
#include "log.h"
/*
* weechat_backtrace_printf: display a backtrage line (on stderr and in WeeChat log)
*/
void
weechat_backtrace_printf (char *message, ...)
{
static char buffer[4096];
va_list argptr;
va_start (argptr, message);
vsnprintf (buffer, sizeof (buffer) - 1, message, argptr);
va_end (argptr);
fprintf (stderr, "%s", buffer);
weechat_log_printf ("%s", buffer);
}
/*
* weechat_backtrace_addr2line: display function name and line with a backtrace address
*/
void
weechat_backtrace_addr2line (int number, void *address, char *symbol)
{
int rc;
Dl_info info;
const void *addr;
FILE *output;
char cmd_line[1024];
char line[1024], *ptr_line, *pos;
char function_name[1024];
int file_line;
rc = dladdr (address, &info);
if ((rc == 0) || !info.dli_fname || !info.dli_fname[0])
{
weechat_backtrace_printf ("%03d %s\n", number, symbol);
return;
}
addr = address;
if (info.dli_fbase >= (const void *) 0x40000000)
addr = (const char *) addr - (unsigned int) info.dli_fbase;
snprintf (cmd_line, sizeof (cmd_line),
"addr2line --functions --demangle -e $(which %s) %p",
info.dli_fname, addr);
output = popen (cmd_line, "r");
if (!output)
{
weechat_backtrace_printf ("%03d %s\n", number, symbol);
return;
}
function_name[0] = '\0';
file_line = 0;
while (!feof (output))
{
ptr_line = fgets (line, sizeof (line) - 1, output);
if (ptr_line && ptr_line[0])
{
pos = strchr (ptr_line, '\n');
if (pos)
pos[0] = '\0';
if (strchr (ptr_line, ':'))
{
file_line = 1;
weechat_backtrace_printf ("%03d %s%s%s%s\n",
number,
ptr_line,
(function_name[0]) ? " [function " : "",
function_name,
(function_name[0]) ? "]" : "");
function_name[0] = '\0';
}
else
{
if (function_name[0])
weechat_backtrace_printf ("%03d %s",
number, function_name);
snprintf (function_name, sizeof (function_name),
"%s", ptr_line);
}
}
}
if (function_name[0])
weechat_backtrace_printf ("%03d %s\n",
number, function_name);
pclose (output);
}
/*
* weechat_backtrace: display backtrace (called when a SIGSEGV is received)
*/
void
weechat_backtrace ()
{
#ifdef HAVE_BACKTRACE
void *trace[BACKTRACE_MAX];
int trace_size, i;
char **symbols;
#endif
weechat_backtrace_printf ("======= WeeChat backtrace =======\n");
#ifdef HAVE_BACKTRACE
trace_size = backtrace (trace, BACKTRACE_MAX);
symbols = backtrace_symbols (trace, trace_size);
for (i = 0; i < trace_size; i++)
{
weechat_backtrace_addr2line (i + 1, trace[i], symbols[i]);
}
#else
weechat_backtrace_printf (" No backtrace info (no debug info available "
"or no backtrace possible on your system).\n");
#endif
weechat_backtrace_printf ("======= End of backtrace =======\n");
}
+28
View File
@@ -0,0 +1,28 @@
/*
* Copyright (c) 2003-2006 by FlashCode <flashcode@flashtux.org>
* See README for License detail, AUTHORS for developers list.
*
* 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 St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef __WEECHAT_BACKTACE_H
#define __WEECHAT_BACKTACE_H 1
#define BACKTRACE_MAX 128
extern void weechat_backtrace ();
#endif /* backtrace.h */
+1292 -563
View File
File diff suppressed because it is too large Load Diff
+34 -24
View File
@@ -38,9 +38,11 @@ struct t_weechat_command
char *completion_template; /* template for completion */
/* NULL=no completion, ""=default (nick) */
int min_arg, max_arg; /* min & max number of arguments */
int (*cmd_function_args)(t_gui_window *, int, char **);
int charset_conversion; /* = 1 if cmd args are converted before */
/* they're executed */
int (*cmd_function_args)(t_irc_server *, t_irc_channel *, int, char **);
/* function called when user enters cmd */
int (*cmd_function_1arg)(t_gui_window *, char *);
int (*cmd_function_1arg)(t_irc_server *, t_irc_channel *, char *);
/* function called when user enters cmd */
};
@@ -50,6 +52,7 @@ struct t_weechat_alias
{
char *alias_name;
char *alias_command;
int running;
t_weechat_alias *prev_alias;
t_weechat_alias *next_alias;
};
@@ -62,32 +65,39 @@ extern t_weelist *last_index_command;
extern void command_index_build ();
extern void command_index_free ();
extern t_weechat_alias *alias_search (char *);
extern t_weechat_alias *alias_new (char *, char *);
extern char *alias_get_final_command (t_weechat_alias *);
extern void alias_free_all ();
extern char **explode_string (char *, char *, int, int *);
extern void free_exploded_string (char **);
extern int exec_weechat_command (t_gui_window *, t_irc_server *, char *);
extern void user_command (t_gui_buffer *, t_irc_server *, char *);
extern int weechat_cmd_alias (t_gui_window *, char *);
extern int weechat_cmd_buffer (t_gui_window *, int, char **);
extern int weechat_cmd_charset (t_gui_window *, int, char **);
extern int weechat_cmd_clear (t_gui_window *, int, char **);
extern int weechat_cmd_connect (t_gui_window *, int, char **);
extern int weechat_cmd_debug (t_gui_window *, int, char **);
extern int weechat_cmd_disconnect (t_gui_window *, int, char **);
extern int weechat_cmd_help (t_gui_window *, int, char **);
extern int weechat_cmd_history (t_gui_window *, int, char **);
extern char **split_multi_command (char *, char);
extern void free_multi_command (char **);
extern int exec_weechat_command (t_irc_server *, t_irc_channel *, char *, int);
extern void user_command (t_irc_server *, t_irc_channel *, char *, int);
extern int weechat_cmd_alias (t_irc_server *, t_irc_channel *, char *);
extern int weechat_cmd_buffer (t_irc_server *, t_irc_channel *, char *);
extern int weechat_cmd_builtin (t_irc_server *, t_irc_channel *, char *);
extern int weechat_cmd_charset (t_irc_server *, t_irc_channel *, int, char **);
extern int weechat_cmd_clear (t_irc_server *, t_irc_channel *, int, char **);
extern int weechat_cmd_connect (t_irc_server *, t_irc_channel *, int, char **);
extern int weechat_cmd_dcc (t_irc_server *, t_irc_channel *, char *);
extern int weechat_cmd_debug (t_irc_server *, t_irc_channel *, int, char **);
extern int weechat_cmd_disconnect (t_irc_server *, t_irc_channel *, int, char **);
extern int weechat_cmd_help (t_irc_server *, t_irc_channel *, int, char **);
extern int weechat_cmd_history (t_irc_server *, t_irc_channel *, int, char **);
extern void weechat_cmd_ignore_display (char *, t_irc_ignore *);
extern int weechat_cmd_ignore (t_gui_window *, int, char **);
extern int weechat_cmd_key (t_gui_window *, char *);
extern int weechat_cmd_plugin (t_gui_window *, int, char **);
extern int weechat_cmd_save (t_gui_window *, int, char **);
extern int weechat_cmd_server (t_gui_window *, int, char **);
extern int weechat_cmd_set (t_gui_window *, char *);
extern int weechat_cmd_unalias (t_gui_window *, char *);
extern int weechat_cmd_unignore (t_gui_window *, int, char **);
extern int weechat_cmd_upgrade (t_gui_window *, int, char **);
extern int weechat_cmd_uptime (t_gui_window *, int, char **);
extern int weechat_cmd_window (t_gui_window *, int, char **);
extern int weechat_cmd_ignore (t_irc_server *, t_irc_channel *, int, char **);
extern int weechat_cmd_key (t_irc_server *, t_irc_channel *, char *);
extern int weechat_cmd_plugin (t_irc_server *, t_irc_channel *, int, char **);
extern int weechat_cmd_save (t_irc_server *, t_irc_channel *, int, char **);
extern int weechat_cmd_server (t_irc_server *, t_irc_channel *, int, char **);
extern int weechat_cmd_set (t_irc_server *, t_irc_channel *, char *);
extern int weechat_cmd_setp (t_irc_server *, t_irc_channel *, char *);
extern int weechat_cmd_unalias (t_irc_server *, t_irc_channel *, char *);
extern int weechat_cmd_unignore (t_irc_server *, t_irc_channel *, int, char **);
extern int weechat_cmd_upgrade (t_irc_server *, t_irc_channel *, int, char **);
extern int weechat_cmd_uptime (t_irc_server *, t_irc_channel *, int, char **);
extern int weechat_cmd_window (t_irc_server *, t_irc_channel *, int, char **);
#endif /* command.h */
+297 -96
View File
@@ -56,6 +56,7 @@ completion_init (t_completion *completion, void *server, void *channel)
completion->position = -1;
completion->base_word = NULL;
completion->args = NULL;
completion->direction = 0;
completion->completion_list = NULL;
completion->last_completion = NULL;
@@ -107,6 +108,8 @@ void
completion_get_command_infos (t_completion *completion,
char **template, int *max_arg)
{
t_weechat_alias *ptr_alias;
char *ptr_command;
int i;
#ifdef PLUGINS
t_weechat_plugin *ptr_plugin;
@@ -116,6 +119,16 @@ completion_get_command_infos (t_completion *completion,
*template = NULL;
*max_arg = MAX_ARGS;
ptr_alias = alias_search (completion->base_command);
if (ptr_alias)
{
ptr_command = alias_get_final_command (ptr_alias);
if (!ptr_command)
return;
}
else
ptr_command = completion->base_command;
#ifdef PLUGINS
/* look for plugin command handler */
for (ptr_plugin = weechat_plugins; ptr_plugin;
@@ -126,7 +139,7 @@ completion_get_command_infos (t_completion *completion,
{
if ((ptr_handler->type == HANDLER_COMMAND)
&& (ascii_strcasecmp (ptr_handler->command,
completion->base_command) == 0))
ptr_command) == 0))
{
*template = ptr_handler->completion_template;
*max_arg = MAX_ARGS;
@@ -140,7 +153,7 @@ completion_get_command_infos (t_completion *completion,
for (i = 0; weechat_commands[i].command_name; i++)
{
if (ascii_strcasecmp (weechat_commands[i].command_name,
completion->base_command) == 0)
ptr_command) == 0)
{
*template = weechat_commands[i].completion_template;
*max_arg = weechat_commands[i].max_arg;
@@ -153,7 +166,7 @@ completion_get_command_infos (t_completion *completion,
{
if ((irc_commands[i].cmd_function_args || irc_commands[i].cmd_function_1arg)
&& (ascii_strcasecmp (irc_commands[i].command_name,
completion->base_command) == 0))
ptr_command) == 0))
{
*template = irc_commands[i].completion_template;
*max_arg = irc_commands[i].max_arg;
@@ -164,6 +177,23 @@ completion_get_command_infos (t_completion *completion,
return;
}
/*
* completion_list_add: add a word to completion word list
*/
void
completion_list_add (t_completion *completion, char *word)
{
if (!completion->base_word || !completion->base_word[0]
|| (ascii_strncasecmp (completion->base_word, word,
strlen (completion->base_word)) == 0))
{
weelist_add (&completion->completion_list,
&completion->last_completion,
word);
}
}
/*
* completion_list_add_alias: add alias to completion list
*/
@@ -175,9 +205,7 @@ completion_list_add_alias (t_completion *completion)
for (ptr_alias = weechat_alias; ptr_alias; ptr_alias = ptr_alias->next_alias)
{
weelist_add (&completion->completion_list,
&completion->last_completion,
ptr_alias->alias_name);
completion_list_add (completion, ptr_alias->alias_name);
}
}
@@ -192,9 +220,7 @@ completion_list_add_alias_cmd (t_completion *completion)
for (ptr_list = index_commands; ptr_list; ptr_list = ptr_list->next_weelist)
{
weelist_add (&completion->completion_list,
&completion->last_completion,
ptr_list->data);
completion_list_add (completion, ptr_list->data);
}
}
@@ -206,9 +232,8 @@ void
completion_list_add_channel (t_completion *completion)
{
if (completion->channel)
weelist_add (&completion->completion_list,
&completion->last_completion,
((t_irc_channel *)(completion->channel))->name);
completion_list_add (completion,
((t_irc_channel *)(completion->channel))->name);
}
/*
@@ -225,9 +250,7 @@ completion_list_add_server_channels (t_completion *completion)
for (ptr_channel = ((t_irc_server *)(completion->server))->channels;
ptr_channel; ptr_channel = ptr_channel->next_channel)
{
weelist_add (&completion->completion_list,
&completion->last_completion,
ptr_channel->name);
completion_list_add (completion, ptr_channel->name);
}
}
}
@@ -261,9 +284,7 @@ completion_list_add_plugin_cmd (t_completion *completion)
ptr_handler; ptr_handler = ptr_handler->next_handler)
{
if (ptr_handler->type == HANDLER_COMMAND)
weelist_add (&completion->completion_list,
&completion->last_completion,
ptr_handler->command);
completion_list_add (completion, ptr_handler->command);
}
}
#else
@@ -284,9 +305,7 @@ completion_list_add_irc_cmd_sent (t_completion *completion)
for (i = 0; irc_commands[i].command_name; i++)
{
if (irc_commands[i].cmd_function_args || irc_commands[i].cmd_function_1arg)
weelist_add (&completion->completion_list,
&completion->last_completion,
irc_commands[i].command_name);
completion_list_add (completion, irc_commands[i].command_name);
}
}
@@ -302,9 +321,7 @@ completion_list_add_irc_cmd_recv (t_completion *completion)
for (i = 0; irc_commands[i].command_name; i++)
{
if (irc_commands[i].recv_function)
weelist_add(&completion->completion_list,
&completion->last_completion,
irc_commands[i].command_name);
completion_list_add(completion, irc_commands[i].command_name);
}
}
@@ -319,9 +336,7 @@ completion_list_add_key_cmd (t_completion *completion)
for (i = 0; gui_key_functions[i].function_name; i++)
{
weelist_add (&completion->completion_list,
&completion->last_completion,
gui_key_functions[i].function_name);
completion_list_add (completion, gui_key_functions[i].function_name);
}
}
@@ -341,16 +356,58 @@ completion_list_add_channel_nicks (t_completion *completion)
for (ptr_nick = ((t_irc_channel *)(completion->channel))->nicks;
ptr_nick; ptr_nick = ptr_nick->next_nick)
{
weelist_add (&completion->completion_list,
&completion->last_completion,
ptr_nick->nick);
completion_list_add (completion, ptr_nick->nick);
}
}
if (((t_irc_channel *)(completion->channel))->type == CHANNEL_TYPE_PRIVATE)
if ((((t_irc_channel *)(completion->channel))->type == CHANNEL_TYPE_PRIVATE)
|| (((t_irc_channel *)(completion->channel))->type == CHANNEL_TYPE_DCC_CHAT))
{
weelist_add (&completion->completion_list,
&completion->last_completion,
((t_irc_channel *)(completion->channel))->name);
completion_list_add (completion,
((t_irc_channel *)(completion->channel))->name);
}
completion->arg_is_nick = 1;
}
}
/*
* completion_list_add_channel_nicks_hosts: add channel nicks and hosts to completion list
*/
void
completion_list_add_channel_nicks_hosts (t_completion *completion)
{
t_irc_nick *ptr_nick;
char *buf;
int length;
if (completion->channel)
{
if (((t_irc_channel *)(completion->channel))->type == CHANNEL_TYPE_CHANNEL)
{
for (ptr_nick = ((t_irc_channel *)(completion->channel))->nicks;
ptr_nick; ptr_nick = ptr_nick->next_nick)
{
completion_list_add (completion, ptr_nick->nick);
if (ptr_nick->host)
{
length = strlen (ptr_nick->nick) + 1 +
strlen (ptr_nick->host) + 1;
buf = (char *) malloc (length);
if (buf)
{
snprintf (buf, length, "%s!%s",
ptr_nick->nick, ptr_nick->host);
completion_list_add (completion, buf);
free (buf);
}
}
}
}
if ((((t_irc_channel *)(completion->channel))->type == CHANNEL_TYPE_PRIVATE)
|| (((t_irc_channel *)(completion->channel))->type == CHANNEL_TYPE_PRIVATE))
{
completion_list_add (completion,
((t_irc_channel *)(completion->channel))->name);
}
completion->arg_is_nick = 1;
}
@@ -374,9 +431,8 @@ completion_list_add_option (t_completion *completion)
{
for (j = 0; weechat_options[i][j].option_name; j++)
{
weelist_add (&completion->completion_list,
&completion->last_completion,
weechat_options[i][j].option_name);
completion_list_add (completion,
weechat_options[i][j].option_name);
}
}
}
@@ -388,13 +444,32 @@ completion_list_add_option (t_completion *completion)
snprintf (option_name, sizeof (option_name), "%s.%s",
ptr_server->name,
weechat_options[CONFIG_SECTION_SERVER][i].option_name);
weelist_add (&completion->completion_list,
&completion->last_completion,
option_name);
completion_list_add (completion, option_name);
}
}
}
/*
* completion_list_add_plugin_option: add plugin option to completion list
*/
void
completion_list_add_plugin_option (t_completion *completion)
{
#ifdef PLUGINS
t_plugin_option *ptr_option;
for (ptr_option = plugin_options; ptr_option;
ptr_option = ptr_option->next_option)
{
completion_list_add (completion, ptr_option->name);
}
#else
/* make gcc happy */
(void) completion;
#endif
}
/*
* completion_list_add_part: add part message to completion list
*/
@@ -403,9 +478,28 @@ void
completion_list_add_part (t_completion *completion)
{
if (cfg_irc_default_msg_part && cfg_irc_default_msg_part[0])
weelist_add (&completion->completion_list,
&completion->last_completion,
cfg_irc_default_msg_part);
completion_list_add (completion, cfg_irc_default_msg_part);
}
/*
* completion_list_add_plugin: add plugin name to completion list
*/
void
completion_list_add_plugin (t_completion *completion)
{
#ifdef PLUGINS
t_weechat_plugin *ptr_plugin;
for (ptr_plugin = weechat_plugins; ptr_plugin;
ptr_plugin = ptr_plugin->next_plugin)
{
completion_list_add (completion, ptr_plugin->name);
}
#else
/* make gcc happy */
(void) completion;
#endif
}
/*
@@ -416,9 +510,7 @@ void
completion_list_add_quit (t_completion *completion)
{
if (cfg_irc_default_msg_quit && cfg_irc_default_msg_quit[0])
weelist_add (&completion->completion_list,
&completion->last_completion,
cfg_irc_default_msg_quit);
completion_list_add (completion, cfg_irc_default_msg_quit);
}
/*
@@ -429,9 +521,8 @@ void
completion_list_add_server (t_completion *completion)
{
if (completion->server)
weelist_add (&completion->completion_list,
&completion->last_completion,
((t_irc_server *)(completion->server))->name);
completion_list_add (completion,
((t_irc_server *)(completion->server))->name);
}
/*
@@ -446,9 +537,7 @@ completion_list_add_servers (t_completion *completion)
for (ptr_server = irc_servers; ptr_server;
ptr_server = ptr_server->next_server)
{
weelist_add (&completion->completion_list,
&completion->last_completion,
ptr_server->name);
completion_list_add (completion, ptr_server->name);
}
}
@@ -474,9 +563,9 @@ completion_list_add_topic (t_completion *completion)
string2 = channel_iconv_decode ((t_irc_server *)(completion->server),
(t_irc_channel *)(completion->channel),
(string) ? string : ((t_irc_channel *)(completion->channel))->topic);
weelist_add (&completion->completion_list,
&completion->last_completion,
(string2) ? string2 : ((string) ? string : ((t_irc_channel *)(completion->channel))->topic));
completion_list_add (completion,
(string2) ? string2 : ((string) ?
string : ((t_irc_channel *)(completion->channel))->topic));
if (string)
free (string);
if (string2)
@@ -510,44 +599,34 @@ completion_list_add_option_value (t_completion *completion)
{
case OPTION_TYPE_BOOLEAN:
if (option_value && (*((int *)(option_value))))
weelist_add (&completion->completion_list,
&completion->last_completion,
"on");
completion_list_add (completion, "on");
else
weelist_add (&completion->completion_list,
&completion->last_completion,
"off");
completion_list_add (completion, "off");
break;
case OPTION_TYPE_INT:
snprintf (option_string, sizeof (option_string) - 1,
"%d", (option_value) ? *((int *)(option_value)) : option->default_int);
weelist_add (&completion->completion_list,
&completion->last_completion,
option_string);
completion_list_add (completion, option_string);
break;
case OPTION_TYPE_INT_WITH_STRING:
weelist_add (&completion->completion_list,
&completion->last_completion,
(option_value) ?
option->array_values[*((int *)(option_value))] :
option->array_values[option->default_int]);
completion_list_add (completion,
(option_value) ?
option->array_values[*((int *)(option_value))] :
option->array_values[option->default_int]);
break;
case OPTION_TYPE_COLOR:
weelist_add (&completion->completion_list,
&completion->last_completion,
(option_value) ?
gui_get_color_name (*((int *)(option_value))) :
option->default_string);
completion_list_add (completion,
(option_value) ?
gui_color_get_name (*((int *)(option_value))) :
option->default_string);
break;
case OPTION_TYPE_STRING:
snprintf (option_string, sizeof (option_string) - 1,
"\"%s\"",
(option_value) ?
((option_value) && (*((char **)(option_value)))) ?
*((char **)(option_value)) :
option->default_string);
weelist_add (&completion->completion_list,
&completion->last_completion,
option_string);
completion_list_add (completion, option_string);
break;
}
}
@@ -556,6 +635,36 @@ completion_list_add_option_value (t_completion *completion)
}
}
/*
* completion_list_add_plugin_option_value: add plugin option value to completion list
*/
void
completion_list_add_plugin_option_value (t_completion *completion)
{
#ifdef PLUGINS
char *pos;
t_plugin_option *ptr_option;
if (completion->args)
{
pos = strchr (completion->args, ' ');
if (pos)
pos[0] = '\0';
ptr_option = plugin_config_search_internal (completion->args);
if (ptr_option)
completion_list_add (completion, ptr_option->value);
if (pos)
pos[0] = ' ';
}
#else
/* make gcc happy */
(void) completion;
#endif
}
/*
* completion_list_add_weechat_cmd: add WeeChat commands to completion list
*/
@@ -567,9 +676,7 @@ completion_list_add_weechat_cmd (t_completion *completion)
for (i = 0; weechat_commands[i].command_name; i++)
{
weelist_add (&completion->completion_list,
&completion->last_completion,
weechat_commands[i].command_name);
completion_list_add (completion, weechat_commands[i].command_name);
}
}
@@ -643,12 +750,21 @@ completion_build_list_template (t_completion *completion, char *template)
case 'n': /* channel nicks */
completion_list_add_channel_nicks (completion);
break;
case 'N': /* channel nicks and hosts */
completion_list_add_channel_nicks_hosts (completion);
break;
case 'o': /* config option */
completion_list_add_option (completion);
break;
case 'O': /* plugin option */
completion_list_add_plugin_option (completion);
break;
case 'p': /* part message */
completion_list_add_part (completion);
break;
case 'P': /* plugin name */
completion_list_add_plugin (completion);
break;
case 'q': /* quit message */
completion_list_add_quit (completion);
break;
@@ -664,6 +780,9 @@ completion_build_list_template (t_completion *completion, char *template)
case 'v': /* value of config option */
completion_list_add_option_value (completion);
break;
case 'V': /* value of plugin option */
completion_list_add_plugin_option_value (completion);
break;
case 'w': /* WeeChat commands */
completion_list_add_weechat_cmd (completion);
break;
@@ -848,7 +967,8 @@ completion_find_context (t_completion *completion, char *buffer, int size, int p
}
if (!completion->completion_list && completion->channel &&
(((t_irc_channel *)(completion->channel))->type == CHANNEL_TYPE_PRIVATE)
((((t_irc_channel *)(completion->channel))->type == CHANNEL_TYPE_PRIVATE)
|| (((t_irc_channel *)(completion->channel))->type == CHANNEL_TYPE_DCC_CHAT))
&& (completion->context == COMPLETION_NICK))
{
/* nick completion in private (only other nick and self) */
@@ -875,20 +995,35 @@ completion_command (t_completion *completion)
length = strlen (completion->base_word) - 1;
word_found_seen = 0;
other_completion = 0;
for (ptr_weelist = index_commands; ptr_weelist; ptr_weelist = ptr_weelist->next_weelist)
if (completion->direction < 0)
ptr_weelist = last_index_command;
else
ptr_weelist = index_commands;
while (ptr_weelist)
{
if (ascii_strncasecmp (ptr_weelist->data, completion->base_word + 1, length) == 0)
{
if ((!completion->word_found) || word_found_seen)
{
completion->word_found = ptr_weelist->data;
for (ptr_weelist2 = ptr_weelist->next_weelist; ptr_weelist2;
ptr_weelist2 = ptr_weelist2->next_weelist)
if (completion->direction < 0)
ptr_weelist2 = ptr_weelist->prev_weelist;
else
ptr_weelist2 = ptr_weelist->next_weelist;
while (ptr_weelist2)
{
if (ascii_strncasecmp (ptr_weelist2->data,
completion->base_word + 1, length) == 0)
completion->base_word + 1, length) == 0)
other_completion++;
if (completion->direction < 0)
ptr_weelist2 = ptr_weelist2->prev_weelist;
else
ptr_weelist2 = ptr_weelist2->next_weelist;
}
if (other_completion == 0)
completion->position = -1;
else
@@ -901,6 +1036,11 @@ completion_command (t_completion *completion)
if (completion->word_found &&
(ascii_strcasecmp (ptr_weelist->data, completion->word_found) == 0))
word_found_seen = 1;
if (completion->direction < 0)
ptr_weelist = ptr_weelist->prev_weelist;
else
ptr_weelist = ptr_weelist->next_weelist;
}
if (completion->word_found)
{
@@ -991,8 +1131,12 @@ completion_command_arg (t_completion *completion, int nick_completion)
length = strlen (completion->base_word);
word_found_seen = 0;
other_completion = 0;
for (ptr_weelist = completion->completion_list; ptr_weelist;
ptr_weelist = ptr_weelist->next_weelist)
if (completion->direction < 0)
ptr_weelist = completion->last_completion;
else
ptr_weelist = completion->completion_list;
while (ptr_weelist)
{
if ((nick_completion && (completion_nickncmp (completion->base_word, ptr_weelist->data, length) == 0))
|| ((!nick_completion) && (ascii_strncasecmp (completion->base_word, ptr_weelist->data, length) == 0)))
@@ -1000,15 +1144,26 @@ completion_command_arg (t_completion *completion, int nick_completion)
if ((!completion->word_found) || word_found_seen)
{
completion->word_found = ptr_weelist->data;
for (ptr_weelist2 = ptr_weelist->next_weelist; ptr_weelist2;
ptr_weelist2 = ptr_weelist2->next_weelist)
if (completion->direction < 0)
ptr_weelist2 = ptr_weelist->prev_weelist;
else
ptr_weelist2 = ptr_weelist->next_weelist;
while (ptr_weelist2)
{
if ((nick_completion
&& (completion_nickncmp (completion->base_word, ptr_weelist2->data, length) == 0))
|| ((!nick_completion)
&& (ascii_strncasecmp (completion->base_word, ptr_weelist2->data, length) == 0)))
other_completion++;
if (completion->direction < 0)
ptr_weelist2 = ptr_weelist2->prev_weelist;
else
ptr_weelist2 = ptr_weelist2->next_weelist;
}
if (other_completion == 0)
completion->position = -1;
else
@@ -1021,6 +1176,11 @@ completion_command_arg (t_completion *completion, int nick_completion)
if (completion->word_found &&
(ascii_strcasecmp (ptr_weelist->data, completion->word_found) == 0))
word_found_seen = 1;
if (completion->direction < 0)
ptr_weelist = ptr_weelist->prev_weelist;
else
ptr_weelist = ptr_weelist->next_weelist;
}
if (completion->word_found)
{
@@ -1042,8 +1202,18 @@ completion_nick (t_completion *completion)
if (!completion->channel)
return;
if (((t_irc_channel *)(completion->channel))->type == CHANNEL_TYPE_PRIVATE)
if ((((t_irc_channel *)(completion->channel))->type == CHANNEL_TYPE_PRIVATE)
|| (((t_irc_channel *)(completion->channel))->type == CHANNEL_TYPE_DCC_CHAT))
{
if (!(completion->completion_list))
{
weelist_add (&completion->completion_list,
&completion->last_completion,
((t_irc_channel *)(completion->channel))->name);
weelist_add (&completion->completion_list,
&completion->last_completion,
((t_irc_server *)(completion->server))->nick);
}
completion_command_arg (completion, 1);
return;
}
@@ -1051,27 +1221,50 @@ completion_nick (t_completion *completion)
length = strlen (completion->base_word);
word_found_seen = 0;
other_completion = 0;
for (ptr_nick = ((t_irc_channel *)(completion->channel))->nicks;
ptr_nick; ptr_nick = ptr_nick->next_nick)
if (completion->direction < 0)
ptr_nick = ((t_irc_channel *)(completion->channel))->last_nick;
else
ptr_nick = ((t_irc_channel *)(completion->channel))->nicks;
while (ptr_nick)
{
if (completion_nickncmp (completion->base_word, ptr_nick->nick, length) == 0)
{
if ((!completion->word_found) || word_found_seen)
{
completion->word_found = ptr_nick->nick;
for (ptr_nick2 = ptr_nick->next_nick; ptr_nick2;
ptr_nick2 = ptr_nick2->next_nick)
if (cfg_look_nick_complete_first)
{
completion->position = -1;
return;
}
if (completion->direction < 0)
ptr_nick2 = ptr_nick->prev_nick;
else
ptr_nick2 = ptr_nick->next_nick;
while (ptr_nick2)
{
if (completion_nickncmp (completion->base_word,
ptr_nick2->nick,
length) == 0)
other_completion++;
if (completion->direction < 0)
ptr_nick2 = ptr_nick2->prev_nick;
else
ptr_nick2 = ptr_nick2->next_nick;
}
if (other_completion == 0)
completion->position = -1;
else
{
if (completion->position < 0)
completion->position = 0;
}
return;
}
other_completion++;
@@ -1079,6 +1272,11 @@ completion_nick (t_completion *completion)
if (completion->word_found &&
(ascii_strcasecmp (ptr_nick->nick, completion->word_found) == 0))
word_found_seen = 1;
if (completion->direction < 0)
ptr_nick = ptr_nick->prev_nick;
else
ptr_nick = ptr_nick->next_nick;
}
if (completion->word_found)
{
@@ -1092,10 +1290,13 @@ completion_nick (t_completion *completion)
*/
void
completion_search (t_completion *completion, char *buffer, int size, int pos)
completion_search (t_completion *completion, int direction,
char *buffer, int size, int pos)
{
char *old_word_found;
completion->direction = direction;
/* if new completion => look for base word */
if (pos != completion->position)
{
+2 -1
View File
@@ -43,6 +43,7 @@ struct t_completion
int base_word_pos; /* beggining of base word */
int position; /* position where Tab was pressed */
char *args; /* command line args (including base word) */
int direction; /* +1 = search next word, -1 = previous word */
/* for command argument completion */
t_weelist *completion_list; /* data list for completion */
@@ -57,6 +58,6 @@ struct t_completion
extern void completion_init (t_completion *, void *, void *);
extern void completion_free (t_completion *);
extern void completion_search (t_completion *, char *, int, int);
extern void completion_search (t_completion *, int, char *, int, int);
#endif /* completion.h */
+14 -15
View File
@@ -34,6 +34,7 @@
#include "weechat.h"
#include "fifo.h"
#include "command.h"
#include "log.h"
#include "weeconfig.h"
#include "../gui/gui.h"
@@ -54,7 +55,7 @@ fifo_create ()
if (cfg_irc_fifo_pipe)
{
/* build FIFO filename: "~/.weechat/weechat_fifo_" + process PID */
/* build FIFO filename: "<weechat_home>/weechat_fifo_" + process PID */
if (!weechat_fifo_filename)
{
filename_length = strlen (weechat_home) + 64;
@@ -101,20 +102,26 @@ fifo_exec (char *text)
char *pos_msg, *pos;
t_irc_server *ptr_server;
t_irc_channel *ptr_channel;
t_gui_buffer *ptr_buffer;
pos = NULL;
ptr_server = NULL;
ptr_channel = NULL;
ptr_buffer = NULL;
/* look for server/channel at beginning of text */
/* text may be: "server,channel *text" or "server *text" or "*text" */
if (text[0] == '*')
{
pos_msg = text + 1;
ptr_buffer = (gui_current_window->buffer->has_input) ? gui_current_window->buffer : gui_buffers;
ptr_server = SERVER(ptr_buffer);
if (gui_current_window->buffer->has_input)
{
ptr_server = SERVER(gui_current_window->buffer);
ptr_channel = CHANNEL(gui_current_window->buffer);
}
else
{
ptr_server = SERVER(gui_buffers);
ptr_channel = NULL;
}
}
else
{
@@ -150,7 +157,7 @@ fifo_exec (char *text)
}
if (ptr_server && pos)
{
ptr_channel = channel_search (ptr_server, pos + 1);
ptr_channel = channel_search_any (ptr_server, pos + 1);
if (!ptr_channel)
{
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
@@ -163,15 +170,7 @@ fifo_exec (char *text)
}
}
if (!ptr_buffer)
{
if (ptr_channel)
ptr_buffer = ptr_channel->buffer;
else
ptr_buffer = gui_buffers;
}
user_command (ptr_buffer, ptr_server, pos_msg);
user_command (ptr_server, ptr_channel, pos_msg, 0);
}
/*
+10
View File
@@ -73,6 +73,9 @@ void
history_buffer_add (void *buffer, char *string)
{
t_history *new_history, *ptr_history;
if (!string)
return;
if ( !((t_gui_buffer *)(buffer))->history
|| ( ((t_gui_buffer *)(buffer))->history
@@ -99,6 +102,8 @@ history_buffer_add (void *buffer, char *string)
&& (((t_gui_buffer *)(buffer))->num_history > cfg_history_max_commands))
{
ptr_history = ((t_gui_buffer *)buffer)->last_history->prev_history;
if (((t_gui_buffer *)buffer)->ptr_history == ((t_gui_buffer *)buffer)->last_history)
((t_gui_buffer *)buffer)->ptr_history = ptr_history;
((t_gui_buffer *)buffer)->last_history->prev_history->next_history = NULL;
if (((t_gui_buffer *)buffer)->last_history->text)
free (((t_gui_buffer *)buffer)->last_history->text);
@@ -119,6 +124,9 @@ history_global_add (char *string)
{
t_history *new_history, *ptr_history;
if (!string)
return;
if (!history_global
|| (history_global
&& ascii_strcasecmp (history_global->text, string) != 0))
@@ -144,6 +152,8 @@ history_global_add (char *string)
&& (num_history_global > cfg_history_max_commands))
{
ptr_history = history_global_last->prev_history;
if (history_global_ptr == history_global_last)
history_global_ptr = ptr_history;
history_global_last->prev_history->next_history = NULL;
if (history_global_last->text)
free (history_global_last->text);
+169 -122
View File
@@ -17,7 +17,7 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/* log.c: log buffers to files */
/* log.c: WeeChat log file */
#ifdef HAVE_CONFIG_H
@@ -27,151 +27,198 @@
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <stdarg.h>
#include <sys/file.h>
#include <sys/types.h>
#include <time.h>
#include "weechat.h"
#include "log.h"
#include "weeconfig.h"
#include "../gui/gui.h"
char *weechat_log_filename = NULL; /* log name (~/.weechat/weechat.log) */
FILE *weechat_log_file = NULL; /* WeeChat log file */
/*
* log_write_date: writes date to log file
* weechat_log_open: initialize log file
*/
int
weechat_log_open (char *filename, char *mode)
{
int filename_length;
/* exit if log already opened */
if (weechat_log_file)
return 0;
if (filename)
weechat_log_filename = strdup (filename);
else
{
filename_length = strlen (weechat_home) + 64;
weechat_log_filename =
(char *) malloc (filename_length * sizeof (char));
snprintf (weechat_log_filename, filename_length,
"%s/%s", weechat_home, WEECHAT_LOG_NAME);
}
weechat_log_file = fopen (weechat_log_filename, mode);
if (!weechat_log_file)
{
free (weechat_log_filename);
weechat_log_filename = NULL;
return 0;
}
#ifdef HAVE_FLOCK
if ((flock (fileno (weechat_log_file), LOCK_EX | LOCK_NB) != 0))
{
fclose (weechat_log_file);
weechat_log_file = NULL;
free (weechat_log_filename);
weechat_log_filename = NULL;
return 0;
}
#endif
return 1;
}
/*
* weechat_log_init: initialize log file
*/
void
log_write_date (t_gui_buffer *buffer)
weechat_log_init ()
{
static char buf_time[256];
if (!weechat_log_open (NULL, "w"))
{
fprintf (stderr,
_("%s unable to create/append to log file\n"
"If another WeeChat process is using this file, try to run WeeChat\n"
"with another home using \"--dir\" command line option.\n"),
WEECHAT_ERROR);
exit (1);
}
}
/*
* weechat_log_printf: write a message in WeeChat log (<weechat_home>/weechat.log)
*/
void
weechat_log_printf (char *message, ...)
{
static char buffer[4096];
char *ptr_buffer;
va_list argptr;
static time_t seconds;
struct tm *date_tmp;
if (buffer->log_file)
{
seconds = time (NULL);
date_tmp = localtime (&seconds);
if (date_tmp)
{
strftime (buf_time, sizeof (buf_time) - 1, cfg_log_timestamp, date_tmp);
fprintf (buffer->log_file, "%s ", buf_time);
fflush (buffer->log_file);
}
}
}
/*
* log_write_line: writes a line to log file
*/
void
log_write_line (t_gui_buffer *buffer, char *message)
{
char *msg_no_color;
if (buffer->log_file)
{
msg_no_color = (char *)gui_color_decode ((unsigned char *)message, 0);
log_write_date (buffer);
fprintf (buffer->log_file, "%s\n",
(msg_no_color) ? msg_no_color : message);
fflush (buffer->log_file);
if (msg_no_color)
free (msg_no_color);
}
}
/*
* log_write: writes a message to log file
*/
void
log_write (t_gui_buffer *buffer, char *message)
{
char *msg_no_color;
if (buffer->log_file)
{
msg_no_color = (char *)gui_color_decode ((unsigned char *)message, 0);
fprintf (buffer->log_file, "%s",
(msg_no_color) ? msg_no_color : message);
fflush (buffer->log_file);
if (msg_no_color)
free (msg_no_color);
}
}
/*
* log_start: starts a log
*/
void
log_start (t_gui_buffer *buffer)
{
int length;
char *ptr_home;
ptr_home = getenv ("HOME");
length = strlen (cfg_log_path) +
((cfg_log_path[0] == '~') ? strlen (ptr_home) : 0) +
64;
if (SERVER(buffer))
length += strlen (SERVER(buffer)->name);
if (CHANNEL(buffer))
length += strlen (CHANNEL(buffer)->name);
buffer->log_filename = (char *) malloc (length);
if (!buffer->log_filename)
{
weechat_log_printf (_("Not enough memory to write log file for a buffer\n"));
if (!weechat_log_file)
return;
}
if (cfg_log_path[0] == '~')
va_start (argptr, message);
vsnprintf (buffer, sizeof (buffer) - 1, message, argptr);
va_end (argptr);
/* keep only valid chars */
ptr_buffer = buffer;
while (ptr_buffer[0])
{
strcpy (buffer->log_filename, ptr_home);
strcat (buffer->log_filename, cfg_log_path + 1);
if ((ptr_buffer[0] != '\n')
&& (ptr_buffer[0] != '\r')
&& ((unsigned char)(ptr_buffer[0]) < 32))
ptr_buffer[0] = '.';
ptr_buffer++;
}
seconds = time (NULL);
date_tmp = localtime (&seconds);
if (date_tmp)
fprintf (weechat_log_file, "[%04d-%02d-%02d %02d:%02d:%02d] %s",
date_tmp->tm_year + 1900, date_tmp->tm_mon + 1, date_tmp->tm_mday,
date_tmp->tm_hour, date_tmp->tm_min, date_tmp->tm_sec,
buffer);
else
strcpy (buffer->log_filename, cfg_log_path);
if (buffer->log_filename[strlen (buffer->log_filename) - 1] != DIR_SEPARATOR_CHAR)
strcat (buffer->log_filename, DIR_SEPARATOR);
if (SERVER(buffer))
{
strcat (buffer->log_filename, SERVER(buffer)->name);
strcat (buffer->log_filename, ".");
}
if (CHANNEL(buffer))
{
strcat (buffer->log_filename, CHANNEL(buffer)->name);
strcat (buffer->log_filename, ".");
}
strcat (buffer->log_filename, "weechatlog");
buffer->log_file = fopen (buffer->log_filename, "a");
if (!buffer->log_file)
{
weechat_log_printf (_("Unable to write log file for a buffer\n"));
free (buffer->log_filename);
return;
}
log_write (buffer, _("**** Beginning of log "));
log_write_date (buffer);
log_write (buffer, "****\n");
fprintf (weechat_log_file, "%s", buffer);
fflush (weechat_log_file);
}
/*
* log_end: ends a log
* weechat_log_close: close log file
*/
void
log_end (t_gui_buffer *buffer)
weechat_log_close ()
{
if (buffer->log_file)
/* close log file */
if (weechat_log_file)
{
log_write (buffer, _("**** End of log "));
log_write_date (buffer);
log_write (buffer, "****\n");
fclose (buffer->log_file);
buffer->log_file = NULL;
#ifdef HAVE_FLOCK
flock (fileno (weechat_log_file), LOCK_UN);
#endif
fclose (weechat_log_file);
weechat_log_file = NULL;
}
/* free filename */
if (weechat_log_filename)
{
free (weechat_log_filename);
weechat_log_filename = NULL;
}
if (buffer->log_filename)
free (buffer->log_filename);
}
/*
* weechat_log_crash_rename: rename log file when crashing
*/
int
weechat_log_crash_rename ()
{
char *old_name, *new_name;
int length;
time_t time_now;
struct tm *local_time;
if (!weechat_log_filename)
return 0;
old_name = strdup (weechat_log_filename);
if (!old_name)
return 0;
weechat_log_close ();
length = strlen (weechat_home) + 128;
new_name = (char *) malloc (length);
if (new_name)
{
time_now = time (NULL);
local_time = localtime (&time_now);
snprintf (new_name, length,
"%s/weechat_crash_%04d%02d%02d_%d.log",
weechat_home,
local_time->tm_year + 1900,
local_time->tm_mon + 1,
local_time->tm_mday,
getpid());
if (rename (old_name, new_name) == 0)
{
fprintf (stderr, "*** Full crash dump was saved to %s file.\n",
new_name);
weechat_log_open (new_name, "a");
free (old_name);
free (new_name);
return 1;
}
free (new_name);
}
free (old_name);
weechat_log_open (NULL, "a");
return 0;
}
+6 -7
View File
@@ -21,13 +21,12 @@
#ifndef __WEECHAT_LOG_H
#define __WEECHAT_LOG_H 1
#include "../irc/irc.h"
#include "../gui/gui.h"
extern char *weechat_log_filename;
extern FILE *weechat_log_file;
extern void log_write_date (t_gui_buffer *);
extern void log_write_line (t_gui_buffer *, char *);
extern void log_write (t_gui_buffer *, char *);
extern void log_start (t_gui_buffer *);
extern void log_end (t_gui_buffer *);
extern void weechat_log_init ();
extern void weechat_log_close ();
extern void weechat_log_printf (char *, ...);
extern int weechat_log_crash_rename ();
#endif /* log.h */
+56 -16
View File
@@ -36,6 +36,7 @@
#include "weechat.h"
#include "session.h"
#include "log.h"
#include "../irc/irc.h"
#include "../gui/gui.h"
@@ -147,6 +148,7 @@ session_save_nick (FILE *file, t_irc_nick *nick)
rc = rc && (session_write_str (file, SESSION_NICK_NICK, nick->nick));
rc = rc && (session_write_int (file, SESSION_NICK_FLAGS, nick->flags));
rc = rc && (session_write_int (file, SESSION_NICK_COLOR, nick->color));
rc = rc && (session_write_str (file, SESSION_NICK_HOST, nick->host));
rc = rc && (session_write_id (file, SESSION_NICK_END));
return rc;
}
@@ -171,6 +173,9 @@ session_save_channel (FILE *file, t_irc_channel *channel)
rc = rc && (session_write_str (file, SESSION_CHAN_KEY, channel->key));
rc = rc && (session_write_int (file, SESSION_CHAN_NICKS_COUNT, channel->nicks_count));
rc = rc && (session_write_int (file, SESSION_CHAN_CHECKING_AWAY, channel->checking_away));
rc = rc && (session_write_str (file, SESSION_CHAN_AWAY_MESSAGE, channel->away_message));
rc = rc && (session_write_int (file, SESSION_CHAN_CYCLE, channel->cycle));
rc = rc && (session_write_int (file, SESSION_CHAN_CLOSE, channel->close));
rc = rc && (session_write_id (file, SESSION_CHAN_END));
if (!rc)
@@ -222,6 +227,7 @@ session_save_servers (FILE *file)
rc = rc && (session_write_str (file, SESSION_SERV_NICK3, ptr_server->nick3));
rc = rc && (session_write_str (file, SESSION_SERV_USERNAME, ptr_server->username));
rc = rc && (session_write_str (file, SESSION_SERV_REALNAME, ptr_server->realname));
rc = rc && (session_write_str (file, SESSION_SERV_HOSTNAME, ptr_server->hostname));
rc = rc && (session_write_str (file, SESSION_SERV_COMMAND, ptr_server->command));
rc = rc && (session_write_int (file, SESSION_SERV_COMMAND_DELAY, ptr_server->command_delay));
rc = rc && (session_write_str (file, SESSION_SERV_AUTOJOIN, ptr_server->autojoin));
@@ -248,6 +254,7 @@ session_save_servers (FILE *file)
#endif
rc = rc && (session_write_str (file, SESSION_SERV_UNTERMINATED_MESSAGE, ptr_server->unterminated_message));
rc = rc && (session_write_str (file, SESSION_SERV_NICK, ptr_server->nick));
rc = rc && (session_write_str (file, SESSION_SERV_NICK_MODES, ptr_server->nick_modes));
rc = rc && (session_write_buf (file, SESSION_SERV_RECONNECT_START, &(ptr_server->reconnect_start), sizeof (time_t)));
rc = rc && (session_write_int (file, SESSION_SERV_RECONNECT_JOIN, ptr_server->reconnect_join));
rc = rc && (session_write_int (file, SESSION_SERV_IS_AWAY, ptr_server->is_away));
@@ -361,7 +368,9 @@ session_save_line (FILE *file, t_gui_line *line)
rc = rc && (session_write_int (file, SESSION_LINE_WITH_MESSAGE, line->line_with_message));
rc = rc && (session_write_int (file, SESSION_LINE_WITH_HIGHLIGHT, line->line_with_highlight));
rc = rc && (session_write_str (file, SESSION_LINE_DATA, line->data));
rc = rc && (session_write_int (file, SESSION_LINE_OFS_AFTER_DATE, line->ofs_after_date));
rc = rc && (session_write_int (file, SESSION_LINE_OFS_AFTER_DATE, line->ofs_start_message));
rc = rc && (session_write_int (file, SESSION_LINE_OFS_START_MESSAGE, line->ofs_start_message));
rc = rc && (session_write_str (file, SESSION_LINE_NICK, line->nick));
rc = rc && (session_write_id (file, SESSION_LINE_END));
return rc;
}
@@ -385,7 +394,8 @@ session_save_buffers (FILE *file)
rc = rc && (session_write_id (file, SESSION_OBJ_BUFFER));
rc = rc && (session_write_str (file, SESSION_BUFF_SERVER, SERVER(ptr_buffer) ? SERVER(ptr_buffer)->name : NULL));
rc = rc && (session_write_str (file, SESSION_BUFF_CHANNEL, CHANNEL(ptr_buffer) ? CHANNEL(ptr_buffer)->name : NULL));
rc = rc && (session_write_int (file, SESSION_BUFF_DCC, ptr_buffer->dcc));
rc = rc && (session_write_int (file, SESSION_BUFF_TYPE, ptr_buffer->type));
rc = rc && (session_write_int (file, SESSION_BUFF_ALL_SERVERS, ptr_buffer->all_servers));
rc = rc && (session_write_id (file, SESSION_BUFF_END));
if (!rc)
@@ -464,7 +474,7 @@ session_crash (FILE *file, char *message, ...)
va_end (argptr);
fclose (file);
gui_end ();
gui_main_end ();
fprintf (stderr, "%s %s\n",
WEECHAT_ERROR, buffer);
fprintf (stderr,
@@ -473,10 +483,12 @@ session_crash (FILE *file, char *message, ...)
session_last_read_pos,
session_last_read_length);
fprintf (stderr,
_("Please send ~/.weechat/%s, ~/.weechat/%s and "
_("Please send %s/%s, %s/%s and "
"above messages to WeeChat developers for support.\n"
"Be careful, private info may be in these files.\n"),
weechat_home,
WEECHAT_LOG_NAME,
weechat_home,
WEECHAT_SESSION_NAME);
exit (EXIT_FAILURE);
}
@@ -852,6 +864,9 @@ session_load_server (FILE *file)
case SESSION_SERV_REALNAME:
rc = rc && (session_read_str (file, &(session_current_server->realname)));
break;
case SESSION_SERV_HOSTNAME:
rc = rc && (session_read_str (file, &(session_current_server->hostname)));
break;
case SESSION_SERV_COMMAND:
rc = rc && (session_read_str (file, &(session_current_server->command)));
break;
@@ -918,6 +933,9 @@ session_load_server (FILE *file)
case SESSION_SERV_NICK:
rc = rc && (session_read_str (file, &(session_current_server->nick)));
break;
case SESSION_SERV_NICK_MODES:
rc = rc && (session_read_str (file, &(session_current_server->nick_modes)));
break;
case SESSION_SERV_RECONNECT_START:
rc = rc && (session_read_buf (file, &(session_current_server->reconnect_start), sizeof (time_t)));
break;
@@ -1038,6 +1056,15 @@ session_load_channel (FILE *file)
case SESSION_CHAN_CHECKING_AWAY:
rc = rc && (session_read_int (file, &(session_current_channel->checking_away)));
break;
case SESSION_CHAN_AWAY_MESSAGE:
rc = rc && (session_read_str (file, &(session_current_channel->away_message)));
break;
case SESSION_CHAN_CYCLE:
rc = rc && (session_read_int (file, &(session_current_channel->cycle)));
break;
case SESSION_CHAN_CLOSE:
rc = rc && (session_read_int (file, &(session_current_channel->close)));
break;
default:
weechat_log_printf (_("session: warning: ignoring value from "
"channel (object id: %d)\n"));
@@ -1105,6 +1132,9 @@ session_load_nick (FILE *file)
case SESSION_NICK_COLOR:
rc = rc && (session_read_int (file, &(nick->color)));
break;
case SESSION_NICK_HOST:
rc = rc && (session_read_str (file, &(nick->host)));
break;
default:
weechat_log_printf (_("session: warning: ignoring value from "
"nick (object id: %d)\n"));
@@ -1183,7 +1213,7 @@ session_load_dcc (FILE *file)
return 0;
if (string && string[0])
{
ptr_channel = channel_search (ptr_server, string);
ptr_channel = channel_search_any (ptr_server, string);
if (!ptr_channel)
{
session_crash (file, _("channel not found for DCC"));
@@ -1328,7 +1358,7 @@ session_load_buffer (FILE *file)
{
int object_id, rc;
char *server_name, *channel_name;
int dcc;
int buffer_type;
t_irc_server *ptr_server;
t_irc_channel *ptr_channel;
@@ -1348,18 +1378,18 @@ session_load_buffer (FILE *file)
return 0;
}
/* read dcc */
if (!session_read_object (file, SESSION_BUFF_DCC, SESSION_TYPE_INT, &dcc, 0))
/* read buffer type */
if (!session_read_object (file, SESSION_BUFF_TYPE, SESSION_TYPE_INT, &buffer_type, 0))
{
session_crash (file, _("dcc flag not found for buffer"));
session_crash (file, _("buffer type not found"));
return 0;
}
/* allocate buffer */
weechat_log_printf (_("session: loading buffer (server: %s, channel: %s, dcc: %d)\n"),
weechat_log_printf (_("session: loading buffer (server: %s, channel: %s, type: %d)\n"),
(server_name) ? server_name : "-",
(channel_name) ? channel_name : "-",
dcc);
buffer_type);
ptr_server = NULL;
ptr_channel = NULL;
if (server_name)
@@ -1374,7 +1404,7 @@ session_load_buffer (FILE *file)
if (channel_name)
{
ptr_channel = channel_search (ptr_server, channel_name);
ptr_channel = channel_search_any_without_buffer (ptr_server, channel_name);
if (!ptr_channel)
{
session_crash (file, _("channel not found for buffer"));
@@ -1382,7 +1412,8 @@ session_load_buffer (FILE *file)
}
}
session_current_buffer = gui_buffer_new (gui_windows, ptr_server, ptr_channel, dcc, 1);
session_current_buffer = gui_buffer_new (gui_windows, ptr_server,
ptr_channel, buffer_type, 1);
if (!session_current_buffer)
{
session_crash (file, _("can't create new buffer"));
@@ -1407,6 +1438,9 @@ session_load_buffer (FILE *file)
{
case SESSION_BUFF_END:
return 1;
case SESSION_BUFF_ALL_SERVERS:
rc = rc && (session_read_int (file, &(session_current_buffer->all_servers)));
break;
default:
weechat_log_printf (_("session: warning: ignoring value from "
"buffer (object id: %d)\n"));
@@ -1435,7 +1469,7 @@ session_load_line (FILE *file)
}
/* allocate line */
line = gui_line_new (session_current_buffer);
line = gui_buffer_line_new (session_current_buffer);
if (!line)
{
session_crash (file, _("can't create new line"));
@@ -1478,6 +1512,12 @@ session_load_line (FILE *file)
case SESSION_LINE_OFS_AFTER_DATE:
rc = rc && (session_read_int (file, &(line->ofs_after_date)));
break;
case SESSION_LINE_OFS_START_MESSAGE:
rc = rc && (session_read_int (file, &(line->ofs_start_message)));
break;
case SESSION_LINE_NICK:
rc = rc && (session_read_str (file, &(line->nick)));
break;
default:
weechat_log_printf (_("session: warning: ignoring value from "
"line (object id: %d)\n"));
@@ -1650,8 +1690,8 @@ session_load (char *filename)
ptr_server->buffer = gui_buffers;
}
gui_switch_to_buffer (gui_windows, gui_buffers);
gui_redraw_buffer (gui_current_window->buffer);
gui_window_switch_to_buffer (gui_windows, gui_buffers);
gui_window_redraw_buffer (gui_current_window->buffer);
fclose (file);
+14 -5
View File
@@ -88,7 +88,9 @@ enum t_session_server
SESSION_SERV_LAG_NEXT_CHECK,
SESSION_SERV_CHARSET_DECODE_ISO,
SESSION_SERV_CHARSET_DECODE_UTF,
SESSION_SERV_CHARSET_ENCODE
SESSION_SERV_CHARSET_ENCODE,
SESSION_SERV_HOSTNAME,
SESSION_SERV_NICK_MODES
};
enum t_session_channel
@@ -101,7 +103,10 @@ enum t_session_channel
SESSION_CHAN_LIMIT,
SESSION_CHAN_KEY,
SESSION_CHAN_NICKS_COUNT,
SESSION_CHAN_CHECKING_AWAY
SESSION_CHAN_CHECKING_AWAY,
SESSION_CHAN_AWAY_MESSAGE,
SESSION_CHAN_CYCLE,
SESSION_CHAN_CLOSE
};
enum t_session_nick
@@ -109,7 +114,8 @@ enum t_session_nick
SESSION_NICK_END = 0,
SESSION_NICK_NICK,
SESSION_NICK_FLAGS,
SESSION_NICK_COLOR
SESSION_NICK_COLOR,
SESSION_NICK_HOST
};
enum t_session_dcc
@@ -152,7 +158,8 @@ enum t_session_buffer
SESSION_BUFF_END = 0,
SESSION_BUFF_SERVER,
SESSION_BUFF_CHANNEL,
SESSION_BUFF_DCC
SESSION_BUFF_TYPE,
SESSION_BUFF_ALL_SERVERS
};
enum t_session_line
@@ -164,7 +171,9 @@ enum t_session_line
SESSION_LINE_WITH_MESSAGE,
SESSION_LINE_WITH_HIGHLIGHT,
SESSION_LINE_DATA,
SESSION_LINE_OFS_AFTER_DATE
SESSION_LINE_OFS_AFTER_DATE,
SESSION_LINE_OFS_START_MESSAGE,
SESSION_LINE_NICK
};
enum t_session_uptime
+47 -7
View File
@@ -24,7 +24,15 @@
#include "config.h"
#endif
#include <stdlib.h>
#include <string.h>
#define __USE_XOPEN
#if defined(__OpenBSD__)
#include <utf8/wchar.h>
#else
#include <wchar.h>
#endif
#include "weechat.h"
#include "utf8.h"
@@ -62,7 +70,7 @@ utf8_init ()
int
utf8_is_valid (char *string)
{
while (string[0])
while (string && string[0])
{
/* UTF-8, 2 bytes, should be: 110vvvvv 10vvvvvv */
if (((unsigned char)(string[0]) & 0xE0) == 0xC0)
@@ -216,7 +224,7 @@ utf8_strlen (char *string)
return strlen (string);
length = 0;
while (string[0])
while (string && string[0])
{
string = utf8_next_char (string);
length++;
@@ -225,7 +233,7 @@ utf8_strlen (char *string)
}
/*
* utf8_strlen: return length of an UTF-8 string, for N bytes
* utf8_strnlen: return length of an UTF-8 string, for N bytes
*/
int
@@ -247,7 +255,7 @@ utf8_strnlen (char *string, int bytes)
start = string;
length = 0;
while (string[0] && (string - start < bytes))
while (string && string[0] && (string - start < bytes))
{
string = utf8_next_char (string);
length++;
@@ -255,6 +263,38 @@ utf8_strnlen (char *string, int bytes)
return length;
}
/*
* utf8_width_screen: return number of chars needed on screen to display UTF-8 string
*/
int
utf8_width_screen (char *string)
{
int length, num_char;
wchar_t *wstring;
if (!string)
return 0;
if (!local_utf8)
return strlen (string);
num_char = mbstowcs (NULL, string, 0) + 1;
wstring = (wchar_t *) malloc ((num_char + 1) * sizeof (wchar_t));
if (!wstring)
return utf8_strlen (string);
if (mbstowcs (wstring, string, num_char) == (size_t)(-1))
{
free (wstring);
return utf8_strlen (string);
}
length = wcswidth (wstring, num_char);
free (wstring);
return length;
}
/*
* utf8_add_offset: moves forward N chars in an UTF-8 string
*/
@@ -271,7 +311,7 @@ utf8_add_offset (char *string, int offset)
return string + offset;
count = 0;
while (string[0] && (count < offset))
while (string && string[0] && (count < offset))
{
string = utf8_next_char (string);
count++;
@@ -295,7 +335,7 @@ utf8_real_pos (char *string, int pos)
count = 0;
real_pos = 0;
while (string[0] && (count < pos))
while (string && string[0] && (count < pos))
{
next_char = utf8_next_char (string);
real_pos += (next_char - string);
@@ -321,7 +361,7 @@ utf8_pos (char *string, int real_pos)
count = 0;
limit = string + real_pos;
while (string[0] && (string < limit))
while (string && string[0] && (string < limit))
{
string = utf8_next_char (string);
count++;
+1
View File
@@ -30,6 +30,7 @@ extern char *utf8_next_char (char *);
extern int utf8_char_size (char *);
extern int utf8_strlen (char *);
extern int utf8_strnlen (char *, int);
extern int utf8_width_screen (char *);
extern char *utf8_add_offset (char *, int);
extern int utf8_real_pos (char *, int);
extern int utf8_pos (char *, int);
+213 -131
View File
@@ -42,7 +42,6 @@
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <sys/stat.h>
#include <time.h>
@@ -61,11 +60,13 @@
#endif
#include "weechat.h"
#include "weeconfig.h"
#include "backtrace.h"
#include "command.h"
#include "fifo.h"
#include "utf8.h"
#include "log.h"
#include "session.h"
#include "utf8.h"
#include "weeconfig.h"
#include "../irc/irc.h"
#include "../gui/gui.h"
@@ -74,25 +75,54 @@
#endif
char *weechat_argv0 = NULL; /* WeeChat binary file name (argv[0]) */
char *weechat_session = NULL; /* WeeChat session file (for /upgrade command) */
time_t weechat_start_time; /* WeeChat start time (used by /uptime command) */
int quit_weechat; /* = 1 if quit request from user... why ? :'( */
int sigsegv = 0; /* SIGSEGV received? */
char *weechat_home = NULL; /* WeeChat home dir. (example: /home/toto/.weechat) */
FILE *weechat_log_file = NULL; /* WeeChat log file (~/.weechat/weechat.log) */
char *weechat_argv0 = NULL; /* WeeChat binary file name (argv[0]) */
char *weechat_session = NULL; /* WeeChat session file (for /upgrade cmd) */
time_t weechat_start_time; /* WeeChat start time (used by /uptime cmd) */
int quit_weechat; /* = 1 if quit request from user... why ? :'( */
int sigsegv = 0; /* SIGSEGV received? */
char *weechat_home = NULL; /* WeeChat home dir. (default: ~/.weechat) */
char *local_charset = NULL; /* local charset, for example: ISO-8859-1, UTF-8 */
char *local_charset = NULL; /* local charset, for ex.: ISO-8859-1, UTF-8 */
int server_cmd_line; /* at least one server on WeeChat command line */
int auto_connect; /* enabled by default, can by disabled on cmd line */
int auto_load_plugins; /* enabled by default, can by disabled on cmd line */
int server_cmd_line; /* at least 1 server on WeeChat command line */
int auto_connect; /* enabled by default (cmd option to disable) */
int auto_load_plugins; /* enabled by default (cmd option to disable) */
#ifdef HAVE_GNUTLS
gnutls_certificate_credentials gnutls_xcred; /* gnutls client credentials */
#endif
/*
* ascii_tolower: locale independant string conversion to lower case
*/
void
ascii_tolower (char *string)
{
while (string && string[0])
{
if ((string[0] >= 'A') && (string[0] <= 'Z'))
string[0] += ('a' - 'A');
string++;
}
}
/*
* ascii_toupper: locale independant string conversion to upper case
*/
void
ascii_toupper (char *string)
{
while (string && string[0])
{
if ((string[0] >= 'a') && (string[0] <= 'z'))
string[0] -= ('a' - 'A');
string++;
}
}
/*
* ascii_strcasecmp: locale and case independent string comparison
*/
@@ -165,49 +195,6 @@ ascii_strncasecmp (char *string1, char *string2, int max)
return (string1[0]) ? 1 : ((string2[0]) ? -1 : 0);
}
/*
* weechat_log_printf: displays a message in WeeChat log (~/.weechat/weechat.log)
*/
void
weechat_log_printf (char *message, ...)
{
static char buffer[4096];
char *ptr_buffer;
va_list argptr;
static time_t seconds;
struct tm *date_tmp;
if (!weechat_log_file)
return;
va_start (argptr, message);
vsnprintf (buffer, sizeof (buffer) - 1, message, argptr);
va_end (argptr);
/* keep only valid chars */
ptr_buffer = buffer;
while (ptr_buffer[0])
{
if ((ptr_buffer[0] != '\n')
&& (ptr_buffer[0] != '\r')
&& ((unsigned char)(ptr_buffer[0]) < 32))
ptr_buffer[0] = '.';
ptr_buffer++;
}
seconds = time (NULL);
date_tmp = localtime (&seconds);
if (date_tmp)
fprintf (weechat_log_file, "[%04d-%02d-%02d %02d:%02d:%02d] %s",
date_tmp->tm_year + 1900, date_tmp->tm_mon + 1, date_tmp->tm_mday,
date_tmp->tm_hour, date_tmp->tm_min, date_tmp->tm_sec,
buffer);
else
fprintf (weechat_log_file, "%s", buffer);
fflush (weechat_log_file);
}
/*
* weechat_iconv: convert string to another charset
*/
@@ -262,6 +249,62 @@ weechat_iconv (char *from_code, char *to_code, char *string)
return outbuf;
}
/*
* weechat_strreplace: replace a string by new one in a string
* note: returned value has to be free() after use
*/
char *
weechat_strreplace (char *string, char *search, char *replace)
{
char *pos, *new_string;
int length1, length2, length_new, count;
if (!string || !search || !replace)
return NULL;
length1 = strlen (search);
length2 = strlen (replace);
/* count number of strings to replace */
count = 0;
pos = string;
while (pos && pos[0] && (pos = strstr (pos, search)))
{
count++;
pos += length1;
}
/* easy: no string to replace! */
if (count == 0)
return strdup (string);
/* compute needed memory for new string */
length_new = strlen (string) - (count * length1) + (count * length2) + 1;
/* allocate new string */
new_string = (char *)malloc (length_new * sizeof (char));
if (!new_string)
return strdup (string);
/* replace all occurences */
new_string[0] = '\0';
while (string && string[0])
{
pos = strstr (string, search);
if (pos)
{
strncat (new_string, string, pos - string);
strcat (new_string, replace);
pos += length1;
}
else
strcat (new_string, string);
string = pos;
}
return new_string;
}
/*
* get_timeval_diff: calculates difference between two times (return in milliseconds)
*/
@@ -300,6 +343,7 @@ weechat_display_usage (char *exec_name)
printf ("\n\n");
printf (_(" -a, --no-connect disable auto-connect to servers at startup\n"
" -c, --config display config file options\n"
" -d, --dir <path> set WeeChat home directory (default: ~/.weechat)\n"
" -f, --key-functions display WeeChat internal functions for keys\n"
" -h, --help this help\n"
" -i, --irc-commands display IRC commands\n"
@@ -320,7 +364,7 @@ weechat_display_config_options ()
{
int i, j, k;
printf (_("WeeChat configuration options (~/.weechat/weechat.rc):\n\n"));
printf (_("WeeChat configuration options (<weechat_home>/weechat.rc):\n\n"));
for (i = 0; i < CONFIG_NUMBER_SECTIONS; i++)
{
if (weechat_options[i])
@@ -477,10 +521,10 @@ weechat_display_keys ()
printf ("\n");
for (ptr_key = gui_keys; ptr_key; ptr_key = ptr_key->next_key)
{
expanded_name = gui_key_get_expanded_name (ptr_key->key);
expanded_name = gui_keyboard_get_expanded_name (ptr_key->key);
printf ("* %s => %s\n",
(expanded_name) ? expanded_name : ptr_key->key,
(ptr_key->function) ? gui_key_function_search_by_ptr (ptr_key->function) : ptr_key->command);
(ptr_key->function) ? gui_keyboard_function_search_by_ptr (ptr_key->function) : ptr_key->command);
if (expanded_name)
free (expanded_name);
}
@@ -498,6 +542,7 @@ weechat_parse_args (int argc, char *argv[])
weechat_argv0 = strdup (argv[0]);
weechat_session = NULL;
weechat_home = NULL;
server_cmd_line = 0;
auto_connect = 1;
auto_load_plugins = 1;
@@ -513,6 +558,19 @@ weechat_parse_args (int argc, char *argv[])
weechat_display_config_options ();
weechat_shutdown (EXIT_SUCCESS, 0);
}
else if ((strcmp (argv[i], "-d") == 0)
|| (strcmp (argv[i], "--dir") == 0))
{
if (i + 1 < argc)
weechat_home = strdup (argv[++i]);
else
{
fprintf (stderr,
_("%s missing argument for --dir option\n"),
WEECHAT_ERROR);
weechat_shutdown (EXIT_FAILURE, 0);
}
}
else if ((strcmp (argv[i], "-f") == 0)
|| (strcmp (argv[i], "--key-functions") == 0))
{
@@ -586,8 +644,9 @@ weechat_parse_args (int argc, char *argv[])
server_tmp.ipv6, server_tmp.ssl,
server_tmp.password, server_tmp.nick1,
server_tmp.nick2, server_tmp.nick3,
NULL, NULL, NULL, 0, server_tmp.autojoin, 1, NULL,
NULL, NULL, NULL))
NULL, NULL, NULL, NULL, 0,
server_tmp.autojoin, 1, NULL, NULL,
NULL, NULL))
fprintf (stderr, _("%s unable to create server ('%s'), ignored\n"),
WEECHAT_WARNING, argv[i]);
server_destroy (&server_tmp);
@@ -626,56 +685,86 @@ weechat_create_dir (char *directory)
}
/*
* weechat_create_home_dirs: create WeeChat directories (if not found)
* weechat_create_home_dirs: create WeeChat directories
*/
void
weechat_create_home_dirs ()
{
char *ptr_home, *dir_name;
char *ptr_home;
int dir_length;
ptr_home = getenv ("HOME");
if (!ptr_home)
{
fprintf (stderr, _("%s unable to get HOME directory\n"),
WEECHAT_ERROR);
weechat_shutdown (EXIT_FAILURE, 0);
}
dir_length = strlen (ptr_home) + 10;
weechat_home =
(char *) malloc (dir_length * sizeof (char));
if (!weechat_home)
{
fprintf (stderr, _("%s not enough memory for home directory\n"),
WEECHAT_ERROR);
weechat_shutdown (EXIT_FAILURE, 0);
ptr_home = getenv ("HOME");
if (!ptr_home)
{
fprintf (stderr, _("%s unable to get HOME directory\n"),
WEECHAT_ERROR);
weechat_shutdown (EXIT_FAILURE, 0);
}
dir_length = strlen (ptr_home) + 10;
weechat_home =
(char *) malloc (dir_length * sizeof (char));
if (!weechat_home)
{
fprintf (stderr, _("%s not enough memory for home directory\n"),
WEECHAT_ERROR);
weechat_shutdown (EXIT_FAILURE, 0);
}
snprintf (weechat_home, dir_length, "%s%s.weechat", ptr_home,
DIR_SEPARATOR);
}
snprintf (weechat_home, dir_length, "%s%s.weechat", ptr_home,
DIR_SEPARATOR);
/* create home directory "~/.weechat" ; error is fatal */
/* create home directory; error is fatal */
if (!weechat_create_dir (weechat_home))
{
fprintf (stderr, _("%s unable to create ~/.weechat directory\n"),
WEECHAT_ERROR);
fprintf (stderr, _("%s unable to create \"%s\" directory\n"),
WEECHAT_ERROR, weechat_home);
weechat_shutdown (EXIT_FAILURE, 0);
}
}
/*
* weechat_create_config_dirs: create config directories (read from config file)
*/
void
weechat_create_config_dirs ()
{
char *dir1, *dir2;
dir_length = strlen (weechat_home) + 64;
dir_name = (char *) malloc (dir_length * sizeof (char));
/* create "~/.weechat/logs" */
snprintf (dir_name, dir_length, "%s%s%s", weechat_home, DIR_SEPARATOR,
"logs");
if (!weechat_create_dir (dir_name))
/* create logs directory" */
dir1 = weechat_strreplace (cfg_log_path, "~", getenv ("HOME"));
dir2 = weechat_strreplace (dir1, "%h", weechat_home);
if (weechat_create_dir (dir2))
{
fprintf (stderr, _("%s unable to create ~/.weechat/logs directory\n"),
WEECHAT_WARNING);
if (strcmp (dir2, getenv ("HOME")) != 0)
chmod (dir2, 0700);
}
chmod (dir_name, 0700);
else
fprintf (stderr, _("%s unable to create \"%s\" directory\n"),
WEECHAT_WARNING, dir2);
if (dir1)
free (dir1);
if (dir2)
free (dir2);
free (dir_name);
/* create DCC download directory */
dir1 = weechat_strreplace (cfg_dcc_download_path, "~", getenv ("HOME"));
dir2 = weechat_strreplace (dir1, "%h", weechat_home);
if (weechat_create_dir (dir2))
{
if (strcmp (dir2, getenv ("HOME")) != 0)
chmod (dir2, 0700);
}
else
fprintf (stderr, _("%s unable to create \"%s\" directory\n"),
WEECHAT_WARNING, dir2);
if (dir1)
free (dir1);
if (dir2)
free (dir2);
}
/*
@@ -700,27 +789,6 @@ weechat_init_vars ()
#endif
}
/*
* weechat_init_log: initialize log file
*/
void
weechat_init_log ()
{
int filename_length;
char *filename;
filename_length = strlen (weechat_home) + 64;
filename =
(char *) malloc (filename_length * sizeof (char));
snprintf (filename, filename_length, "%s/" WEECHAT_LOG_NAME, weechat_home);
if ((weechat_log_file = fopen (filename, "wt")) == NULL)
fprintf (stderr,
_("%s unable to create/append to log file (~/.weechat/%s)"),
WEECHAT_WARNING, WEECHAT_LOG_NAME);
free (filename);
}
/*
* weechat_config_read: read WeeChat config file
*/
@@ -806,8 +874,7 @@ weechat_shutdown (int return_code, int crash)
fifo_remove ();
if (weechat_home)
free (weechat_home);
if (weechat_log_file)
fclose (weechat_log_file);
weechat_log_close ();
if (local_charset)
free (local_charset);
alias_free_all ();
@@ -824,7 +891,7 @@ weechat_shutdown (int return_code, int crash)
}
/*
* weechat_dump writes dump to WeeChat log file
* weechat_dump: write dump to WeeChat log file
*/
void
@@ -921,7 +988,7 @@ weechat_dump (int crash)
}
/*
* weechat_sigsegv: SIGSEGV handler: save crash log to ~/.weechat/weechat.log and exit
* weechat_sigsegv: SIGSEGV handler: save crash log to <weechat_home>/weechat.log and exit
*/
void
@@ -930,13 +997,27 @@ weechat_sigsegv ()
weechat_dump (1);
dcc_end ();
server_free_all ();
gui_end ();
gui_main_end ();
fprintf (stderr, "\n");
fprintf (stderr, "*** Very bad! WeeChat has crashed (SIGSEGV received)\n");
fprintf (stderr, "*** Full crash dump was saved to ~/.weechat/weechat.log file\n");
fprintf (stderr, "*** Please send this file to WeeChat developers.\n");
fprintf (stderr, "*** (be careful, private info may be in this file since\n");
fprintf (stderr, "*** part of chats are displayed, so remove lines if needed)\n\n");
fprintf (stderr, "*** Very bad! WeeChat is crashing (SIGSEGV received)\n");
fprintf (stderr, "*** (%s, compiled on %s %s)\n",
PACKAGE_STRING, __DATE__, __TIME__);
if (!weechat_log_crash_rename ())
fprintf (stderr, "*** Full crash dump was saved to %s/weechat.log file.\n",
weechat_home);
fprintf (stderr, "***\n");
fprintf (stderr, "*** Please help WeeChat developers to fix this bug:\n");
fprintf (stderr, "*** 1. If you have a core file, please run: gdb weechat-curses core\n");
fprintf (stderr, "*** then issue \"bt\" command and send result to developers\n");
fprintf (stderr, "*** To enable core files with bash shell: ulimit -c 10000\n");
fprintf (stderr, "*** 2. Otherwise send backtrace (below) and weechat.log\n");
fprintf (stderr, "*** (be careful, private info may be in this file since\n");
fprintf (stderr, "*** part of chats are displayed, so remove lines if needed)\n\n");
weechat_backtrace ();
/* shutdown with error code */
weechat_shutdown (EXIT_FAILURE, 1);
}
@@ -961,20 +1042,21 @@ main (int argc, char *argv[])
signal (SIGQUIT, SIG_IGN); /* ignore SIGQUIT signal */
signal (SIGPIPE, SIG_IGN); /* ignore SIGPIPE signal */
signal (SIGSEGV, weechat_sigsegv); /* crash dump when SIGSEGV received */
gui_pre_init (&argc, &argv); /* pre-initiliaze interface */
gui_main_pre_init (&argc, &argv); /* pre-initiliaze interface */
weechat_init_vars (); /* initialize some variables */
gui_key_init (); /* init keyb. (default key bindings)*/
gui_keyboard_init (); /* init keyb. (default key bindings)*/
weechat_parse_args (argc, argv); /* parse command line args */
weechat_create_home_dirs (); /* create WeeChat directories */
weechat_init_log (); /* init log file */
weechat_log_init (); /* init log file */
command_index_build (); /* build cmd index for completion */
weechat_config_read (); /* read configuration */
weechat_create_config_dirs (); /* create config directories */
utf8_init (); /* init UTF-8 in WeeChat */
gui_init (); /* init WeeChat interface */
weechat_welcome_message (); /* display WeeChat welcome message */
gui_main_init (); /* init WeeChat interface */
fifo_create (); /* FIFO pipe for remote control */
if (weechat_session)
session_load (weechat_session); /* load previous session if asked */
weechat_welcome_message (); /* display WeeChat welcome message */
#ifdef PLUGINS
plugin_init (auto_load_plugins); /* init plugin interface(s) */
#endif
@@ -992,7 +1074,7 @@ main (int argc, char *argv[])
command_index_free (); /* free commands index */
dcc_end (); /* remove all DCC */
server_free_all (); /* free all servers */
gui_end (); /* shut down WeeChat GUI */
gui_main_end (); /* shut down WeeChat GUI */
weechat_shutdown (EXIT_SUCCESS, 0); /* quit WeeChat (oh no, why?) */
return EXIT_SUCCESS; /* make gcc happy (never executed) */
+4 -3
View File
@@ -98,18 +98,19 @@ extern char *weechat_argv0;
extern time_t weechat_start_time;
extern int quit_weechat;
extern char *weechat_home;
extern FILE *weechat_log_file;
extern char *local_charset;
#ifdef HAVE_GNUTLS
extern gnutls_certificate_credentials gnutls_xcred;
#endif
extern void ascii_tolower (char *);
extern void ascii_toupper (char *);
extern int ascii_strcasecmp (char *, char *);
extern int ascii_strncasecmp (char *, char *, int);
extern void weechat_log_printf (char *, ...);
extern void weechat_dump (int);
extern char *weechat_iconv (char *, char *, char *);
extern char *weechat_strreplace (char *, char *, char *);
extern void weechat_dump (int);
extern long get_timeval_diff (struct timeval *, struct timeval *);
extern void weechat_shutdown (int, int);
+130 -47
View File
@@ -73,6 +73,8 @@ char *cfg_look_charset_decode_utf;
char *cfg_look_charset_encode;
char *cfg_look_charset_internal;
int cfg_look_one_server_buffer;
int cfg_look_scroll_amount;
int cfg_look_open_near_server;
char *cfg_look_buffer_timestamp;
int cfg_look_color_nicks_number;
int cfg_look_color_actions;
@@ -85,8 +87,17 @@ int cfg_look_nicklist_max_size;
int cfg_look_nickmode;
int cfg_look_nickmode_empty;
char *cfg_look_no_nickname;
char *cfg_look_completor;
char *cfg_look_nick_prefix;
char *cfg_look_nick_suffix;
int cfg_look_align_nick;
char *cfg_look_align_nick_values[] =
{ "none", "left", "right", NULL };
int cfg_look_align_other;
int cfg_look_align_size;
int cfg_look_align_size_max;
char *cfg_look_nick_completor;
char *cfg_look_nick_completion_ignore;
int cfg_look_nick_complete_first;
int cfg_look_infobar;
char *cfg_look_infobar_timestamp;
int cfg_look_infobar_seconds;
@@ -97,6 +108,7 @@ int cfg_look_hotlist_names_length;
int cfg_look_day_change;
char *cfg_look_day_change_timestamp;
char *cfg_look_read_marker;
char *cfg_look_input_format;
t_config_option weechat_options_look[] =
{ { "look_set_title", N_("set title for window (terminal for Curses GUI) with name and version"),
@@ -117,16 +129,16 @@ t_config_option weechat_options_look[] =
"the geekest IRC client!", NULL, NULL, &cfg_look_weechat_slogan, config_change_noop },
{ "look_charset_decode_iso", N_("ISO charset for decoding messages from server (used only if locale is UTF-8)"),
N_("ISO charset for decoding messages from server (used only if locale is UTF-8) "
"(if empty, messages are not converted if locale is UTF-8"),
"(if empty, messages are not converted if locale is UTF-8)"),
OPTION_TYPE_STRING, 0, 0, 0,
"ISO-8859-1", NULL, NULL, &cfg_look_charset_decode_iso, config_change_charset },
{ "look_charset_decode_utf", N_("UTF charset for decoding messages from server (used only if locale is not UTF-8)"),
N_("UTF charset for decoding messages from server (used only if locale is not UTF-8) "
"(if empty, messages are not converted if locale is not UTF-8"),
"(if empty, messages are not converted if locale is not UTF-8)"),
OPTION_TYPE_STRING, 0, 0, 0,
"UTF-8", NULL, NULL, &cfg_look_charset_decode_utf, config_change_charset },
{ "look_charset_encode", N_("charset for encoding messages sent to server"),
N_("charset for encoding messages sent to server, examples: UFT-8, ISO-8859-1 (if empty, messages are not converted)"),
N_("charset for encoding messages sent to server, examples: UTF-8, ISO-8859-1 (if empty, messages are not converted)"),
OPTION_TYPE_STRING, 0, 0, 0,
"", NULL, NULL, &cfg_look_charset_encode, config_change_charset },
{ "look_charset_internal", N_("forces internal WeeChat charset (should be empty in most cases)"),
@@ -137,6 +149,14 @@ t_config_option weechat_options_look[] =
N_("use same buffer for all servers"),
OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_FALSE,
NULL, NULL, &cfg_look_one_server_buffer, NULL, config_change_one_server_buffer },
{ "look_open_near_server", N_("open new channels/privates near server"),
N_("open new channels/privates near server"),
OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_FALSE,
NULL, NULL, &cfg_look_open_near_server, NULL, config_change_noop },
{ "look_scroll_amount", N_("how many lines to scroll by with scroll_up and scroll_down"),
N_("how many lines to scroll by with scroll_up and scroll_down"),
OPTION_TYPE_INT, 1, INT_MAX, 3,
NULL, NULL, &cfg_look_scroll_amount, NULL, config_change_buffer_content },
{ "look_buffer_timestamp", N_("timestamp for buffers"),
N_("timestamp for buffers"),
OPTION_TYPE_STRING, 0, 0, 0,
@@ -179,14 +199,43 @@ t_config_option weechat_options_look[] =
N_("display space if nick mode is not (half)op/voice"),
OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_FALSE,
NULL, NULL, &cfg_look_nickmode_empty, NULL, config_change_buffers },
{ "look_nick_prefix", N_("text to display before nick in chat window"),
N_("text to display before nick in chat window"),
OPTION_TYPE_STRING, 0, 0, 0,
"", NULL, NULL, &cfg_look_nick_prefix, config_change_noop },
{ "look_nick_suffix", N_("text to display after nick in chat window"),
N_("text to display after nick in chat window"),
OPTION_TYPE_STRING, 0, 0, 0,
" |", NULL, NULL, &cfg_look_nick_suffix, config_change_noop },
{ "look_align_nick", N_("nick alignment (fixed size for nicks in chat window)"),
N_("nick alignment (fixed size for nicks in chat window (none, left, right))"),
OPTION_TYPE_INT_WITH_STRING, 0, 0, 0,
"right", cfg_look_align_nick_values, &cfg_look_align_nick, NULL, config_change_noop },
{ "look_align_other", N_("alignment for other messages (not beginning with a nick)"),
N_("alignment for other messages (not beginning with a nick)"),
OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE,
NULL, NULL, &cfg_look_align_other, NULL, config_change_noop },
{ "look_align_size", N_("size for aligning nick and other messages"),
N_("size for aligning nick and other messages"),
OPTION_TYPE_INT, 8, 64, 14,
NULL, NULL, &cfg_look_align_size, NULL, config_change_noop },
{ "look_align_size_max", N_("max size for aligning nick and other messages"),
N_("max size for aligning nick and other messages (should be >= to "
"look_align_size)"),
OPTION_TYPE_INT, 8, 64, 20,
NULL, NULL, &cfg_look_align_size_max, NULL, config_change_noop },
{ "look_nick_completor", N_("the string inserted after nick completion"),
N_("the string inserted after nick completion"),
OPTION_TYPE_STRING, 0, 0, 0,
":", NULL, NULL, &cfg_look_completor, config_change_noop },
":", NULL, NULL, &cfg_look_nick_completor, config_change_noop },
{ "look_nick_completion_ignore", N_("chars ignored for nick completion"),
N_("chars ignored for nick completion"),
OPTION_TYPE_STRING, 0, 0, 0,
"[]-^", NULL, NULL, &cfg_look_nick_completion_ignore, config_change_noop },
{ "look_nick_complete_first", N_("complete only with first nick found"),
N_("complete only with first nick found"),
OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_FALSE,
NULL, NULL, &cfg_look_nick_complete_first, NULL, config_change_noop },
{ "look_infobar", N_("enable info bar"),
N_("enable info bar"),
OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE,
@@ -228,7 +277,12 @@ t_config_option weechat_options_look[] =
{ "look_read_marker", N_("use a marker on servers/channels to show first unread line"),
N_("use a marker on servers/channels to show first unread line"),
OPTION_TYPE_STRING, 0, 0, 0,
" ", NULL, NULL, &cfg_look_read_marker, config_change_read_marker},
" ", NULL, NULL, &cfg_look_read_marker, config_change_read_marker },
{ "look_input_format", N_("format for input prompt"),
N_("format for input prompt ('%c' is replaced by channel or server, "
"'%n' by nick and '%m' by nick modes)"),
OPTION_TYPE_STRING, 0, 0, 0,
"[%n(%m)] ", NULL, NULL, &cfg_look_input_format, config_change_buffer_content },
{ NULL, NULL, NULL, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL }
};
@@ -268,6 +322,7 @@ int cfg_col_infobar_delimiters;
int cfg_col_infobar_highlight;
int cfg_col_infobar_bg;
int cfg_col_input;
int cfg_col_input_server;
int cfg_col_input_channel;
int cfg_col_input_nick;
int cfg_col_input_delimiters;
@@ -442,6 +497,10 @@ t_config_option weechat_options_colors[] =
N_("color for input text"),
OPTION_TYPE_COLOR, 0, 0, 0,
"default", NULL, &cfg_col_input, NULL, &config_change_color },
{ "col_input_server", N_("color for input text (server name)"),
N_("color for input text (server name)"),
OPTION_TYPE_COLOR, 0, 0, 0,
"brown", NULL, &cfg_col_input_server, NULL, &config_change_color },
{ "col_input_channel", N_("color for input text (channel name)"),
N_("color for input text (channel name)"),
OPTION_TYPE_COLOR, 0, 0, 0,
@@ -633,9 +692,10 @@ t_config_option weechat_options_log[] =
OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_FALSE,
NULL, NULL, &cfg_log_plugin_msg, NULL, &config_change_noop },
{ "log_path", N_("path for log files"),
N_("path for WeeChat log files"),
N_("path for WeeChat log files ('%h' will be replaced by WeeChat home, "
"~/.weechat by default)"),
OPTION_TYPE_STRING, 0, 0, 0,
"~/.weechat/logs/", NULL, NULL, &cfg_log_path, &config_change_noop },
"%h/logs/", NULL, NULL, &cfg_log_path, &config_change_noop },
{ "log_timestamp", N_("timestamp for log"),
N_("timestamp for log (see man strftime for date/time specifiers)"),
OPTION_TYPE_STRING, 0, 0, 0,
@@ -650,12 +710,14 @@ t_config_option weechat_options_log[] =
/* config, irc section */
int cfg_irc_display_away;
int cfg_irc_show_away_once;
char *cfg_irc_display_away_values[] =
{ "off", "local", "channel", NULL };
char *cfg_irc_default_msg_part;
char *cfg_irc_default_msg_quit;
int cfg_irc_notice_as_pv;
int cfg_irc_away_check;
int cfg_irc_away_check_max_nicks;
int cfg_irc_lag_check;
int cfg_irc_lag_min_show;
int cfg_irc_lag_disconnect;
@@ -669,8 +731,13 @@ t_config_option weechat_options_irc[] =
N_("display message when (un)marking as away"),
OPTION_TYPE_INT_WITH_STRING, 0, 0, 0,
"off", cfg_irc_display_away_values, &cfg_irc_display_away, NULL, &config_change_noop },
{ "irc_show_away_once", N_("show remote away message only once in private"),
N_("show remote away message only once in private"),
OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE,
NULL, NULL, &cfg_irc_show_away_once, NULL, &config_change_noop },
{ "irc_default_msg_part", N_("default part message (leaving channel)"),
N_("default part message (leaving channel)"),
N_("default part message (leaving channel) ('%v' will be replaced by "
"WeeChat version in string)"),
OPTION_TYPE_STRING, 0, 0, 0,
"WeeChat %v", NULL, NULL, &cfg_irc_default_msg_part, &config_change_noop },
{ "irc_default_msg_quit", N_("default quit message"),
@@ -685,6 +752,10 @@ t_config_option weechat_options_irc[] =
N_("interval between two checks for away (in minutes, 0 = never check)"),
OPTION_TYPE_INT, 0, INT_MAX, 0,
NULL, NULL, &cfg_irc_away_check, NULL, &config_change_away_check },
{ "irc_away_check_max_nicks", N_("max number of nicks for away check"),
N_("do not check away nicks on channels with high number of nicks (0 = unlimited)"),
OPTION_TYPE_INT, 0, INT_MAX, 0,
NULL, NULL, &cfg_irc_away_check_max_nicks, NULL, &config_change_away_check },
{ "irc_lag_check", N_("interval between two checks for lag"),
N_("interval between two checks for lag (in seconds)"),
OPTION_TYPE_INT, 30, INT_MAX, 60,
@@ -764,7 +835,7 @@ t_config_option weechat_options_dcc[] =
{ "dcc_download_path", N_("path for incoming files with dcc"),
N_("path for writing incoming files with dcc (default: user home)"),
OPTION_TYPE_STRING, 0, 0, 0,
"~", NULL, NULL, &cfg_dcc_download_path, &config_change_noop },
"%h/dcc", NULL, NULL, &cfg_dcc_download_path, &config_change_noop },
{ "dcc_upload_path", N_("default path for sending files with dcc"),
N_("path for reading files when sending thru dcc (when no path is specified)"),
OPTION_TYPE_STRING, 0, 0, 0, "~",
@@ -836,9 +907,10 @@ char *cfg_plugins_extension;
t_config_option weechat_options_plugins[] =
{ { "plugins_path", N_("path for searching plugins"),
N_("path for searching plugins"),
N_("path for searching plugins ('%h' will be replaced by WeeChat home, "
"~/.weechat by default)"),
OPTION_TYPE_STRING, 0, 0, 0,
"~/.weechat/plugins", NULL, NULL, &cfg_plugins_path, &config_change_noop },
"%h/plugins", NULL, NULL, &cfg_plugins_path, &config_change_noop },
{ "plugins_autoload", N_("list of plugins to load automatically"),
N_("comma separated list of plugins to load automatically at startup, "
"\"*\" means all plugins found "
@@ -919,8 +991,13 @@ t_config_option weechat_options_server[] =
N_("real name to use on IRC server"),
OPTION_TYPE_STRING, 0, 0, 0,
"", NULL, NULL, &(cfg_server.realname), NULL },
{ "server_command", N_("first command to run when connected to server"),
N_("first command to run when connected to server"),
{ "server_hostname", N_("custom hostname/IP for server"),
N_("custom hostname/IP for server (optional, if empty local hostname is used)"),
OPTION_TYPE_STRING, 0, 0, 0,
"", NULL, NULL, &(cfg_server.hostname), NULL },
{ "server_command", N_("command(s) to run when connected to server"),
N_("command(s) to run when connected to server (many commands should be "
"separated by ';', use '\\;' for a semicolon)"),
OPTION_TYPE_STRING, 0, 0, 0,
"", NULL, NULL, &(cfg_server.command), NULL },
{ "server_command_delay", N_("delay (in seconds) after command was executed"),
@@ -1033,9 +1110,9 @@ void
config_change_title ()
{
if (cfg_look_set_title)
gui_set_window_title ();
gui_window_set_title ();
else
gui_reset_window_title ();
gui_window_reset_title ();
}
/*
@@ -1045,8 +1122,8 @@ config_change_title ()
void
config_change_buffers ()
{
gui_switch_to_buffer (gui_current_window, gui_current_window->buffer);
gui_redraw_buffer (gui_current_window->buffer);
gui_window_switch_to_buffer (gui_current_window, gui_current_window->buffer);
gui_window_redraw_buffer (gui_current_window->buffer);
}
/*
@@ -1056,7 +1133,7 @@ config_change_buffers ()
void
config_change_buffer_content ()
{
gui_redraw_buffer (gui_current_window->buffer);
gui_window_redraw_buffer (gui_current_window->buffer);
}
/*
@@ -1069,7 +1146,7 @@ config_change_read_marker ()
t_gui_window *ptr_win;
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
gui_redraw_buffer (ptr_win->buffer);
gui_window_redraw_buffer (ptr_win->buffer);
}
/*
@@ -1080,7 +1157,7 @@ void
config_change_charset ()
{
utf8_init ();
gui_redraw_buffer (gui_current_window->buffer);
gui_window_redraw_buffer (gui_current_window->buffer);
}
/*
@@ -1092,9 +1169,9 @@ void
config_change_one_server_buffer ()
{
if (cfg_look_one_server_buffer)
gui_merge_servers (gui_current_window);
gui_buffer_merge_servers (gui_current_window);
else
gui_split_server (gui_current_window);
gui_buffer_split_server (gui_current_window);
}
/*
@@ -1104,9 +1181,9 @@ config_change_one_server_buffer ()
void
config_change_color ()
{
gui_init_color_pairs ();
gui_rebuild_weechat_colors ();
gui_refresh_windows ();
gui_color_init_pairs ();
gui_color_rebuild_weechat ();
gui_window_refresh_windows ();
}
/*
@@ -1146,12 +1223,12 @@ config_change_nicks_colors ()
void
config_change_away_check ()
{
check_away = 0;
if (cfg_irc_away_check == 0)
{
/* reset away flag for all nicks/chans/servers */
server_remove_away ();
}
check_away = cfg_irc_away_check * 60;
}
/*
@@ -1205,23 +1282,23 @@ config_change_log ()
if (BUFFER_IS_SERVER(ptr_buffer))
{
if (cfg_log_auto_server && !ptr_buffer->log_file)
log_start (ptr_buffer);
gui_log_start (ptr_buffer);
else if (!cfg_log_auto_server && ptr_buffer->log_file)
log_end (ptr_buffer);
gui_log_end (ptr_buffer);
}
if (BUFFER_IS_CHANNEL(ptr_buffer))
{
if (cfg_log_auto_channel && !ptr_buffer->log_file)
log_start (ptr_buffer);
gui_log_start (ptr_buffer);
else if (!cfg_log_auto_channel && ptr_buffer->log_file)
log_end (ptr_buffer);
gui_log_end (ptr_buffer);
}
if (BUFFER_IS_PRIVATE(ptr_buffer))
{
if (cfg_log_auto_private && !ptr_buffer->log_file)
log_start (ptr_buffer);
gui_log_start (ptr_buffer);
else if (!cfg_log_auto_private && ptr_buffer->log_file)
log_end (ptr_buffer);
gui_log_end (ptr_buffer);
}
}
}
@@ -1261,7 +1338,7 @@ config_option_set_value (t_config_option *option, char *value)
*(option->ptr_int) = int_value;
break;
case OPTION_TYPE_COLOR:
if (!gui_assign_color (option->ptr_int, value))
if (!gui_color_assign (option->ptr_int, value))
return -1;
break;
case OPTION_TYPE_STRING:
@@ -1418,6 +1495,8 @@ config_get_server_option_ptr (t_irc_server *server, char *option_name)
return (void *)(&server->username);
if (ascii_strcasecmp (option_name, "server_realname") == 0)
return (void *)(&server->realname);
if (ascii_strcasecmp (option_name, "server_hostname") == 0)
return (void *)(&server->hostname);
if (ascii_strcasecmp (option_name, "server_command") == 0)
return (void *)(&server->command);
if (ascii_strcasecmp (option_name, "server_command_delay") == 0)
@@ -1495,7 +1574,7 @@ config_set_server_value (t_irc_server *server, char *option_name,
*((int *)(ptr_data)) = int_value;
break;
case OPTION_TYPE_COLOR:
if (!gui_assign_color ((int *)ptr_data, value))
if (!gui_color_assign ((int *)ptr_data, value))
return -2;
break;
case OPTION_TYPE_STRING:
@@ -1658,7 +1737,8 @@ config_allocate_server (char *filename, int line_number)
cfg_server.port, cfg_server.ipv6, cfg_server.ssl,
cfg_server.password, cfg_server.nick1, cfg_server.nick2,
cfg_server.nick3, cfg_server.username, cfg_server.realname,
cfg_server.command, cfg_server.command_delay, cfg_server.autojoin,
cfg_server.hostname, cfg_server.command,
cfg_server.command_delay, cfg_server.autojoin,
cfg_server.autorejoin, cfg_server.notify_levels,
cfg_server.charset_decode_iso, cfg_server.charset_decode_utf,
cfg_server.charset_encode))
@@ -1712,7 +1792,7 @@ config_default_values ()
int_value;
break;
case OPTION_TYPE_COLOR:
if (!gui_assign_color (
if (!gui_color_assign (
weechat_options[i][j].ptr_int,
weechat_options[i][j].default_string))
gui_printf (NULL,
@@ -1884,12 +1964,12 @@ config_read ()
if (pos[0])
{
/* bind key (overwrite any binding with same key) */
gui_key_bind (line, pos);
gui_keyboard_bind (line, pos);
}
else
{
/* unbin key if no value given */
gui_key_unbind (line);
gui_keyboard_unbind (line);
}
}
else if (section == CONFIG_SECTION_ALIAS)
@@ -1940,7 +2020,7 @@ config_read ()
{
case OPTION_TYPE_BOOLEAN:
gui_printf (NULL,
_("%s %s, line %d: invalid value for"
_("%s %s, line %d: invalid value for "
"option '%s'\n"
"Expected: boolean value: "
"'off' or 'on'\n"),
@@ -2097,10 +2177,10 @@ config_create_default ()
fprintf (file, "\n[keys]\n");
for (ptr_key = gui_keys; ptr_key; ptr_key = ptr_key->next_key)
{
expanded_name = gui_key_get_expanded_name (ptr_key->key);
expanded_name = gui_keyboard_get_expanded_name (ptr_key->key);
if (ptr_key->function)
{
function_name = gui_key_function_search_by_ptr (ptr_key->function);
function_name = gui_keyboard_function_search_by_ptr (ptr_key->function);
if (function_name)
fprintf (file, "%s = \"%s\"\n",
(expanded_name) ? expanded_name : ptr_key->key,
@@ -2137,7 +2217,7 @@ config_create_default ()
fprintf (file, "UB = \"unban\"\n");
fprintf (file, "UNIG = \"unignore\"\n");
fprintf (file, "W = \"who\"\n");
fprintf (file, "WC = \"part\"\n");
fprintf (file, "WC = \"window merge\"\n");
fprintf (file, "WI = \"whois\"\n");
fprintf (file, "WW = \"whowas\"\n");
@@ -2194,6 +2274,7 @@ config_create_default ()
fprintf (file, "server_realname = \"WeeChat default realname\"\n");
}
fprintf (file, "server_hostname = \"\"\n");
fprintf (file, "server_command = \"\"\n");
fprintf (file, "server_command_delay = 0\n");
fprintf (file, "server_autojoin = \"\"\n");
@@ -2296,7 +2377,7 @@ config_write (char *config_name)
fprintf (file, "%s = %s\n",
weechat_options[i][j].option_name,
(weechat_options[i][j].ptr_int) ?
gui_get_color_name (*weechat_options[i][j].ptr_int) :
gui_color_get_name (*weechat_options[i][j].ptr_int) :
weechat_options[i][j].default_string);
break;
case OPTION_TYPE_STRING:
@@ -2315,10 +2396,10 @@ config_write (char *config_name)
fprintf (file, "\n[keys]\n");
for (ptr_key = gui_keys; ptr_key; ptr_key = ptr_key->next_key)
{
expanded_name = gui_key_get_expanded_name (ptr_key->key);
expanded_name = gui_keyboard_get_expanded_name (ptr_key->key);
if (ptr_key->function)
{
function_name = gui_key_function_search_by_ptr (ptr_key->function);
function_name = gui_keyboard_function_search_by_ptr (ptr_key->function);
if (function_name)
fprintf (file, "%s = \"%s\"\n",
(expanded_name) ? expanded_name : ptr_key->key,
@@ -2338,7 +2419,7 @@ config_write (char *config_name)
ptr_alias = ptr_alias->next_alias)
{
fprintf (file, "%s = \"%s\"\n",
ptr_alias->alias_name, ptr_alias->alias_command + 1);
ptr_alias->alias_name, ptr_alias->alias_command);
}
/* ignore section */
@@ -2380,6 +2461,8 @@ config_write (char *config_name)
fprintf (file, "server_nick3 = \"%s\"\n", ptr_server->nick3);
fprintf (file, "server_username = \"%s\"\n", ptr_server->username);
fprintf (file, "server_realname = \"%s\"\n", ptr_server->realname);
fprintf (file, "server_hostname = \"%s\"\n",
(ptr_server->hostname) ? ptr_server->hostname : "");
fprintf (file, "server_command = \"%s\"\n",
(ptr_server->command) ? ptr_server->command : "");
fprintf (file, "server_command_delay = %d\n", ptr_server->command_delay);
+18 -1
View File
@@ -54,6 +54,10 @@
#define CFG_LOOK_NICKLIST_TOP 2
#define CFG_LOOK_NICKLIST_BOTTOM 3
#define CFG_LOOK_ALIGN_NICK_NONE 0
#define CFG_LOOK_ALIGN_NICK_LEFT 1
#define CFG_LOOK_ALIGN_NICK_RIGHT 2
#define CFG_IRC_DISPLAY_AWAY_OFF 0
#define CFG_IRC_DISPLAY_AWAY_LOCAL 1
#define CFG_IRC_DISPLAY_AWAY_CHANNEL 2
@@ -92,6 +96,8 @@ extern char *cfg_look_charset_decode_utf;
extern char *cfg_look_charset_encode;
extern char *cfg_look_charset_internal;
extern int cfg_look_one_server_buffer;
extern int cfg_look_open_near_server;
extern int cfg_look_scroll_amount;
extern char *cfg_look_buffer_timestamp;
extern int cfg_look_color_nicks_number;
extern int cfg_look_color_actions;
@@ -102,8 +108,15 @@ extern int cfg_look_nicklist_max_size;
extern int cfg_look_nickmode;
extern int cfg_look_nickmode_empty;
extern char *cfg_look_no_nickname;
extern char *cfg_look_completor;
extern char *cfg_look_nick_prefix;
extern char *cfg_look_nick_suffix;
extern int cfg_look_align_nick;
extern int cfg_look_align_other;
extern int cfg_look_align_size;
extern int cfg_look_align_size_max;
extern char *cfg_look_nick_completor;
extern char *cfg_look_nick_completion_ignore;
extern int cfg_look_nick_complete_first;
extern int cfg_look_infobar;
extern char *cfg_look_infobar_timestamp;
extern int cfg_look_infobar_seconds;
@@ -114,6 +127,7 @@ extern int cfg_look_hotlist_names_length;
extern int cfg_look_day_change;
extern char *cfg_look_day_change_timestamp;
extern char *cfg_look_read_marker;
extern char *cfg_look_input_format;
extern int cfg_col_real_white;
extern int cfg_col_separator;
@@ -149,6 +163,7 @@ extern int cfg_col_infobar_delimiters;
extern int cfg_col_infobar_highlight;
extern int cfg_col_infobar_bg;
extern int cfg_col_input;
extern int cfg_col_input_server;
extern int cfg_col_input_channel;
extern int cfg_col_input_nick;
extern int cfg_col_input_delimiters;
@@ -187,10 +202,12 @@ extern char *cfg_log_timestamp;
extern int cfg_log_hide_nickserv_pwd;
extern int cfg_irc_display_away;
extern int cfg_irc_show_away_once;
extern char *cfg_irc_default_msg_part;
extern char *cfg_irc_default_msg_quit;
extern int cfg_irc_notice_as_pv;
extern int cfg_irc_away_check;
extern int cfg_irc_away_check_max_nicks;
extern int cfg_irc_lag_check;
extern int cfg_irc_lag_min_show;
extern int cfg_irc_lag_disconnect;
+11 -2
View File
@@ -19,10 +19,19 @@ INCLUDES = -DLOCALEDIR=\"$(datadir)/locale\"
noinst_LIBRARIES = lib_weechat_gui_common.a
lib_weechat_gui_common_a_SOURCES = gui-common.c \
lib_weechat_gui_common_a_SOURCES = gui-buffer.c \
gui-common.c \
gui-action.c \
gui-keyboard.c \
gui.h
gui-log.c \
gui-window.c \
gui-panel.c \
gui.h \
gui-buffer.h \
gui-color.h \
gui-keyboard.h \
gui-panel.h \
gui-window.h
if GUI_NCURSES
curses_dir=curses
+13 -6
View File
@@ -20,8 +20,7 @@ INCLUDES = -DLOCALEDIR=\"$(datadir)/locale\"
bin_PROGRAMS = weechat-curses
if PLUGINS
weechat_curses_LDADD = ../gui-common.o ../gui-keyboard.o \
../gui-action.o \
weechat_curses_LDADD = ../lib_weechat_gui_common.a \
../../common/lib_weechat_main.a \
../../irc/lib_weechat_irc.a \
../../plugins/lib_weechat_plugins.a \
@@ -29,8 +28,7 @@ weechat_curses_LDADD = ../gui-common.o ../gui-keyboard.o \
$(NCURSES_LIBS) \
$(GNUTLS_LFLAGS)
else
weechat_curses_LDADD = ../gui-common.o ../gui-keyboard.o \
../gui-action.o \
weechat_curses_LDADD = ../lib_weechat_gui_common.a \
../../common/lib_weechat_main.a \
../../irc/lib_weechat_irc.a \
$(PLUGINS_LIBS) \
@@ -38,5 +36,14 @@ weechat_curses_LDADD = ../gui-common.o ../gui-keyboard.o \
$(GNUTLS_LFLAGS)
endif
weechat_curses_SOURCES = gui-display.c \
gui-input.c
weechat_curses_SOURCES = gui-curses-chat.c \
gui-curses-color.c \
gui-curses-infobar.c \
gui-curses-input.c \
gui-curses-keyboard.c \
gui-curses-main.c \
gui-curses-nicklist.c \
gui-curses-status.c \
gui-curses-window.c \
gui-curses-panel.c \
gui-curses.h
File diff suppressed because it is too large Load Diff
+601
View File
@@ -0,0 +1,601 @@
/*
* Copyright (c) 2003-2006 by FlashCode <flashcode@flashtux.org>
* See README for License detail, AUTHORS for developers list.
*
* 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 St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/* gui-curses-color.c: color functions for Curses GUI */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "../../common/weechat.h"
#include "../gui.h"
#include "../../common/weeconfig.h"
#include "gui-curses.h"
t_gui_color gui_weechat_colors[] =
{ { -1, 0, 0, "default" },
{ WEECHAT_COLOR_BLACK, 0, 0, "black" },
{ WEECHAT_COLOR_RED, 0, 0, "red" },
{ WEECHAT_COLOR_RED, 0, A_BOLD, "lightred" },
{ WEECHAT_COLOR_GREEN, 0, 0, "green" },
{ WEECHAT_COLOR_GREEN, 0, A_BOLD, "lightgreen" },
{ WEECHAT_COLOR_YELLOW, 0, 0, "brown" },
{ WEECHAT_COLOR_YELLOW, 0, A_BOLD, "yellow" },
{ WEECHAT_COLOR_BLUE, 0, 0, "blue" },
{ WEECHAT_COLOR_BLUE, 0, A_BOLD, "lightblue" },
{ WEECHAT_COLOR_MAGENTA, 0, 0, "magenta" },
{ WEECHAT_COLOR_MAGENTA, 0, A_BOLD, "lightmagenta" },
{ WEECHAT_COLOR_CYAN, 0, 0, "cyan" },
{ WEECHAT_COLOR_CYAN, 0, A_BOLD, "lightcyan" },
{ WEECHAT_COLOR_WHITE, 0, A_BOLD, "white" },
{ 0, 0, 0, NULL }
};
int gui_irc_colors[GUI_NUM_IRC_COLORS][2] =
{ { /* 0 */ WEECHAT_COLOR_WHITE, A_BOLD },
{ /* 1 */ WEECHAT_COLOR_BLACK, 0 },
{ /* 2 */ WEECHAT_COLOR_BLUE, 0 },
{ /* 3 */ WEECHAT_COLOR_GREEN, 0 },
{ /* 4 */ WEECHAT_COLOR_RED, A_BOLD },
{ /* 5 */ WEECHAT_COLOR_RED, 0 },
{ /* 6 */ WEECHAT_COLOR_MAGENTA, 0 },
{ /* 7 */ WEECHAT_COLOR_YELLOW, 0 },
{ /* 8 */ WEECHAT_COLOR_YELLOW, A_BOLD },
{ /* 9 */ WEECHAT_COLOR_GREEN, A_BOLD },
{ /* 10 */ WEECHAT_COLOR_CYAN, 0 },
{ /* 11 */ WEECHAT_COLOR_CYAN, A_BOLD },
{ /* 12 */ WEECHAT_COLOR_BLUE, A_BOLD },
{ /* 13 */ WEECHAT_COLOR_MAGENTA, A_BOLD },
{ /* 14 */ WEECHAT_COLOR_WHITE, 0 },
{ /* 15 */ WEECHAT_COLOR_WHITE, A_BOLD }
};
t_gui_color *gui_color[GUI_NUM_COLORS];
/*
* gui_color_assign: assign a WeeChat color (read from config)
*/
int
gui_color_assign (int *color, char *color_name)
{
int i;
/* look for curses colors in table */
i = 0;
while (gui_weechat_colors[i].string)
{
if (ascii_strcasecmp (gui_weechat_colors[i].string, color_name) == 0)
{
*color = i;
return 1;
}
i++;
}
/* color not found */
return 0;
}
/*
* gui_color_get_name: get color name
*/
char *
gui_color_get_name (int num_color)
{
return gui_weechat_colors[num_color].string;
}
/*
* gui_color_decode: parses a message (coming from IRC server),
* and according:
* - remove any color/style in message
* or:
* - change colors by codes to be compatible with
* other IRC clients
* After use, string returned has to be free()
*/
unsigned char *
gui_color_decode (unsigned char *string, int keep_colors)
{
unsigned char *out;
int out_length, out_pos;
char str_fg[3], str_bg[3];
int fg, bg, attr;
out_length = (strlen ((char *)string) * 2) + 1;
out = (unsigned char *)malloc (out_length);
if (!out)
return NULL;
out_pos = 0;
while (string[0] && (out_pos < out_length - 1))
{
switch (string[0])
{
case GUI_ATTR_BOLD_CHAR:
case GUI_ATTR_RESET_CHAR:
case GUI_ATTR_FIXED_CHAR:
case GUI_ATTR_REVERSE_CHAR:
case GUI_ATTR_REVERSE2_CHAR:
case GUI_ATTR_ITALIC_CHAR:
case GUI_ATTR_UNDERLINE_CHAR:
if (keep_colors)
out[out_pos++] = string[0];
string++;
break;
case GUI_ATTR_COLOR_CHAR:
string++;
str_fg[0] = '\0';
str_bg[0] = '\0';
if (isdigit (string[0]))
{
str_fg[0] = string[0];
str_fg[1] = '\0';
string++;
if (isdigit (string[0]))
{
str_fg[1] = string[0];
str_fg[2] = '\0';
string++;
}
}
if (string[0] == ',')
{
string++;
if (isdigit (string[0]))
{
str_bg[0] = string[0];
str_bg[1] = '\0';
string++;
if (isdigit (string[0]))
{
str_bg[1] = string[0];
str_bg[2] = '\0';
string++;
}
}
}
if (keep_colors)
{
if (!str_fg[0] && !str_bg[0])
out[out_pos++] = GUI_ATTR_COLOR_CHAR;
else
{
attr = 0;
if (str_fg[0])
{
sscanf (str_fg, "%d", &fg);
fg %= GUI_NUM_IRC_COLORS;
attr |= gui_irc_colors[fg][1];
}
if (str_bg[0])
{
sscanf (str_bg, "%d", &bg);
bg %= GUI_NUM_IRC_COLORS;
attr |= gui_irc_colors[bg][1];
}
if (attr & A_BOLD)
{
out[out_pos++] = GUI_ATTR_WEECHAT_SET_CHAR;
out[out_pos++] = GUI_ATTR_BOLD_CHAR;
}
else
{
out[out_pos++] = GUI_ATTR_WEECHAT_REMOVE_CHAR;
out[out_pos++] = GUI_ATTR_BOLD_CHAR;
}
out[out_pos++] = GUI_ATTR_COLOR_CHAR;
if (str_fg[0])
{
out[out_pos++] = (gui_irc_colors[fg][0] / 10) + '0';
out[out_pos++] = (gui_irc_colors[fg][0] % 10) + '0';
}
if (str_bg[0])
{
out[out_pos++] = ',';
out[out_pos++] = (gui_irc_colors[bg][0] / 10) + '0';
out[out_pos++] = (gui_irc_colors[bg][0] % 10) + '0';
}
}
}
break;
case GUI_ATTR_WEECHAT_COLOR_CHAR:
string++;
if (isdigit (string[0]) && isdigit (string[1]))
{
if (keep_colors)
{
out[out_pos++] = string[0];
out[out_pos++] = string[1];
}
string += 2;
}
break;
case GUI_ATTR_WEECHAT_SET_CHAR:
case GUI_ATTR_WEECHAT_REMOVE_CHAR:
string++;
if (string[0])
{
if (keep_colors)
{
out[out_pos++] = *(string - 1);
out[out_pos++] = string[0];
}
string++;
}
break;
default:
out[out_pos++] = string[0];
string++;
}
}
out[out_pos] = '\0';
return out;
}
/*
* gui_color_decode_for_user_entry: parses a message (coming from IRC server),
* and replaces colors/bold/.. by %C, %B, ..
* After use, string returned has to be free()
*/
unsigned char *
gui_color_decode_for_user_entry (unsigned char *string)
{
unsigned char *out;
int out_length, out_pos;
out_length = (strlen ((char *)string) * 2) + 1;
out = (unsigned char *)malloc (out_length);
if (!out)
return NULL;
out_pos = 0;
while (string[0] && (out_pos < out_length - 1))
{
switch (string[0])
{
case GUI_ATTR_BOLD_CHAR:
out[out_pos++] = '%';
out[out_pos++] = 'B';
string++;
break;
case GUI_ATTR_FIXED_CHAR:
string++;
break;
case GUI_ATTR_RESET_CHAR:
out[out_pos++] = '%';
out[out_pos++] = 'O';
string++;
break;
case GUI_ATTR_REVERSE_CHAR:
case GUI_ATTR_REVERSE2_CHAR:
out[out_pos++] = '%';
out[out_pos++] = 'R';
string++;
break;
case GUI_ATTR_ITALIC_CHAR:
string++;
break;
case GUI_ATTR_UNDERLINE_CHAR:
out[out_pos++] = '%';
out[out_pos++] = 'R';
string++;
break;
case GUI_ATTR_COLOR_CHAR:
out[out_pos++] = '%';
out[out_pos++] = 'C';
string++;
break;
default:
out[out_pos++] = string[0];
string++;
}
}
out[out_pos] = '\0';
return out;
}
/*
* gui_color_encode: parses a message (entered by user), and
* encode special chars (%B, %C, ..) in IRC colors
* After use, string returned has to be free()
*/
unsigned char *
gui_color_encode (unsigned char *string)
{
unsigned char *out;
int out_length, out_pos;
out_length = (strlen ((char *)string) * 2) + 1;
out = (unsigned char *)malloc (out_length);
if (!out)
return NULL;
out_pos = 0;
while (string[0] && (out_pos < out_length - 1))
{
switch (string[0])
{
case '%':
string++;
switch (string[0])
{
case '\0':
out[out_pos++] = '%';
break;
case '%': /* double '%' replaced by single '%' */
out[out_pos++] = string[0];
string++;
break;
case 'B': /* bold */
out[out_pos++] = GUI_ATTR_BOLD_CHAR;
string++;
break;
case 'C': /* color */
out[out_pos++] = GUI_ATTR_COLOR_CHAR;
string++;
if (isdigit (string[0]))
{
out[out_pos++] = string[0];
string++;
if (isdigit (string[0]))
{
out[out_pos++] = string[0];
string++;
}
}
if (string[0] == ',')
{
out[out_pos++] = ',';
string++;
if (isdigit (string[0]))
{
out[out_pos++] = string[0];
string++;
if (isdigit (string[0]))
{
out[out_pos++] = string[0];
string++;
}
}
}
break;
case 'O': /* reset */
out[out_pos++] = GUI_ATTR_RESET_CHAR;
string++;
break;
case 'R': /* reverse */
out[out_pos++] = GUI_ATTR_REVERSE_CHAR;
string++;
break;
case 'U': /* underline */
out[out_pos++] = GUI_ATTR_UNDERLINE_CHAR;
string++;
break;
default:
out[out_pos++] = '%';
out[out_pos++] = string[0];
string++;
}
break;
default:
out[out_pos++] = string[0];
string++;
}
}
out[out_pos] = '\0';
return out;
}
/*
* gui_color_build: build a WeeChat color with foreground,
* background and attributes (attributes are
* given with foreground color, with a OR)
*/
t_gui_color *
gui_color_build (int number, int foreground, int background)
{
t_gui_color *new_color;
new_color = (t_gui_color *)malloc (sizeof (t_gui_color));
if (!new_color)
return NULL;
new_color->foreground = gui_weechat_colors[foreground].foreground;
new_color->background = gui_weechat_colors[background].foreground;
new_color->attributes = gui_weechat_colors[foreground].attributes;
new_color->string = (char *)malloc (4);
if (new_color->string)
snprintf (new_color->string, 4,
"%s%02d",
GUI_ATTR_WEECHAT_COLOR_STR, number);
return new_color;
}
/*
* gui_color_get_pair: get color pair with a WeeChat color number
*/
int
gui_color_get_pair (int num_color)
{
int fg, bg;
if ((num_color < 0) || (num_color > GUI_NUM_COLORS - 1))
return WEECHAT_COLOR_WHITE;
fg = gui_color[num_color]->foreground;
bg = gui_color[num_color]->background;
if (((fg == -1) || (fg == 99))
&& ((bg == -1) || (bg == 99)))
return 63;
if ((fg == -1) || (fg == 99))
fg = WEECHAT_COLOR_WHITE;
if ((bg == -1) || (bg == 99))
bg = 0;
return (bg * 8) + fg;
}
/*
* gui_color_init_pairs: init color pairs
*/
void
gui_color_init_pairs ()
{
int i;
char shift_colors[8] = { 0, 4, 2, 6, 1, 5, 3, 7 };
if (has_colors ())
{
for (i = 1; i < 64; i++)
init_pair (i, shift_colors[i % 8], (i < 8) ? -1 : shift_colors[i / 8]);
/* disable white on white, replaced by black on white */
init_pair (63, -1, -1);
/* white on default bg is default (-1) */
if (!cfg_col_real_white)
init_pair (WEECHAT_COLOR_WHITE, -1, -1);
}
}
/*
* gui_color_init_weechat: init WeeChat colors
*/
void
gui_color_init_weechat ()
{
int i;
gui_color[COLOR_WIN_SEPARATOR] = gui_color_build (COLOR_WIN_SEPARATOR, cfg_col_separator, cfg_col_separator);
gui_color[COLOR_WIN_TITLE] = gui_color_build (COLOR_WIN_TITLE, cfg_col_title, cfg_col_title_bg);
gui_color[COLOR_WIN_CHAT] = gui_color_build (COLOR_WIN_CHAT, cfg_col_chat, cfg_col_chat_bg);
gui_color[COLOR_WIN_CHAT_TIME] = gui_color_build (COLOR_WIN_CHAT_TIME, cfg_col_chat_time, cfg_col_chat_bg);
gui_color[COLOR_WIN_CHAT_TIME_SEP] = gui_color_build (COLOR_WIN_CHAT_TIME_SEP, cfg_col_chat_time_sep, cfg_col_chat_bg);
gui_color[COLOR_WIN_CHAT_PREFIX1] = gui_color_build (COLOR_WIN_CHAT_PREFIX1, cfg_col_chat_prefix1, cfg_col_chat_bg);
gui_color[COLOR_WIN_CHAT_PREFIX2] = gui_color_build (COLOR_WIN_CHAT_PREFIX2, cfg_col_chat_prefix2, cfg_col_chat_bg);
gui_color[COLOR_WIN_CHAT_SERVER] = gui_color_build (COLOR_WIN_CHAT_SERVER, cfg_col_chat_server, cfg_col_chat_bg);
gui_color[COLOR_WIN_CHAT_JOIN] = gui_color_build (COLOR_WIN_CHAT_JOIN, cfg_col_chat_join, cfg_col_chat_bg);
gui_color[COLOR_WIN_CHAT_PART] = gui_color_build (COLOR_WIN_CHAT_PART, cfg_col_chat_part, cfg_col_chat_bg);
gui_color[COLOR_WIN_CHAT_NICK] = gui_color_build (COLOR_WIN_CHAT_NICK, cfg_col_chat_nick, cfg_col_chat_bg);
gui_color[COLOR_WIN_CHAT_HOST] = gui_color_build (COLOR_WIN_CHAT_HOST, cfg_col_chat_host, cfg_col_chat_bg);
gui_color[COLOR_WIN_CHAT_CHANNEL] = gui_color_build (COLOR_WIN_CHAT_CHANNEL, cfg_col_chat_channel, cfg_col_chat_bg);
gui_color[COLOR_WIN_CHAT_DARK] = gui_color_build (COLOR_WIN_CHAT_DARK, cfg_col_chat_dark, cfg_col_chat_bg);
gui_color[COLOR_WIN_CHAT_HIGHLIGHT] = gui_color_build (COLOR_WIN_CHAT_HIGHLIGHT, cfg_col_chat_highlight, cfg_col_chat_bg);
gui_color[COLOR_WIN_CHAT_READ_MARKER] = gui_color_build (COLOR_WIN_CHAT_READ_MARKER, cfg_col_chat_read_marker, cfg_col_chat_read_marker_bg);
gui_color[COLOR_WIN_STATUS] = gui_color_build (COLOR_WIN_STATUS, cfg_col_status, cfg_col_status_bg);
gui_color[COLOR_WIN_STATUS_DELIMITERS] = gui_color_build (COLOR_WIN_STATUS_DELIMITERS, cfg_col_status_delimiters, cfg_col_status_bg);
gui_color[COLOR_WIN_STATUS_CHANNEL] = gui_color_build (COLOR_WIN_STATUS_CHANNEL, cfg_col_status_channel, cfg_col_status_bg);
gui_color[COLOR_WIN_STATUS_DATA_MSG] = gui_color_build (COLOR_WIN_STATUS_DATA_MSG, cfg_col_status_data_msg, cfg_col_status_bg);
gui_color[COLOR_WIN_STATUS_DATA_PRIVATE] = gui_color_build (COLOR_WIN_STATUS_DATA_PRIVATE, cfg_col_status_data_private, cfg_col_status_bg);
gui_color[COLOR_WIN_STATUS_DATA_HIGHLIGHT] = gui_color_build (COLOR_WIN_STATUS_DATA_HIGHLIGHT, cfg_col_status_data_highlight, cfg_col_status_bg);
gui_color[COLOR_WIN_STATUS_DATA_OTHER] = gui_color_build (COLOR_WIN_STATUS_DATA_OTHER, cfg_col_status_data_other, cfg_col_status_bg);
gui_color[COLOR_WIN_STATUS_MORE] = gui_color_build (COLOR_WIN_STATUS_MORE, cfg_col_status_more, cfg_col_status_bg);
gui_color[COLOR_WIN_INFOBAR] = gui_color_build (COLOR_WIN_INFOBAR, cfg_col_infobar, cfg_col_infobar_bg);
gui_color[COLOR_WIN_INFOBAR_DELIMITERS] = gui_color_build (COLOR_WIN_INFOBAR_DELIMITERS, cfg_col_infobar_delimiters, cfg_col_infobar_bg);
gui_color[COLOR_WIN_INFOBAR_HIGHLIGHT] = gui_color_build (COLOR_WIN_INFOBAR_HIGHLIGHT, cfg_col_infobar_highlight, cfg_col_infobar_bg);
gui_color[COLOR_WIN_INPUT] = gui_color_build (COLOR_WIN_INPUT, cfg_col_input, cfg_col_input_bg);
gui_color[COLOR_WIN_INPUT_SERVER] = gui_color_build (COLOR_WIN_INPUT_SERVER, cfg_col_input_server, cfg_col_input_bg);
gui_color[COLOR_WIN_INPUT_CHANNEL] = gui_color_build (COLOR_WIN_INPUT_CHANNEL, cfg_col_input_channel, cfg_col_input_bg);
gui_color[COLOR_WIN_INPUT_NICK] = gui_color_build (COLOR_WIN_INPUT_NICK, cfg_col_input_nick, cfg_col_input_bg);
gui_color[COLOR_WIN_INPUT_DELIMITERS] = gui_color_build (COLOR_WIN_INPUT_DELIMITERS, cfg_col_input_delimiters, cfg_col_input_bg);
gui_color[COLOR_WIN_NICK] = gui_color_build (COLOR_WIN_NICK, cfg_col_nick, cfg_col_nick_bg);
gui_color[COLOR_WIN_NICK_AWAY] = gui_color_build (COLOR_WIN_NICK_AWAY, cfg_col_nick_away, cfg_col_nick_bg);
gui_color[COLOR_WIN_NICK_CHANOWNER] = gui_color_build (COLOR_WIN_NICK_CHANOWNER, cfg_col_nick_chanowner, cfg_col_nick_bg);
gui_color[COLOR_WIN_NICK_CHANADMIN] = gui_color_build (COLOR_WIN_NICK_CHANADMIN, cfg_col_nick_chanadmin, cfg_col_nick_bg);
gui_color[COLOR_WIN_NICK_OP] = gui_color_build (COLOR_WIN_NICK_OP, cfg_col_nick_op, cfg_col_nick_bg);
gui_color[COLOR_WIN_NICK_HALFOP] = gui_color_build (COLOR_WIN_NICK_HALFOP, cfg_col_nick_halfop, cfg_col_nick_bg);
gui_color[COLOR_WIN_NICK_VOICE] = gui_color_build (COLOR_WIN_NICK_VOICE, cfg_col_nick_voice, cfg_col_nick_bg);
gui_color[COLOR_WIN_NICK_MORE] = gui_color_build (COLOR_WIN_NICK_MORE, cfg_col_nick_more, cfg_col_nick_bg);
gui_color[COLOR_WIN_NICK_SEP] = gui_color_build (COLOR_WIN_NICK_SEP, cfg_col_nick_sep, cfg_col_nick_bg);
gui_color[COLOR_WIN_NICK_SELF] = gui_color_build (COLOR_WIN_NICK_SELF, cfg_col_nick_self, cfg_col_nick_bg);
gui_color[COLOR_WIN_NICK_PRIVATE] = gui_color_build (COLOR_WIN_NICK_PRIVATE, cfg_col_nick_private, cfg_col_nick_bg);
for (i = 0; i < COLOR_WIN_NICK_NUMBER; i++)
{
gui_color[COLOR_WIN_NICK_1 + i] = gui_color_build (COLOR_WIN_NICK_1 + i, cfg_col_nick_colors[i], cfg_col_chat_bg);
}
gui_color[COLOR_DCC_SELECTED] = gui_color_build (COLOR_DCC_SELECTED, cfg_col_dcc_selected, cfg_col_chat_bg);
gui_color[COLOR_DCC_WAITING] = gui_color_build (COLOR_DCC_WAITING, cfg_col_dcc_waiting, cfg_col_chat_bg);
gui_color[COLOR_DCC_CONNECTING] = gui_color_build (COLOR_DCC_CONNECTING, cfg_col_dcc_connecting, cfg_col_chat_bg);
gui_color[COLOR_DCC_ACTIVE] = gui_color_build (COLOR_DCC_ACTIVE, cfg_col_dcc_active, cfg_col_chat_bg);
gui_color[COLOR_DCC_DONE] = gui_color_build (COLOR_DCC_DONE, cfg_col_dcc_done, cfg_col_chat_bg);
gui_color[COLOR_DCC_FAILED] = gui_color_build (COLOR_DCC_FAILED, cfg_col_dcc_failed, cfg_col_chat_bg);
gui_color[COLOR_DCC_ABORTED] = gui_color_build (COLOR_DCC_ABORTED, cfg_col_dcc_aborted, cfg_col_chat_bg);
}
/*
* gui_color_rebuild_weechat: rebuild WeeChat colors
*/
void
gui_color_rebuild_weechat ()
{
int i;
if (has_colors ())
{
for (i = 0; i < GUI_NUM_COLORS; i++)
{
if (gui_color[i])
{
if (gui_color[i]->string)
free (gui_color[i]->string);
free (gui_color[i]);
gui_color[i] = NULL;
}
}
gui_color_init_weechat ();
}
}
/*
* gui_color_init: init GUI colors
*/
void
gui_color_init ()
{
if (has_colors ())
{
start_color ();
use_default_colors ();
}
gui_color_init_pairs ();
gui_color_init_weechat ();
}
+131
View File
@@ -0,0 +1,131 @@
/*
* Copyright (c) 2003-2006 by FlashCode <flashcode@flashtux.org>
* See README for License detail, AUTHORS for developers list.
*
* 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 St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/* gui-curses-infobar.c: infobar display functions for Curses GUI */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include <string.h>
#include "../../common/weechat.h"
#include "../gui.h"
#include "../../common/hotlist.h"
#include "../../common/weeconfig.h"
#include "gui-curses.h"
/*
* gui_infobar_draw_time: draw time in infobar window
*/
void
gui_infobar_draw_time (t_gui_buffer *buffer)
{
t_gui_window *ptr_win;
time_t time_seconds;
struct tm *local_time;
/* make gcc happy */
(void) buffer;
if (!gui_ok)
return;
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
{
time_seconds = time (NULL);
local_time = localtime (&time_seconds);
if (local_time)
{
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_infobar, COLOR_WIN_INFOBAR);
mvwprintw (GUI_CURSES(ptr_win)->win_infobar,
0, 1,
"%02d:%02d",
local_time->tm_hour, local_time->tm_min);
if (cfg_look_infobar_seconds)
wprintw (GUI_CURSES(ptr_win)->win_infobar,
":%02d",
local_time->tm_sec);
}
wnoutrefresh (GUI_CURSES(ptr_win)->win_infobar);
}
}
/*
* gui_infobar_draw: draw infobar window for a buffer
*/
void
gui_infobar_draw (t_gui_buffer *buffer, int erase)
{
t_gui_window *ptr_win;
time_t time_seconds;
struct tm *local_time;
char text_time[1024 + 1];
/* make gcc happy */
(void) buffer;
if (!gui_ok)
return;
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
{
if (erase)
gui_window_curses_clear (GUI_CURSES(ptr_win)->win_infobar, COLOR_WIN_INFOBAR);
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_infobar, COLOR_WIN_INFOBAR);
time_seconds = time (NULL);
local_time = localtime (&time_seconds);
if (local_time)
{
strftime (text_time, 1024, cfg_look_infobar_timestamp, local_time);
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_infobar, COLOR_WIN_INFOBAR_DELIMITERS);
wprintw (GUI_CURSES(ptr_win)->win_infobar, "[");
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_infobar, COLOR_WIN_INFOBAR);
wprintw (GUI_CURSES(ptr_win)->win_infobar,
"%02d:%02d",
local_time->tm_hour, local_time->tm_min);
if (cfg_look_infobar_seconds)
wprintw (GUI_CURSES(ptr_win)->win_infobar,
":%02d",
local_time->tm_sec);
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_infobar, COLOR_WIN_INFOBAR_DELIMITERS);
wprintw (GUI_CURSES(ptr_win)->win_infobar, "]");
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_infobar, COLOR_WIN_INFOBAR);
wprintw (GUI_CURSES(ptr_win)->win_infobar,
" %s", text_time);
}
if (gui_infobar)
{
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_infobar, COLOR_WIN_INFOBAR_DELIMITERS);
wprintw (GUI_CURSES(ptr_win)->win_infobar, " | ");
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_infobar, gui_infobar->color);
wprintw (GUI_CURSES(ptr_win)->win_infobar, "%s", gui_infobar->text);
}
wnoutrefresh (GUI_CURSES(ptr_win)->win_infobar);
refresh ();
}
}
+446
View File
@@ -0,0 +1,446 @@
/*
* Copyright (c) 2003-2006 by FlashCode <flashcode@flashtux.org>
* See README for License detail, AUTHORS for developers list.
*
* 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 St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/* gui-curses-input: input display functions for Curses GUI */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include "../../common/weechat.h"
#include "../gui.h"
#include "../../common/utf8.h"
#include "../../common/weeconfig.h"
#include "gui-curses.h"
#ifdef PLUGINS
#include "../../plugins/plugins.h"
#endif
/*
* gui_input_set_color: set color for an input window
*/
void
gui_input_set_color (t_gui_window *window, int irc_color)
{
int fg, bg;
fg = gui_irc_colors[irc_color][0];
bg = gui_color[COLOR_WIN_INPUT]->background;
irc_color %= GUI_NUM_IRC_COLORS;
if (gui_irc_colors[irc_color][1] & A_BOLD)
wattron (GUI_CURSES(window)->win_input, A_BOLD);
if (((fg == -1) || (fg == 99))
&& ((bg == -1) || (bg == 99)))
wattron (GUI_CURSES(window)->win_input, COLOR_PAIR(63));
else
{
if ((fg == -1) || (fg == 99))
fg = WEECHAT_COLOR_WHITE;
if ((bg == -1) || (bg == 99))
bg = 0;
wattron (GUI_CURSES(window)->win_input, COLOR_PAIR((bg * 8) + fg));
}
}
/*
* gui_input_get_prompt_length: return input prompt length (displayed on screen)
*/
int
gui_input_get_prompt_length (t_gui_window *window, char *nick)
{
char *pos, saved_char, *modes;
int char_size, length, mode_found;
length = 0;
pos = cfg_look_input_format;
while (pos && pos[0])
{
switch (pos[0])
{
case '%':
pos++;
switch (pos[0])
{
case 'c':
if (CHANNEL(window->buffer))
length += utf8_strlen (CHANNEL(window->buffer)->name);
else
{
if (SERVER(window->buffer))
length += utf8_strlen (SERVER(window->buffer)->name);
}
pos++;
break;
case 'm':
if (SERVER(window->buffer))
{
mode_found = 0;
for (modes = SERVER(window->buffer)->nick_modes;
modes && modes[0]; modes++)
{
if (modes[0] != ' ')
{
length++;
mode_found = 1;
}
}
if (mode_found)
length++;
}
pos++;
break;
case 'n':
length += utf8_strlen (nick);
pos++;
break;
default:
length++;
if (pos[0])
{
if (pos[0] == '%')
pos++;
else
{
length++;
pos += utf8_char_size (pos);
}
}
break;
}
break;
default:
char_size = utf8_char_size (pos);
saved_char = pos[char_size];
pos[char_size] = '\0';
length += utf8_width_screen (pos);
pos[char_size] = saved_char;
pos += char_size;
break;
}
}
return length;
}
/*
* gui_input_draw_prompt: display input prompt
* return: # chars displayed on screen (one UTF-8 char
* may be displayed on more than 1 char on screen)
*/
void
gui_input_draw_prompt (t_gui_window *window, char *nick)
{
char *pos, saved_char, *modes;
int char_size, mode_found;
wmove (GUI_CURSES(window)->win_input, 0, 0);
pos = cfg_look_input_format;
while (pos && pos[0])
{
switch (pos[0])
{
case '%':
pos++;
switch (pos[0])
{
case 'c':
if (CHANNEL(window->buffer))
{
gui_window_set_weechat_color (GUI_CURSES(window)->win_input,
COLOR_WIN_INPUT_CHANNEL);
wprintw (GUI_CURSES(window)->win_input, "%s",
CHANNEL(window->buffer)->name);
}
else
{
if (SERVER(window->buffer))
{
gui_window_set_weechat_color (GUI_CURSES(window)->win_input,
COLOR_WIN_INPUT_SERVER);
wprintw (GUI_CURSES(window)->win_input, "%s",
SERVER(window->buffer)->name);
}
}
pos++;
break;
case 'm':
if (SERVER(window->buffer))
{
mode_found = 0;
for (modes = SERVER(window->buffer)->nick_modes;
modes && modes[0]; modes++)
{
if (modes[0] != ' ')
mode_found = 1;
}
if (mode_found)
{
gui_window_set_weechat_color (GUI_CURSES(window)->win_input,
COLOR_WIN_INPUT);
wprintw (GUI_CURSES(window)->win_input, "+");
for (modes = SERVER(window->buffer)->nick_modes;
modes && modes[0]; modes++)
{
if (modes[0] != ' ')
wprintw (GUI_CURSES(window)->win_input, "%c",
modes[0]);
}
}
}
pos++;
break;
case 'n':
gui_window_set_weechat_color (GUI_CURSES(window)->win_input,
COLOR_WIN_INPUT_NICK);
wprintw (GUI_CURSES(window)->win_input, "%s", nick);
pos++;
break;
default:
if (pos[0])
{
char_size = utf8_char_size (pos);
saved_char = pos[char_size];
pos[char_size] = '\0';
gui_window_set_weechat_color (GUI_CURSES(window)->win_input,
COLOR_WIN_INPUT_DELIMITERS);
wprintw (GUI_CURSES(window)->win_input, "%%%s", pos);
pos[char_size] = saved_char;
pos += char_size;
}
else
{
wprintw (GUI_CURSES(window)->win_input, "%%");
pos++;
}
break;
}
break;
default:
char_size = utf8_char_size (pos);
saved_char = pos[char_size];
pos[char_size] = '\0';
gui_window_set_weechat_color (GUI_CURSES(window)->win_input,
COLOR_WIN_INPUT_DELIMITERS);
wprintw (GUI_CURSES(window)->win_input, "%s", pos);
pos[char_size] = saved_char;
pos += char_size;
break;
}
}
}
/*
* gui_input_draw_text: display text in input buffer, according to color mask
* return: offset for cursor position on screen (one UTF-8
* char may be displayed on more than 1 char on screen)
*/
int
gui_input_draw_text (t_gui_window *window, int input_width)
{
char *ptr_start, *ptr_next, saved_char;
int pos_mask, size, last_color, color, count_cursor, offset_cursor;
ptr_start = utf8_add_offset (window->buffer->input_buffer,
window->buffer->input_buffer_1st_display);
pos_mask = ptr_start - window->buffer->input_buffer;
last_color = -1;
count_cursor = window->buffer->input_buffer_pos -
window->buffer->input_buffer_1st_display;
offset_cursor = 0;
while ((input_width > 0) && ptr_start && ptr_start[0])
{
ptr_next = utf8_next_char (ptr_start);
if (ptr_next)
{
saved_char = ptr_next[0];
ptr_next[0] = '\0';
size = ptr_next - ptr_start;
if (window->buffer->input_buffer_color_mask[pos_mask] != ' ')
color = window->buffer->input_buffer_color_mask[pos_mask] - '0';
else
color = -1;
if (color != last_color)
{
if (color == -1)
gui_window_set_weechat_color (GUI_CURSES(window)->win_input, COLOR_WIN_INPUT);
else
gui_input_set_color (window, color);
}
last_color = color;
wprintw (GUI_CURSES(window)->win_input, "%s", ptr_start);
if (count_cursor > 0)
{
offset_cursor += utf8_width_screen (ptr_start);
count_cursor--;
}
ptr_next[0] = saved_char;
ptr_start = ptr_next;
pos_mask += size;
}
else
ptr_start = NULL;
input_width--;
}
return offset_cursor;
}
/*
* gui_input_draw: draw input window for a buffer
*/
void
gui_input_draw (t_gui_buffer *buffer, int erase)
{
t_gui_window *ptr_win;
char format[32];
char *ptr_nickname;
int prompt_length, display_prompt, offset_cursor;
t_irc_dcc *dcc_selected;
if (!gui_ok)
return;
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
{
if (ptr_win->buffer == buffer)
{
if (erase)
gui_window_curses_clear (GUI_CURSES(ptr_win)->win_input, COLOR_WIN_INPUT);
switch (buffer->type)
{
case BUFFER_TYPE_STANDARD:
if (buffer->has_input)
{
if (buffer->input_buffer_length == 0)
buffer->input_buffer[0] = '\0';
if (SERVER(buffer))
ptr_nickname = (SERVER(buffer)->nick) ?
SERVER(buffer)->nick : SERVER(buffer)->nick1;
else
ptr_nickname = cfg_look_no_nickname;
prompt_length = gui_input_get_prompt_length (ptr_win, ptr_nickname);
if (ptr_win->win_width - prompt_length < 3)
{
prompt_length = 0;
display_prompt = 0;
}
else
display_prompt = 1;
if (buffer->input_buffer_pos - buffer->input_buffer_1st_display + 1 >
ptr_win->win_width - prompt_length)
buffer->input_buffer_1st_display = buffer->input_buffer_pos -
(ptr_win->win_width - prompt_length) + 1;
else
{
if (buffer->input_buffer_pos < buffer->input_buffer_1st_display)
buffer->input_buffer_1st_display = buffer->input_buffer_pos;
else
{
if ((buffer->input_buffer_1st_display > 0) &&
(buffer->input_buffer_pos -
buffer->input_buffer_1st_display + 1)
< ptr_win->win_width - prompt_length)
{
buffer->input_buffer_1st_display =
buffer->input_buffer_pos -
(ptr_win->win_width - prompt_length) + 1;
if (buffer->input_buffer_1st_display < 0)
buffer->input_buffer_1st_display = 0;
}
}
}
if (display_prompt)
gui_input_draw_prompt (ptr_win, ptr_nickname);
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_input, COLOR_WIN_INPUT);
snprintf (format, 32, "%%-%ds", ptr_win->win_width - prompt_length);
offset_cursor = 0;
if (ptr_win == gui_current_window)
offset_cursor = gui_input_draw_text (ptr_win,
ptr_win->win_width - prompt_length);
else
wprintw (GUI_CURSES(ptr_win)->win_input, format, "");
wclrtoeol (GUI_CURSES(ptr_win)->win_input);
ptr_win->win_input_x = prompt_length + offset_cursor;
if (ptr_win == gui_current_window)
move (ptr_win->win_y + ptr_win->win_height - 1,
ptr_win->win_x + ptr_win->win_input_x);
}
break;
case BUFFER_TYPE_DCC:
dcc_selected = (ptr_win->dcc_selected) ? (t_irc_dcc *) ptr_win->dcc_selected : dcc_list;
wmove (GUI_CURSES(ptr_win)->win_input, 0, 0);
if (dcc_selected)
{
switch (dcc_selected->status)
{
case DCC_WAITING:
if (DCC_IS_RECV(dcc_selected->type))
wprintw (GUI_CURSES(ptr_win)->win_input, _(" [A] Accept"));
wprintw (GUI_CURSES(ptr_win)->win_input, _(" [C] Cancel"));
break;
case DCC_CONNECTING:
case DCC_ACTIVE:
wprintw (GUI_CURSES(ptr_win)->win_input, _(" [C] Cancel"));
break;
case DCC_DONE:
case DCC_FAILED:
case DCC_ABORTED:
wprintw (GUI_CURSES(ptr_win)->win_input, _(" [R] Remove"));
break;
}
}
wprintw (GUI_CURSES(ptr_win)->win_input, _(" [P] Purge old DCC"));
wprintw (GUI_CURSES(ptr_win)->win_input, _(" [Q] Close DCC view"));
wclrtoeol (GUI_CURSES(ptr_win)->win_input);
ptr_win->win_input_x = 0;
if (ptr_win == gui_current_window)
move (ptr_win->win_y + ptr_win->win_height - 1,
ptr_win->win_x);
break;
case BUFFER_TYPE_RAW_DATA:
mvwprintw (GUI_CURSES(ptr_win)->win_input, 0, 0, _(" [Q] Close raw data view"));
wclrtoeol (GUI_CURSES(ptr_win)->win_input);
ptr_win->win_input_x = 0;
if (ptr_win == gui_current_window)
move (ptr_win->win_y + ptr_win->win_height - 1,
ptr_win->win_x);
break;
}
doupdate ();
wrefresh (GUI_CURSES(ptr_win)->win_input);
refresh ();
}
}
}
+320
View File
@@ -0,0 +1,320 @@
/*
* Copyright (c) 2003-2006 by FlashCode <flashcode@flashtux.org>
* See README for License detail, AUTHORS for developers list.
*
* 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 St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/* gui-curses-keyboard.c: keyboard functions for Curses GUI */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include <string.h>
#include "../../common/weechat.h"
#include "../gui.h"
#include "../../common/utf8.h"
#include "gui-curses.h"
#ifdef PLUGINS
#include "../../plugins/plugins.h"
#endif
/*
* gui_keyboard_default_bindings: create default key bindings
*/
void
gui_keyboard_default_bindings ()
{
int i;
char key_str[32], command[32];
/* keys binded with internal functions */
gui_keyboard_bind ( /* RC */ "ctrl-M", "return");
gui_keyboard_bind ( /* RC */ "ctrl-J", "return");
gui_keyboard_bind ( /* tab */ "ctrl-I", "tab");
gui_keyboard_bind ( /* s-tab */ "meta2-Z", "tab_previous");
gui_keyboard_bind ( /* basckp */ "ctrl-H", "backspace");
gui_keyboard_bind ( /* basckp */ "ctrl-?", "backspace");
gui_keyboard_bind ( /* del */ "meta2-3~", "delete");
gui_keyboard_bind ( /* ^K */ "ctrl-K", "delete_end_line");
gui_keyboard_bind ( /* ^U */ "ctrl-U", "delete_beginning_line");
gui_keyboard_bind ( /* ^W */ "ctrl-W", "delete_previous_word");
gui_keyboard_bind ( /* ^Y */ "ctrl-Y", "clipboard_paste");
gui_keyboard_bind ( /* ^T */ "ctrl-T", "transpose_chars");
gui_keyboard_bind ( /* home */ "meta2-1~", "home");
gui_keyboard_bind ( /* home */ "meta2-H", "home");
gui_keyboard_bind ( /* home */ "meta2-7~", "home");
gui_keyboard_bind ( /* ^A */ "ctrl-A", "home");
gui_keyboard_bind ( /* end */ "meta2-4~", "end");
gui_keyboard_bind ( /* end */ "meta2-F", "end");
gui_keyboard_bind ( /* end */ "meta2-8~", "end");
gui_keyboard_bind ( /* ^E */ "ctrl-E", "end");
gui_keyboard_bind ( /* left */ "meta2-D", "left");
gui_keyboard_bind ( /* right */ "meta2-C", "right");
gui_keyboard_bind ( /* up */ "meta2-A", "up");
gui_keyboard_bind ( /* ^up */ "meta-Oa", "up_global");
gui_keyboard_bind ( /* down */ "meta2-B", "down");
gui_keyboard_bind ( /* ^down */ "meta-Ob", "down_global");
gui_keyboard_bind ( /* pgup */ "meta2-5~", "page_up");
gui_keyboard_bind ( /* pgdn */ "meta2-6~", "page_down");
gui_keyboard_bind ( /* m-pgup */ "meta-meta2-5~", "scroll_up");
gui_keyboard_bind ( /* m-pgdn */ "meta-meta2-6~", "scroll_down");
gui_keyboard_bind ( /* m-home */ "meta-meta2-1~", "scroll_top");
gui_keyboard_bind ( /* m-end */ "meta-meta2-4~", "scroll_bottom");
gui_keyboard_bind ( /* F10 */ "meta2-21~", "infobar_clear");
gui_keyboard_bind ( /* F11 */ "meta2-23~", "nick_page_up");
gui_keyboard_bind ( /* F12 */ "meta2-24~", "nick_page_down");
gui_keyboard_bind ( /* m-F11 */ "meta-meta2-23~", "nick_beginning");
gui_keyboard_bind ( /* m-F12 */ "meta-meta2-24~", "nick_end");
gui_keyboard_bind ( /* ^L */ "ctrl-L", "refresh");
gui_keyboard_bind ( /* m-a */ "meta-a", "jump_smart");
gui_keyboard_bind ( /* m-b */ "meta-b", "previous_word");
gui_keyboard_bind ( /* ^left */ "meta-Od", "previous_word");
gui_keyboard_bind ( /* m-d */ "meta-d", "delete_next_word");
gui_keyboard_bind ( /* m-f */ "meta-f", "next_word");
gui_keyboard_bind ( /* ^right */ "meta-Oc", "next_word");
gui_keyboard_bind ( /* m-h */ "meta-h", "hotlist_clear");
gui_keyboard_bind ( /* m-j,m-d */ "meta-jmeta-d", "jump_dcc");
gui_keyboard_bind ( /* m-j,m-l */ "meta-jmeta-l", "jump_last_buffer");
gui_keyboard_bind ( /* m-j,m-s */ "meta-jmeta-s", "jump_server");
gui_keyboard_bind ( /* m-j,m-x */ "meta-jmeta-x", "jump_next_server");
gui_keyboard_bind ( /* m-j,m-r */ "meta-jmeta-r", "jump_raw_data");
gui_keyboard_bind ( /* m-k */ "meta-k", "grab_key");
gui_keyboard_bind ( /* m-n */ "meta-n", "scroll_next_highlight");
gui_keyboard_bind ( /* m-p */ "meta-p", "scroll_previous_highlight");
gui_keyboard_bind ( /* m-r */ "meta-r", "delete_line");
gui_keyboard_bind ( /* m-s */ "meta-s", "switch_server");
gui_keyboard_bind ( /* m-u */ "meta-u", "scroll_unread");
/* keys binded with commands */
gui_keyboard_bind ( /* m-left */ "meta-meta2-D", "/buffer -1");
gui_keyboard_bind ( /* F5 */ "meta2-15~", "/buffer -1");
gui_keyboard_bind ( /* m-right */ "meta-meta2-C", "/buffer +1");
gui_keyboard_bind ( /* F6 */ "meta2-17~", "/buffer +1");
gui_keyboard_bind ( /* F7 */ "meta2-18~", "/window -1");
gui_keyboard_bind ( /* F8 */ "meta2-19~", "/window +1");
gui_keyboard_bind ( /* m-w,m-up */ "meta-wmeta-meta2-A", "/window up");
gui_keyboard_bind ( /* m-w,m-down */ "meta-wmeta-meta2-B", "/window down");
gui_keyboard_bind ( /* m-w,m-left */ "meta-wmeta-meta2-D", "/window left");
gui_keyboard_bind ( /* m-w,m-right */ "meta-wmeta-meta2-C", "/window right");
gui_keyboard_bind ( /* m-0 */ "meta-0", "/buffer 10");
gui_keyboard_bind ( /* m-1 */ "meta-1", "/buffer 1");
gui_keyboard_bind ( /* m-2 */ "meta-2", "/buffer 2");
gui_keyboard_bind ( /* m-3 */ "meta-3", "/buffer 3");
gui_keyboard_bind ( /* m-4 */ "meta-4", "/buffer 4");
gui_keyboard_bind ( /* m-5 */ "meta-5", "/buffer 5");
gui_keyboard_bind ( /* m-6 */ "meta-6", "/buffer 6");
gui_keyboard_bind ( /* m-7 */ "meta-7", "/buffer 7");
gui_keyboard_bind ( /* m-8 */ "meta-8", "/buffer 8");
gui_keyboard_bind ( /* m-9 */ "meta-9", "/buffer 9");
/* bind meta-j + {01..99} to switch to buffers # > 10 */
for (i = 1; i < 100; i++)
{
sprintf (key_str, "meta-j%02d", i);
sprintf (command, "/buffer %d", i);
gui_keyboard_bind (key_str, command);
}
}
/*
* gui_keyboard_grab_end: insert grabbed key in input buffer
*/
void
gui_keyboard_grab_end ()
{
char *expanded_key, *expanded_key2;
int length;
char *buffer_before_key;
/* get expanded name (for example: ^U => ctrl-u) */
expanded_key = gui_keyboard_get_expanded_name (gui_key_buffer);
if (expanded_key)
{
if (gui_current_window->buffer->has_input)
{
buffer_before_key =
(gui_current_window->buffer->input_buffer) ?
strdup (gui_current_window->buffer->input_buffer) : strdup ("");
gui_insert_string_input (gui_current_window, expanded_key, -1);
gui_current_window->buffer->input_buffer_pos += utf8_strlen (expanded_key);
gui_input_draw (gui_current_window->buffer, 1);
gui_current_window->buffer->completion.position = -1;
#ifdef PLUGINS
length = strlen (expanded_key) + 1 + 1;
expanded_key2 = (char *) malloc (length);
if (expanded_key2)
{
snprintf (expanded_key2, length, "*%s", expanded_key);
(void) plugin_keyboard_handler_exec (expanded_key2,
buffer_before_key,
gui_current_window->buffer->input_buffer);
free (expanded_key2);
}
#endif
if (buffer_before_key)
free (buffer_before_key);
}
free (expanded_key);
}
/* end grab mode */
gui_key_grab = 0;
gui_key_grab_count = 0;
gui_key_buffer[0] = '\0';
}
/*
* gui_keyboard_read: read keyboard chars
*/
void
gui_keyboard_read ()
{
int key, i, insert_ok;
char key_str[32], key_str2[33];
char *buffer_before_key;
i = 0;
/* do not loop too much here (for example when big paste was made),
to read also socket & co */
while (i < 8)
{
if (gui_key_grab && (gui_key_grab_count > 10))
gui_keyboard_grab_end ();
key = getch ();
insert_ok = 1;
if (key == ERR)
{
if (gui_key_grab && (gui_key_grab_count > 0))
gui_keyboard_grab_end ();
break;
}
if (key == KEY_RESIZE)
{
gui_window_refresh_screen ();
continue;
}
gui_last_activity_time = time (NULL);
if (key < 32)
{
insert_ok = 0;
key_str[0] = '^';
key_str[1] = (char) key + '@';
key_str[2] = '\0';
}
else if (key == 127)
{
key_str[0] = '^';
key_str[1] = '?';
key_str[2] = '\0';
}
else
{
if (local_utf8)
{
/* 1 char: 0vvvvvvv */
if (key < 0x80)
{
key_str[0] = (char) key;
key_str[1] = '\0';
}
/* 2 chars: 110vvvvv 10vvvvvv */
else if ((key & 0xE0) == 0xC0)
{
key_str[0] = (char) key;
key_str[1] = (char) (getch ());
key_str[2] = '\0';
}
/* 3 chars: 1110vvvv 10vvvvvv 10vvvvvv */
else if ((key & 0xF0) == 0xE0)
{
key_str[0] = (char) key;
key_str[1] = (char) (getch ());
key_str[2] = (char) (getch ());
key_str[3] = '\0';
}
/* 4 chars: 11110vvv 10vvvvvv 10vvvvvv 10vvvvvv */
else if ((key & 0xF8) == 0xF0)
{
key_str[0] = (char) key;
key_str[1] = (char) (getch ());
key_str[2] = (char) (getch ());
key_str[3] = (char) (getch ());
key_str[4] = '\0';
}
}
else
{
key_str[0] = (char) key;
key_str[1] = '\0';
}
}
if (strcmp (key_str, "^") == 0)
{
key_str[1] = '^';
key_str[2] = '\0';
}
/*gui_printf (gui_current_window->buffer, "gui_input_read: key = %s (%d)\n", key_str, key);*/
if ((gui_keyboard_pressed (key_str) != 0) && (insert_ok))
{
if (strcmp (key_str, "^^") == 0)
key_str[1] = '\0';
switch (gui_current_window->buffer->type)
{
case BUFFER_TYPE_STANDARD:
buffer_before_key =
(gui_current_window->buffer->input_buffer) ?
strdup (gui_current_window->buffer->input_buffer) : strdup ("");
gui_insert_string_input (gui_current_window, key_str, -1);
gui_current_window->buffer->input_buffer_pos += utf8_strlen (key_str);
gui_input_draw (gui_current_window->buffer, 0);
gui_current_window->buffer->completion.position = -1;
#ifdef PLUGINS
snprintf (key_str2, sizeof (key_str2), "*%s", key_str);
(void) plugin_keyboard_handler_exec (key_str2,
buffer_before_key,
gui_current_window->buffer->input_buffer);
#endif
break;
case BUFFER_TYPE_DCC:
gui_exec_action_dcc (gui_current_window, key_str);
break;
case BUFFER_TYPE_RAW_DATA:
gui_exec_action_raw_data (gui_current_window, key_str);
break;
}
}
i++;
}
}
+355
View File
@@ -0,0 +1,355 @@
/*
* Copyright (c) 2003-2006 by FlashCode <flashcode@flashtux.org>
* See README for License detail, AUTHORS for developers list.
*
* 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 St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/* gui-curses-main.c: main loop for Curses GUI */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <signal.h>
#include "../../common/weechat.h"
#include "../gui.h"
#include "../../common/fifo.h"
#include "../../common/utf8.h"
#include "../../common/weeconfig.h"
#include "gui-curses.h"
#ifdef PLUGINS
#include "../../plugins/plugins.h"
#endif
/*
* gui_main_loop: main loop for WeeChat with ncurses GUI
*/
void
gui_main_loop ()
{
fd_set read_fd;
static struct timeval timeout, tv;
static struct timezone tz;
t_irc_server *ptr_server;
t_gui_buffer *ptr_buffer;
int old_day, old_min, old_sec, diff;
char text_time[1024];
time_t new_time;
struct tm *local_time;
quit_weechat = 0;
new_time = time (NULL);
gui_last_activity_time = new_time;
local_time = localtime (&new_time);
old_day = local_time->tm_mday;
old_min = -1;
old_sec = -1;
check_away = 0;
while (!quit_weechat)
{
/* refresh needed ? */
if (gui_refresh_screen_needed)
gui_window_refresh_screen ();
new_time = time (NULL);
local_time = localtime (&new_time);
/* minute has changed ? => redraw infobar */
if (local_time->tm_min != old_min)
{
old_min = local_time->tm_min;
gui_infobar_draw (gui_current_window->buffer, 1);
if (cfg_look_day_change
&& (local_time->tm_mday != old_day))
{
strftime (text_time, sizeof (text_time),
cfg_look_day_change_timestamp, local_time);
gui_add_hotlist = 0;
for (ptr_buffer = gui_buffers; ptr_buffer;
ptr_buffer = ptr_buffer->next_buffer)
{
if (ptr_buffer->type == BUFFER_TYPE_STANDARD)
gui_printf_nolog_notime (ptr_buffer,
_("Day changed to %s\n"),
text_time);
}
gui_add_hotlist = 1;
}
old_day = local_time->tm_mday;
}
/* second has changed ? */
if (local_time->tm_sec != old_sec)
{
old_sec = local_time->tm_sec;
if (cfg_look_infobar_seconds)
{
gui_infobar_draw_time (gui_current_window->buffer);
wmove (GUI_CURSES(gui_current_window)->win_input,
0, gui_current_window->win_input_x);
wrefresh (GUI_CURSES(gui_current_window)->win_input);
}
/* infobar count down */
if (gui_infobar && gui_infobar->remaining_time > 0)
{
gui_infobar->remaining_time--;
if (gui_infobar->remaining_time == 0)
{
gui_infobar_remove ();
gui_infobar_draw (gui_current_window->buffer, 1);
}
}
/* away check */
if (cfg_irc_away_check != 0)
{
check_away++;
if (check_away >= (cfg_irc_away_check * 60))
{
check_away = 0;
server_check_away ();
}
}
#ifdef PLUGINS
/* call timer handlers */
plugin_timer_handler_exec ();
#endif
}
/* read keyboard */
/* on GNU/Hurd 2 select() are causing troubles with keyboard */
/* waiting for a fix, we use only one select() */
#ifndef __GNU__
FD_ZERO (&read_fd);
timeout.tv_sec = 0;
timeout.tv_usec = 8000;
FD_SET (STDIN_FILENO, &read_fd);
if (select (FD_SETSIZE, &read_fd, NULL, NULL, &timeout) > 0)
{
if (FD_ISSET (STDIN_FILENO, &read_fd))
{
gui_keyboard_read ();
}
}
#endif
/* read sockets (servers, child process when connecting, FIFO pipe) */
FD_ZERO (&read_fd);
#ifdef __GNU__
timeout.tv_sec = 0;
timeout.tv_usec = 10000;
FD_SET (STDIN_FILENO, &read_fd);
#else
timeout.tv_sec = 0;
timeout.tv_usec = 2000;
#endif
if (weechat_fifo != -1)
FD_SET (weechat_fifo, &read_fd);
for (ptr_server = irc_servers; ptr_server;
ptr_server = ptr_server->next_server)
{
/* check if reconnection is pending */
if ((!ptr_server->is_connected)
&& (ptr_server->reconnect_start > 0)
&& (new_time >= (ptr_server->reconnect_start + ptr_server->autoreconnect_delay)))
server_reconnect (ptr_server);
else
{
if (ptr_server->is_connected)
{
/* check for lag */
if ((ptr_server->lag_check_time.tv_sec == 0)
&& (new_time >= ptr_server->lag_next_check))
{
server_sendf (ptr_server, "PING %s\r\n", ptr_server->address);
gettimeofday (&(ptr_server->lag_check_time), &tz);
}
/* lag timeout => disconnect */
if ((ptr_server->lag_check_time.tv_sec != 0)
&& (cfg_irc_lag_disconnect > 0))
{
gettimeofday (&tv, &tz);
diff = (int) get_timeval_diff (&(ptr_server->lag_check_time), &tv);
if (diff / 1000 > cfg_irc_lag_disconnect * 60)
{
irc_display_prefix (ptr_server, ptr_server->buffer, PREFIX_ERROR);
gui_printf (ptr_server->buffer,
_("%s lag is high, disconnecting from server...\n"),
WEECHAT_WARNING);
server_disconnect (ptr_server, 1);
continue;
}
}
}
if (!ptr_server->is_connected && (ptr_server->child_pid > 0))
FD_SET (ptr_server->child_read, &read_fd);
else
{
if (ptr_server->sock >= 0)
FD_SET (ptr_server->sock, &read_fd);
}
}
}
if (select (FD_SETSIZE, &read_fd, NULL, NULL, &timeout) > 0)
{
#ifdef __GNU__
if (FD_ISSET (STDIN_FILENO, &read_fd))
{
gui_keyboard_read ();
}
#endif
if ((weechat_fifo != -1) && (FD_ISSET (weechat_fifo, &read_fd)))
{
fifo_read ();
}
for (ptr_server = irc_servers; ptr_server;
ptr_server = ptr_server->next_server)
{
if (!ptr_server->is_connected && (ptr_server->child_pid > 0))
{
if (FD_ISSET (ptr_server->child_read, &read_fd))
server_child_read (ptr_server);
}
else
{
if ((ptr_server->sock >= 0) &&
(FD_ISSET (ptr_server->sock, &read_fd)))
server_recv (ptr_server);
}
}
}
/* manages active DCC */
dcc_handle ();
}
}
/*
* gui_main_pre_init: pre-initialize GUI (called before gui_init)
*/
void
gui_main_pre_init (int *argc, char **argv[])
{
/* nothing for Curses interface */
(void) argc;
(void) argv;
}
/*
* gui_main_init: init GUI
*/
void
gui_main_init ()
{
initscr ();
curs_set (1);
noecho ();
nodelay (stdscr, TRUE);
gui_color_init ();
gui_infobar = NULL;
gui_ok = ((COLS > 5) && (LINES > 5));
refresh ();
/* init clipboard buffer */
gui_input_clipboard = NULL;
/* create new window/buffer */
if (gui_window_new (NULL, 0, 0, COLS, LINES, 100, 100))
{
gui_current_window = gui_windows;
gui_buffer_new (gui_windows, NULL, NULL, BUFFER_TYPE_STANDARD, 1);
if (cfg_look_set_title)
gui_window_set_title ();
gui_init_ok = 1;
signal (SIGWINCH, gui_window_refresh_screen_sigwinch);
}
}
/*
* gui_main_end: GUI end
*/
void
gui_main_end ()
{
/* free clipboard buffer */
if (gui_input_clipboard)
free (gui_input_clipboard);
/* delete all panels */
while (gui_panels)
gui_panel_free (gui_panels);
/* delete all buffers */
gui_window_merge_all (gui_current_window);
while (gui_buffers)
gui_buffer_free (gui_buffers, 0);
/* delete all windows */
while (gui_windows)
gui_window_free (gui_windows);
gui_window_tree_free (&gui_windows_tree);
/* delete global history */
history_global_free ();
/* delete infobar messages */
while (gui_infobar)
gui_infobar_remove ();
/* reset title */
if (cfg_look_set_title)
gui_window_reset_title ();
/* end of Curses output */
refresh ();
endwin ();
}
+230
View File
@@ -0,0 +1,230 @@
/*
* Copyright (c) 2003-2006 by FlashCode <flashcode@flashtux.org>
* See README for License detail, AUTHORS for developers list.
*
* 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 St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/* gui-curses-nicklist.c: nicklist display functions for Curses GUI */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "../../common/weechat.h"
#include "../gui.h"
#include "../../common/weeconfig.h"
#include "../../irc/irc.h"
#include "gui-curses.h"
/*
* gui_nicklist_draw: draw nick window for a buffer
*/
void
gui_nicklist_draw (t_gui_buffer *buffer, int erase)
{
t_gui_window *ptr_win;
int i, j, x, y, x2, column, max_length, nicks_displayed;
char format[32], format_empty[32];
t_irc_nick *ptr_nick;
if (!gui_ok || !BUFFER_HAS_NICKLIST(buffer))
return;
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
{
if ((ptr_win->buffer == buffer) && (buffer->num_displayed > 0))
{
max_length = nick_get_max_length (CHANNEL(buffer));
if (gui_window_calculate_pos_size (ptr_win, 0))
{
delwin (GUI_CURSES(ptr_win)->win_chat);
delwin (GUI_CURSES(ptr_win)->win_nick);
GUI_CURSES(ptr_win)->win_chat = newwin (ptr_win->win_chat_height,
ptr_win->win_chat_width,
ptr_win->win_chat_y,
ptr_win->win_chat_x);
GUI_CURSES(ptr_win)->win_nick = newwin (ptr_win->win_nick_height,
ptr_win->win_nick_width,
ptr_win->win_nick_y,
ptr_win->win_nick_x);
gui_chat_draw (buffer, 1);
erase = 1;
}
if (erase)
{
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_nick, COLOR_WIN_NICK);
snprintf (format_empty, 32, "%%-%ds", ptr_win->win_nick_width);
for (i = 0; i < ptr_win->win_nick_height; i++)
{
mvwprintw (GUI_CURSES(ptr_win)->win_nick, i, 0, format_empty, " ");
}
}
if ((cfg_look_nicklist_position == CFG_LOOK_NICKLIST_TOP) ||
(cfg_look_nicklist_position == CFG_LOOK_NICKLIST_BOTTOM))
snprintf (format, 32, "%%.%ds", max_length);
else
snprintf (format, 32, "%%.%ds",
((cfg_look_nicklist_min_size > 0)
&& (max_length < cfg_look_nicklist_min_size)) ?
cfg_look_nicklist_min_size :
(((cfg_look_nicklist_max_size > 0)
&& (max_length > cfg_look_nicklist_max_size)) ?
cfg_look_nicklist_max_size : max_length));
if (has_colors ())
{
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_nick, COLOR_WIN_NICK_SEP);
switch (cfg_look_nicklist_position)
{
case CFG_LOOK_NICKLIST_LEFT:
mvwvline (GUI_CURSES(ptr_win)->win_nick,
0, ptr_win->win_nick_width - 1, ACS_VLINE,
ptr_win->win_chat_height);
break;
case CFG_LOOK_NICKLIST_RIGHT:
mvwvline (GUI_CURSES(ptr_win)->win_nick,
0, 0, ACS_VLINE,
ptr_win->win_chat_height);
break;
case CFG_LOOK_NICKLIST_TOP:
mvwhline (GUI_CURSES(ptr_win)->win_nick,
ptr_win->win_nick_height - 1, 0, ACS_HLINE,
ptr_win->win_chat_width);
break;
case CFG_LOOK_NICKLIST_BOTTOM:
mvwhline (GUI_CURSES(ptr_win)->win_nick,
0, 0, ACS_HLINE,
ptr_win->win_chat_width);
break;
}
}
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_nick, COLOR_WIN_NICK);
x = 0;
y = (cfg_look_nicklist_position == CFG_LOOK_NICKLIST_BOTTOM) ? 1 : 0;
column = 0;
if ((cfg_look_nicklist_position == CFG_LOOK_NICKLIST_TOP) ||
(cfg_look_nicklist_position == CFG_LOOK_NICKLIST_BOTTOM))
nicks_displayed = (ptr_win->win_width / (max_length + 2)) * (ptr_win->win_nick_height - 1);
else
nicks_displayed = ptr_win->win_nick_height;
ptr_nick = CHANNEL(buffer)->nicks;
for (i = 0; i < ptr_win->win_nick_start; i++)
{
if (!ptr_nick)
break;
ptr_nick = ptr_nick->next_nick;
}
if (ptr_nick)
{
for (i = 0; i < nicks_displayed; i++)
{
switch (cfg_look_nicklist_position)
{
case CFG_LOOK_NICKLIST_LEFT:
x = 0;
break;
case CFG_LOOK_NICKLIST_RIGHT:
x = 1;
break;
case CFG_LOOK_NICKLIST_TOP:
case CFG_LOOK_NICKLIST_BOTTOM:
x = column;
break;
}
if ( ((i == 0) && (ptr_win->win_nick_start > 0))
|| ((i == nicks_displayed - 1) && (ptr_nick->next_nick)) )
{
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_nick, COLOR_WIN_NICK_MORE);
j = (max_length + 1) >= 4 ? 4 : max_length + 1;
for (x2 = 1; x2 <= j; x2++)
mvwprintw (GUI_CURSES(ptr_win)->win_nick, y, x + x2, "+");
}
else
{
if (ptr_nick->flags & NICK_CHANOWNER)
{
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_nick, COLOR_WIN_NICK_CHANOWNER);
mvwprintw (GUI_CURSES(ptr_win)->win_nick, y, x, "~");
x++;
}
else if (ptr_nick->flags & NICK_CHANADMIN)
{
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_nick, COLOR_WIN_NICK_CHANADMIN);
mvwprintw (GUI_CURSES(ptr_win)->win_nick, y, x, "&");
x++;
}
else if (ptr_nick->flags & NICK_OP)
{
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_nick, COLOR_WIN_NICK_OP);
mvwprintw (GUI_CURSES(ptr_win)->win_nick, y, x, "@");
x++;
}
else if (ptr_nick->flags & NICK_HALFOP)
{
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_nick, COLOR_WIN_NICK_HALFOP);
mvwprintw (GUI_CURSES(ptr_win)->win_nick, y, x, "%%");
x++;
}
else if (ptr_nick->flags & NICK_VOICE)
{
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_nick, COLOR_WIN_NICK_VOICE);
mvwprintw (GUI_CURSES(ptr_win)->win_nick, y, x, "+");
x++;
}
else
{
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_nick, COLOR_WIN_NICK);
mvwprintw (GUI_CURSES(ptr_win)->win_nick, y, x, " ");
x++;
}
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_nick,
((cfg_irc_away_check > 0) && (ptr_nick->flags & NICK_AWAY)) ?
COLOR_WIN_NICK_AWAY : COLOR_WIN_NICK);
mvwprintw (GUI_CURSES(ptr_win)->win_nick, y, x, format, ptr_nick->nick);
ptr_nick = ptr_nick->next_nick;
if (!ptr_nick)
break;
}
y++;
if ((cfg_look_nicklist_position == CFG_LOOK_NICKLIST_TOP) ||
(cfg_look_nicklist_position == CFG_LOOK_NICKLIST_BOTTOM))
{
if (y - ((cfg_look_nicklist_position == CFG_LOOK_NICKLIST_BOTTOM) ? 1 : 0) >= ptr_win->win_nick_height - 1)
{
column += max_length + 2;
y = (cfg_look_nicklist_position == CFG_LOOK_NICKLIST_TOP) ?
0 : 1;
}
}
}
}
wnoutrefresh (GUI_CURSES(ptr_win)->win_nick);
refresh ();
}
}
}
+202
View File
@@ -0,0 +1,202 @@
/*
* Copyright (c) 2003-2006 by FlashCode <flashcode@flashtux.org>
* See README for License detail, AUTHORS for developers list.
*
* 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 St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/* gui-curses-panel.c: panel functions for Curses GUI */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include "../../common/weechat.h"
#include "../gui.h"
#include "../../irc/irc.h"
#include "gui-curses.h"
/*
* gui_panel_get_size: get total panel size for a position
*/
int
gui_panel_get_size (t_gui_window *window, int position)
{
t_gui_panel_window *ptr_panel_win;
int total_size;
total_size = 0;
for (ptr_panel_win = GUI_CURSES(window)->panel_windows; ptr_panel_win;
ptr_panel_win = ptr_panel_win->next_panel_window)
{
if (ptr_panel_win->panel->position == position)
{
switch (position)
{
case GUI_PANEL_TOP:
case GUI_PANEL_BOTTOM:
total_size += ptr_panel_win->height;
break;
case GUI_PANEL_LEFT:
case GUI_PANEL_RIGHT:
total_size += ptr_panel_win->width;
break;
}
if (ptr_panel_win->panel->separator)
total_size++;
}
}
return total_size;
}
/*
* gui_panel_window_new: create a new "window panel" for a panel, in screen or a window
* if window is not NULL, panel window will be in this window
*/
int
gui_panel_window_new (t_gui_panel *panel, t_gui_window *window)
{
t_gui_panel_window *new_panel_win;
int x1, y1, x2, y2;
if (window)
{
x1 = window->win_x;
y1 = window->win_y + 1;
x2 = x1 + window->win_width - 1;
y2 = y1 + window->win_height - 1 - 4;
}
else
{
x1 = 0;
y1 = 0;
x2 = gui_window_get_width () - 1;
y2 = gui_window_get_height () - 1;
}
if ((new_panel_win = (t_gui_panel_window *) malloc (sizeof (t_gui_panel_window))))
{
new_panel_win->panel = panel;
if (window)
{
panel->panel_window = NULL;
new_panel_win->next_panel_window = GUI_CURSES(window)->panel_windows;
GUI_CURSES(window)->panel_windows = new_panel_win;
}
else
{
panel->panel_window = new_panel_win;
new_panel_win->next_panel_window = NULL;
}
switch (panel->position)
{
case GUI_PANEL_TOP:
new_panel_win->x = x1;
new_panel_win->y = y1;
new_panel_win->width = x2 - x1 + 1;
new_panel_win->height = panel->size;
break;
case GUI_PANEL_BOTTOM:
new_panel_win->x = x1;
new_panel_win->y = y2 - panel->size + 1;
new_panel_win->width = x2 - x1 + 1;
new_panel_win->height = panel->size;
break;
case GUI_PANEL_LEFT:
new_panel_win->x = x1;
new_panel_win->y = y1;
new_panel_win->width = panel->size;
new_panel_win->height = y2 - y1 + 1;
break;
case GUI_PANEL_RIGHT:
new_panel_win->x = x2 - panel->size + 1;
new_panel_win->y = y1;
new_panel_win->width = panel->size;
new_panel_win->height = y2 - y1 + 1;
break;
}
new_panel_win->win_panel = newwin (new_panel_win->height,
new_panel_win->width,
new_panel_win->y,
new_panel_win->x);
new_panel_win->win_separator = NULL;
if (new_panel_win->panel->separator)
{
switch (panel->position)
{
case GUI_PANEL_LEFT:
new_panel_win->win_separator = newwin (new_panel_win->height,
1,
new_panel_win->y,
new_panel_win->x + new_panel_win->width);
break;
}
}
return 1;
}
else
return 0;
}
/*
* gui_panel_window_free: delete a panel window
*/
void
gui_panel_window_free (void *panel_win)
{
t_gui_panel_window *ptr_panel_win;
ptr_panel_win = (t_gui_panel_window *)panel_win;
free (ptr_panel_win);
}
/*
* gui_panel_redraw_buffer: redraw panels for windows displaying a buffer
*/
void
gui_panel_redraw_buffer (t_gui_buffer *buffer)
{
t_gui_window *ptr_win;
t_gui_panel_window *ptr_panel_win;
if (!gui_ok)
return;
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
{
if ((ptr_win->buffer == buffer) && (buffer->num_displayed > 0))
{
for (ptr_panel_win = GUI_CURSES(ptr_win)->panel_windows;
ptr_panel_win;
ptr_panel_win = ptr_panel_win->next_panel_window)
{
switch (ptr_panel_win->panel->position)
{
case GUI_PANEL_LEFT:
break;
}
}
}
}
}
+396
View File
@@ -0,0 +1,396 @@
/*
* Copyright (c) 2003-2006 by FlashCode <flashcode@flashtux.org>
* See README for License detail, AUTHORS for developers list.
*
* 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 St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/* gui-curses-status.c: status display functions for Curses GUI */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include <string.h>
#include "../../common/weechat.h"
#include "../gui.h"
#include "../../common/hotlist.h"
#include "../../common/weeconfig.h"
#include "gui-curses.h"
/*
* gui_status_draw: draw status window for a buffer
*/
void
gui_status_draw (t_gui_buffer *buffer, int erase)
{
t_gui_window *ptr_win;
t_weechat_hotlist *ptr_hotlist;
char format[32], str_nicks[32], *more;
int i, first_mode, x, server_pos, server_total;
int display_name, names_count;
/* make gcc happy */
(void) buffer;
if (!gui_ok)
return;
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
{
if (erase)
gui_window_curses_clear (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS);
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS);
/* display number of buffers */
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
COLOR_WIN_STATUS_DELIMITERS);
mvwprintw (GUI_CURSES(ptr_win)->win_status, 0, 0, "[");
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
COLOR_WIN_STATUS);
wprintw (GUI_CURSES(ptr_win)->win_status, "%d",
(last_gui_buffer) ? last_gui_buffer->number : 0);
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
COLOR_WIN_STATUS_DELIMITERS);
wprintw (GUI_CURSES(ptr_win)->win_status, "] ");
/* display "<servers>" or current server */
if (ptr_win->buffer->all_servers)
{
wprintw (GUI_CURSES(ptr_win)->win_status, "[");
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
COLOR_WIN_STATUS);
wprintw (GUI_CURSES(ptr_win)->win_status, _("<servers>"));
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
COLOR_WIN_STATUS_DELIMITERS);
wprintw (GUI_CURSES(ptr_win)->win_status, "] ");
}
else if (SERVER(ptr_win->buffer) && SERVER(ptr_win->buffer)->name)
{
wprintw (GUI_CURSES(ptr_win)->win_status, "[");
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
COLOR_WIN_STATUS);
wprintw (GUI_CURSES(ptr_win)->win_status, "%s", SERVER(ptr_win->buffer)->name);
if (SERVER(ptr_win->buffer)->is_away)
wprintw (GUI_CURSES(ptr_win)->win_status, _("(away)"));
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
COLOR_WIN_STATUS_DELIMITERS);
wprintw (GUI_CURSES(ptr_win)->win_status, "] ");
}
/* infos about current server buffer */
if (SERVER(ptr_win->buffer) && !CHANNEL(ptr_win->buffer))
{
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
COLOR_WIN_STATUS);
wprintw (GUI_CURSES(ptr_win)->win_status, "%d",
ptr_win->buffer->number);
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
COLOR_WIN_STATUS_DELIMITERS);
wprintw (GUI_CURSES(ptr_win)->win_status, ":");
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
COLOR_WIN_STATUS_CHANNEL);
if (SERVER(ptr_win->buffer)->is_connected)
wprintw (GUI_CURSES(ptr_win)->win_status, "[%s] ",
SERVER(ptr_win->buffer)->name);
else
wprintw (GUI_CURSES(ptr_win)->win_status, "(%s) ",
SERVER(ptr_win->buffer)->name);
if (ptr_win->buffer->all_servers)
{
server_get_number_buffer (SERVER(ptr_win->buffer),
&server_pos,
&server_total);
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
COLOR_WIN_STATUS_DELIMITERS);
wprintw (GUI_CURSES(ptr_win)->win_status, "(");
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
COLOR_WIN_STATUS);
wprintw (GUI_CURSES(ptr_win)->win_status, "%d", server_pos);
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
COLOR_WIN_STATUS_DELIMITERS);
wprintw (GUI_CURSES(ptr_win)->win_status, "/");
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
COLOR_WIN_STATUS);
wprintw (GUI_CURSES(ptr_win)->win_status, "%d", server_total);
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
COLOR_WIN_STATUS_DELIMITERS);
wprintw (GUI_CURSES(ptr_win)->win_status, ") ");
}
}
/* infos about current channel/pv buffer */
if (SERVER(ptr_win->buffer) && CHANNEL(ptr_win->buffer))
{
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
COLOR_WIN_STATUS);
wprintw (GUI_CURSES(ptr_win)->win_status, "%d",
ptr_win->buffer->number);
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
COLOR_WIN_STATUS_DELIMITERS);
wprintw (GUI_CURSES(ptr_win)->win_status, ":");
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
COLOR_WIN_STATUS_CHANNEL);
if (((CHANNEL(ptr_win->buffer)->type != CHANNEL_TYPE_PRIVATE)
&& (CHANNEL(ptr_win->buffer)->type != CHANNEL_TYPE_DCC_CHAT)
&& (!CHANNEL(ptr_win->buffer)->nicks))
|| ((CHANNEL(ptr_win->buffer)->type == CHANNEL_TYPE_DCC_CHAT)
&& (CHANNEL(ptr_win->buffer)->dcc_chat)
&& (((t_irc_dcc *)(CHANNEL(ptr_win->buffer)->dcc_chat))->sock < 0)))
wprintw (GUI_CURSES(ptr_win)->win_status, "(%s)",
CHANNEL(ptr_win->buffer)->name);
else
wprintw (GUI_CURSES(ptr_win)->win_status, "%s",
CHANNEL(ptr_win->buffer)->name);
if (ptr_win->buffer == CHANNEL(ptr_win->buffer)->buffer)
{
/* display channel modes */
if (CHANNEL(ptr_win->buffer)->type == CHANNEL_TYPE_CHANNEL)
{
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
COLOR_WIN_STATUS_DELIMITERS);
wprintw (GUI_CURSES(ptr_win)->win_status, "(");
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
COLOR_WIN_STATUS);
i = 0;
first_mode = 1;
while (CHANNEL(ptr_win->buffer)->modes[i])
{
if (CHANNEL(ptr_win->buffer)->modes[i] != ' ')
{
if (first_mode)
{
wprintw (GUI_CURSES(ptr_win)->win_status, "+");
first_mode = 0;
}
wprintw (GUI_CURSES(ptr_win)->win_status, "%c",
CHANNEL(ptr_win->buffer)->modes[i]);
}
i++;
}
if (CHANNEL(ptr_win->buffer)->modes[CHANNEL_MODE_KEY] != ' ')
wprintw (GUI_CURSES(ptr_win)->win_status, ",%s",
CHANNEL(ptr_win->buffer)->key);
if (CHANNEL(ptr_win->buffer)->modes[CHANNEL_MODE_LIMIT] != ' ')
wprintw (GUI_CURSES(ptr_win)->win_status, ",%d",
CHANNEL(ptr_win->buffer)->limit);
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
COLOR_WIN_STATUS_DELIMITERS);
wprintw (GUI_CURSES(ptr_win)->win_status, ")");
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
COLOR_WIN_STATUS);
}
/* display DCC if private is DCC CHAT */
if (CHANNEL(ptr_win->buffer)->type == CHANNEL_TYPE_DCC_CHAT)
{
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
COLOR_WIN_STATUS_DELIMITERS);
wprintw (GUI_CURSES(ptr_win)->win_status, "(");
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
COLOR_WIN_STATUS_CHANNEL);
wprintw (GUI_CURSES(ptr_win)->win_status, "DCC");
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
COLOR_WIN_STATUS_DELIMITERS);
wprintw (GUI_CURSES(ptr_win)->win_status, ")");
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
COLOR_WIN_STATUS);
}
}
wprintw (GUI_CURSES(ptr_win)->win_status, " ");
}
if (!SERVER(ptr_win->buffer))
{
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS);
wprintw (GUI_CURSES(ptr_win)->win_status, "%d",
ptr_win->buffer->number);
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS_DELIMITERS);
wprintw (GUI_CURSES(ptr_win)->win_status, ":");
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS_CHANNEL);
switch (ptr_win->buffer->type)
{
case BUFFER_TYPE_STANDARD:
wprintw (GUI_CURSES(ptr_win)->win_status, _("[not connected] "));
break;
case BUFFER_TYPE_DCC:
wprintw (GUI_CURSES(ptr_win)->win_status, "<DCC> ");
break;
case BUFFER_TYPE_RAW_DATA:
wprintw (GUI_CURSES(ptr_win)->win_status, _("<RAW_IRC> "));
break;
}
}
/* display list of other active windows (if any) with numbers */
if (hotlist)
{
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
COLOR_WIN_STATUS_DELIMITERS);
wprintw (GUI_CURSES(ptr_win)->win_status, "[");
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS);
wprintw (GUI_CURSES(ptr_win)->win_status, _("Act: "));
names_count = 0;
for (ptr_hotlist = hotlist; ptr_hotlist;
ptr_hotlist = ptr_hotlist->next_hotlist)
{
switch (ptr_hotlist->priority)
{
case HOTLIST_LOW:
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
COLOR_WIN_STATUS_DATA_OTHER);
display_name = ((cfg_look_hotlist_names_level & 1) != 0);
break;
case HOTLIST_MSG:
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
COLOR_WIN_STATUS_DATA_MSG);
display_name = ((cfg_look_hotlist_names_level & 2) != 0);
break;
case HOTLIST_PRIVATE:
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
COLOR_WIN_STATUS_DATA_PRIVATE);
display_name = ((cfg_look_hotlist_names_level & 4) != 0);
break;
case HOTLIST_HIGHLIGHT:
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
COLOR_WIN_STATUS_DATA_HIGHLIGHT);
display_name = ((cfg_look_hotlist_names_level & 8) != 0);
break;
default:
display_name = 0;
break;
}
switch (ptr_hotlist->buffer->type)
{
case BUFFER_TYPE_STANDARD:
wprintw (GUI_CURSES(ptr_win)->win_status, "%d",
ptr_hotlist->buffer->number);
if (display_name && (cfg_look_hotlist_names_count != 0)
&& (names_count < cfg_look_hotlist_names_count))
{
names_count++;
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
COLOR_WIN_STATUS_DELIMITERS);
wprintw (GUI_CURSES(ptr_win)->win_status, ":");
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
COLOR_WIN_STATUS);
if (cfg_look_hotlist_names_length == 0)
snprintf (format, sizeof (format) - 1, "%%s");
else
snprintf (format, sizeof (format) - 1, "%%.%ds", cfg_look_hotlist_names_length);
if (BUFFER_IS_SERVER(ptr_hotlist->buffer))
wprintw (GUI_CURSES(ptr_win)->win_status, format,
(ptr_hotlist->server) ?
ptr_hotlist->server->name :
SERVER(ptr_hotlist->buffer)->name);
else if (BUFFER_IS_CHANNEL(ptr_hotlist->buffer)
|| BUFFER_IS_PRIVATE(ptr_hotlist->buffer))
wprintw (GUI_CURSES(ptr_win)->win_status, format, CHANNEL(ptr_hotlist->buffer)->name);
}
break;
case BUFFER_TYPE_DCC:
wprintw (GUI_CURSES(ptr_win)->win_status, "%d",
ptr_hotlist->buffer->number);
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
COLOR_WIN_STATUS_DELIMITERS);
wprintw (GUI_CURSES(ptr_win)->win_status, ":");
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
COLOR_WIN_STATUS);
wprintw (GUI_CURSES(ptr_win)->win_status, "DCC");
break;
case BUFFER_TYPE_RAW_DATA:
wprintw (GUI_CURSES(ptr_win)->win_status, "%d",
ptr_hotlist->buffer->number);
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
COLOR_WIN_STATUS_DELIMITERS);
wprintw (GUI_CURSES(ptr_win)->win_status, ":");
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
COLOR_WIN_STATUS);
wprintw (GUI_CURSES(ptr_win)->win_status, _("RAW_IRC"));
break;
}
if (ptr_hotlist->next_hotlist)
wprintw (GUI_CURSES(ptr_win)->win_status, ",");
}
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
COLOR_WIN_STATUS_DELIMITERS);
wprintw (GUI_CURSES(ptr_win)->win_status, "] ");
}
/* display lag */
if (SERVER(ptr_win->buffer))
{
if (SERVER(ptr_win->buffer)->lag / 1000 >= cfg_irc_lag_min_show)
{
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
COLOR_WIN_STATUS_DELIMITERS);
wprintw (GUI_CURSES(ptr_win)->win_status, "[");
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS);
wprintw (GUI_CURSES(ptr_win)->win_status, _("Lag: %.1f"),
((float)(SERVER(ptr_win->buffer)->lag)) / 1000);
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
COLOR_WIN_STATUS_DELIMITERS);
wprintw (GUI_CURSES(ptr_win)->win_status, "]");
}
}
/* display "-MORE-" (if last line is not displayed) & nicks count */
if (BUFFER_HAS_NICKLIST(ptr_win->buffer))
{
snprintf (str_nicks, sizeof (str_nicks) - 1, "%d", CHANNEL(ptr_win->buffer)->nicks_count);
x = ptr_win->win_width - strlen (str_nicks) - 4;
}
else
x = ptr_win->win_width - 2;
more = strdup (_("-MORE-"));
x -= strlen (more) - 1;
if (x < 0)
x = 0;
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS_MORE);
if (ptr_win->scroll)
mvwprintw (GUI_CURSES(ptr_win)->win_status, 0, x, "%s", more);
else
{
snprintf (format, sizeof (format) - 1, "%%-%ds", (int)(strlen (more)));
mvwprintw (GUI_CURSES(ptr_win)->win_status, 0, x, format, " ");
}
if (BUFFER_HAS_NICKLIST(ptr_win->buffer))
{
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
COLOR_WIN_STATUS_DELIMITERS);
wprintw (GUI_CURSES(ptr_win)->win_status, " [");
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS);
wprintw (GUI_CURSES(ptr_win)->win_status, "%s", str_nicks);
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
COLOR_WIN_STATUS_DELIMITERS);
wprintw (GUI_CURSES(ptr_win)->win_status, "]");
}
free (more);
wnoutrefresh (GUI_CURSES(ptr_win)->win_status);
refresh ();
}
}
File diff suppressed because it is too large Load Diff
+98
View File
@@ -0,0 +1,98 @@
/*
* Copyright (c) 2003-2006 by FlashCode <flashcode@flashtux.org>
* See README for License detail, AUTHORS for developers list.
*
* 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 St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef __WEECHAT_GUI_CURSES_H
#define __WEECHAT_GUI_CURSES_H 1
#ifdef HAVE_NCURSESW_CURSES_H
#include <ncursesw/ncurses.h>
#else
#include <ncurses.h>
#endif
/* shift ncurses colors for compatibility with colors
in IRC messages (same as other IRC clients) */
#define WEECHAT_COLOR_BLACK COLOR_BLACK
#define WEECHAT_COLOR_RED COLOR_BLUE
#define WEECHAT_COLOR_GREEN COLOR_GREEN
#define WEECHAT_COLOR_YELLOW COLOR_CYAN
#define WEECHAT_COLOR_BLUE COLOR_RED
#define WEECHAT_COLOR_MAGENTA COLOR_MAGENTA
#define WEECHAT_COLOR_CYAN COLOR_YELLOW
#define WEECHAT_COLOR_WHITE COLOR_WHITE
#define GUI_CURSES(window) ((t_gui_curses_objects *)(window->gui_objects))
typedef struct t_gui_panel_window t_gui_panel_window;
struct t_gui_panel_window
{
t_gui_panel *panel; /* pointer to panel */
int x, y; /* position of window */
int width, height; /* window size */
WINDOW *win_panel; /* panel Curses window */
WINDOW *win_separator; /* separator (optional) */
t_gui_panel_window *next_panel_window;
/* link to next panel window */
/* (only used if panel is in windows) */
};
typedef struct t_gui_curses_objects t_gui_curses_objects;
struct t_gui_curses_objects
{
WINDOW *win_title; /* title window */
WINDOW *win_chat; /* chat window (example: channel) */
WINDOW *win_nick; /* nick window */
WINDOW *win_status; /* status window */
WINDOW *win_infobar; /* info bar window */
WINDOW *win_input; /* input window */
WINDOW *win_separator; /* separation between 2 splited (V) win */
t_gui_panel_window *panel_windows; /* panel windows */
};
extern t_gui_color gui_weechat_colors[];
extern int gui_irc_colors[GUI_NUM_IRC_COLORS][2];
extern int gui_refresh_screen_needed;
/* color functions */
extern int gui_color_get_pair (int);
extern void gui_color_init ();
/* chat functions */
extern void gui_chat_calculate_line_diff (t_gui_window *, t_gui_line **, int *, int);
/* keyboard functions */
extern void gui_keyboard_default_bindings ();
extern void gui_keyboard_read ();
/* window functions */
extern void gui_window_curses_clear (WINDOW *, int);
extern void gui_window_set_weechat_color (WINDOW *, int);
extern void gui_window_refresh_screen_sigwinch ();
extern void gui_window_set_title ();
extern void gui_window_reset_title ();
/* panel functions */
extern int gui_panel_get_size (t_gui_window *, int);
extern void gui_panel_redraw_buffer (t_gui_buffer *);
#endif /* gui-curses.h */
File diff suppressed because it is too large Load Diff
-469
View File
@@ -1,469 +0,0 @@
/*
* Copyright (c) 2003-2006 by FlashCode <flashcode@flashtux.org>
* See README for License detail, AUTHORS for developers list.
*
* 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 St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/* gui-input: user input functions for Curses GUI */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <signal.h>
#include <time.h>
#include <sys/socket.h>
#ifdef HAVE_NCURSESW_CURSES_H
#include <ncursesw/ncurses.h>
#else
#include <ncurses.h>
#endif
#include "../../common/weechat.h"
#include "../gui.h"
#include "../../common/weeconfig.h"
#include "../../common/command.h"
#include "../../common/hotlist.h"
#include "../../common/fifo.h"
#include "../../common/utf8.h"
#include "../../irc/irc.h"
/*
* gui_input_default_key_bindings: create default key bindings
*/
void
gui_input_default_key_bindings ()
{
int i;
char key_str[32], command[32];
/* keys binded with internal functions */
gui_key_bind ( /* RC */ "ctrl-M", "return");
gui_key_bind ( /* RC */ "ctrl-J", "return");
gui_key_bind ( /* tab */ "ctrl-I", "tab");
gui_key_bind ( /* basckp */ "ctrl-H", "backspace");
gui_key_bind ( /* basckp */ "ctrl-?", "backspace");
gui_key_bind ( /* del */ "meta2-3~", "delete");
gui_key_bind ( /* ^K */ "ctrl-K", "delete_end_line");
gui_key_bind ( /* ^U */ "ctrl-U", "delete_beginning_line");
gui_key_bind ( /* ^W */ "ctrl-W", "delete_previous_word");
gui_key_bind ( /* ^Y */ "ctrl-Y", "clipboard_paste");
gui_key_bind ( /* ^T */ "ctrl-T", "transpose_chars");
gui_key_bind ( /* home */ "meta2-1~", "home");
gui_key_bind ( /* home */ "meta2-H", "home");
gui_key_bind ( /* home */ "meta2-7~", "home");
gui_key_bind ( /* ^A */ "ctrl-A", "home");
gui_key_bind ( /* end */ "meta2-4~", "end");
gui_key_bind ( /* end */ "meta2-F", "end");
gui_key_bind ( /* end */ "meta2-8~", "end");
gui_key_bind ( /* ^E */ "ctrl-E", "end");
gui_key_bind ( /* left */ "meta2-D", "left");
gui_key_bind ( /* right */ "meta2-C", "right");
gui_key_bind ( /* up */ "meta2-A", "up");
gui_key_bind ( /* ^up */ "meta-Oa", "up_global");
gui_key_bind ( /* down */ "meta2-B", "down");
gui_key_bind ( /* ^down */ "meta-Ob", "down_global");
gui_key_bind ( /* pgup */ "meta2-5~", "page_up");
gui_key_bind ( /* pgdn */ "meta2-6~", "page_down");
gui_key_bind ( /* F10 */ "meta2-21~", "infobar_clear");
gui_key_bind ( /* F11 */ "meta2-23~", "nick_page_up");
gui_key_bind ( /* F12 */ "meta2-24~", "nick_page_down");
gui_key_bind ( /* m-F11 */ "meta-meta2-1~", "nick_beginning");
gui_key_bind ( /* m-F12 */ "meta-meta2-4~", "nick_end");
gui_key_bind ( /* ^L */ "ctrl-L", "refresh");
gui_key_bind ( /* m-a */ "meta-a", "jump_smart");
gui_key_bind ( /* m-b */ "meta-b", "previous_word");
gui_key_bind ( /* ^left */ "meta-Od", "previous_word");
gui_key_bind ( /* m-d */ "meta-d", "delete_next_word");
gui_key_bind ( /* m-f */ "meta-f", "next_word");
gui_key_bind ( /* ^right */ "meta-Oc", "next_word");
gui_key_bind ( /* m-h */ "meta-h", "hotlist_clear");
gui_key_bind ( /* m-j,m-d */ "meta-jmeta-d", "jump_dcc");
gui_key_bind ( /* m-j,m-l */ "meta-jmeta-l", "jump_last_buffer");
gui_key_bind ( /* m-j,m-s */ "meta-jmeta-s", "jump_server");
gui_key_bind ( /* m-j,m-x */ "meta-jmeta-x", "jump_next_server");
gui_key_bind ( /* m-k */ "meta-k", "grab_key");
gui_key_bind ( /* m-n */ "meta-n", "scroll_next_highlight");
gui_key_bind ( /* m-p */ "meta-p", "scroll_previous_highlight");
gui_key_bind ( /* m-r */ "meta-r", "delete_line");
gui_key_bind ( /* m-s */ "meta-s", "switch_server");
gui_key_bind ( /* m-u */ "meta-u", "scroll_unread");
/* keys binded with commands */
gui_key_bind ( /* m-left */ "meta-meta2-D", "/buffer -1");
gui_key_bind ( /* F5 */ "meta2-15~", "/buffer -1");
gui_key_bind ( /* m-right */ "meta-meta2-C", "/buffer +1");
gui_key_bind ( /* F6 */ "meta2-17~", "/buffer +1");
gui_key_bind ( /* F7 */ "meta2-18~", "/window -1");
gui_key_bind ( /* F8 */ "meta2-19~", "/window +1");
gui_key_bind ( /* m-w,m-up */ "meta-wmeta-meta2-A", "/window up");
gui_key_bind ( /* m-w,m-down */ "meta-wmeta-meta2-B", "/window down");
gui_key_bind ( /* m-w,m-left */ "meta-wmeta-meta2-D", "/window left");
gui_key_bind ( /* m-w,m-right */ "meta-wmeta-meta2-C", "/window right");
gui_key_bind ( /* m-0 */ "meta-0", "/buffer 10");
gui_key_bind ( /* m-1 */ "meta-1", "/buffer 1");
gui_key_bind ( /* m-2 */ "meta-2", "/buffer 2");
gui_key_bind ( /* m-3 */ "meta-3", "/buffer 3");
gui_key_bind ( /* m-4 */ "meta-4", "/buffer 4");
gui_key_bind ( /* m-5 */ "meta-5", "/buffer 5");
gui_key_bind ( /* m-6 */ "meta-6", "/buffer 6");
gui_key_bind ( /* m-7 */ "meta-7", "/buffer 7");
gui_key_bind ( /* m-8 */ "meta-8", "/buffer 8");
gui_key_bind ( /* m-9 */ "meta-9", "/buffer 9");
/* bind meta-j + {01..99} to switch to buffers # > 10 */
for (i = 1; i < 100; i++)
{
sprintf (key_str, "meta-j%02d", i);
sprintf (command, "/buffer %d", i);
gui_key_bind (key_str, command);
}
}
/*
* gui_input_grab_end: insert grabbed key in input buffer
*/
void
gui_input_grab_end ()
{
char *expanded_key;
/* get expanded name (for example: ^U => ctrl-u) */
expanded_key = gui_key_get_expanded_name (gui_key_buffer);
if (expanded_key)
{
if (gui_current_window->buffer->has_input)
{
gui_insert_string_input (gui_current_window, expanded_key, -1);
gui_current_window->buffer->input_buffer_pos += utf8_strlen (expanded_key);
gui_draw_buffer_input (gui_current_window->buffer, 1);
}
free (expanded_key);
}
/* end grab mode */
gui_key_grab = 0;
gui_key_grab_count = 0;
gui_key_buffer[0] = '\0';
}
/*
* gui_input_read: read keyboard chars
*/
void
gui_input_read ()
{
int key, i, insert_ok;
char key_str[32];
i = 0;
/* do not loop too much here (for example when big paste was made),
to read also socket & co */
while (i < 8)
{
if (gui_key_grab && (gui_key_grab_count > 10))
gui_input_grab_end ();
key = getch ();
insert_ok = 1;
if (key == ERR)
{
if (gui_key_grab && (gui_key_grab_count > 0))
gui_input_grab_end ();
break;
}
if (key == KEY_RESIZE)
{
gui_refresh_screen ();
continue;
}
if (key < 32)
{
insert_ok = 0;
key_str[0] = '^';
key_str[1] = (char) key + '@';
key_str[2] = '\0';
}
else if (key == 127)
{
key_str[0] = '^';
key_str[1] = '?';
key_str[2] = '\0';
}
else
{
if (local_utf8)
{
/* 1 char: 0vvvvvvv */
if (key < 0x80)
{
key_str[0] = (char) key;
key_str[1] = '\0';
}
/* 2 chars: 110vvvvv 10vvvvvv */
else if ((key & 0xE0) == 0xC0)
{
key_str[0] = (char) key;
key_str[1] = (char) (getch ());
key_str[2] = '\0';
}
/* 3 chars: 1110vvvv 10vvvvvv 10vvvvvv */
else if ((key & 0xF0) == 0xE0)
{
key_str[0] = (char) key;
key_str[1] = (char) (getch ());
key_str[2] = (char) (getch ());
key_str[3] = '\0';
}
/* 4 chars: 11110vvv 10vvvvvv 10vvvvvv 10vvvvvv */
else if ((key & 0xF8) == 0xF0)
{
key_str[0] = (char) key;
key_str[1] = (char) (getch ());
key_str[2] = (char) (getch ());
key_str[3] = (char) (getch ());
key_str[4] = '\0';
}
}
else
{
key_str[0] = (char) key;
key_str[1] = '\0';
}
}
if (strcmp (key_str, "^") == 0)
{
key_str[1] = '^';
key_str[2] = '\0';
}
/*gui_printf (gui_current_window->buffer, "gui_input_read: key = %s (%d)\n", key_str, key);*/
if ((gui_key_pressed (key_str) != 0) && (insert_ok))
{
if (strcmp (key_str, "^^") == 0)
key_str[1] = '\0';
if (gui_current_window->buffer->dcc)
gui_exec_action_dcc (gui_current_window, key_str);
else
{
gui_insert_string_input (gui_current_window, key_str, -1);
gui_current_window->buffer->input_buffer_pos += utf8_strlen (key_str);
gui_draw_buffer_input (gui_current_window->buffer, 0);
gui_current_window->buffer->completion.position = -1;
}
}
i++;
}
}
/*
* gui_main_loop: main loop for WeeChat with ncurses GUI
*/
void
gui_main_loop ()
{
fd_set read_fd;
static struct timeval timeout, tv;
static struct timezone tz;
t_irc_server *ptr_server;
t_gui_buffer *ptr_buffer;
int old_day, old_min, old_sec, diff;
char text_time[1024];
time_t new_time;
struct tm *local_time;
quit_weechat = 0;
new_time = time (NULL);
local_time = localtime (&new_time);
old_day = local_time->tm_mday;
old_min = -1;
old_sec = -1;
check_away = 0;
while (!quit_weechat)
{
new_time = time (NULL);
local_time = localtime (&new_time);
/* minute has changed ? => redraw infobar */
if (local_time->tm_min != old_min)
{
old_min = local_time->tm_min;
gui_draw_buffer_infobar (gui_current_window->buffer, 1);
if (cfg_look_day_change
&& (local_time->tm_mday != old_day))
{
strftime (text_time, sizeof (text_time),
cfg_look_day_change_timestamp, local_time);
gui_add_hotlist = 0;
for (ptr_buffer = gui_buffers; ptr_buffer;
ptr_buffer = ptr_buffer->next_buffer)
{
if (!ptr_buffer->dcc)
gui_printf_nolog_notime (ptr_buffer,
_("Day changed to %s\n"),
text_time);
}
gui_add_hotlist = 1;
}
old_day = local_time->tm_mday;
}
/* second has changed ? */
if (local_time->tm_sec != old_sec)
{
old_sec = local_time->tm_sec;
if (cfg_look_infobar_seconds)
{
gui_draw_buffer_infobar_time (gui_current_window->buffer);
wmove (gui_current_window->win_input,
0, gui_current_window->win_input_x);
wrefresh (gui_current_window->win_input);
}
/* infobar count down */
if (gui_infobar && gui_infobar->remaining_time > 0)
{
gui_infobar->remaining_time--;
if (gui_infobar->remaining_time == 0)
{
gui_infobar_remove ();
gui_draw_buffer_infobar (gui_current_window->buffer, 1);
}
}
/* away check */
if (cfg_irc_away_check != 0)
{
check_away++;
if (check_away >= (cfg_irc_away_check * 60))
{
check_away = 0;
server_check_away ();
}
}
}
FD_ZERO (&read_fd);
FD_SET (STDIN_FILENO, &read_fd);
if (weechat_fifo != -1)
FD_SET (weechat_fifo, &read_fd);
timeout.tv_sec = 0;
timeout.tv_usec = 10000;
for (ptr_server = irc_servers; ptr_server;
ptr_server = ptr_server->next_server)
{
/* check if reconnection is pending */
if ((!ptr_server->is_connected)
&& (ptr_server->reconnect_start > 0)
&& (new_time >= (ptr_server->reconnect_start + ptr_server->autoreconnect_delay)))
server_reconnect (ptr_server);
else
{
if (ptr_server->is_connected)
{
/* check for lag */
if ((ptr_server->lag_check_time.tv_sec == 0)
&& (new_time >= ptr_server->lag_next_check))
{
server_sendf (ptr_server, "PING %s\r\n", ptr_server->address);
gettimeofday (&(ptr_server->lag_check_time), &tz);
}
/* lag timeout => disconnect */
if ((ptr_server->lag_check_time.tv_sec != 0)
&& (cfg_irc_lag_disconnect > 0))
{
gettimeofday (&tv, &tz);
diff = (int) get_timeval_diff (&(ptr_server->lag_check_time), &tv);
if (diff / 1000 > cfg_irc_lag_disconnect * 60)
{
irc_display_prefix (ptr_server, ptr_server->buffer, PREFIX_ERROR);
gui_printf (ptr_server->buffer,
_("%s lag is high, disconnecting from server...\n"),
WEECHAT_WARNING);
server_disconnect (ptr_server, 1);
continue;
}
}
}
if (!ptr_server->is_connected && (ptr_server->child_pid > 0))
FD_SET (ptr_server->child_read, &read_fd);
else
{
if (ptr_server->sock >= 0)
FD_SET (ptr_server->sock, &read_fd);
}
}
}
if (select (FD_SETSIZE, &read_fd, NULL, NULL, &timeout) > 0)
{
if (FD_ISSET (STDIN_FILENO, &read_fd))
{
gui_input_read ();
}
if ((weechat_fifo != -1) && (FD_ISSET (weechat_fifo, &read_fd)))
{
fifo_read ();
}
for (ptr_server = irc_servers; ptr_server;
ptr_server = ptr_server->next_server)
{
if (!ptr_server->is_connected && (ptr_server->child_pid > 0))
{
if (FD_ISSET (ptr_server->child_read, &read_fd))
server_child_read (ptr_server);
}
else
{
if ((ptr_server->sock >= 0) &&
(FD_ISSET (ptr_server->sock, &read_fd)))
server_recv (ptr_server);
}
}
}
/* manages active DCC */
dcc_handle ();
}
}
+23 -3
View File
@@ -19,11 +19,31 @@ INCLUDES = -DLOCALEDIR=\"$(datadir)/locale\" $(GTK_CFLAGS)
bin_PROGRAMS = weechat-gtk
if PLUGINS
weechat_gtk_LDADD = ../lib_weechat_gui_common.a \
../../common/lib_weechat_main.a \
../../irc/lib_weechat_irc.a \
../../plugins/lib_weechat_plugins.a \
$(PLUGINS_LIBS) \
$(GTK_LIBS) \
../../plugins/lib_weechat_plugins.a $(PLUGINS_LIBS)
$(GNUTLS_LFLAGS)
else
weechat_gtk_LDADD = ../lib_weechat_gui_common.a \
../../common/lib_weechat_main.a \
../../irc/lib_weechat_irc.a \
$(PLUGINS_LIBS) \
$(GTK_LIBS) \
$(GNUTLS_LFLAGS)
endif
weechat_gtk_SOURCES = gui-display.c \
gui-input.c
weechat_gtk_SOURCES = gui-gtk-chat.c \
gui-gtk-color.c \
gui-gtk-infobar.c \
gui-gtk-input.c \
gui-gtk-keyboard.c \
gui-gtk-main.c \
gui-gtk-nicklist.c \
gui-gtk-status.c \
gui-gtk-window.c \
gui-gtk-panel.c \
gui-gtk.h
-789
View File
@@ -1,789 +0,0 @@
/*
* Copyright (c) 2003-2006 by FlashCode <flashcode@flashtux.org>
* See README for License detail, AUTHORS for developers list.
*
* 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 St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/* gui-display.c: display functions for Gtk GUI */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <signal.h>
#include <time.h>
#include <gtk/gtk.h>
#include "../../common/weechat.h"
#include "../gui.h"
#include "../../common/weeconfig.h"
#include "../../irc/irc.h"
t_gui_color gui_colors[] =
{ { "default", 0 },
{ "black", 0 },
{ "red", 0 },
{ "lightred", 0 },
{ "green", 0 },
{ "lightgreen", 0 },
{ "brown", 0 },
{ "yellow", 0 },
{ "blue", 0 },
{ "lightblue", 0 },
{ "magenta", 0L },
{ "lightmagenta", 0 },
{ "cyan", 0 },
{ "lightcyan", 0 },
{ "gray", 0 },
{ "white", 0 },
{ NULL, 0 }
};
char *nicks_colors[COLOR_WIN_NICK_NUMBER] =
{ "cyan", "magenta", "green", "brown", "lightblue", "gray",
"lightcyan", "lightmagenta", "lightgreen", "blue" };
int color_attr[NUM_COLORS];
GtkWidget *gtk_main_window;
GtkWidget *vbox1;
GtkWidget *entry_topic;
GtkWidget *notebook1;
GtkWidget *vbox2;
GtkWidget *hbox1;
GtkWidget *scrolledwindow_chat;
GtkWidget *scrolledwindow_nick;
GtkWidget *entry_input;
GtkWidget *label1;
/*
* gui_assign_color: assign a color (read from config)
*/
int
gui_assign_color (int *color, char *color_name)
{
int i;
/* look for Gtk colors in table */
i = 0;
while (gui_colors[i].name)
{
if (ascii_strcasecmp (gui_colors[i].name, color_name) == 0)
{
*color = gui_colors[i].color;
return 1;
}
i++;
}
/* color not found */
return 0;
}
/*
* gui_get_color_by_name: get color by name
*/
int
gui_get_color_by_name (char *color_name)
{
int i;
/* look for Gtk in table */
i = 0;
while (gui_colors[i].name)
{
if (ascii_strcasecmp (gui_colors[i].name, color_name) == 0)
return gui_colors[i].color;
i++;
}
/* color not found */
return -1;
}
/*
* gui_get_color_by_value: get color name by value
*/
char *
gui_get_color_by_value (int color_value)
{
int i;
/* look for Gtk colors in table */
i = 0;
while (gui_colors[i].name)
{
if (gui_colors[i].color == color_value)
return gui_colors[i].name;
i++;
}
/* color not found */
return NULL;
}
/*
* gui_window_has_nicklist: returns 1 if window has nicklist
*/
int
gui_window_has_nicklist (t_gui_window *window)
{
return (window->textbuffer_nicklist != NULL);
}
/*
* gui_calculate_pos_size: calculate position and size for a window & sub-win
*/
void
gui_calculate_pos_size (t_gui_window *window)
{
/* TODO: write gui_calculate_pos_size for Gtk GUI */
(void) window;
}
/*
* gui_draw_window_title: draw title window
*/
void
gui_draw_window_title (t_gui_window *window)
{
char format[32];
/* TODO: manage splitted windows! */
if (window != gui_current_window)
return;
if (CHANNEL(window))
{
sprintf (format, "%%-%ds", window->win_width);
/* TODO: display topic */
}
else
{
/* TODO: display title for server window */
}
}
/*
* gui_redraw_window_title: redraw title window
*/
void
gui_redraw_window_title (t_gui_window *window)
{
/* TODO: manage splitted windows! */
if (window != gui_current_window)
return;
/* TODO: first delete window content */
gui_draw_window_title (window);
}
/*
* gui_get_line_num_splits: returns number of lines on window
* (depending on window width and type (server/channel)
* for alignment)
*/
int
gui_get_line_num_splits (t_gui_window *window, t_gui_line *line)
{
int length, width;
/* TODO: modify arbitraty value for non aligning messages on time/nick? */
if (line->length_align >= window->win_chat_width - 5)
{
length = line->length;
width = window->win_chat_width;
}
else
{
length = line->length - line->length_align;
width = window->win_chat_width - line->length_align;
}
return (length % width == 0) ? (length / width) : ((length / width) + 1);
}
/*
* gui_display_end_of_line: display end of a line in the chat window
*/
void
gui_display_end_of_line (t_gui_window *window, t_gui_line *line, int count)
{
/* TODO: display end of line! */
(void) window;
(void) line;
(void) count;
}
/*
* gui_display_line: display a line in the chat window
* if stop_at_end == 1, screen will not scroll and then we
* exit since chat window is full
* returns: 1 if stop_at_end == 0 or screen not full
* 0 if screen is full and if stop_at_end == 1
*/
int
gui_display_line (t_gui_window *window, t_gui_line *line, int stop_at_end)
{
/* TODO: display line! */
(void) window;
(void) line;
(void) stop_at_end;
return 1;
}
/*
* gui_draw_window_chat: draw chat window
*/
void
gui_draw_window_chat (t_gui_window *window)
{
/* TODO: manage splitted windows! */
if (window != gui_current_window)
return;
/* TODO: draw chat window */
}
/*
* gui_redraw_window_chat: redraw chat window
*/
void
gui_redraw_window_chat (t_gui_window *window)
{
/* TODO: manage splitted windows! */
if (window != gui_current_window)
return;
/* TODO: first delete window content */
gui_draw_window_chat (window);
}
/*
* gui_draw_window_nick: draw nick window
*/
void
gui_draw_window_nick (t_gui_window *window)
{
/* TODO: manage splitted windows! */
if (window != gui_current_window)
return;
/* TODO: display nicklist for Gtk GUI */
}
/*
* gui_redraw_window_nick: redraw nick window
*/
void
gui_redraw_window_nick (t_gui_window *window)
{
/* TODO: manage splitted windows! */
if (window != gui_current_window)
return;
/* TODO: first delete window content */
gui_draw_window_nick (window);
}
/*
* gui_draw_window_status: draw status window
*/
void
gui_draw_window_status (t_gui_window *window)
{
/* TODO: manage splitted windows! */
if (window != gui_current_window)
return;
/* TODO: draw status window! */
}
/*
* gui_redraw_window_status: redraw status window
*/
void
gui_redraw_window_status (t_gui_window *window)
{
/* TODO: manage splitted windows! */
if (window != gui_current_window)
return;
/* TODO: first delete window content */
gui_draw_window_status (window);
}
/*
* gui_draw_window_infobar: draw infobar window
*/
void
gui_draw_window_infobar (t_gui_window *window)
{
/* TODO: manage splitted windows! */
if (window != gui_current_window)
return;
/* TODO: draw infobar window! */
}
/*
* gui_redraw_window_infobar: redraw infobar window
*/
void
gui_redraw_window_infobar (t_gui_window *window)
{
/* TODO: manage splitted windows! */
if (window != gui_current_window)
return;
/* TODO: first delete window content */
gui_draw_window_infobar (window);
}
/*
* gui_draw_window_input: draw input window
*/
void
gui_draw_window_input (t_gui_window *window)
{
/* TODO: manage splitted windows! */
if (window != gui_current_window)
return;
/* TODO: draw input window */
}
/*
* gui_redraw_window_input: redraw input window
*/
void
gui_redraw_window_input (t_gui_window *window)
{
/* TODO: manage splitted windows! */
if (window != gui_current_window)
return;
/* TODO: first delete window content */
gui_draw_window_input (window);
}
/*
* gui_redraw_window: redraw a window
*/
void
gui_redraw_window (t_gui_window *window)
{
/* TODO: manage splitted windows! */
if (window != gui_current_window)
return;
gui_redraw_window_title (window);
gui_redraw_window_chat (window);
if (gui_window_has_nicklist (window))
gui_redraw_window_nick (window);
gui_redraw_window_status (window);
gui_redraw_window_input (window);
}
/*
* gui_switch_to_window: switch to another window
*/
void
gui_switch_to_window (t_gui_window *window)
{
t_gui_window *ptr_win;
GtkTextIter start, end;
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
{
if (ptr_win->is_displayed)
{
/* TODO: manage splitted windows */
ptr_win->is_displayed = 0;
break;
}
}
gui_calculate_pos_size (window);
if (!window->textview_chat)
{
window->textview_chat = gtk_text_view_new ();
gtk_widget_show (window->textview_chat);
gtk_container_add (GTK_CONTAINER (scrolledwindow_chat), window->textview_chat);
gtk_widget_set_size_request (window->textview_chat, 300, -1);
gtk_text_view_set_editable (GTK_TEXT_VIEW (window->textview_chat), FALSE);
gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (window->textview_chat), FALSE);
window->textbuffer_chat = gtk_text_buffer_new (NULL);
gtk_text_view_set_buffer (GTK_TEXT_VIEW (window->textview_chat), window->textbuffer_chat);
window->texttag_chat = gtk_text_buffer_create_tag(window->textbuffer_chat, "courier", "font_family", "lucida");
gtk_text_buffer_get_bounds (window->textbuffer_chat, &start, &end);
gtk_text_buffer_apply_tag (window->textbuffer_chat, window->texttag_chat, &start, &end);
}
if (WIN_IS_CHANNEL (window) && !window->textbuffer_nicklist)
{
window->textview_nicklist = gtk_text_view_new ();
gtk_widget_show (window->textview_nicklist);
gtk_container_add (GTK_CONTAINER (scrolledwindow_nick), window->textview_nicklist);
gtk_text_view_set_editable (GTK_TEXT_VIEW (window->textview_nicklist), FALSE);
gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (window->textview_nicklist), FALSE);
window->textbuffer_nicklist = gtk_text_buffer_new (NULL);
gtk_text_view_set_buffer (GTK_TEXT_VIEW (window->textview_nicklist), window->textbuffer_nicklist);
}
/* change current window to the new window */
gui_current_window = window;
window->is_displayed = 1;
window->unread_data = 0;
}
/*
* gui_switch_to_previous_window: switch to previous window
*/
void
gui_switch_to_previous_window ()
{
/* if only one windows then return */
if (gui_windows == last_gui_window)
return;
if (gui_current_window->prev_window)
gui_switch_to_window (gui_current_window->prev_window);
else
gui_switch_to_window (last_gui_window);
gui_redraw_window (gui_current_window);
}
/*
* gui_switch_to_next_window: switch to next window
*/
void
gui_switch_to_next_window ()
{
/* if only one windows then return */
if (gui_windows == last_gui_window)
return;
if (gui_current_window->next_window)
gui_switch_to_window (gui_current_window->next_window);
else
gui_switch_to_window (gui_windows);
gui_redraw_window (gui_current_window);
}
/*
* gui_move_page_up: display previous page on window
*/
void
gui_move_page_up ()
{
if (!gui_current_window->first_line_displayed)
{
gui_current_window->sub_lines += gui_current_window->win_chat_height - 1;
gui_redraw_window_chat (gui_current_window);
gui_redraw_window_status (gui_current_window);
}
}
/*
* gui_move_page_down: display next page on window
*/
void
gui_move_page_down ()
{
if (gui_current_window->sub_lines > 0)
{
gui_current_window->sub_lines -= gui_current_window->win_chat_height - 1;
if (gui_current_window->sub_lines < 0)
gui_current_window->sub_lines = 0;
if (gui_current_window->sub_lines == 0)
gui_current_window->unread_data = 0;
gui_redraw_window_chat (gui_current_window);
gui_redraw_window_status (gui_current_window);
}
}
/*
* gui_gtk_resize_handler: called when term size is modified
*/
void
gui_gtk_resize_handler ()
{
/* TODO: write resize handler for Gtk */
}
/*
* gui_window_init_subwindows: init subwindows for a WeeChat window
*/
void
gui_window_init_subwindows (t_gui_window *window)
{
window->textview_chat = NULL;
window->textbuffer_chat = NULL;
window->texttag_chat = NULL;
window->textview_nicklist = NULL;
window->textbuffer_nicklist = NULL;
}
/*
* gui_pre_init: pre-initialize GUI (called before gui_init)
*/
void
gui_pre_init (int *argc, char **argv[])
{
/* Initialise Gtk+ */
gtk_init (argc, argv);
}
/*
* gui_init_colors: init GUI colors
*/
void
gui_init_colors ()
{
/* TODO: init colors for Gtk */
}
/*
* gui_set_window_title: set window title
*/
void
gui_set_window_title ()
{
/* TODO: set window title for Gtk */
}
/*
* gui_init: init GUI
*/
void
gui_init ()
{
gtk_main_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (gtk_main_window), PACKAGE_STRING);
vbox1 = gtk_vbox_new (FALSE, 0);
gtk_widget_show (vbox1);
gtk_container_add (GTK_CONTAINER (gtk_main_window), vbox1);
entry_topic = gtk_entry_new ();
gtk_widget_show (entry_topic);
gtk_box_pack_start (GTK_BOX (vbox1), entry_topic, FALSE, FALSE, 0);
notebook1 = gtk_notebook_new ();
gtk_widget_show (notebook1);
gtk_box_pack_start (GTK_BOX (vbox1), notebook1, TRUE, TRUE, 0);
gtk_notebook_set_tab_pos (GTK_NOTEBOOK (notebook1), GTK_POS_BOTTOM);
vbox2 = gtk_vbox_new (FALSE, 0);
gtk_widget_show (vbox2);
gtk_container_add (GTK_CONTAINER (notebook1), vbox2);
hbox1 = gtk_hbox_new (FALSE, 0);
gtk_widget_show (hbox1);
gtk_box_pack_start (GTK_BOX (vbox2), hbox1, TRUE, TRUE, 0);
scrolledwindow_chat = gtk_scrolled_window_new (NULL, NULL);
gtk_widget_show (scrolledwindow_chat);
gtk_box_pack_start (GTK_BOX (hbox1), scrolledwindow_chat, TRUE, TRUE, 0);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow_chat), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
scrolledwindow_nick = gtk_scrolled_window_new (NULL, NULL);
gtk_widget_show (scrolledwindow_nick);
gtk_box_pack_start (GTK_BOX (hbox1), scrolledwindow_nick, TRUE, TRUE, 0);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow_nick), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
entry_input = gtk_entry_new ();
gtk_widget_show (entry_input);
gtk_box_pack_start (GTK_BOX (vbox2), entry_input, FALSE, FALSE, 0);
label1 = gtk_label_new (_("server"));
gtk_widget_show (label1);
gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook1), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook1), 0), label1);
gtk_label_set_justify (GTK_LABEL (label1), GTK_JUSTIFY_LEFT);
gtk_widget_show_all (gtk_main_window);
/* create a new window */
gui_current_window = gui_window_new (NULL, NULL, 1 /*0, 0, COLS, LINES*/);
/* TODO: set gui_ready to 1 when Gtk display functions will be ok */
gui_ready = 1;
}
/*
* gui_end: GUI end
*/
void
gui_end ()
{
t_gui_window *ptr_win;
/* delete all windows */
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
{
/* TODO: delete Gtk windows */
/* TODO: free input buffer, lines, messages, completion */
}
}
/*
* gui_add_message: add a message to a window
*/
void
gui_add_message (t_gui_window *window, int type, int color, char *message)
{
char *pos;
int length;
GtkTextIter start, end;
/* create new line if previous was ending by '\n' (or if 1st line) */
if (window->line_complete)
{
gtk_text_buffer_insert_at_cursor (window->textbuffer_chat, "\n", -1);
window->line_complete = 0;
}
pos = strchr (message, '\n');
if (pos)
{
pos[0] = '\0';
window->line_complete = 1;
}
gtk_text_buffer_insert_at_cursor (window->textbuffer_chat, message, -1);
gtk_text_buffer_get_bounds (window->textbuffer_chat, &start, &end);
gtk_text_buffer_apply_tag (window->textbuffer_chat, window->texttag_chat, &start, &end);
if (pos)
pos[0] = '\n';
}
/*
* gui_printf_color_type: display a message in a window
*/
void
gui_printf_color_type (t_gui_window *window, int type, int color, char *message, ...)
{
static char buffer[8192];
char timestamp[16];
char *pos;
va_list argptr;
static time_t seconds;
struct tm *date_tmp;
if (gui_ready)
{
if (color == -1)
color = COLOR_WIN_CHAT;
if (window == NULL)
{
if (SERVER(gui_current_window))
window = SERVER(gui_current_window)->window;
else
window = gui_current_window;
}
if (window == NULL)
{
wee_log_printf ("gui_printf without window! this is a bug, please send to developers - thanks\n");
return;
}
}
va_start (argptr, message);
vsnprintf (buffer, sizeof (buffer) - 1, message, argptr);
va_end (argptr);
if (gui_ready)
{
seconds = time (NULL);
date_tmp = localtime (&seconds);
pos = buffer - 1;
while (pos)
{
/* TODO: read timestamp format from config! */
if (window->line_complete)
{
gui_add_message (window, MSG_TYPE_TIME, COLOR_WIN_CHAT_DARK, "[");
sprintf (timestamp, "%02d", date_tmp->tm_hour);
gui_add_message (window, MSG_TYPE_TIME, COLOR_WIN_CHAT_TIME, timestamp);
gui_add_message (window, MSG_TYPE_TIME, COLOR_WIN_CHAT_TIME_SEP, ":");
sprintf (timestamp, "%02d", date_tmp->tm_min);
gui_add_message (window, MSG_TYPE_TIME, COLOR_WIN_CHAT_TIME, timestamp);
gui_add_message (window, MSG_TYPE_TIME, COLOR_WIN_CHAT_TIME_SEP, ":");
sprintf (timestamp, "%02d", date_tmp->tm_sec);
gui_add_message (window, MSG_TYPE_TIME, COLOR_WIN_CHAT_TIME, timestamp);
gui_add_message (window, MSG_TYPE_TIME, COLOR_WIN_CHAT_DARK, "] ");
}
gui_add_message (window, type, color, pos + 1);
pos = strchr (pos + 1, '\n');
if (pos && !pos[1])
pos = NULL;
}
}
else
g_print ("%s", buffer);
}
+646
View File
@@ -0,0 +1,646 @@
/*
* Copyright (c) 2003-2006 by FlashCode <flashcode@flashtux.org>
* See README for License detail, AUTHORS for developers list.
*
* 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 St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/* gui-gtk-chat.c: chat display functions for Gtk GUI */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "../../common/weechat.h"
#include "../gui.h"
#include "../../common/utf8.h"
#include "../../common/weeconfig.h"
#include "../../irc/irc.h"
#include "gui-gtk.h"
/*
* gui_chat_set_style: set style (bold, underline, ..)
* for a chat window
*/
void
gui_chat_set_style (t_gui_window *window, int style)
{
/* TODO: write this function for Gtk */
/*wattron (window->win_chat, style);*/
(void) window;
(void) style;
}
/*
* gui_chat_remove_style: remove style (bold, underline, ..)
* for a chat window
*/
void
gui_chat_remove_style (t_gui_window *window, int style)
{
/* TODO: write this function for Gtk */
/*wattroff (window->win_chat, style);*/
(void) window;
(void) style;
}
/*
* gui_chat_toggle_style: toggle a style (bold, underline, ..)
* for a chat window
*/
void
gui_chat_toggle_style (t_gui_window *window, int style)
{
window->current_style_attr ^= style;
if (window->current_style_attr & style)
gui_chat_set_style (window, style);
else
gui_chat_remove_style (window, style);
}
/*
* gui_chat_reset_style: reset style (color and attr)
* for a chat window
*/
void
gui_chat_reset_style (t_gui_window *window)
{
window->current_style_fg = -1;
window->current_style_bg = -1;
window->current_style_attr = 0;
window->current_color_attr = 0;
/* TODO: change following function call */
/*gui_window_set_weechat_color (window->win_chat, COLOR_WIN_CHAT);*/
gui_chat_remove_style (window,
A_BOLD | A_UNDERLINE | A_REVERSE);
}
/*
* gui_chat_set_color_style: set style for color
*/
void
gui_chat_set_color_style (t_gui_window *window, int style)
{
window->current_color_attr |= style;
/* TODO: change following function call */
/*wattron (window->win_chat, style);*/
}
/*
* gui_chat_remove_color_style: remove style for color
*/
void
gui_chat_remove_color_style (t_gui_window *window, int style)
{
window->current_color_attr &= !style;
/* TODO: change following function call */
/*wattroff (window->win_chat, style);*/
}
/*
* gui_chat_reset_color_style: reset style for color
*/
void
gui_chat_reset_color_style (t_gui_window *window)
{
/* TODO: change following function call */
/*wattroff (window->win_chat, window->current_color_attr);*/
window->current_color_attr = 0;
}
/*
* gui_chat_set_color: set color for a chat window
*/
void
gui_chat_set_color (t_gui_window *window, int fg, int bg)
{
/* TODO: write this function for Gtk */
/*if (((fg == -1) || (fg == 99))
&& ((bg == -1) || (bg == 99)))
wattron (window->win_chat, COLOR_PAIR(63));
else
{
if ((fg == -1) || (fg == 99))
fg = WEECHAT_COLOR_WHITE;
if ((bg == -1) || (bg == 99))
bg = 0;
wattron (window->win_chat, COLOR_PAIR((bg * 8) + fg));
}*/
(void) window;
(void) fg;
(void) bg;
}
/*
* gui_chat_set_weechat_color: set a WeeChat color for a chat window
*/
void
gui_chat_set_weechat_color (t_gui_window *window, int weechat_color)
{
gui_chat_reset_style (window);
gui_chat_set_style (window,
gui_color[weechat_color]->attributes);
gui_chat_set_color (window,
gui_color[weechat_color]->foreground,
gui_color[weechat_color]->background);
}
/*
* gui_chat_draw_title: draw title window for a buffer
*/
void
gui_chat_draw_title (t_gui_buffer *buffer, int erase)
{
/* TODO: write this function for Gtk */
(void) buffer;
(void) erase;
}
/*
* gui_chat_word_get_next_char: returns next char of a word
* special chars like colors, bold, .. are skipped
*/
char *
gui_chat_word_get_next_char (t_gui_window *window, unsigned char *string,
int apply_style, int *width_screen)
{
char str_fg[3], str_bg[3], utf_char[16];
int fg, bg, weechat_color, char_size;
if (width_screen)
*width_screen = 0;
while (string[0])
{
switch (string[0])
{
case GUI_ATTR_BOLD_CHAR:
string++;
if (apply_style)
gui_chat_toggle_style (window, A_BOLD);
break;
case GUI_ATTR_COLOR_CHAR:
string++;
str_fg[0] = '\0';
str_bg[0] = '\0';
fg = 99;
bg = 99;
if (isdigit (string[0]))
{
str_fg[0] = string[0];
str_fg[1] = '\0';
string++;
if (isdigit (string[0]))
{
str_fg[1] = string[0];
str_fg[2] = '\0';
string++;
}
}
if (string[0] == ',')
{
string++;
if (isdigit (string[0]))
{
str_bg[0] = string[0];
str_bg[1] = '\0';
string++;
if (isdigit (string[0]))
{
str_bg[1] = string[0];
str_bg[2] = '\0';
string++;
}
}
}
if (apply_style)
{
if (str_fg[0] || str_bg[0])
{
if (str_fg[0])
sscanf (str_fg, "%d", &fg);
else
fg = window->current_style_fg;
if (str_bg[0])
sscanf (str_bg, "%d", &bg);
else
bg = window->current_style_bg;
}
if (!str_fg[0] && !str_bg[0])
gui_chat_reset_color_style (window);
window->current_style_fg = fg;
window->current_style_bg = bg;
gui_chat_set_color (window, fg, bg);
}
break;
case GUI_ATTR_RESET_CHAR:
string++;
if (apply_style)
gui_chat_reset_style (window);
break;
case GUI_ATTR_FIXED_CHAR:
string++;
break;
case GUI_ATTR_REVERSE_CHAR:
case GUI_ATTR_REVERSE2_CHAR:
string++;
if (apply_style)
gui_chat_toggle_style (window, A_REVERSE);
break;
case GUI_ATTR_WEECHAT_COLOR_CHAR:
string++;
if (isdigit (string[0]) && isdigit (string[1]))
{
str_fg[0] = string[0];
str_fg[1] = string[1];
str_fg[2] = '\0';
string += 2;
if (apply_style)
{
sscanf (str_fg, "%d", &weechat_color);
gui_chat_set_weechat_color (window, weechat_color);
}
}
break;
case GUI_ATTR_WEECHAT_SET_CHAR:
string++;
switch (string[0])
{
case GUI_ATTR_BOLD_CHAR:
string++;
if (apply_style)
gui_chat_set_color_style (window, A_BOLD);
break;
case GUI_ATTR_REVERSE_CHAR:
case GUI_ATTR_REVERSE2_CHAR:
string++;
if (apply_style)
gui_chat_set_color_style (window, A_REVERSE);
break;
case GUI_ATTR_UNDERLINE_CHAR:
string++;
if (apply_style)
gui_chat_set_color_style (window, A_UNDERLINE);
break;
}
break;
case GUI_ATTR_WEECHAT_REMOVE_CHAR:
string++;
switch (string[0])
{
case GUI_ATTR_BOLD_CHAR:
string++;
if (apply_style)
gui_chat_remove_color_style (window, A_BOLD);
break;
case GUI_ATTR_REVERSE_CHAR:
case GUI_ATTR_REVERSE2_CHAR:
string++;
if (apply_style)
gui_chat_remove_color_style (window, A_REVERSE);
break;
case GUI_ATTR_UNDERLINE_CHAR:
string++;
if (apply_style)
gui_chat_remove_color_style (window, A_UNDERLINE);
break;
}
break;
case GUI_ATTR_ITALIC_CHAR:
string++;
break;
case GUI_ATTR_UNDERLINE_CHAR:
string++;
if (apply_style)
gui_chat_toggle_style (window, A_UNDERLINE);
break;
default:
if (string[0] < 32)
string++;
else
{
char_size = utf8_char_size ((char *) string);
if (width_screen)
{
memcpy (utf_char, string, char_size);
utf_char[char_size] = '\0';
*width_screen = utf8_width_screen (utf_char);
}
return (char *)string + char_size;
}
}
}
/* nothing found except color/attrib codes, so return NULL */
return NULL;
}
/*
* gui_chat_display_word_raw: display word on chat buffer, letter by letter
* special chars like color, bold, .. are interpreted
*/
void
gui_chat_display_word_raw (t_gui_window *window, char *string)
{
/*char *prev_char, *next_char, saved_char;*/
/* TODO: write this function for Gtk */
(void) window;
(void) string;
}
/*
* gui_chat_display_word: display a word on chat buffer
*/
void
gui_chat_display_word (t_gui_window *window,
t_gui_line *line,
char *data,
char *end_offset,
int num_lines, int count, int *lines_displayed, int simulate)
{
/*char *end_line, saved_char_end, saved_char;
int pos_saved_char, chars_to_display, num_displayed;*/
/* TODO: write this function for Gtk */
(void) window;
(void) line;
(void) data;
(void) end_offset;
(void) num_lines;
(void) count;
(void) lines_displayed;
(void) simulate;
}
/*
* gui_chat_get_word_info: returns info about next word: beginning, end, length
*/
void
gui_chat_get_word_info (t_gui_window *window,
char *data,
int *word_start_offset, int *word_end_offset,
int *word_length_with_spaces, int *word_length)
{
char *start_data, *prev_char, *next_char;
int leading_spaces, char_size;
*word_start_offset = 0;
*word_end_offset = 0;
*word_length_with_spaces = 0;
*word_length = 0;
start_data = data;
leading_spaces = 1;
while (data && data[0])
{
next_char = gui_chat_word_get_next_char (window,
(unsigned char *)data,
0, NULL);
if (next_char)
{
prev_char = utf8_prev_char (data, next_char);
if (prev_char)
{
if (prev_char[0] != ' ')
{
if (leading_spaces)
*word_start_offset = prev_char - start_data;
leading_spaces = 0;
char_size = next_char - prev_char;
*word_end_offset = next_char - start_data - 1;
(*word_length_with_spaces) += char_size;
(*word_length) += char_size;
}
else
{
if (leading_spaces)
(*word_length_with_spaces)++;
else
{
*word_end_offset = prev_char - start_data - 1;
return;
}
}
data = next_char;
}
}
else
{
*word_end_offset = data + strlen (data) - start_data - 1;
return;
}
}
}
/*
* gui_chat_display_line: display a line in the chat window
* if count == 0, display whole line
* if count > 0, display 'count' lines (beginning from the end)
* if simulate == 1, nothing is displayed (for counting how
* many lines would have been lines displayed)
* returns: number of lines displayed (or simulated)
*/
int
gui_chat_display_line (t_gui_window *window, t_gui_line *line, int count,
int simulate)
{
/* TODO: write this function for Gtk */
(void) window;
(void) line;
(void) count;
(void) simulate;
return 1;
}
/*
* gui_chat_calculate_line_diff: returns pointer to line & offset for a difference
* with given line
*/
void
gui_chat_calculate_line_diff (t_gui_window *window, t_gui_line **line,
int *line_pos, int difference)
{
int backward, current_size;
if (!line || !line_pos)
return;
backward = (difference < 0);
if (!(*line))
{
/* if looking backward, start at last line of buffer */
if (backward)
{
*line = window->buffer->last_line;
if (!(*line))
return;
current_size = gui_chat_display_line (window, *line, 0, 1);
if (current_size == 0)
current_size = 1;
*line_pos = current_size - 1;
}
/* if looking forward, start at first line of buffer */
else
{
*line = window->buffer->lines;
if (!(*line))
return;
*line_pos = 0;
current_size = gui_chat_display_line (window, *line, 0, 1);
}
}
else
current_size = gui_chat_display_line (window, *line, 0, 1);
while ((*line) && (difference != 0))
{
/* looking backward */
if (backward)
{
if (*line_pos > 0)
(*line_pos)--;
else
{
*line = (*line)->prev_line;
if (*line)
{
current_size = gui_chat_display_line (window, *line, 0, 1);
if (current_size == 0)
current_size = 1;
*line_pos = current_size - 1;
}
}
difference++;
}
/* looking forward */
else
{
if (*line_pos < current_size - 1)
(*line_pos)++;
else
{
*line = (*line)->next_line;
if (*line)
{
current_size = gui_chat_display_line (window, *line, 0, 1);
if (current_size == 0)
current_size = 1;
*line_pos = 0;
}
}
difference--;
}
}
/* first or last line reached */
if (!(*line))
{
if (backward)
{
/* first line reached */
*line = window->buffer->lines;
*line_pos = 0;
}
else
{
/* last line reached => consider we'll display all until the end */
*line_pos = 0;
}
}
}
/*
* gui_chat_draw: draw chat window for a buffer
*/
void
gui_chat_draw (t_gui_buffer *buffer, int erase)
{
/*t_gui_window *ptr_win;
t_gui_line *ptr_line;
t_irc_dcc *dcc_first, *dcc_selected, *ptr_dcc;
char format_empty[32];
int i, j, line_pos, count, num_bars;
char *unit_name[] = { N_("bytes"), N_("Kb"), N_("Mb"), N_("Gb") };
char *unit_format[] = { "%.0Lf", "%.1Lf", "%.02Lf", "%.02Lf" };
long unit_divide[] = { 1, 1024, 1024*1024, 1024*1024,1024 };
int num_unit;
char format[32], date[128], *buf;
struct tm *date_tmp;*/
if (!gui_ok)
return;
/* TODO: write this function for Gtk */
(void) buffer;
(void) erase;
}
/*
* gui_chat_draw_line: add a line to chat window for a buffer
*/
void
gui_chat_draw_line (t_gui_buffer *buffer, t_gui_line *line)
{
t_gui_window *ptr_win;
unsigned char *text_without_color;
GtkTextIter start, end;
ptr_win = gui_buffer_find_window (buffer);
if (ptr_win)
{
text_without_color = gui_color_decode ((unsigned char *)(line->data), 0);
if (text_without_color)
{
gtk_text_buffer_insert_at_cursor (GUI_GTK(ptr_win)->textbuffer_chat,
(char *)text_without_color, -1);
gtk_text_buffer_insert_at_cursor (GUI_GTK(ptr_win)->textbuffer_chat,
"\n", -1);
gtk_text_buffer_get_bounds (GUI_GTK(ptr_win)->textbuffer_chat,
&start, &end);
/* TODO */
/*gtk_text_buffer_apply_tag (ptr_win->textbuffer_chat, ptr_win->texttag_chat, &start, &end);*/
free (text_without_color);
}
}
}
+578
View File
@@ -0,0 +1,578 @@
/*
* Copyright (c) 2003-2006 by FlashCode <flashcode@flashtux.org>
* See README for License detail, AUTHORS for developers list.
*
* 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 St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/* gui-gtk-color.c: color functions for Gtk GUI */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "../../common/weechat.h"
#include "../gui.h"
#include "../../common/weeconfig.h"
#include "gui-gtk.h"
t_gui_color gui_weechat_colors[] =
{ { -1, 0, 0, "default" },
{ WEECHAT_COLOR_BLACK, 0, 0, "black" },
{ WEECHAT_COLOR_RED, 0, 0, "red" },
{ WEECHAT_COLOR_RED, 0, A_BOLD, "lightred" },
{ WEECHAT_COLOR_GREEN, 0, 0, "green" },
{ WEECHAT_COLOR_GREEN, 0, A_BOLD, "lightgreen" },
{ WEECHAT_COLOR_YELLOW, 0, 0, "brown" },
{ WEECHAT_COLOR_YELLOW, 0, A_BOLD, "yellow" },
{ WEECHAT_COLOR_BLUE, 0, 0, "blue" },
{ WEECHAT_COLOR_BLUE, 0, A_BOLD, "lightblue" },
{ WEECHAT_COLOR_MAGENTA, 0, 0, "magenta" },
{ WEECHAT_COLOR_MAGENTA, 0, A_BOLD, "lightmagenta" },
{ WEECHAT_COLOR_CYAN, 0, 0, "cyan" },
{ WEECHAT_COLOR_CYAN, 0, A_BOLD, "lightcyan" },
{ WEECHAT_COLOR_WHITE, 0, A_BOLD, "white" },
{ 0, 0, 0, NULL }
};
int gui_irc_colors[GUI_NUM_IRC_COLORS][2] =
{ { /* 0 */ WEECHAT_COLOR_WHITE, A_BOLD },
{ /* 1 */ WEECHAT_COLOR_BLACK, 0 },
{ /* 2 */ WEECHAT_COLOR_BLUE, 0 },
{ /* 3 */ WEECHAT_COLOR_GREEN, 0 },
{ /* 4 */ WEECHAT_COLOR_RED, A_BOLD },
{ /* 5 */ WEECHAT_COLOR_RED, 0 },
{ /* 6 */ WEECHAT_COLOR_MAGENTA, 0 },
{ /* 7 */ WEECHAT_COLOR_YELLOW, 0 },
{ /* 8 */ WEECHAT_COLOR_YELLOW, A_BOLD },
{ /* 9 */ WEECHAT_COLOR_GREEN, A_BOLD },
{ /* 10 */ WEECHAT_COLOR_CYAN, 0 },
{ /* 11 */ WEECHAT_COLOR_CYAN, A_BOLD },
{ /* 12 */ WEECHAT_COLOR_BLUE, A_BOLD },
{ /* 13 */ WEECHAT_COLOR_MAGENTA, A_BOLD },
{ /* 14 */ WEECHAT_COLOR_WHITE, 0 },
{ /* 15 */ WEECHAT_COLOR_WHITE, A_BOLD }
};
t_gui_color *gui_color[GUI_NUM_COLORS];
/*
* gui_color_assign: assign a WeeChat color (read from config)
*/
int
gui_color_assign (int *color, char *color_name)
{
int i;
/* look for curses colors in table */
i = 0;
while (gui_weechat_colors[i].string)
{
if (ascii_strcasecmp (gui_weechat_colors[i].string, color_name) == 0)
{
*color = i;
return 1;
}
i++;
}
/* color not found */
return 0;
}
/*
* gui_color_get_name: get color name
*/
char *
gui_color_get_name (int num_color)
{
return gui_weechat_colors[num_color].string;
}
/*
* gui_color_decode: parses a message (coming from IRC server),
* and according:
* - remove any color/style in message
* or:
* - change colors by codes to be compatible with
* other IRC clients
* After use, string returned has to be free()
*/
unsigned char *
gui_color_decode (unsigned char *string, int keep_colors)
{
unsigned char *out;
int out_length, out_pos;
char str_fg[3], str_bg[3];
int fg, bg, attr;
out_length = (strlen ((char *)string) * 2) + 1;
out = (unsigned char *)malloc (out_length);
if (!out)
return NULL;
out_pos = 0;
while (string[0] && (out_pos < out_length - 1))
{
switch (string[0])
{
case GUI_ATTR_BOLD_CHAR:
case GUI_ATTR_RESET_CHAR:
case GUI_ATTR_FIXED_CHAR:
case GUI_ATTR_REVERSE_CHAR:
case GUI_ATTR_REVERSE2_CHAR:
case GUI_ATTR_ITALIC_CHAR:
case GUI_ATTR_UNDERLINE_CHAR:
if (keep_colors)
out[out_pos++] = string[0];
string++;
break;
case GUI_ATTR_COLOR_CHAR:
string++;
str_fg[0] = '\0';
str_bg[0] = '\0';
if (isdigit (string[0]))
{
str_fg[0] = string[0];
str_fg[1] = '\0';
string++;
if (isdigit (string[0]))
{
str_fg[1] = string[0];
str_fg[2] = '\0';
string++;
}
}
if (string[0] == ',')
{
string++;
if (isdigit (string[0]))
{
str_bg[0] = string[0];
str_bg[1] = '\0';
string++;
if (isdigit (string[0]))
{
str_bg[1] = string[0];
str_bg[2] = '\0';
string++;
}
}
}
if (keep_colors)
{
if (!str_fg[0] && !str_bg[0])
out[out_pos++] = GUI_ATTR_COLOR_CHAR;
else
{
attr = 0;
if (str_fg[0])
{
sscanf (str_fg, "%d", &fg);
fg %= 16;
attr |= gui_irc_colors[fg][1];
}
if (str_bg[0])
{
sscanf (str_bg, "%d", &bg);
bg %= 16;
attr |= gui_irc_colors[bg][1];
}
if (attr & A_BOLD)
{
out[out_pos++] = GUI_ATTR_WEECHAT_SET_CHAR;
out[out_pos++] = GUI_ATTR_BOLD_CHAR;
}
else
{
out[out_pos++] = GUI_ATTR_WEECHAT_REMOVE_CHAR;
out[out_pos++] = GUI_ATTR_BOLD_CHAR;
}
out[out_pos++] = GUI_ATTR_COLOR_CHAR;
if (str_fg[0])
{
out[out_pos++] = (gui_irc_colors[fg][0] / 10) + '0';
out[out_pos++] = (gui_irc_colors[fg][0] % 10) + '0';
}
if (str_bg[0])
{
out[out_pos++] = ',';
out[out_pos++] = (gui_irc_colors[bg][0] / 10) + '0';
out[out_pos++] = (gui_irc_colors[bg][0] % 10) + '0';
}
}
}
break;
case GUI_ATTR_WEECHAT_COLOR_CHAR:
string++;
if (isdigit (string[0]) && isdigit (string[1]))
{
if (keep_colors)
{
out[out_pos++] = string[0];
out[out_pos++] = string[1];
}
string += 2;
}
break;
case GUI_ATTR_WEECHAT_SET_CHAR:
case GUI_ATTR_WEECHAT_REMOVE_CHAR:
string++;
if (string[0])
{
if (keep_colors)
{
out[out_pos++] = *(string - 1);
out[out_pos++] = string[0];
}
string++;
}
break;
default:
out[out_pos++] = string[0];
string++;
}
}
out[out_pos] = '\0';
return out;
}
/*
* gui_color_decode_for_user_entry: parses a message (coming from IRC server),
* and replaces colors/bold/.. by %C, %B, ..
* After use, string returned has to be free()
*/
unsigned char *
gui_color_decode_for_user_entry (unsigned char *string)
{
unsigned char *out;
int out_length, out_pos;
out_length = (strlen ((char *)string) * 2) + 1;
out = (unsigned char *)malloc (out_length);
if (!out)
return NULL;
out_pos = 0;
while (string[0] && (out_pos < out_length - 1))
{
switch (string[0])
{
case GUI_ATTR_BOLD_CHAR:
out[out_pos++] = '%';
out[out_pos++] = 'B';
string++;
break;
case GUI_ATTR_FIXED_CHAR:
string++;
break;
case GUI_ATTR_RESET_CHAR:
out[out_pos++] = '%';
out[out_pos++] = 'O';
string++;
break;
case GUI_ATTR_REVERSE_CHAR:
case GUI_ATTR_REVERSE2_CHAR:
out[out_pos++] = '%';
out[out_pos++] = 'R';
string++;
break;
case GUI_ATTR_ITALIC_CHAR:
string++;
break;
case GUI_ATTR_UNDERLINE_CHAR:
out[out_pos++] = '%';
out[out_pos++] = 'R';
string++;
break;
case GUI_ATTR_COLOR_CHAR:
out[out_pos++] = '%';
out[out_pos++] = 'C';
string++;
break;
default:
out[out_pos++] = string[0];
string++;
}
}
out[out_pos] = '\0';
return out;
}
/*
* gui_color_encode: parses a message (entered by user), and
* encode special chars (%B, %C, ..) in IRC colors
* After use, string returned has to be free()
*/
unsigned char *
gui_color_encode (unsigned char *string)
{
unsigned char *out;
int out_length, out_pos;
out_length = (strlen ((char *)string) * 2) + 1;
out = (unsigned char *)malloc (out_length);
if (!out)
return NULL;
out_pos = 0;
while (string[0] && (out_pos < out_length - 1))
{
switch (string[0])
{
case '%':
string++;
switch (string[0])
{
case '\0':
out[out_pos++] = '%';
break;
case '%': /* double '%' replaced by single '%' */
out[out_pos++] = string[0];
string++;
break;
case 'B': /* bold */
out[out_pos++] = GUI_ATTR_BOLD_CHAR;
string++;
break;
case 'C': /* color */
out[out_pos++] = GUI_ATTR_COLOR_CHAR;
string++;
if (isdigit (string[0]))
{
out[out_pos++] = string[0];
string++;
if (isdigit (string[0]))
{
out[out_pos++] = string[0];
string++;
}
}
if (string[0] == ',')
{
out[out_pos++] = ',';
string++;
if (isdigit (string[0]))
{
out[out_pos++] = string[0];
string++;
if (isdigit (string[0]))
{
out[out_pos++] = string[0];
string++;
}
}
}
break;
case 'O': /* reset */
out[out_pos++] = GUI_ATTR_RESET_CHAR;
string++;
break;
case 'R': /* reverse */
out[out_pos++] = GUI_ATTR_REVERSE_CHAR;
string++;
break;
case 'U': /* underline */
out[out_pos++] = GUI_ATTR_UNDERLINE_CHAR;
string++;
break;
default:
out[out_pos++] = '%';
out[out_pos++] = string[0];
string++;
}
break;
default:
out[out_pos++] = string[0];
string++;
}
}
out[out_pos] = '\0';
return out;
}
/*
* gui_color_build: build a WeeChat color with foreground,
* background and attributes (attributes are
* given with foreground color, with a OR)
*/
t_gui_color *
gui_color_build (int number, int foreground, int background)
{
t_gui_color *new_color;
new_color = (t_gui_color *)malloc (sizeof (t_gui_color));
if (!new_color)
return NULL;
new_color->foreground = gui_weechat_colors[foreground].foreground;
new_color->background = gui_weechat_colors[background].foreground;
new_color->attributes = gui_weechat_colors[foreground].attributes;
new_color->string = (char *)malloc (4);
if (new_color->string)
snprintf (new_color->string, 4,
"%s%02d",
GUI_ATTR_WEECHAT_COLOR_STR, number);
return new_color;
}
/*
* gui_color_get_pair: get color pair with a WeeChat color number
*/
int
gui_color_get_pair (int num_color)
{
int fg, bg;
if ((num_color < 0) || (num_color > GUI_NUM_COLORS - 1))
return WEECHAT_COLOR_WHITE;
fg = gui_color[num_color]->foreground;
bg = gui_color[num_color]->background;
if (((fg == -1) || (fg == 99))
&& ((bg == -1) || (bg == 99)))
return 63;
if ((fg == -1) || (fg == 99))
fg = WEECHAT_COLOR_WHITE;
if ((bg == -1) || (bg == 99))
bg = 0;
return (bg * 8) + fg;
}
/*
* gui_color_init_pairs: init color pairs
*/
void
gui_color_init_pairs ()
{
/* This function does nothing in Gtk GUI */
}
/*
* gui_color_init_weechat: init WeeChat colors
*/
void
gui_color_init_weechat ()
{
int i;
gui_color[COLOR_WIN_SEPARATOR] = gui_color_build (COLOR_WIN_SEPARATOR, cfg_col_separator, cfg_col_separator);
gui_color[COLOR_WIN_TITLE] = gui_color_build (COLOR_WIN_TITLE, cfg_col_title, cfg_col_title_bg);
gui_color[COLOR_WIN_CHAT] = gui_color_build (COLOR_WIN_CHAT, cfg_col_chat, cfg_col_chat_bg);
gui_color[COLOR_WIN_CHAT_TIME] = gui_color_build (COLOR_WIN_CHAT_TIME, cfg_col_chat_time, cfg_col_chat_bg);
gui_color[COLOR_WIN_CHAT_TIME_SEP] = gui_color_build (COLOR_WIN_CHAT_TIME_SEP, cfg_col_chat_time_sep, cfg_col_chat_bg);
gui_color[COLOR_WIN_CHAT_PREFIX1] = gui_color_build (COLOR_WIN_CHAT_PREFIX1, cfg_col_chat_prefix1, cfg_col_chat_bg);
gui_color[COLOR_WIN_CHAT_PREFIX2] = gui_color_build (COLOR_WIN_CHAT_PREFIX2, cfg_col_chat_prefix2, cfg_col_chat_bg);
gui_color[COLOR_WIN_CHAT_SERVER] = gui_color_build (COLOR_WIN_CHAT_SERVER, cfg_col_chat_server, cfg_col_chat_bg);
gui_color[COLOR_WIN_CHAT_JOIN] = gui_color_build (COLOR_WIN_CHAT_JOIN, cfg_col_chat_join, cfg_col_chat_bg);
gui_color[COLOR_WIN_CHAT_PART] = gui_color_build (COLOR_WIN_CHAT_PART, cfg_col_chat_part, cfg_col_chat_bg);
gui_color[COLOR_WIN_CHAT_NICK] = gui_color_build (COLOR_WIN_CHAT_NICK, cfg_col_chat_nick, cfg_col_chat_bg);
gui_color[COLOR_WIN_CHAT_HOST] = gui_color_build (COLOR_WIN_CHAT_HOST, cfg_col_chat_host, cfg_col_chat_bg);
gui_color[COLOR_WIN_CHAT_CHANNEL] = gui_color_build (COLOR_WIN_CHAT_CHANNEL, cfg_col_chat_channel, cfg_col_chat_bg);
gui_color[COLOR_WIN_CHAT_DARK] = gui_color_build (COLOR_WIN_CHAT_DARK, cfg_col_chat_dark, cfg_col_chat_bg);
gui_color[COLOR_WIN_CHAT_HIGHLIGHT] = gui_color_build (COLOR_WIN_CHAT_HIGHLIGHT, cfg_col_chat_highlight, cfg_col_chat_bg);
gui_color[COLOR_WIN_CHAT_READ_MARKER] = gui_color_build (COLOR_WIN_CHAT_READ_MARKER, cfg_col_chat_read_marker, cfg_col_chat_read_marker_bg);
gui_color[COLOR_WIN_STATUS] = gui_color_build (COLOR_WIN_STATUS, cfg_col_status, cfg_col_status_bg);
gui_color[COLOR_WIN_STATUS_DELIMITERS] = gui_color_build (COLOR_WIN_STATUS_DELIMITERS, cfg_col_status_delimiters, cfg_col_status_bg);
gui_color[COLOR_WIN_STATUS_CHANNEL] = gui_color_build (COLOR_WIN_STATUS_CHANNEL, cfg_col_status_channel, cfg_col_status_bg);
gui_color[COLOR_WIN_STATUS_DATA_MSG] = gui_color_build (COLOR_WIN_STATUS_DATA_MSG, cfg_col_status_data_msg, cfg_col_status_bg);
gui_color[COLOR_WIN_STATUS_DATA_PRIVATE] = gui_color_build (COLOR_WIN_STATUS_DATA_PRIVATE, cfg_col_status_data_private, cfg_col_status_bg);
gui_color[COLOR_WIN_STATUS_DATA_HIGHLIGHT] = gui_color_build (COLOR_WIN_STATUS_DATA_HIGHLIGHT, cfg_col_status_data_highlight, cfg_col_status_bg);
gui_color[COLOR_WIN_STATUS_DATA_OTHER] = gui_color_build (COLOR_WIN_STATUS_DATA_OTHER, cfg_col_status_data_other, cfg_col_status_bg);
gui_color[COLOR_WIN_STATUS_MORE] = gui_color_build (COLOR_WIN_STATUS_MORE, cfg_col_status_more, cfg_col_status_bg);
gui_color[COLOR_WIN_INFOBAR] = gui_color_build (COLOR_WIN_INFOBAR, cfg_col_infobar, cfg_col_infobar_bg);
gui_color[COLOR_WIN_INFOBAR_DELIMITERS] = gui_color_build (COLOR_WIN_INFOBAR_DELIMITERS, cfg_col_infobar_delimiters, cfg_col_infobar_bg);
gui_color[COLOR_WIN_INFOBAR_HIGHLIGHT] = gui_color_build (COLOR_WIN_INFOBAR_HIGHLIGHT, cfg_col_infobar_highlight, cfg_col_infobar_bg);
gui_color[COLOR_WIN_INPUT] = gui_color_build (COLOR_WIN_INPUT, cfg_col_input, cfg_col_input_bg);
gui_color[COLOR_WIN_INPUT_CHANNEL] = gui_color_build (COLOR_WIN_INPUT_CHANNEL, cfg_col_input_channel, cfg_col_input_bg);
gui_color[COLOR_WIN_INPUT_NICK] = gui_color_build (COLOR_WIN_INPUT_NICK, cfg_col_input_nick, cfg_col_input_bg);
gui_color[COLOR_WIN_INPUT_DELIMITERS] = gui_color_build (COLOR_WIN_INPUT_DELIMITERS, cfg_col_input_delimiters, cfg_col_input_bg);
gui_color[COLOR_WIN_NICK] = gui_color_build (COLOR_WIN_NICK, cfg_col_nick, cfg_col_nick_bg);
gui_color[COLOR_WIN_NICK_AWAY] = gui_color_build (COLOR_WIN_NICK_AWAY, cfg_col_nick_away, cfg_col_nick_bg);
gui_color[COLOR_WIN_NICK_CHANOWNER] = gui_color_build (COLOR_WIN_NICK_CHANOWNER, cfg_col_nick_chanowner, cfg_col_nick_bg);
gui_color[COLOR_WIN_NICK_CHANADMIN] = gui_color_build (COLOR_WIN_NICK_CHANADMIN, cfg_col_nick_chanadmin, cfg_col_nick_bg);
gui_color[COLOR_WIN_NICK_OP] = gui_color_build (COLOR_WIN_NICK_OP, cfg_col_nick_op, cfg_col_nick_bg);
gui_color[COLOR_WIN_NICK_HALFOP] = gui_color_build (COLOR_WIN_NICK_HALFOP, cfg_col_nick_halfop, cfg_col_nick_bg);
gui_color[COLOR_WIN_NICK_VOICE] = gui_color_build (COLOR_WIN_NICK_VOICE, cfg_col_nick_voice, cfg_col_nick_bg);
gui_color[COLOR_WIN_NICK_MORE] = gui_color_build (COLOR_WIN_NICK_MORE, cfg_col_nick_more, cfg_col_nick_bg);
gui_color[COLOR_WIN_NICK_SEP] = gui_color_build (COLOR_WIN_NICK_SEP, cfg_col_nick_sep, cfg_col_nick_bg);
gui_color[COLOR_WIN_NICK_SELF] = gui_color_build (COLOR_WIN_NICK_SELF, cfg_col_nick_self, cfg_col_nick_bg);
gui_color[COLOR_WIN_NICK_PRIVATE] = gui_color_build (COLOR_WIN_NICK_PRIVATE, cfg_col_nick_private, cfg_col_nick_bg);
for (i = 0; i < COLOR_WIN_NICK_NUMBER; i++)
{
gui_color[COLOR_WIN_NICK_1 + i] = gui_color_build (COLOR_WIN_NICK_1 + i, cfg_col_nick_colors[i], cfg_col_chat_bg);
}
gui_color[COLOR_DCC_SELECTED] = gui_color_build (COLOR_DCC_SELECTED, cfg_col_dcc_selected, cfg_col_chat_bg);
gui_color[COLOR_DCC_WAITING] = gui_color_build (COLOR_DCC_WAITING, cfg_col_dcc_waiting, cfg_col_chat_bg);
gui_color[COLOR_DCC_CONNECTING] = gui_color_build (COLOR_DCC_CONNECTING, cfg_col_dcc_connecting, cfg_col_chat_bg);
gui_color[COLOR_DCC_ACTIVE] = gui_color_build (COLOR_DCC_ACTIVE, cfg_col_dcc_active, cfg_col_chat_bg);
gui_color[COLOR_DCC_DONE] = gui_color_build (COLOR_DCC_DONE, cfg_col_dcc_done, cfg_col_chat_bg);
gui_color[COLOR_DCC_FAILED] = gui_color_build (COLOR_DCC_FAILED, cfg_col_dcc_failed, cfg_col_chat_bg);
gui_color[COLOR_DCC_ABORTED] = gui_color_build (COLOR_DCC_ABORTED, cfg_col_dcc_aborted, cfg_col_chat_bg);
}
/*
* gui_color_rebuild_weechat: rebuild WeeChat colors
*/
void
gui_color_rebuild_weechat ()
{
int i;
for (i = 0; i < GUI_NUM_COLORS; i++)
{
if (gui_color[i])
{
if (gui_color[i]->string)
free (gui_color[i]->string);
free (gui_color[i]);
gui_color[i] = NULL;
}
}
gui_color_init_weechat ();
}
/*
* gui_color_init: init GUI colors
*/
void
gui_color_init ()
{
gui_color_init_pairs ();
gui_color_init_weechat ();
}
+79
View File
@@ -0,0 +1,79 @@
/*
* Copyright (c) 2003-2006 by FlashCode <flashcode@flashtux.org>
* See README for License detail, AUTHORS for developers list.
*
* 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 St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/* gui-gtk-infobar.c: infobar display functions for Gtk GUI */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include <string.h>
#include "../../common/weechat.h"
#include "../gui.h"
#include "../../common/hotlist.h"
#include "../../common/weeconfig.h"
#include "gui-gtk.h"
/*
* gui_infobar_draw_time: draw time in infobar window
*/
void
gui_infobar_draw_time (t_gui_buffer *buffer)
{
/*t_gui_window *ptr_win;
time_t time_seconds;
struct tm *local_time;*/
/* make gcc happy */
(void) buffer;
if (!gui_ok)
return;
/* TODO: write this function for Gtk */
(void) buffer;
}
/*
* gui_infobar_draw: draw infobar window for a buffer
*/
void
gui_infobar_draw (t_gui_buffer *buffer, int erase)
{
/*t_gui_window *ptr_win;
time_t time_seconds;
struct tm *local_time;
char text_time[1024 + 1];*/
/* make gcc happy */
(void) buffer;
if (!gui_ok)
return;
/* TODO: write this function for Gtk */
(void) buffer;
(void) erase;
}
+179
View File
@@ -0,0 +1,179 @@
/*
* Copyright (c) 2003-2006 by FlashCode <flashcode@flashtux.org>
* See README for License detail, AUTHORS for developers list.
*
* 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 St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/* gui-gtk-input: user input functions for Gtk GUI */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include "../../common/weechat.h"
#include "../gui.h"
#include "../../common/utf8.h"
#include "../../common/weeconfig.h"
#include "gui-gtk.h"
#ifdef PLUGINS
#include "../../plugins/plugins.h"
#endif
/*
* gui_input_set_color: set color for an input window
*/
void
gui_input_set_color (t_gui_window *window, int irc_color)
{
/*int fg, bg;*/
/* TODO: write this function for Gtk */
(void) window;
(void) irc_color;
}
/*
* gui_input_get_prompt_length: return input prompt length
*/
int
gui_input_get_prompt_length (t_gui_window *window, char *nick)
{
char *pos, *modes;
int length, mode_found;
length = 0;
pos = cfg_look_input_format;
while (pos && pos[0])
{
switch (pos[0])
{
case '%':
pos++;
switch (pos[0])
{
case 'c':
if (CHANNEL(window->buffer))
length += utf8_strlen (CHANNEL(window->buffer)->name);
else
{
if (SERVER(window->buffer))
length += utf8_strlen (SERVER(window->buffer)->name);
}
pos++;
break;
case 'm':
if (SERVER(window->buffer))
{
mode_found = 0;
for (modes = SERVER(window->buffer)->nick_modes;
modes && modes[0]; modes++)
{
if (modes[0] != ' ')
{
length++;
mode_found = 1;
}
}
if (mode_found)
length++;
}
pos++;
break;
case 'n':
length += utf8_strlen (nick);
pos++;
break;
default:
length++;
if (pos[0])
{
if (pos[0] == '%')
pos++;
else
{
length++;
pos += utf8_char_size (pos);
}
}
break;
}
break;
default:
length++;
pos += utf8_char_size (pos);
break;
}
}
return length;
}
/*
* gui_input_draw_prompt: display input prompt
*/
void
gui_input_draw_prompt (t_gui_window *window, char *nick)
{
/*char *pos, saved_char, *modes;
int char_size, mode_found;*/
/* TODO: write this function for Gtk */
(void) window;
(void) nick;
}
/*
* gui_input_draw_text: display text in input buffer, according to color mask
*/
void
gui_input_draw_text (t_gui_window *window, int input_width)
{
/*char *ptr_start, *ptr_next, saved_char;
int pos_mask, size, last_color, color;*/
/* TODO: write this function for Gtk */
(void) window;
(void) input_width;
}
/*
* gui_input_draw: draw input window for a buffer
*/
void
gui_input_draw (t_gui_buffer *buffer, int erase)
{
/*t_gui_window *ptr_win;
char format[32];
char *ptr_nickname;
int input_width;
t_irc_dcc *dcc_selected;*/
if (!gui_ok)
return;
/* TODO: write this function for Gtk */
(void) buffer;
(void) erase;
}
+172
View File
@@ -0,0 +1,172 @@
/*
* Copyright (c) 2003-2006 by FlashCode <flashcode@flashtux.org>
* See README for License detail, AUTHORS for developers list.
*
* 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 St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/* gui-gtk-keyboard.c: keyboard functions for Gtk GUI */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include <string.h>
#include "../../common/weechat.h"
#include "../gui.h"
#include "../../common/utf8.h"
#include "gui-gtk.h"
#ifdef PLUGINS
#include "../../plugins/plugins.h"
#endif
/*
* gui_keyboard_default_bindings: create default key bindings
*/
void
gui_keyboard_default_bindings ()
{
int i;
char key_str[32], command[32];
/* keys binded with internal functions */
gui_keyboard_bind ( /* RC */ "ctrl-M", "return");
gui_keyboard_bind ( /* RC */ "ctrl-J", "return");
gui_keyboard_bind ( /* tab */ "ctrl-I", "tab");
gui_keyboard_bind ( /* basckp */ "ctrl-H", "backspace");
gui_keyboard_bind ( /* basckp */ "ctrl-?", "backspace");
gui_keyboard_bind ( /* del */ "meta2-3~", "delete");
gui_keyboard_bind ( /* ^K */ "ctrl-K", "delete_end_line");
gui_keyboard_bind ( /* ^U */ "ctrl-U", "delete_beginning_line");
gui_keyboard_bind ( /* ^W */ "ctrl-W", "delete_previous_word");
gui_keyboard_bind ( /* ^Y */ "ctrl-Y", "clipboard_paste");
gui_keyboard_bind ( /* ^T */ "ctrl-T", "transpose_chars");
gui_keyboard_bind ( /* home */ "meta2-1~", "home");
gui_keyboard_bind ( /* home */ "meta2-H", "home");
gui_keyboard_bind ( /* home */ "meta2-7~", "home");
gui_keyboard_bind ( /* ^A */ "ctrl-A", "home");
gui_keyboard_bind ( /* end */ "meta2-4~", "end");
gui_keyboard_bind ( /* end */ "meta2-F", "end");
gui_keyboard_bind ( /* end */ "meta2-8~", "end");
gui_keyboard_bind ( /* ^E */ "ctrl-E", "end");
gui_keyboard_bind ( /* left */ "meta2-D", "left");
gui_keyboard_bind ( /* right */ "meta2-C", "right");
gui_keyboard_bind ( /* up */ "meta2-A", "up");
gui_keyboard_bind ( /* ^up */ "meta-Oa", "up_global");
gui_keyboard_bind ( /* down */ "meta2-B", "down");
gui_keyboard_bind ( /* ^down */ "meta-Ob", "down_global");
gui_keyboard_bind ( /* pgup */ "meta2-5~", "page_up");
gui_keyboard_bind ( /* pgdn */ "meta2-6~", "page_down");
gui_keyboard_bind ( /* m-pgup */ "meta-meta2-5~", "scroll_up");
gui_keyboard_bind ( /* m-pgdn */ "meta-meta2-6~", "scroll_down");
gui_keyboard_bind ( /* F10 */ "meta2-21~", "infobar_clear");
gui_keyboard_bind ( /* F11 */ "meta2-23~", "nick_page_up");
gui_keyboard_bind ( /* F12 */ "meta2-24~", "nick_page_down");
gui_keyboard_bind ( /* m-F11 */ "meta-meta2-1~", "nick_beginning");
gui_keyboard_bind ( /* m-F12 */ "meta-meta2-4~", "nick_end");
gui_keyboard_bind ( /* ^L */ "ctrl-L", "refresh");
gui_keyboard_bind ( /* m-a */ "meta-a", "jump_smart");
gui_keyboard_bind ( /* m-b */ "meta-b", "previous_word");
gui_keyboard_bind ( /* ^left */ "meta-Od", "previous_word");
gui_keyboard_bind ( /* m-d */ "meta-d", "delete_next_word");
gui_keyboard_bind ( /* m-f */ "meta-f", "next_word");
gui_keyboard_bind ( /* ^right */ "meta-Oc", "next_word");
gui_keyboard_bind ( /* m-h */ "meta-h", "hotlist_clear");
gui_keyboard_bind ( /* m-j,m-d */ "meta-jmeta-d", "jump_dcc");
gui_keyboard_bind ( /* m-j,m-l */ "meta-jmeta-l", "jump_last_buffer");
gui_keyboard_bind ( /* m-j,m-s */ "meta-jmeta-s", "jump_server");
gui_keyboard_bind ( /* m-j,m-x */ "meta-jmeta-x", "jump_next_server");
gui_keyboard_bind ( /* m-k */ "meta-k", "grab_key");
gui_keyboard_bind ( /* m-n */ "meta-n", "scroll_next_highlight");
gui_keyboard_bind ( /* m-p */ "meta-p", "scroll_previous_highlight");
gui_keyboard_bind ( /* m-r */ "meta-r", "delete_line");
gui_keyboard_bind ( /* m-s */ "meta-s", "switch_server");
gui_keyboard_bind ( /* m-u */ "meta-u", "scroll_unread");
/* keys binded with commands */
gui_keyboard_bind ( /* m-left */ "meta-meta2-D", "/buffer -1");
gui_keyboard_bind ( /* F5 */ "meta2-15~", "/buffer -1");
gui_keyboard_bind ( /* m-right */ "meta-meta2-C", "/buffer +1");
gui_keyboard_bind ( /* F6 */ "meta2-17~", "/buffer +1");
gui_keyboard_bind ( /* F7 */ "meta2-18~", "/window -1");
gui_keyboard_bind ( /* F8 */ "meta2-19~", "/window +1");
gui_keyboard_bind ( /* m-w,m-up */ "meta-wmeta-meta2-A", "/window up");
gui_keyboard_bind ( /* m-w,m-down */ "meta-wmeta-meta2-B", "/window down");
gui_keyboard_bind ( /* m-w,m-left */ "meta-wmeta-meta2-D", "/window left");
gui_keyboard_bind ( /* m-w,m-right */ "meta-wmeta-meta2-C", "/window right");
gui_keyboard_bind ( /* m-0 */ "meta-0", "/buffer 10");
gui_keyboard_bind ( /* m-1 */ "meta-1", "/buffer 1");
gui_keyboard_bind ( /* m-2 */ "meta-2", "/buffer 2");
gui_keyboard_bind ( /* m-3 */ "meta-3", "/buffer 3");
gui_keyboard_bind ( /* m-4 */ "meta-4", "/buffer 4");
gui_keyboard_bind ( /* m-5 */ "meta-5", "/buffer 5");
gui_keyboard_bind ( /* m-6 */ "meta-6", "/buffer 6");
gui_keyboard_bind ( /* m-7 */ "meta-7", "/buffer 7");
gui_keyboard_bind ( /* m-8 */ "meta-8", "/buffer 8");
gui_keyboard_bind ( /* m-9 */ "meta-9", "/buffer 9");
/* bind meta-j + {01..99} to switch to buffers # > 10 */
for (i = 1; i < 100; i++)
{
sprintf (key_str, "meta-j%02d", i);
sprintf (command, "/buffer %d", i);
gui_keyboard_bind (key_str, command);
}
}
/*
* gui_keyboard_grab_end: insert grabbed key in input buffer
*/
void
gui_keyboard_grab_end ()
{
char *expanded_key;
/* get expanded name (for example: ^U => ctrl-u) */
expanded_key = gui_keyboard_get_expanded_name (gui_key_buffer);
if (expanded_key)
{
if (gui_current_window->buffer->has_input)
{
gui_insert_string_input (gui_current_window, expanded_key, -1);
gui_current_window->buffer->input_buffer_pos += utf8_strlen (expanded_key);
gui_input_draw (gui_current_window->buffer, 1);
}
free (expanded_key);
}
/* end grab mode */
gui_key_grab = 0;
gui_key_grab_count = 0;
gui_key_buffer[0] = '\0';
}
/*
* gui_keyboard_read: read keyboard chars
*/
void
gui_keyboard_read ()
{
/* TODO: write this function for Gtk */
}
+220
View File
@@ -0,0 +1,220 @@
/*
* Copyright (c) 2003-2006 by FlashCode <flashcode@flashtux.org>
* See README for License detail, AUTHORS for developers list.
*
* 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 St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/* gui-gtk-main.c: main loop for Gtk GUI */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <signal.h>
#include "../../common/weechat.h"
#include "../gui.h"
#include "../../common/fifo.h"
#include "../../common/utf8.h"
#include "../../common/weeconfig.h"
#include "gui-gtk.h"
#ifdef PLUGINS
#include "../../plugins/plugins.h"
#endif
GtkWidget *gtk_main_window;
GtkWidget *vbox1;
GtkWidget *entry_topic;
GtkWidget *notebook1;
GtkWidget *vbox2;
GtkWidget *hbox1;
GtkWidget *hpaned1;
GtkWidget *scrolledwindow_chat;
GtkWidget *scrolledwindow_nick;
GtkWidget *entry_input;
GtkWidget *label1;
/*
* gui_main_loop: main loop for WeeChat with Gtk GUI
*/
void
gui_main_loop ()
{
/* TODO: write this function for Gtk */
gtk_main ();
}
/*
* gui_main_pre_init: pre-initialize GUI (called before gui_init)
*/
void
gui_main_pre_init (int *argc, char **argv[])
{
/* Initialise Gtk */
gtk_init (argc, argv);
}
/*
* gui_main_init: init GUI
*/
void
gui_main_init ()
{
GdkColor color_fg, color_bg;
gui_color_init ();
gui_infobar = NULL;
gui_ok = 1;
/* init clipboard buffer */
gui_input_clipboard = NULL;
/* create Gtk widgets */
gdk_color_parse ("white", &color_fg);
gdk_color_parse ("black", &color_bg);
gtk_main_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (gtk_main_window), PACKAGE_STRING);
g_signal_connect (G_OBJECT (gtk_main_window), "destroy", gtk_main_quit, NULL);
vbox1 = gtk_vbox_new (FALSE, 0);
gtk_widget_show (vbox1);
gtk_container_add (GTK_CONTAINER (gtk_main_window), vbox1);
entry_topic = gtk_entry_new ();
gtk_widget_show (entry_topic);
gtk_box_pack_start (GTK_BOX (vbox1), entry_topic, FALSE, FALSE, 0);
gtk_widget_modify_text (entry_topic, GTK_STATE_NORMAL, &color_fg);
gtk_widget_modify_base (entry_topic, GTK_STATE_NORMAL, &color_bg);
notebook1 = gtk_notebook_new ();
gtk_widget_show (notebook1);
gtk_box_pack_start (GTK_BOX (vbox1), notebook1, TRUE, TRUE, 0);
gtk_notebook_set_tab_pos (GTK_NOTEBOOK (notebook1), GTK_POS_BOTTOM);
vbox2 = gtk_vbox_new (FALSE, 0);
gtk_widget_show (vbox2);
gtk_container_add (GTK_CONTAINER (notebook1), vbox2);
hbox1 = gtk_hbox_new (FALSE, 0);
gtk_widget_show (hbox1);
gtk_box_pack_start (GTK_BOX (vbox2), hbox1, TRUE, TRUE, 0);
hpaned1 = gtk_hpaned_new ();
gtk_widget_show (hpaned1);
gtk_box_pack_start (GTK_BOX (hbox1), hpaned1, TRUE, TRUE, 0);
gtk_paned_set_position (GTK_PANED (hpaned1), 0);
scrolledwindow_chat = gtk_scrolled_window_new (NULL, NULL);
gtk_widget_show (scrolledwindow_chat);
gtk_paned_pack1 (GTK_PANED (hpaned1), scrolledwindow_chat, FALSE, TRUE);
//gtk_box_pack_start (GTK_PANED (hpaned1), scrolledwindow_chat, TRUE, TRUE, 0);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow_chat), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
gtk_widget_modify_text (scrolledwindow_chat, GTK_STATE_NORMAL, &color_fg);
gtk_widget_modify_base (scrolledwindow_chat, GTK_STATE_NORMAL, &color_bg);
scrolledwindow_nick = gtk_scrolled_window_new (NULL, NULL);
gtk_widget_show (scrolledwindow_nick);
gtk_paned_pack2 (GTK_PANED (hpaned1), scrolledwindow_nick, FALSE, TRUE);
//gtk_box_pack_start (GTK_PANED (hpaned1), scrolledwindow_nick, TRUE, TRUE, 0);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow_nick), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
gtk_widget_modify_text (scrolledwindow_nick, GTK_STATE_NORMAL, &color_fg);
gtk_widget_modify_base (scrolledwindow_nick, GTK_STATE_NORMAL, &color_bg);
entry_input = gtk_entry_new ();
gtk_widget_show (entry_input);
gtk_box_pack_start (GTK_BOX (vbox2), entry_input, FALSE, FALSE, 0);
gtk_widget_modify_text (entry_input, GTK_STATE_NORMAL, &color_fg);
gtk_widget_modify_base (entry_input, GTK_STATE_NORMAL, &color_bg);
label1 = gtk_label_new (_("server"));
gtk_widget_show (label1);
gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook1), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook1), 0), label1);
gtk_label_set_justify (GTK_LABEL (label1), GTK_JUSTIFY_LEFT);
gtk_widget_show_all (gtk_main_window);
/* create new window/buffer */
if (gui_window_new (NULL, 0, 0, 0, 0, 100, 100))
{
gui_current_window = gui_windows;
gui_buffer_new (gui_windows, NULL, NULL, 0, 1);
if (cfg_look_set_title)
gui_window_set_title ();
gui_init_ok = 1;
}
}
/*
* gui_main_end: GUI end
*/
void
gui_main_end ()
{
t_gui_window *ptr_win;
/* free clipboard buffer */
if (gui_input_clipboard)
free(gui_input_clipboard);
/* delete all panels */
while (gui_panels)
gui_panel_free (gui_panels);
/* delete all windows */
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
{
/* TODO: destroy Gtk widgets */
}
/* delete all buffers */
while (gui_buffers)
gui_buffer_free (gui_buffers, 0);
/* delete all windows */
while (gui_windows)
gui_window_free (gui_windows);
gui_window_tree_free (&gui_windows_tree);
/* delete global history */
history_global_free ();
/* delete infobar messages */
while (gui_infobar)
gui_infobar_remove ();
/* reset title */
if (cfg_look_set_title)
gui_window_reset_title ();
}
@@ -17,46 +17,36 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/* gui-input: user input functions for Gtk GUI */
/* gui-gtk-nicklist.c: nicklist display functions for Gtk GUI */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <signal.h>
#include <time.h>
#include <sys/socket.h>
#include <gtk/gtk.h>
#include "../../common/weechat.h"
#include "../gui.h"
#include "../../common/weeconfig.h"
#include "../../common/command.h"
#include "../../irc/irc.h"
#include "gui-gtk.h"
/*
* gui_read_keyb: read keyboard line
* gui_nicklist_draw: draw nick window for a buffer
*/
void
gui_read_keyb ()
gui_nicklist_draw (t_gui_buffer *buffer, int erase)
{
/* TODO: read keyboard for Gtk GUI */
}
/*
* gui_main_loop: main loop for WeeChat with Gtk GUI
*/
void
gui_main_loop ()
{
/* TODO: main loop function for Gtk GUI */
gtk_main ();
/*t_gui_window *ptr_win;
int i, j, x, y, column, max_length, nicks_displayed;
char format[32], format_empty[32];
t_irc_nick *ptr_nick;*/
if (!gui_ok || !BUFFER_HAS_NICKLIST(buffer))
return;
/* TODO: write this function for Gtk */
(void) buffer;
(void) erase;
}
+61
View File
@@ -0,0 +1,61 @@
/*
* Copyright (c) 2003-2006 by FlashCode <flashcode@flashtux.org>
* See README for License detail, AUTHORS for developers list.
*
* 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 St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/* gui-gtk-panel.c: panel functions for Gtk GUI */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include "../../common/weechat.h"
#include "../gui.h"
#include "gui-gtk.h"
/*
* gui_panel_window_new: create a new "window panel" for a panel, in screen or a window
* if window is not NULL, panel window will be in this window
*/
int
gui_panel_window_new (t_gui_panel *panel, t_gui_window *window)
{
/* TODO: write this function for Gtk */
(void) panel;
(void) window;
return 1;
}
/*
* gui_panel_window_free: delete a panel window
*/
void
gui_panel_window_free (void *panel_win)
{
t_gui_panel_window *ptr_panel_win;
ptr_panel_win = (t_gui_panel_window *)panel_win;
free (ptr_panel_win);
}
+59
View File
@@ -0,0 +1,59 @@
/*
* Copyright (c) 2003-2006 by FlashCode <flashcode@flashtux.org>
* See README for License detail, AUTHORS for developers list.
*
* 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 St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/* gui-gtk-status.c: status display functions for Gtk GUI */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include <string.h>
#include "../../common/weechat.h"
#include "../gui.h"
#include "../../common/hotlist.h"
#include "../../common/weeconfig.h"
#include "gui-gtk.h"
/*
* gui_status_draw: draw status window for a buffer
*/
void
gui_status_draw (t_gui_buffer *buffer, int erase)
{
/*t_gui_window *ptr_win;
t_weechat_hotlist *ptr_hotlist;
char format[32], str_nicks[32], *more;
int i, first_mode, x, server_pos, server_total;
int display_name, names_count;*/
/* make gcc happy */
(void) buffer;
if (!gui_ok)
return;
/* TODO: write this function for Gtk */
(void) buffer;
(void) erase;
}
+886
View File
@@ -0,0 +1,886 @@
/*
* Copyright (c) 2003-2006 by FlashCode <flashcode@flashtux.org>
* See README for License detail, AUTHORS for developers list.
*
* 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 St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/* gui-gtk-window.c: window display functions for Gtk GUI */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include <string.h>
#include "../../common/weechat.h"
#include "../gui.h"
#include "../../common/hotlist.h"
#include "../../common/log.h"
#include "../../common/weeconfig.h"
#include "gui-gtk.h"
/*
* gui_window_get_width: get screen width
*/
int
gui_window_get_width ()
{
return 0;
}
/*
* gui_window_get_height: get screen height
*/
int
gui_window_get_height ()
{
return 0;
}
/*
* gui_window_objects_init: init Gtk widgets
*/
int
gui_window_objects_init (t_gui_window *window)
{
t_gui_gtk_objects *new_objects;
if ((new_objects = (t_gui_gtk_objects *) malloc (sizeof (t_gui_gtk_objects))))
{
window->gui_objects = new_objects;
GUI_GTK(window)->textview_chat = NULL;
GUI_GTK(window)->textbuffer_chat = NULL;
GUI_GTK(window)->texttag_chat = NULL;
GUI_GTK(window)->textview_nicklist = NULL;
GUI_GTK(window)->textbuffer_nicklist = NULL;
GUI_GTK(window)->panel_windows = NULL;
return 1;
}
else
return 0;
}
/*
* gui_window_objects_free: free Gtk widgets for a window
*/
void
gui_window_objects_free (t_gui_window *window, int free_separator)
{
/* TODO: write this function for Gtk */
(void) window;
(void) free_separator;
}
/*
* gui_window_set_weechat_color: set WeeChat color for window
*/
/* TODO: write this function for Gtk */
/*void
gui_window_set_weechat_color (WINDOW *window, int num_color)
{
if ((num_color >= 0) && (num_color <= GUI_NUM_COLORS - 1))
{
wattroff (window, A_BOLD | A_UNDERLINE | A_REVERSE);
wattron (window, COLOR_PAIR(gui_color_get_pair (num_color)) |
gui_color[num_color]->attributes);
}
}*/
/*
* gui_window_calculate_pos_size: calculate position and size for a window & sub-win
*/
int
gui_window_calculate_pos_size (t_gui_window *window, int force_calculate)
{
/* TODO: write this function for Gtk */
(void) window;
(void) force_calculate;
return 0;
}
/*
* gui_window_draw_separator: draw window separation
*/
void
gui_window_draw_separator (t_gui_window *window)
{
/* TODO: write this function for Gtk */
/*if (window->win_separator)
delwin (window->win_separator);
if (window->win_x > 0)
{
window->win_separator = newwin (window->win_height,
1,
window->win_y,
window->win_x - 1);
gui_window_set_weechat_color (window->win_separator, COLOR_WIN_SEPARATOR);
wborder (window->win_separator, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ');
wnoutrefresh (window->win_separator);
refresh ();
}*/
(void) window;
}
/*
* gui_window_redraw_buffer: redraw a buffer
*/
void
gui_window_redraw_buffer (t_gui_buffer *buffer)
{
/* TODO: write this function for Gtk */
(void) buffer;
}
/*
* gui_window_switch_to_buffer: switch to another buffer
*/
void
gui_window_switch_to_buffer (t_gui_window *window, t_gui_buffer *buffer)
{
GtkTextIter start, end;
if (window->buffer->num_displayed > 0)
window->buffer->num_displayed--;
if (window->buffer != buffer)
{
window->buffer->last_read_line = window->buffer->last_line;
if (buffer->last_read_line == buffer->last_line)
buffer->last_read_line = NULL;
}
window->buffer = buffer;
window->win_nick_start = 0;
gui_window_calculate_pos_size (window, 1);
if (!GUI_GTK(window)->textview_chat)
{
GUI_GTK(window)->textview_chat = gtk_text_view_new ();
gtk_widget_show (GUI_GTK(window)->textview_chat);
gtk_container_add (GTK_CONTAINER (scrolledwindow_chat), GUI_GTK(window)->textview_chat);
gtk_widget_set_size_request (GUI_GTK(window)->textview_chat, 300, -1);
gtk_text_view_set_editable (GTK_TEXT_VIEW (GUI_GTK(window)->textview_chat), FALSE);
gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (GUI_GTK(window)->textview_chat), FALSE);
GUI_GTK(window)->textbuffer_chat = gtk_text_buffer_new (NULL);
gtk_text_view_set_buffer (GTK_TEXT_VIEW (GUI_GTK(window)->textview_chat), GUI_GTK(window)->textbuffer_chat);
/*GUI_GTK(window)->texttag_chat = gtk_text_buffer_create_tag(GUI_GTK(window)->textbuffer_chat, "courier", "font_family", "lucida");*/
gtk_text_buffer_get_bounds (GUI_GTK(window)->textbuffer_chat, &start, &end);
gtk_text_buffer_apply_tag (GUI_GTK(window)->textbuffer_chat, GUI_GTK(window)->texttag_chat, &start, &end);
}
if (BUFFER_IS_CHANNEL(buffer) && !GUI_GTK(window)->textbuffer_nicklist)
{
GUI_GTK(window)->textview_nicklist = gtk_text_view_new ();
gtk_widget_show (GUI_GTK(window)->textview_nicklist);
gtk_container_add (GTK_CONTAINER (scrolledwindow_nick), GUI_GTK(window)->textview_nicklist);
gtk_text_view_set_editable (GTK_TEXT_VIEW (GUI_GTK(window)->textview_nicklist), FALSE);
gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (GUI_GTK(window)->textview_nicklist), FALSE);
GUI_GTK(window)->textbuffer_nicklist = gtk_text_buffer_new (NULL);
gtk_text_view_set_buffer (GTK_TEXT_VIEW (GUI_GTK(window)->textview_nicklist), GUI_GTK(window)->textbuffer_nicklist);
}
window->start_line = NULL;
window->start_line_pos = 0;
buffer->num_displayed++;
hotlist_remove_buffer (buffer);
}
/*
* gui_window_page_up: display previous page on buffer
*/
void
gui_window_page_up (t_gui_window *window)
{
if (!gui_ok)
return;
if (!window->first_line_displayed)
{
gui_chat_calculate_line_diff (window, &window->start_line,
&window->start_line_pos,
(window->start_line) ?
(-1) * (window->win_chat_height - 1) :
(-1) * ((window->win_chat_height - 1) * 2));
gui_chat_draw (window->buffer, 0);
gui_status_draw (window->buffer, 0);
}
}
/*
* gui_window_page_down: display next page on buffer
*/
void
gui_window_page_down (t_gui_window *window)
{
t_gui_line *ptr_line;
int line_pos;
if (!gui_ok)
return;
if (window->start_line)
{
gui_chat_calculate_line_diff (window, &window->start_line,
&window->start_line_pos,
window->win_chat_height - 1);
/* check if we can display all */
ptr_line = window->start_line;
line_pos = window->start_line_pos;
gui_chat_calculate_line_diff (window, &ptr_line,
&line_pos,
window->win_chat_height - 1);
if (!ptr_line)
{
window->start_line = NULL;
window->start_line_pos = 0;
}
gui_chat_draw (window->buffer, 0);
gui_status_draw (window->buffer, 0);
}
}
/*
* gui_window_scroll_up: display previous few lines in buffer
*/
void
gui_window_scroll_up (t_gui_window *window)
{
if (!gui_ok)
return;
if (!window->first_line_displayed)
{
gui_chat_calculate_line_diff (window, &window->start_line,
&window->start_line_pos,
(window->start_line) ?
(-1) * cfg_look_scroll_amount :
(-1) * ( (window->win_chat_height - 1) + cfg_look_scroll_amount));
gui_chat_draw (window->buffer, 0);
gui_status_draw (window->buffer, 0);
}
}
/*
* gui_window_scroll_down: display next few lines in buffer
*/
void
gui_window_scroll_down (t_gui_window *window)
{
t_gui_line *ptr_line;
int line_pos;
if (!gui_ok)
return;
if (window->start_line)
{
gui_chat_calculate_line_diff (window, &window->start_line,
&window->start_line_pos,
cfg_look_scroll_amount);
/* check if we can display all */
ptr_line = window->start_line;
line_pos = window->start_line_pos;
gui_chat_calculate_line_diff (window, &ptr_line,
&line_pos,
window->win_chat_height - 1);
if (!ptr_line)
{
window->start_line = NULL;
window->start_line_pos = 0;
}
gui_chat_draw (window->buffer, 0);
gui_status_draw (window->buffer, 0);
}
}
/*
* gui_window_scroll_top: scroll to top of buffer
*/
void
gui_window_scroll_top (t_gui_window *window)
{
if (!gui_ok)
return;
if (!window->first_line_displayed)
{
window->start_line = window->buffer->lines;
window->start_line_pos = 0;
gui_chat_draw (window->buffer, 0);
gui_status_draw (window->buffer, 0);
}
}
/*
* gui_window_scroll_bottom: scroll to bottom of buffer
*/
void
gui_window_scroll_bottom (t_gui_window *window)
{
if (!gui_ok)
return;
if (window->start_line)
{
window->start_line = NULL;
window->start_line_pos = 0;
gui_chat_draw (window->buffer, 0);
gui_status_draw (window->buffer, 0);
}
}
/*
* gui_window_nick_beginning: go to beginning of nicklist
*/
void
gui_window_nick_beginning (t_gui_window *window)
{
if (!gui_ok)
return;
if (BUFFER_HAS_NICKLIST(window->buffer))
{
if (window->win_nick_start > 0)
{
window->win_nick_start = 0;
gui_nicklist_draw (window->buffer, 1);
}
}
}
/*
* gui_window_nick_end: go to the end of nicklist
*/
void
gui_window_nick_end (t_gui_window *window)
{
int new_start;
if (!gui_ok)
return;
if (BUFFER_HAS_NICKLIST(window->buffer))
{
new_start =
CHANNEL(window->buffer)->nicks_count - window->win_nick_height;
if (new_start < 0)
new_start = 0;
else if (new_start >= 1)
new_start++;
if (new_start != window->win_nick_start)
{
window->win_nick_start = new_start;
gui_nicklist_draw (window->buffer, 1);
}
}
}
/*
* gui_window_nick_page_up: scroll one page up in nicklist
*/
void
gui_window_nick_page_up (t_gui_window *window)
{
if (!gui_ok)
return;
if (BUFFER_HAS_NICKLIST(window->buffer))
{
if (window->win_nick_start > 0)
{
window->win_nick_start -= (window->win_nick_height - 1);
if (window->win_nick_start <= 1)
window->win_nick_start = 0;
gui_nicklist_draw (window->buffer, 1);
}
}
}
/*
* gui_window_nick_page_down: scroll one page down in nicklist
*/
void
gui_window_nick_page_down (t_gui_window *window)
{
if (!gui_ok)
return;
if (BUFFER_HAS_NICKLIST(window->buffer))
{
if ((CHANNEL(window->buffer)->nicks_count > window->win_nick_height)
&& (window->win_nick_start + window->win_nick_height - 1
< CHANNEL(window->buffer)->nicks_count))
{
if (window->win_nick_start == 0)
window->win_nick_start += (window->win_nick_height - 1);
else
window->win_nick_start += (window->win_nick_height - 2);
gui_nicklist_draw (window->buffer, 1);
}
}
}
/*
* gui_window_auto_resize: auto-resize all windows, according to % of global size
* This function is called after a terminal resize.
* Returns 0 if ok, -1 if all window should be merged
* (not enough space according to windows %)
*/
int
gui_window_auto_resize (t_gui_window_tree *tree,
int x, int y, int width, int height,
int simulate)
{
int size1, size2;
if (tree)
{
if (tree->window)
{
if ((width < WINDOW_MIN_WIDTH) || (height < WINDOW_MIN_HEIGHT))
return -1;
if (!simulate)
{
tree->window->win_x = x;
tree->window->win_y = y;
tree->window->win_width = width;
tree->window->win_height = height;
}
}
else
{
if (tree->split_horiz)
{
size1 = (height * tree->split_pct) / 100;
size2 = height - size1;
if (gui_window_auto_resize (tree->child1, x, y + size1,
width, size2, simulate) < 0)
return -1;
if (gui_window_auto_resize (tree->child2, x, y,
width, size1, simulate) < 0)
return -1;
}
else
{
size1 = (width * tree->split_pct) / 100;
size2 = width - size1 - 1;
if (gui_window_auto_resize (tree->child1, x, y,
size1, height, simulate) < 0)
return -1;
if (gui_window_auto_resize (tree->child2, x + size1 + 1, y,
size2, height, simulate) < 0)
return -1;
}
}
}
return 0;
}
/*
* gui_window_refresh_windows: auto resize and refresh all windows
*/
void
gui_window_refresh_windows ()
{
/*t_gui_window *ptr_win, *old_current_window;*/
if (gui_ok)
{
/* TODO: write this function for Gtk */
}
}
/*
* gui_window_split_horiz: split a window horizontally
*/
void
gui_window_split_horiz (t_gui_window *window, int pourcentage)
{
t_gui_window *new_window;
int height1, height2;
if (!gui_ok)
return;
height1 = (window->win_height * pourcentage) / 100;
height2 = window->win_height - height1;
if ((height1 >= WINDOW_MIN_HEIGHT) && (height2 >= WINDOW_MIN_HEIGHT)
&& (pourcentage > 0) && (pourcentage <= 100))
{
if ((new_window = gui_window_new (window,
window->win_x, window->win_y,
window->win_width, height1,
100, pourcentage)))
{
/* reduce old window height (bottom window) */
window->win_y = new_window->win_y + new_window->win_height;
window->win_height = height2;
window->win_height_pct = 100 - pourcentage;
/* assign same buffer for new window (top window) */
new_window->buffer = window->buffer;
new_window->buffer->num_displayed++;
gui_window_switch_to_buffer (window, window->buffer);
gui_current_window = new_window;
gui_window_switch_to_buffer (gui_current_window, gui_current_window->buffer);
gui_window_redraw_buffer (gui_current_window->buffer);
}
}
}
/*
* gui_window_split_vertic: split a window vertically
*/
void
gui_window_split_vertic (t_gui_window *window, int pourcentage)
{
t_gui_window *new_window;
int width1, width2;
if (!gui_ok)
return;
width1 = (window->win_width * pourcentage) / 100;
width2 = window->win_width - width1 - 1;
if ((width1 >= WINDOW_MIN_WIDTH) && (width2 >= WINDOW_MIN_WIDTH)
&& (pourcentage > 0) && (pourcentage <= 100))
{
if ((new_window = gui_window_new (window,
window->win_x + width1 + 1, window->win_y,
width2, window->win_height,
pourcentage, 100)))
{
/* reduce old window height (left window) */
window->win_width = width1;
window->win_width_pct = 100 - pourcentage;
/* assign same buffer for new window (right window) */
new_window->buffer = window->buffer;
new_window->buffer->num_displayed++;
gui_window_switch_to_buffer (window, window->buffer);
gui_current_window = new_window;
gui_window_switch_to_buffer (gui_current_window, gui_current_window->buffer);
gui_window_redraw_buffer (gui_current_window->buffer);
/* create & draw separator */
gui_window_draw_separator (gui_current_window);
}
}
}
/*
* gui_window_resize: resize window
*/
void
gui_window_resize (t_gui_window *window, int pourcentage)
{
/* TODO: write this function for Gtk */
(void) window;
(void) pourcentage;
}
/*
* gui_window_merge: merge window with its sister
*/
int
gui_window_merge (t_gui_window *window)
{
t_gui_window_tree *parent, *sister;
parent = window->ptr_tree->parent_node;
if (parent)
{
sister = (parent->child1->window == window) ?
parent->child2 : parent->child1;
if (!(sister->window))
return 0;
if (window->win_y == sister->window->win_y)
{
/* horizontal merge */
window->win_width += sister->window->win_width + 1;
window->win_width_pct += sister->window->win_width_pct;
}
else
{
/* vertical merge */
window->win_height += sister->window->win_height;
window->win_height_pct += sister->window->win_height_pct;
}
if (sister->window->win_x < window->win_x)
window->win_x = sister->window->win_x;
if (sister->window->win_y < window->win_y)
window->win_y = sister->window->win_y;
gui_window_free (sister->window);
gui_window_tree_node_to_leaf (parent, window);
gui_window_switch_to_buffer (window, window->buffer);
gui_window_redraw_buffer (window->buffer);
return 1;
}
return 0;
}
/*
* gui_window_merge_all: merge all windows into only one
*/
void
gui_window_merge_all (t_gui_window *window)
{
/* TODO: write this function for Gtk */
(void) window;
}
/*
* gui_window_side_by_side: return a code about position of 2 windows:
* 0 = they're not side by side
* 1 = side by side (win2 is over the win1)
* 2 = side by side (win2 on the right)
* 3 = side by side (win2 below win1)
* 4 = side by side (win2 on the left)
*/
int
gui_window_side_by_side (t_gui_window *win1, t_gui_window *win2)
{
/* win2 over win1 ? */
if (win2->win_y + win2->win_height == win1->win_y)
{
if (win2->win_x >= win1->win_x + win1->win_width)
return 0;
if (win2->win_x + win2->win_width <= win1->win_x)
return 0;
return 1;
}
/* win2 on the right ? */
if (win2->win_x == win1->win_x + win1->win_width + 1)
{
if (win2->win_y >= win1->win_y + win1->win_height)
return 0;
if (win2->win_y + win2->win_height <= win1->win_y)
return 0;
return 2;
}
/* win2 below win1 ? */
if (win2->win_y == win1->win_y + win1->win_height)
{
if (win2->win_x >= win1->win_x + win1->win_width)
return 0;
if (win2->win_x + win2->win_width <= win1->win_x)
return 0;
return 3;
}
/* win2 on the left ? */
if (win2->win_x + win2->win_width + 1 == win1->win_x)
{
if (win2->win_y >= win1->win_y + win1->win_height)
return 0;
if (win2->win_y + win2->win_height <= win1->win_y)
return 0;
return 4;
}
return 0;
}
/*
* gui_window_switch_up: search and switch to a window over current window
*/
void
gui_window_switch_up (t_gui_window *window)
{
t_gui_window *ptr_win;
for (ptr_win = gui_windows; ptr_win;
ptr_win = ptr_win->next_window)
{
if ((ptr_win != window) &&
(gui_window_side_by_side (window, ptr_win) == 1))
{
gui_current_window = ptr_win;
gui_window_switch_to_buffer (gui_current_window, gui_current_window->buffer);
gui_window_redraw_buffer (gui_current_window->buffer);
return;
}
}
}
/*
* gui_window_switch_down: search and switch to a window below current window
*/
void
gui_window_switch_down (t_gui_window *window)
{
t_gui_window *ptr_win;
for (ptr_win = gui_windows; ptr_win;
ptr_win = ptr_win->next_window)
{
if ((ptr_win != window) &&
(gui_window_side_by_side (window, ptr_win) == 3))
{
gui_current_window = ptr_win;
gui_window_switch_to_buffer (gui_current_window, gui_current_window->buffer);
gui_window_redraw_buffer (gui_current_window->buffer);
return;
}
}
}
/*
* gui_window_switch_left: search and switch to a window on the left of current window
*/
void
gui_window_switch_left (t_gui_window *window)
{
t_gui_window *ptr_win;
for (ptr_win = gui_windows; ptr_win;
ptr_win = ptr_win->next_window)
{
if ((ptr_win != window) &&
(gui_window_side_by_side (window, ptr_win) == 4))
{
gui_current_window = ptr_win;
gui_window_switch_to_buffer (gui_current_window, gui_current_window->buffer);
gui_window_redraw_buffer (gui_current_window->buffer);
return;
}
}
}
/*
* gui_window_switch_right: search and switch to a window on the right of current window
*/
void
gui_window_switch_right (t_gui_window *window)
{
t_gui_window *ptr_win;
for (ptr_win = gui_windows; ptr_win;
ptr_win = ptr_win->next_window)
{
if ((ptr_win != window) &&
(gui_window_side_by_side (window, ptr_win) == 2))
{
gui_current_window = ptr_win;
gui_window_switch_to_buffer (gui_current_window, gui_current_window->buffer);
gui_window_redraw_buffer (gui_current_window->buffer);
return;
}
}
}
/*
* gui_window_refresh_screen: called when term size is modified
*/
void
gui_window_refresh_screen ()
{
/* TODO: write this function for Gtk */
}
/*
* gui_window_set_title: set terminal title
*/
void
gui_window_set_title ()
{
/* TODO: write this function for Gtk */
}
/*
* gui_window_reset_title: reset terminal title
*/
void
gui_window_reset_title ()
{
/* This function does nothing in Gtk GUI */
}
/*
* gui_window_objects_print_log: print Gtk objects infos in log
* (usually for crash dump)
*/
void
gui_window_objects_print_log (t_gui_window *window)
{
weechat_log_printf (" textview_chat . . . : 0x%X\n", GUI_GTK(window)->textview_chat);
weechat_log_printf (" textbuffer_chat . . : 0x%X\n", GUI_GTK(window)->textbuffer_chat);
weechat_log_printf (" texttag_chat. . . . : 0x%X\n", GUI_GTK(window)->texttag_chat);
weechat_log_printf (" textview_nicklist . : 0x%X\n", GUI_GTK(window)->textview_nicklist);
weechat_log_printf (" textbuffer_nicklist : 0x%X\n", GUI_GTK(window)->textbuffer_nicklist);
}
+106
View File
@@ -0,0 +1,106 @@
/*
* Copyright (c) 2003-2006 by FlashCode <flashcode@flashtux.org>
* See README for License detail, AUTHORS for developers list.
*
* 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 St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef __WEECHAT_GUI_GTK_H
#define __WEECHAT_GUI_GTK_H 1
#include <gtk/gtk.h>
/* TODO: remove these temporary defines */
#define A_BOLD 1
#define A_UNDERLINE 2
#define A_REVERSE 4
#define COLOR_BLACK 0
#define COLOR_BLUE 1
#define COLOR_GREEN 2
#define COLOR_CYAN 3
#define COLOR_RED 4
#define COLOR_MAGENTA 5
#define COLOR_YELLOW 6
#define COLOR_WHITE 7
/* shift ncurses colors for compatibility with colors
in IRC messages (same as other IRC clients) */
#define WEECHAT_COLOR_BLACK COLOR_BLACK
#define WEECHAT_COLOR_RED COLOR_BLUE
#define WEECHAT_COLOR_GREEN COLOR_GREEN
#define WEECHAT_COLOR_YELLOW COLOR_CYAN
#define WEECHAT_COLOR_BLUE COLOR_RED
#define WEECHAT_COLOR_MAGENTA COLOR_MAGENTA
#define WEECHAT_COLOR_CYAN COLOR_YELLOW
#define WEECHAT_COLOR_WHITE COLOR_WHITE
#define GUI_GTK(window) ((t_gui_gtk_objects *)(window->gui_objects))
typedef struct t_gui_panel_window t_gui_panel_window;
struct t_gui_panel_window
{
t_gui_panel *panel; /* pointer to panel */
int x, y; /* position of window */
int width, height; /* window size */
};
typedef struct t_gui_gtk_objects t_gui_gtk_objects;
struct t_gui_gtk_objects
{
GtkWidget *textview_chat; /* textview widget for chat */
GtkTextBuffer *textbuffer_chat; /* textbuffer widget for chat */
GtkTextTag *texttag_chat; /* texttag widget for chat */
GtkWidget *textview_nicklist; /* textview widget for nicklist */
GtkTextBuffer *textbuffer_nicklist; /* textbuffer widget for nicklist */
t_gui_panel_window *panel_windows; /* panel windows */
};
extern t_gui_color gui_weechat_colors[];
extern int gui_irc_colors[GUI_NUM_IRC_COLORS][2];
extern GtkWidget *gtk_main_window;
extern GtkWidget *vbox1;
extern GtkWidget *entry_topic;
extern GtkWidget *notebook1;
extern GtkWidget *vbox2;
extern GtkWidget *hbox1;
extern GtkWidget *hpaned1;
extern GtkWidget *scrolledwindow_chat;
extern GtkWidget *scrolledwindow_nick;
extern GtkWidget *entry_input;
extern GtkWidget *label1;
/* color functions */
extern int gui_color_get_pair (int);
extern void gui_color_init ();
/* chat functions */
extern void gui_chat_calculate_line_diff (t_gui_window *, t_gui_line **, int *, int);
/* keyboard functions */
extern void gui_keyboard_default_bindings ();
extern void gui_keyboard_read ();
/* window functions */
extern void gui_window_set_title ();
extern void gui_window_reset_title ();
#endif /* gui-gtk.h */
+193 -165
View File
@@ -76,7 +76,7 @@ gui_action_clipboard_paste (t_gui_window *window)
{
gui_insert_string_input (window, gui_input_clipboard, -1);
window->buffer->input_buffer_pos += utf8_strlen (gui_input_clipboard);
gui_draw_buffer_input (window->buffer, 0);
gui_input_draw (window->buffer, 0);
window->buffer->completion.position = -1;
}
}
@@ -95,20 +95,24 @@ gui_action_return (t_gui_window *window)
if (window->buffer->input_buffer_size > 0)
{
window->buffer->input_buffer[window->buffer->input_buffer_size] = '\0';
window->buffer->input_buffer_color_mask[window->buffer->input_buffer_size] = '\0';
command = strdup (window->buffer->input_buffer);
if (!command)
return;
history_buffer_add (window->buffer, window->buffer->input_buffer);
history_global_add (window->buffer->input_buffer);
window->buffer->input_buffer[0] = '\0';
window->buffer->input_buffer_color_mask[0] = '\0';
window->buffer->input_buffer_size = 0;
window->buffer->input_buffer_length = 0;
window->buffer->input_buffer_pos = 0;
window->buffer->input_buffer_1st_display = 0;
window->buffer->completion.position = -1;
window->buffer->ptr_history = NULL;
gui_draw_buffer_input (window->buffer, 0);
user_command (window->buffer, SERVER(window->buffer), command);
gui_input_optimize_size (window->buffer);
gui_input_draw (window->buffer, 0);
user_command (SERVER(window->buffer), CHANNEL(window->buffer),
command, 0);
free (command);
}
}
@@ -121,100 +125,32 @@ gui_action_return (t_gui_window *window)
void
gui_action_tab (t_gui_window *window)
{
int i;
if (window->buffer->has_input)
{
completion_search (&(window->buffer->completion),
completion_search (&(window->buffer->completion), 1,
window->buffer->input_buffer,
window->buffer->input_buffer_size,
utf8_real_pos (window->buffer->input_buffer,
window->buffer->input_buffer_pos));
if (window->buffer->completion.word_found)
{
/* replace word with new completed word into input buffer */
if (window->buffer->completion.diff_size > 0)
{
window->buffer->input_buffer_size +=
window->buffer->completion.diff_size;
window->buffer->input_buffer_length +=
window->buffer->completion.diff_length;
gui_optimize_input_buffer_size (window->buffer);
window->buffer->input_buffer[window->buffer->input_buffer_size] = '\0';
for (i = window->buffer->input_buffer_size - 1;
i >= window->buffer->completion.position_replace +
(int)strlen (window->buffer->completion.word_found); i--)
window->buffer->input_buffer[i] =
window->buffer->input_buffer[i - window->buffer->completion.diff_size];
}
else
{
for (i = window->buffer->completion.position_replace +
strlen (window->buffer->completion.word_found);
i < window->buffer->input_buffer_size; i++)
window->buffer->input_buffer[i] =
window->buffer->input_buffer[i - window->buffer->completion.diff_size];
window->buffer->input_buffer_size +=
window->buffer->completion.diff_size;
window->buffer->input_buffer_length +=
window->buffer->completion.diff_length;
gui_optimize_input_buffer_size (window->buffer);
window->buffer->input_buffer[window->buffer->input_buffer_size] = '\0';
}
strncpy (window->buffer->input_buffer + window->buffer->completion.position_replace,
window->buffer->completion.word_found,
strlen (window->buffer->completion.word_found));
window->buffer->input_buffer_pos =
utf8_pos (window->buffer->input_buffer,
window->buffer->completion.position_replace) +
utf8_strlen (window->buffer->completion.word_found);
/* position is < 0 this means only one word was found to complete,
so reinit to stop completion */
if (window->buffer->completion.position >= 0)
window->buffer->completion.position =
utf8_real_pos (window->buffer->input_buffer,
window->buffer->input_buffer_pos);
/* add space or completor to the end of completion, if needed */
if ((window->buffer->completion.context == COMPLETION_COMMAND)
|| (window->buffer->completion.context == COMPLETION_COMMAND_ARG))
{
if (window->buffer->input_buffer[utf8_real_pos (window->buffer->input_buffer,
window->buffer->input_buffer_pos)] != ' ')
gui_insert_string_input (window, " ",
window->buffer->input_buffer_pos);
if (window->buffer->completion.position >= 0)
window->buffer->completion.position++;
window->buffer->input_buffer_pos++;
}
else
{
/* add nick completor if position 0 and completing nick */
if ((window->buffer->completion.base_word_pos == 0)
&& (window->buffer->completion.context == COMPLETION_NICK))
{
if (strncmp (utf8_add_offset (window->buffer->input_buffer,
window->buffer->input_buffer_pos),
cfg_look_completor, strlen (cfg_look_completor)) != 0)
gui_insert_string_input (window, cfg_look_completor,
window->buffer->input_buffer_pos);
if (window->buffer->completion.position >= 0)
window->buffer->completion.position += strlen (cfg_look_completor);
window->buffer->input_buffer_pos += utf8_strlen (cfg_look_completor);
if (window->buffer->input_buffer[utf8_real_pos (window->buffer->input_buffer,
window->buffer->input_buffer_pos)] != ' ')
gui_insert_string_input (window, " ",
window->buffer->input_buffer_pos);
if (window->buffer->completion.position >= 0)
window->buffer->completion.position++;
window->buffer->input_buffer_pos++;
}
}
gui_draw_buffer_input (window->buffer, 0);
}
gui_input_complete (window);
}
}
/*
* gui_action_tab_previous: shift-tab key => find previous completion
*/
void
gui_action_tab_previous (t_gui_window *window)
{
if (window->buffer->has_input)
{
completion_search (&(window->buffer->completion), -1,
window->buffer->input_buffer,
window->buffer->input_buffer_size,
utf8_real_pos (window->buffer->input_buffer,
window->buffer->input_buffer_pos));
gui_input_complete (window);
}
}
@@ -237,13 +173,14 @@ gui_action_backspace (t_gui_window *window)
pos_last = utf8_prev_char (window->buffer->input_buffer, pos);
char_size = pos - pos_last;
size_to_move = strlen (pos);
memmove (pos_last, pos, size_to_move);
gui_input_move (window->buffer, pos_last, pos, size_to_move);
window->buffer->input_buffer_size -= char_size;
window->buffer->input_buffer_length--;
window->buffer->input_buffer_pos--;
window->buffer->input_buffer[window->buffer->input_buffer_size] = '\0';
gui_optimize_input_buffer_size (window->buffer);
gui_draw_buffer_input (window->buffer, 0);
window->buffer->input_buffer_color_mask[window->buffer->input_buffer_size] = '\0';
gui_input_optimize_size (window->buffer);
gui_input_draw (window->buffer, 0);
window->buffer->completion.position = -1;
}
}
@@ -269,12 +206,13 @@ gui_action_delete (t_gui_window *window)
pos_next = utf8_next_char (pos);
char_size = pos_next - pos;
size_to_move = strlen (pos_next);
memmove (pos, pos_next, size_to_move);
gui_input_move (window->buffer, pos, pos_next, size_to_move);
window->buffer->input_buffer_size -= char_size;
window->buffer->input_buffer_length--;
window->buffer->input_buffer[window->buffer->input_buffer_size] = '\0';
gui_optimize_input_buffer_size (window->buffer);
gui_draw_buffer_input (window->buffer, 0);
window->buffer->input_buffer_color_mask[window->buffer->input_buffer_size] = '\0';
gui_input_optimize_size (window->buffer);
gui_input_draw (window->buffer, 0);
window->buffer->completion.position = -1;
}
}
@@ -326,14 +264,15 @@ gui_action_delete_previous_word (t_gui_window *window)
gui_action_clipboard_copy (string, size_deleted);
memmove (string, string + size_deleted, strlen (string + size_deleted));
gui_input_move (window->buffer, string, string + size_deleted, strlen (string + size_deleted));
window->buffer->input_buffer_size -= size_deleted;
window->buffer->input_buffer_length -= length_deleted;
window->buffer->input_buffer[window->buffer->input_buffer_size] = '\0';
window->buffer->input_buffer_color_mask[window->buffer->input_buffer_size] = '\0';
window->buffer->input_buffer_pos -= length_deleted;
gui_optimize_input_buffer_size (window->buffer);
gui_draw_buffer_input (window->buffer, 0);
gui_input_optimize_size (window->buffer);
gui_input_draw (window->buffer, 0);
window->buffer->completion.position = -1;
}
}
@@ -366,13 +305,14 @@ gui_action_delete_next_word (t_gui_window *window)
gui_action_clipboard_copy(start, size_deleted);
memmove (start, string, strlen (string));
gui_input_move (window->buffer, start, string, strlen (string));
window->buffer->input_buffer_size -= size_deleted;
window->buffer->input_buffer_length -= length_deleted;
window->buffer->input_buffer[window->buffer->input_buffer_size] = '\0';
gui_optimize_input_buffer_size (window->buffer);
gui_draw_buffer_input (window->buffer, 0);
window->buffer->input_buffer_color_mask[window->buffer->input_buffer_size] = '\0';
gui_input_optimize_size (window->buffer);
gui_input_draw (window->buffer, 0);
window->buffer->completion.position = -1;
}
}
@@ -384,7 +324,7 @@ gui_action_delete_next_word (t_gui_window *window)
void
gui_action_delete_begin_of_line (t_gui_window *window)
{
int length_deleted, size_deleted;
int length_deleted, size_deleted, pos_start;
char *start;
if (window->buffer->has_input)
@@ -393,19 +333,21 @@ gui_action_delete_begin_of_line (t_gui_window *window)
{
start = utf8_add_offset (window->buffer->input_buffer,
window->buffer->input_buffer_pos);
pos_start = start - window->buffer->input_buffer;
size_deleted = start - window->buffer->input_buffer;
length_deleted = utf8_strnlen (window->buffer->input_buffer, size_deleted);
gui_action_clipboard_copy (window->buffer->input_buffer,
start - window->buffer->input_buffer);
memmove (window->buffer->input_buffer, start, strlen (start));
gui_input_move (window->buffer, window->buffer->input_buffer, start, strlen (start));
window->buffer->input_buffer_size -= size_deleted;
window->buffer->input_buffer_length -= length_deleted;
window->buffer->input_buffer[window->buffer->input_buffer_size] = '\0';
window->buffer->input_buffer_color_mask[window->buffer->input_buffer_size] = '\0';
window->buffer->input_buffer_pos = 0;
gui_optimize_input_buffer_size (window->buffer);
gui_draw_buffer_input (window->buffer, 0);
gui_input_optimize_size (window->buffer);
gui_input_draw (window->buffer, 0);
window->buffer->completion.position = -1;
}
}
@@ -419,20 +361,22 @@ void
gui_action_delete_end_of_line (t_gui_window *window)
{
char *start;
int size_deleted, length_deleted;
int size_deleted, length_deleted, pos_start;
if (window->buffer->has_input)
{
start = utf8_add_offset (window->buffer->input_buffer,
window->buffer->input_buffer_pos);
pos_start = start - window->buffer->input_buffer;
size_deleted = strlen (start);
length_deleted = utf8_strlen (start);
gui_action_clipboard_copy (start, size_deleted);
start[0] = '\0';
window->buffer->input_buffer_color_mask[pos_start] = '\0';
window->buffer->input_buffer_size = strlen (window->buffer->input_buffer);
window->buffer->input_buffer_length = utf8_strlen (window->buffer->input_buffer);
gui_optimize_input_buffer_size (window->buffer);
gui_draw_buffer_input (window->buffer, 0);
gui_input_optimize_size (window->buffer);
gui_input_draw (window->buffer, 0);
window->buffer->completion.position = -1;
}
}
@@ -447,11 +391,12 @@ gui_action_delete_line (t_gui_window *window)
if (window->buffer->has_input)
{
window->buffer->input_buffer[0] = '\0';
window->buffer->input_buffer_color_mask[0] = '\0';
window->buffer->input_buffer_size = 0;
window->buffer->input_buffer_length = 0;
window->buffer->input_buffer_pos = 0;
gui_optimize_input_buffer_size (window->buffer);
gui_draw_buffer_input (window->buffer, 0);
gui_input_optimize_size (window->buffer);
gui_input_draw (window->buffer, 0);
window->buffer->completion.position = -1;
}
}
@@ -464,7 +409,8 @@ void
gui_action_transpose_chars (t_gui_window *window)
{
char *start, *prev_char, saved_char[4];
int size_current_char;
int size_current_char, size_start_char;
int pos_prev_char, pos_start;
if (window->buffer->has_input)
{
@@ -475,17 +421,26 @@ gui_action_transpose_chars (t_gui_window *window)
start = utf8_add_offset (window->buffer->input_buffer,
window->buffer->input_buffer_pos);
pos_start = start - window->buffer->input_buffer;
prev_char = utf8_prev_char (window->buffer->input_buffer,
start);
pos_prev_char = prev_char - window->buffer->input_buffer;
size_current_char = start - prev_char;
size_start_char = utf8_char_size (start);
memcpy (saved_char, prev_char, size_current_char);
memcpy (prev_char, start, utf8_char_size (start));
start = utf8_next_char (prev_char);
memcpy (prev_char, start, size_start_char);
memcpy (start, saved_char, size_current_char);
memcpy (saved_char, window->buffer->input_buffer_color_mask + pos_prev_char, size_current_char);
memcpy (window->buffer->input_buffer_color_mask + pos_prev_char,
window->buffer->input_buffer_color_mask + pos_start, size_start_char);
memcpy (window->buffer->input_buffer_color_mask + pos_start,
saved_char, size_current_char);
window->buffer->input_buffer_pos++;
gui_draw_buffer_input (window->buffer, 0);
gui_input_draw (window->buffer, 0);
window->buffer->completion.position = -1;
}
}
@@ -503,7 +458,7 @@ gui_action_home (t_gui_window *window)
if (window->buffer->input_buffer_pos > 0)
{
window->buffer->input_buffer_pos = 0;
gui_draw_buffer_input (window->buffer, 0);
gui_input_draw (window->buffer, 0);
}
}
}
@@ -522,7 +477,7 @@ gui_action_end (t_gui_window *window)
{
window->buffer->input_buffer_pos =
window->buffer->input_buffer_length;
gui_draw_buffer_input (window->buffer, 0);
gui_input_draw (window->buffer, 0);
}
}
}
@@ -539,7 +494,7 @@ gui_action_left (t_gui_window *window)
if (window->buffer->input_buffer_pos > 0)
{
window->buffer->input_buffer_pos--;
gui_draw_buffer_input (window->buffer, 0);
gui_input_draw (window->buffer, 0);
}
}
}
@@ -579,13 +534,13 @@ gui_action_previous_word (t_gui_window *window)
else
window->buffer->input_buffer_pos = 0;
gui_draw_buffer_input (window->buffer, 0);
gui_input_draw (window->buffer, 0);
}
}
}
/*
* gui_action_right: move to previous char
* gui_action_right: move to next char
*/
void
@@ -597,7 +552,7 @@ gui_action_right (t_gui_window *window)
window->buffer->input_buffer_length)
{
window->buffer->input_buffer_pos++;
gui_draw_buffer_input (window->buffer, 0);
gui_input_draw (window->buffer, 0);
}
}
}
@@ -641,7 +596,7 @@ gui_action_next_word (t_gui_window *window)
utf8_pos (window->buffer->input_buffer,
utf8_prev_char (window->buffer->input_buffer, pos) - window->buffer->input_buffer);
gui_draw_buffer_input (window->buffer, 0);
gui_input_draw (window->buffer, 0);
}
}
}
@@ -653,7 +608,7 @@ gui_action_next_word (t_gui_window *window)
void
gui_action_up (t_gui_window *window)
{
if (window->buffer->dcc)
if (window->buffer->type == BUFFER_TYPE_DCC)
{
if (dcc_list)
{
@@ -666,8 +621,8 @@ gui_action_up (t_gui_window *window)
((t_irc_dcc *)(window->dcc_first))->prev_dcc;
window->dcc_selected =
((t_irc_dcc *)(window->dcc_selected))->prev_dcc;
gui_draw_buffer_chat (window->buffer, 1);
gui_draw_buffer_input (window->buffer, 1);
gui_chat_draw (window->buffer, 1);
gui_input_draw (window->buffer, 1);
}
}
}
@@ -692,6 +647,7 @@ gui_action_up (t_gui_window *window)
if (window->buffer->input_buffer_size > 0)
{
window->buffer->input_buffer[window->buffer->input_buffer_size] = '\0';
window->buffer->input_buffer_color_mask[window->buffer->input_buffer_size] = '\0';
history_buffer_add (window->buffer, window->buffer->input_buffer);
history_global_add (window->buffer->input_buffer);
}
@@ -701,6 +657,7 @@ gui_action_up (t_gui_window *window)
if (window->buffer->input_buffer_size > 0)
{
window->buffer->input_buffer[window->buffer->input_buffer_size] = '\0';
window->buffer->input_buffer_color_mask[window->buffer->input_buffer_size] = '\0';
if (window->buffer->ptr_history->prev_history->text)
free(window->buffer->ptr_history->prev_history->text);
window->buffer->ptr_history->prev_history->text = strdup (window->buffer->input_buffer);
@@ -710,13 +667,14 @@ gui_action_up (t_gui_window *window)
strlen (window->buffer->ptr_history->text);
window->buffer->input_buffer_length =
utf8_strlen (window->buffer->ptr_history->text);
gui_optimize_input_buffer_size (window->buffer);
gui_input_optimize_size (window->buffer);
window->buffer->input_buffer_pos =
window->buffer->input_buffer_length;
window->buffer->input_buffer_1st_display = 0;
strcpy (window->buffer->input_buffer,
window->buffer->ptr_history->text);
gui_draw_buffer_input (window->buffer, 0);
gui_input_init_color_mask (window->buffer);
gui_input_draw (window->buffer, 0);
}
}
}
@@ -744,13 +702,14 @@ gui_action_up_global (t_gui_window *window)
strlen (history_global_ptr->text);
window->buffer->input_buffer_length =
utf8_strlen (history_global_ptr->text);
gui_optimize_input_buffer_size (window->buffer);
gui_input_optimize_size (window->buffer);
window->buffer->input_buffer_pos =
window->buffer->input_buffer_length;
window->buffer->input_buffer_1st_display = 0;
strcpy (window->buffer->input_buffer,
history_global_ptr->text);
gui_draw_buffer_input (window->buffer, 0);
gui_input_init_color_mask (window->buffer);
gui_input_draw (window->buffer, 0);
}
}
}
@@ -762,7 +721,7 @@ gui_action_up_global (t_gui_window *window)
void
gui_action_down (t_gui_window *window)
{
if (window->buffer->dcc)
if (window->buffer->type == BUFFER_TYPE_DCC)
{
if (dcc_list)
{
@@ -786,8 +745,8 @@ gui_action_down (t_gui_window *window)
else
window->dcc_selected =
dcc_list->next_dcc;
gui_draw_buffer_chat (window->buffer, 1);
gui_draw_buffer_input (window->buffer, 1);
gui_chat_draw (window->buffer, 1);
gui_input_draw (window->buffer, 1);
}
}
}
@@ -809,14 +768,17 @@ gui_action_down (t_gui_window *window)
window->buffer->input_buffer_size = 0;
window->buffer->input_buffer_length = 0;
}
gui_optimize_input_buffer_size (window->buffer);
gui_input_optimize_size (window->buffer);
window->buffer->input_buffer_pos =
window->buffer->input_buffer_length;
window->buffer->input_buffer_1st_display = 0;
if (window->buffer->ptr_history)
{
strcpy (window->buffer->input_buffer,
window->buffer->ptr_history->text);
gui_draw_buffer_input (window->buffer, 0);
gui_input_init_color_mask (window->buffer);
}
gui_input_draw (window->buffer, 0);
}
}
}
@@ -845,14 +807,17 @@ gui_action_down_global (t_gui_window *window)
window->buffer->input_buffer_size = 0;
window->buffer->input_buffer_length = 0;
}
gui_optimize_input_buffer_size (window->buffer);
gui_input_optimize_size (window->buffer);
window->buffer->input_buffer_pos =
window->buffer->input_buffer_length;
window->buffer->input_buffer_1st_display = 0;
if (history_global_ptr)
{
strcpy (window->buffer->input_buffer,
history_global_ptr->text);
gui_draw_buffer_input (window->buffer, 0);
gui_input_init_color_mask (window->buffer);
}
gui_input_draw (window->buffer, 0);
}
}
}
@@ -877,6 +842,46 @@ gui_action_page_down (t_gui_window *window)
gui_window_page_down (window);
}
/*
* gui_action_scroll_up: display previous few lines in buffer
*/
void
gui_action_scroll_up (t_gui_window *window)
{
gui_window_scroll_up (window);
}
/*
* gui_action_scroll_down: display next few lines in buffer
*/
void
gui_action_scroll_down (t_gui_window *window)
{
gui_window_scroll_down (window);
}
/*
* gui_action_scroll_top: scroll to top of buffer
*/
void
gui_action_scroll_top (t_gui_window *window)
{
gui_window_scroll_top (window);
}
/*
* gui_action_scroll_bottom: scroll to bottom of buffer
*/
void
gui_action_scroll_bottom (t_gui_window *window)
{
gui_window_scroll_bottom (window);
}
/*
* gui_action_nick_beginning: go to beginning of nicklist
*/
@@ -928,15 +933,15 @@ gui_action_jump_smart (t_gui_window *window)
{
if (!hotlist_initial_buffer)
hotlist_initial_buffer = window->buffer;
gui_switch_to_buffer (window, hotlist->buffer);
gui_redraw_buffer (window->buffer);
gui_window_switch_to_buffer (window, hotlist->buffer);
gui_window_redraw_buffer (window->buffer);
}
else
{
if (hotlist_initial_buffer)
{
gui_switch_to_buffer (window, hotlist_initial_buffer);
gui_redraw_buffer (window->buffer);
gui_window_switch_to_buffer (window, hotlist_initial_buffer);
gui_window_redraw_buffer (window->buffer);
hotlist_initial_buffer = NULL;
}
}
@@ -949,22 +954,45 @@ gui_action_jump_smart (t_gui_window *window)
void
gui_action_jump_dcc (t_gui_window *window)
{
if (window->buffer->dcc)
if (window->buffer->type == BUFFER_TYPE_DCC)
{
if (buffer_before_dcc)
if (gui_buffer_before_dcc)
{
gui_switch_to_buffer (window,
buffer_before_dcc);
gui_redraw_buffer (window->buffer);
gui_window_switch_to_buffer (window,
gui_buffer_before_dcc);
gui_window_redraw_buffer (window->buffer);
}
}
else
{
buffer_before_dcc = window->buffer;
gui_buffer_before_dcc = window->buffer;
gui_buffer_switch_dcc (window);
}
}
/*
* gui_action_jump_raw_data: jump to raw IRC data buffer
*/
void
gui_action_jump_raw_data (t_gui_window *window)
{
if (window->buffer->type == BUFFER_TYPE_RAW_DATA)
{
if (gui_buffer_before_raw_data)
{
gui_window_switch_to_buffer (window,
gui_buffer_before_raw_data);
gui_window_redraw_buffer (window->buffer);
}
}
else
{
gui_buffer_before_raw_data = window->buffer;
gui_buffer_switch_raw_data (window);
}
}
/*
* gui_action_jump_last_buffer: jump to last buffer
*/
@@ -988,9 +1016,9 @@ gui_action_jump_server (t_gui_window *window)
if (SERVER(window->buffer)->buffer !=
window->buffer)
{
gui_switch_to_buffer (window,
SERVER(window->buffer)->buffer);
gui_redraw_buffer (window->buffer);
gui_window_switch_to_buffer (window,
SERVER(window->buffer)->buffer);
gui_window_redraw_buffer (window->buffer);
}
}
}
@@ -1031,8 +1059,8 @@ gui_action_jump_next_server (t_gui_window *window)
if ((ptr_server->buffer == ptr_buffer)
&& (ptr_buffer->all_servers))
ptr_buffer->server = ptr_server;
gui_switch_to_buffer (window, ptr_buffer);
gui_redraw_buffer (window->buffer);
gui_window_switch_to_buffer (window, ptr_buffer);
gui_window_redraw_buffer (window->buffer);
}
}
}
@@ -1057,7 +1085,7 @@ gui_action_scroll_previous_highlight (t_gui_window *window)
{
t_gui_line *ptr_line;
if (!window->buffer->dcc)
if (window->buffer->type == BUFFER_TYPE_STANDARD)
{
if (window->buffer->lines)
{
@@ -1071,8 +1099,8 @@ gui_action_scroll_previous_highlight (t_gui_window *window)
window->start_line_pos = 0;
window->first_line_displayed =
(window->start_line == window->buffer->lines);
gui_draw_buffer_chat (window->buffer, 1);
gui_draw_buffer_status (window->buffer, 0);
gui_chat_draw (window->buffer, 1);
gui_status_draw (window->buffer, 0);
return;
}
ptr_line = ptr_line->prev_line;
@@ -1090,7 +1118,7 @@ gui_action_scroll_next_highlight (t_gui_window *window)
{
t_gui_line *ptr_line;
if (!window->buffer->dcc)
if (window->buffer->type == BUFFER_TYPE_STANDARD)
{
if (window->buffer->lines)
{
@@ -1104,8 +1132,8 @@ gui_action_scroll_next_highlight (t_gui_window *window)
window->start_line_pos = 0;
window->first_line_displayed =
(window->start_line == window->buffer->lines);
gui_draw_buffer_chat (window->buffer, 1);
gui_draw_buffer_status (window->buffer, 0);
gui_chat_draw (window->buffer, 1);
gui_status_draw (window->buffer, 0);
return;
}
ptr_line = ptr_line->next_line;
@@ -1123,7 +1151,7 @@ gui_action_scroll_unread (t_gui_window *window)
{
if (cfg_look_read_marker &&
cfg_look_read_marker[0] &&
!window->buffer->dcc &&
(window->buffer->type == BUFFER_TYPE_STANDARD) &&
window->buffer->last_read_line &&
window->buffer->last_read_line != window->buffer->last_line)
{
@@ -1131,8 +1159,8 @@ gui_action_scroll_unread (t_gui_window *window)
window->start_line_pos = 0;
window->first_line_displayed =
(window->start_line == window->buffer->lines);
gui_draw_buffer_chat (window->buffer, 1);
gui_draw_buffer_status (window->buffer, 0);
gui_chat_draw (window->buffer, 1);
gui_status_draw (window->buffer, 0);
}
}
@@ -1146,7 +1174,7 @@ gui_action_hotlist_clear (t_gui_window *window)
if (hotlist)
{
hotlist_free_all ();
gui_redraw_buffer (window->buffer);
gui_window_redraw_buffer (window->buffer);
}
hotlist_initial_buffer = window->buffer;
}
@@ -1159,7 +1187,7 @@ void
gui_action_infobar_clear (t_gui_window *window)
{
gui_infobar_remove ();
gui_draw_buffer_infobar (window->buffer, 1);
gui_infobar_draw (window->buffer, 1);
}
/*
@@ -1172,7 +1200,7 @@ gui_action_refresh_screen (t_gui_window *window)
/* make gcc happy */
(void) window;
gui_refresh_screen ();
gui_window_refresh_screen ();
}
/*
@@ -1183,5 +1211,5 @@ void
gui_action_grab_key (t_gui_window *window)
{
if (window->buffer->has_input)
gui_key_init_grab ();
gui_keyboard_init_grab ();
}
+942
View File
@@ -0,0 +1,942 @@
/*
* Copyright (c) 2003-2006 by FlashCode <flashcode@flashtux.org>
* See README for License detail, AUTHORS for developers list.
*
* 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 St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/* gui-window.c: window functions, used by all GUI */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <unistd.h>
#include <string.h>
#include <signal.h>
#include <time.h>
#include <ctype.h>
#include "../common/weechat.h"
#include "gui.h"
#include "../common/command.h"
#include "../common/weeconfig.h"
#include "../common/history.h"
#include "../common/hotlist.h"
#include "../common/log.h"
#include "../common/utf8.h"
#include "../irc/irc.h"
t_gui_buffer *gui_buffers = NULL; /* pointer to first buffer */
t_gui_buffer *last_gui_buffer = NULL; /* pointer to last buffer */
t_gui_buffer *gui_buffer_before_dcc = NULL; /* buffer before dcc switch */
t_gui_buffer *gui_buffer_raw_data = NULL; /* buffer with raw IRC data */
t_gui_buffer *gui_buffer_before_raw_data = NULL; /* buffer before raw switch*/
/*
* gui_buffer_servers_search: search servers buffer
* (when same buffer is used for all servers)
*/
t_gui_buffer *
gui_buffer_servers_search ()
{
t_gui_buffer *ptr_buffer;
for (ptr_buffer = gui_buffers; ptr_buffer;
ptr_buffer = ptr_buffer->next_buffer)
{
if (ptr_buffer->all_servers)
return ptr_buffer;
}
/* buffer not found */
return NULL;
}
/*
* gui_buffer_new: create a new buffer in current window
*/
t_gui_buffer *
gui_buffer_new (t_gui_window *window, void *server, void *channel, int type,
int switch_to_buffer)
{
t_gui_buffer *new_buffer, *ptr_buffer;
#ifdef DEBUG
weechat_log_printf ("Creating new buffer\n");
#endif
/* use first buffer if no server was assigned to this buffer */
if ((type == BUFFER_TYPE_STANDARD) && gui_buffers && (!SERVER(gui_buffers)))
{
if (server)
((t_irc_server *)(server))->buffer = gui_buffers;
if (channel)
((t_irc_channel *)(channel))->buffer = gui_buffers;
gui_buffers->server = server;
gui_buffers->channel = channel;
if (cfg_look_one_server_buffer && server && !channel)
gui_buffers->all_servers = 1;
if (cfg_log_auto_server)
gui_log_start (gui_buffers);
return gui_buffers;
}
if (cfg_look_one_server_buffer && (type == BUFFER_TYPE_STANDARD) &&
gui_buffers && server && !channel)
{
ptr_buffer = gui_buffer_servers_search ();
if (ptr_buffer)
{
((t_irc_server *)(server))->buffer = gui_buffers;
gui_buffers->server = server;
if (switch_to_buffer)
gui_window_switch_to_buffer (window, gui_buffers);
gui_window_redraw_buffer (gui_buffers);
return gui_buffers;
}
}
if ((new_buffer = (t_gui_buffer *)(malloc (sizeof (t_gui_buffer)))))
{
new_buffer->num_displayed = 0;
new_buffer->number = (last_gui_buffer) ? last_gui_buffer->number + 1 : 1;
/* assign server and channel to buffer */
new_buffer->server = server;
new_buffer->all_servers = 0;
new_buffer->channel = channel;
new_buffer->type = type;
if (new_buffer->type == BUFFER_TYPE_RAW_DATA)
gui_buffer_raw_data = new_buffer;
/* assign buffer to server and channel */
if (server && !channel)
{
SERVER(new_buffer)->buffer = new_buffer;
new_buffer->all_servers = (cfg_look_one_server_buffer) ? 1 : 0;
}
if (!gui_buffers && cfg_look_one_server_buffer)
new_buffer->all_servers = 1;
if (channel)
CHANNEL(new_buffer)->buffer = new_buffer;
if (!window->buffer)
{
window->buffer = new_buffer;
window->first_line_displayed = 1;
window->start_line = NULL;
window->start_line_pos = 0;
gui_window_calculate_pos_size (window, 1);
}
/* init lines */
new_buffer->lines = NULL;
new_buffer->last_line = NULL;
new_buffer->last_read_line = NULL;
new_buffer->num_lines = 0;
new_buffer->line_complete = 1;
/* notify level */
new_buffer->notify_level = channel_get_notify_level (server, channel);
/* create/append to log file */
new_buffer->log_filename = NULL;
new_buffer->log_file = NULL;
if ((cfg_log_auto_server && BUFFER_IS_SERVER(new_buffer))
|| (cfg_log_auto_channel && BUFFER_IS_CHANNEL(new_buffer))
|| (cfg_log_auto_private && BUFFER_IS_PRIVATE(new_buffer)))
gui_log_start (new_buffer);
/* init input buffer */
new_buffer->has_input = (new_buffer->type == BUFFER_TYPE_STANDARD) ? 1 : 0;
if (new_buffer->has_input)
{
new_buffer->input_buffer_alloc = INPUT_BUFFER_BLOCK_SIZE;
new_buffer->input_buffer = (char *) malloc (INPUT_BUFFER_BLOCK_SIZE);
new_buffer->input_buffer_color_mask = (char *) malloc (INPUT_BUFFER_BLOCK_SIZE);
new_buffer->input_buffer[0] = '\0';
new_buffer->input_buffer_color_mask[0] = '\0';
}
else
{
new_buffer->input_buffer = NULL;
new_buffer->input_buffer_color_mask = NULL;
}
new_buffer->input_buffer_size = 0;
new_buffer->input_buffer_length = 0;
new_buffer->input_buffer_pos = 0;
new_buffer->input_buffer_1st_display = 0;
/* init completion */
completion_init (&(new_buffer->completion), server, channel);
/* init history */
new_buffer->history = NULL;
new_buffer->last_history = NULL;
new_buffer->ptr_history = NULL;
new_buffer->num_history = 0;
/* add buffer to buffers queue */
new_buffer->prev_buffer = last_gui_buffer;
if (gui_buffers)
last_gui_buffer->next_buffer = new_buffer;
else
gui_buffers = new_buffer;
last_gui_buffer = new_buffer;
new_buffer->next_buffer = NULL;
/* move buffer next to server */
if (server && cfg_look_open_near_server && (!cfg_look_one_server_buffer))
{
ptr_buffer = SERVER(new_buffer)->buffer;
while (ptr_buffer && (ptr_buffer->server == server))
{
ptr_buffer = ptr_buffer->next_buffer;
}
if (ptr_buffer)
gui_buffer_move_to_number (new_buffer, ptr_buffer->number);
}
/* switch to new buffer */
if (switch_to_buffer)
gui_window_switch_to_buffer (window, new_buffer);
/* redraw buffer */
gui_window_redraw_buffer (new_buffer);
}
else
return NULL;
return new_buffer;
}
/*
* gui_buffer_search: search a buffer by server and channel name
*/
t_gui_buffer *
gui_buffer_search (char *server, char *channel)
{
t_irc_server *ptr_server;
t_irc_channel *ptr_channel;
t_gui_buffer *ptr_buffer;
ptr_server = NULL;
ptr_channel = NULL;
ptr_buffer = NULL;
/* nothing given => print on current buffer */
if ((!server || !server[0]) && (!channel || !channel[0]))
ptr_buffer = gui_current_window->buffer;
else
{
if (server && server[0])
{
ptr_server = server_search (server);
if (!ptr_server)
return NULL;
}
else
{
ptr_server = SERVER(gui_current_window->buffer);
if (!ptr_server)
ptr_server = SERVER(gui_buffers);
}
if (channel && channel[0])
{
if (ptr_server)
{
ptr_channel = channel_search_any (ptr_server, channel);
if (ptr_channel)
ptr_buffer = ptr_channel->buffer;
}
}
else
{
if (ptr_server)
ptr_buffer = ptr_server->buffer;
else
ptr_buffer = gui_current_window->buffer;
}
}
if (!ptr_buffer)
return NULL;
return (ptr_buffer->type != BUFFER_TYPE_STANDARD) ?
gui_buffers : ptr_buffer;
}
/*
* gui_buffer_find_window: find a window displaying buffer
*/
t_gui_window *
gui_buffer_find_window (t_gui_buffer *buffer)
{
t_gui_window *ptr_win;
if (gui_current_window->buffer == buffer)
return gui_current_window;
for (ptr_win = gui_windows; ptr_win;
ptr_win = ptr_win->next_window)
{
if (ptr_win->buffer == buffer)
return ptr_win;
}
/* no window found */
return NULL;
}
/*
* gui_buffer_get_dcc: get pointer to DCC buffer (DCC buffer created if not existing)
*/
t_gui_buffer *
gui_buffer_get_dcc (t_gui_window *window)
{
t_gui_buffer *ptr_buffer;
/* check if dcc buffer exists */
for (ptr_buffer = gui_buffers; ptr_buffer; ptr_buffer = ptr_buffer->next_buffer)
{
if (ptr_buffer->type == BUFFER_TYPE_DCC)
break;
}
if (ptr_buffer)
return ptr_buffer;
else
return gui_buffer_new (window, NULL, NULL, BUFFER_TYPE_DCC, 0);
}
/*
* gui_buffer_clear: clear buffer content
*/
void
gui_buffer_clear (t_gui_buffer *buffer)
{
t_gui_window *ptr_win;
t_gui_line *ptr_line;
/* remove buffer from hotlist */
hotlist_remove_buffer (buffer);
/* remove lines from buffer */
while (buffer->lines)
{
ptr_line = buffer->lines->next_line;
if (buffer->lines->data)
free (buffer->lines->data);
free (buffer->lines);
buffer->lines = ptr_line;
}
buffer->lines = NULL;
buffer->last_line = NULL;
buffer->num_lines = 0;
buffer->line_complete = 1;
/* remove any scroll for buffer */
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
{
if (ptr_win->buffer == buffer)
{
ptr_win->first_line_displayed = 1;
ptr_win->start_line = NULL;
ptr_win->start_line_pos = 0;
}
}
gui_chat_draw (buffer, 1);
gui_status_draw (buffer, 1);
}
/*
* gui_buffer_clear_all: clear all buffers content
*/
void
gui_buffer_clear_all ()
{
t_gui_buffer *ptr_buffer;
for (ptr_buffer = gui_buffers; ptr_buffer; ptr_buffer = ptr_buffer->next_buffer)
gui_buffer_clear (ptr_buffer);
}
/*
* gui_buffer_line_free: delete a line from a buffer
*/
void
gui_buffer_line_free (t_gui_line *line)
{
t_gui_window *ptr_win;
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
{
if (ptr_win->start_line == line)
{
ptr_win->start_line = ptr_win->start_line->next_line;
ptr_win->start_line_pos = 0;
gui_chat_draw (ptr_win->buffer, 0);
gui_status_draw (ptr_win->buffer, 0);
}
}
if (line->nick)
free (line->nick);
if (line->data)
free (line->data);
free (line);
}
/*
* gui_buffer_free: delete a buffer
*/
void
gui_buffer_free (t_gui_buffer *buffer, int switch_to_another)
{
t_gui_window *ptr_win;
t_gui_buffer *ptr_buffer;
t_gui_line *ptr_line;
t_irc_server *ptr_server;
int create_new;
create_new = (buffer->server || buffer->channel);
hotlist_remove_buffer (buffer);
if (hotlist_initial_buffer == buffer)
hotlist_initial_buffer = NULL;
if (gui_buffer_before_dcc == buffer)
gui_buffer_before_dcc = NULL;
if (gui_buffer_before_raw_data == buffer)
gui_buffer_before_raw_data = NULL;
if (buffer->type == BUFFER_TYPE_RAW_DATA)
gui_buffer_raw_data = NULL;
/* purge DCC chat using this buffer */
if (CHANNEL(buffer))
dcc_chat_remove_channel (CHANNEL(buffer));
for (ptr_server = irc_servers; ptr_server;
ptr_server = ptr_server->next_server)
{
if (ptr_server->saved_buffer == buffer)
ptr_server->saved_buffer = NULL;
}
if (switch_to_another)
{
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
{
if ((buffer == ptr_win->buffer) &&
((buffer->next_buffer) || (buffer->prev_buffer)))
gui_buffer_switch_previous (ptr_win);
}
}
/* decrease buffer number for all next buffers */
for (ptr_buffer = buffer->next_buffer; ptr_buffer; ptr_buffer = ptr_buffer->next_buffer)
{
ptr_buffer->number--;
}
/* free lines and messages */
while (buffer->lines)
{
ptr_line = buffer->lines->next_line;
gui_buffer_line_free (buffer->lines);
buffer->lines = ptr_line;
}
/* close log if opened */
if (buffer->log_file)
gui_log_end (buffer);
if (buffer->input_buffer)
free (buffer->input_buffer);
if (buffer->input_buffer_color_mask)
free (buffer->input_buffer_color_mask);
completion_free (&(buffer->completion));
history_buffer_free (buffer);
/* remove buffer from buffers list */
if (buffer->prev_buffer)
buffer->prev_buffer->next_buffer = buffer->next_buffer;
if (buffer->next_buffer)
buffer->next_buffer->prev_buffer = buffer->prev_buffer;
if (gui_buffers == buffer)
gui_buffers = buffer->next_buffer;
if (last_gui_buffer == buffer)
last_gui_buffer = buffer->prev_buffer;
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
{
if (ptr_win->buffer == buffer)
ptr_win->buffer = NULL;
}
free (buffer);
/* always at least one buffer */
if (!gui_buffers && create_new && switch_to_another)
(void) gui_buffer_new (gui_windows, NULL, NULL,
BUFFER_TYPE_STANDARD, 1);
}
/*
* gui_buffer_line_new: create new line for a buffer
*/
t_gui_line *
gui_buffer_line_new (t_gui_buffer *buffer)
{
t_gui_line *new_line, *ptr_line;
if ((new_line = (t_gui_line *) malloc (sizeof (struct t_gui_line))))
{
new_line->length = 0;
new_line->length_align = 0;
new_line->log_write = 1;
new_line->line_with_message = 0;
new_line->line_with_highlight = 0;
new_line->nick = NULL;
new_line->data = NULL;
new_line->ofs_after_date = -1;
new_line->ofs_start_message = -1;
if (!buffer->lines)
buffer->lines = new_line;
else
buffer->last_line->next_line = new_line;
new_line->prev_line = buffer->last_line;
new_line->next_line = NULL;
buffer->last_line = new_line;
buffer->num_lines++;
}
else
{
weechat_log_printf (_("Not enough memory for new line\n"));
return NULL;
}
/* remove one line if necessary */
if ((cfg_history_max_lines > 0)
&& (buffer->num_lines > cfg_history_max_lines))
{
if (buffer->last_line == buffer->lines)
buffer->last_line = NULL;
ptr_line = buffer->lines->next_line;
gui_buffer_line_free (buffer->lines);
buffer->lines = ptr_line;
ptr_line->prev_line = NULL;
buffer->num_lines--;
gui_chat_draw (buffer, 1);
}
return new_line;
}
/*
* gui_buffer_merge_servers: merge server buffers in one buffer
*/
void
gui_buffer_merge_servers (t_gui_window *window)
{
t_gui_buffer *ptr_buffer_server, *ptr_buffer;
t_irc_server *ptr_server;
/* new server buffer is the first server buffer found */
for (ptr_buffer_server = gui_buffers; ptr_buffer_server;
ptr_buffer_server = ptr_buffer_server->next_buffer)
{
if (BUFFER_IS_SERVER(ptr_buffer_server))
break;
}
/* no server buffer found */
if (!ptr_buffer_server)
return;
for (ptr_buffer = gui_buffers; ptr_buffer;
ptr_buffer = ptr_buffer->next_buffer)
{
if ((ptr_buffer != ptr_buffer_server)
&& (BUFFER_IS_SERVER(ptr_buffer)))
{
ptr_server = SERVER(ptr_buffer);
/* add (by pointer artefact) lines from buffer found to server buffer */
if (ptr_buffer->lines)
{
if (ptr_buffer_server->lines)
{
ptr_buffer->lines->prev_line =
ptr_buffer_server->last_line;
ptr_buffer_server->last_line->next_line =
ptr_buffer->lines;
ptr_buffer_server->last_line =
ptr_buffer->last_line;
}
else
{
ptr_buffer_server->lines = ptr_buffer->lines;
ptr_buffer_server->last_line = ptr_buffer->last_line;
}
}
/* free buffer but not lines, because they're now used by
our unique server buffer */
ptr_buffer->lines = NULL;
gui_buffer_free (ptr_buffer, 1);
/* asociate server with new server buffer */
ptr_server->buffer = ptr_buffer_server;
}
}
ptr_buffer_server->all_servers = 1;
gui_window_redraw_buffer (window->buffer);
}
/*
* gui_buffer_split_server: split the server buffer into many buffers (one by server)
*/
void
gui_buffer_split_server (t_gui_window *window)
{
t_gui_buffer *ptr_buffer;
t_irc_server *ptr_server;
ptr_buffer = gui_buffer_servers_search ();
if (ptr_buffer)
{
if (SERVER(ptr_buffer))
{
for (ptr_server = irc_servers; ptr_server;
ptr_server = ptr_server->next_server)
{
if (ptr_server->buffer
&& (ptr_server != SERVER(ptr_buffer))
&& (ptr_server->buffer == ptr_buffer))
{
ptr_server->buffer = NULL;
gui_buffer_new (window, ptr_server, NULL,
BUFFER_TYPE_STANDARD, 0);
}
}
}
ptr_buffer->all_servers = 0;
gui_status_draw (window->buffer, 1);
gui_input_draw (window->buffer, 1);
}
}
/*
* gui_buffer_switch_previous: switch to previous buffer
*/
void
gui_buffer_switch_previous (t_gui_window *window)
{
if (!gui_ok)
return;
/* if only one buffer then return */
if (gui_buffers == last_gui_buffer)
return;
if (window->buffer->prev_buffer)
gui_window_switch_to_buffer (window, window->buffer->prev_buffer);
else
gui_window_switch_to_buffer (window, last_gui_buffer);
gui_window_redraw_buffer (window->buffer);
}
/*
* gui_buffer_switch_next: switch to next buffer
*/
void
gui_buffer_switch_next (t_gui_window *window)
{
if (!gui_ok)
return;
/* if only one buffer then return */
if (gui_buffers == last_gui_buffer)
return;
if (window->buffer->next_buffer)
gui_window_switch_to_buffer (window, window->buffer->next_buffer);
else
gui_window_switch_to_buffer (window, gui_buffers);
gui_window_redraw_buffer (window->buffer);
}
/*
* gui_buffer_switch_dcc: switch to dcc buffer (create it if it does not exist)
*/
void
gui_buffer_switch_dcc (t_gui_window *window)
{
t_gui_buffer *ptr_buffer;
/* check if dcc buffer exists */
for (ptr_buffer = gui_buffers; ptr_buffer; ptr_buffer = ptr_buffer->next_buffer)
{
if (ptr_buffer->type == BUFFER_TYPE_DCC)
break;
}
if (ptr_buffer)
{
gui_window_switch_to_buffer (window, ptr_buffer);
gui_window_redraw_buffer (ptr_buffer);
}
else
gui_buffer_new (window, NULL, NULL, BUFFER_TYPE_DCC, 1);
}
/*
* gui_buffer_switch_raw_data: switch to rax IRC data buffer (create it if it does not exist)
*/
void
gui_buffer_switch_raw_data (t_gui_window *window)
{
t_gui_buffer *ptr_buffer;
/* check if raw IRC data buffer exists */
for (ptr_buffer = gui_buffers; ptr_buffer; ptr_buffer = ptr_buffer->next_buffer)
{
if (ptr_buffer->type == BUFFER_TYPE_RAW_DATA)
break;
}
if (ptr_buffer)
{
gui_window_switch_to_buffer (window, ptr_buffer);
gui_window_redraw_buffer (ptr_buffer);
}
else
gui_buffer_new (window, NULL, NULL, BUFFER_TYPE_RAW_DATA, 1);
}
/*
* gui_buffer_switch_by_number: switch to another buffer with number
*/
t_gui_buffer *
gui_buffer_switch_by_number (t_gui_window *window, int number)
{
t_gui_buffer *ptr_buffer;
/* invalid buffer */
if (number < 0)
return NULL;
/* buffer is currently displayed ? */
if (number == window->buffer->number)
return window->buffer;
/* search for buffer in the list */
for (ptr_buffer = gui_buffers; ptr_buffer; ptr_buffer = ptr_buffer->next_buffer)
{
if ((ptr_buffer != window->buffer) && (number == ptr_buffer->number))
{
gui_window_switch_to_buffer (window, ptr_buffer);
gui_window_redraw_buffer (window->buffer);
return ptr_buffer;
}
}
/* buffer not found */
return NULL;
}
/*
* gui_buffer_move_to_number: move a buffer to another number
*/
void
gui_buffer_move_to_number (t_gui_buffer *buffer, int number)
{
t_gui_buffer *ptr_buffer;
int i;
/* if only one buffer then return */
if (gui_buffers == last_gui_buffer)
return;
/* buffer number is already ok ? */
if (number == buffer->number)
return;
if (number < 1)
number = 1;
/* remove buffer from list */
if (buffer == gui_buffers)
{
gui_buffers = buffer->next_buffer;
gui_buffers->prev_buffer = NULL;
}
if (buffer == last_gui_buffer)
{
last_gui_buffer = buffer->prev_buffer;
last_gui_buffer->next_buffer = NULL;
}
if (buffer->prev_buffer)
(buffer->prev_buffer)->next_buffer = buffer->next_buffer;
if (buffer->next_buffer)
(buffer->next_buffer)->prev_buffer = buffer->prev_buffer;
if (number == 1)
{
gui_buffers->prev_buffer = buffer;
buffer->prev_buffer = NULL;
buffer->next_buffer = gui_buffers;
gui_buffers = buffer;
}
else
{
/* assign new number to all buffers */
i = 1;
for (ptr_buffer = gui_buffers; ptr_buffer; ptr_buffer = ptr_buffer->next_buffer)
{
ptr_buffer->number = i++;
}
/* search for new position in the list */
for (ptr_buffer = gui_buffers; ptr_buffer; ptr_buffer = ptr_buffer->next_buffer)
{
if (ptr_buffer->number == number)
break;
}
if (ptr_buffer)
{
/* insert before buffer found */
buffer->prev_buffer = ptr_buffer->prev_buffer;
buffer->next_buffer = ptr_buffer;
if (ptr_buffer->prev_buffer)
(ptr_buffer->prev_buffer)->next_buffer = buffer;
ptr_buffer->prev_buffer = buffer;
}
else
{
/* number not found (too big)? => add to end */
buffer->prev_buffer = last_gui_buffer;
buffer->next_buffer = NULL;
last_gui_buffer->next_buffer = buffer;
last_gui_buffer = buffer;
}
}
/* assign new number to all buffers */
i = 1;
for (ptr_buffer = gui_buffers; ptr_buffer; ptr_buffer = ptr_buffer->next_buffer)
{
ptr_buffer->number = i++;
}
gui_window_redraw_buffer (buffer);
}
/*
* gui_buffer_print_log: print buffer infos in log (usually for crash dump)
*/
void
gui_buffer_print_log (t_gui_buffer *buffer)
{
t_gui_line *ptr_line;
int num;
weechat_log_printf ("[buffer (addr:0x%X)]\n", buffer);
weechat_log_printf (" num_displayed. . . . . : %d\n", buffer->num_displayed);
weechat_log_printf (" number . . . . . . . . : %d\n", buffer->number);
weechat_log_printf (" server . . . . . . . . : 0x%X\n", buffer->server);
weechat_log_printf (" all_servers. . . . . . : %d\n", buffer->all_servers);
weechat_log_printf (" channel. . . . . . . . : 0x%X\n", buffer->channel);
weechat_log_printf (" type . . . . . . . . . : %d\n", buffer->type);
weechat_log_printf (" lines. . . . . . . . . : 0x%X\n", buffer->lines);
weechat_log_printf (" last_line. . . . . . . : 0x%X\n", buffer->last_line);
weechat_log_printf (" last_read_line . . . . : 0x%X\n", buffer->last_read_line);
weechat_log_printf (" num_lines. . . . . . . : %d\n", buffer->num_lines);
weechat_log_printf (" line_complete. . . . . : %d\n", buffer->line_complete);
weechat_log_printf (" notify_level . . . . . : %d\n", buffer->notify_level);
weechat_log_printf (" log_filename . . . . . : '%s'\n", buffer->log_filename);
weechat_log_printf (" log_file . . . . . . . : 0x%X\n", buffer->log_file);
weechat_log_printf (" has_input. . . . . . . : %d\n", buffer->has_input);
weechat_log_printf (" input_buffer . . . . . : '%s'\n", buffer->input_buffer);
weechat_log_printf (" input_buffer_color_mask: '%s'\n", buffer->input_buffer_color_mask);
weechat_log_printf (" input_buffer_alloc . . : %d\n", buffer->input_buffer_alloc);
weechat_log_printf (" input_buffer_size. . . : %d\n", buffer->input_buffer_size);
weechat_log_printf (" input_buffer_length. . : %d\n", buffer->input_buffer_length);
weechat_log_printf (" input_buffer_pos . . . : %d\n", buffer->input_buffer_pos);
weechat_log_printf (" input_buffer_1st_disp. : %d\n", buffer->input_buffer_1st_display);
weechat_log_printf (" history. . . . . . . . : 0x%X\n", buffer->history);
weechat_log_printf (" last_history . . . . . : 0x%X\n", buffer->last_history);
weechat_log_printf (" ptr_history. . . . . . : 0x%X\n", buffer->ptr_history);
weechat_log_printf (" prev_buffer. . . . . . : 0x%X\n", buffer->prev_buffer);
weechat_log_printf (" next_buffer. . . . . . : 0x%X\n", buffer->next_buffer);
weechat_log_printf ("\n");
weechat_log_printf (" => last 100 lines:\n");
num = 0;
ptr_line = buffer->last_line;
while (ptr_line && (num < 100))
{
num++;
ptr_line = ptr_line->prev_line;
}
if (!ptr_line)
ptr_line = buffer->lines;
else
ptr_line = ptr_line->next_line;
while (ptr_line)
{
num--;
weechat_log_printf (" line N-%05d: %s\n",
num,
(ptr_line->data) ? ptr_line->data : "(empty)");
ptr_line = ptr_line->next_line;
}
}
+137
View File
@@ -0,0 +1,137 @@
/*
* Copyright (c) 2003-2006 by FlashCode <flashcode@flashtux.org>
* See README for License detail, AUTHORS for developers list.
*
* 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 St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef __WEECHAT_GUI_BUFFER_H
#define __WEECHAT_GUI_BUFFER_H 1
#include "../common/completion.h"
#include "../common/history.h"
#define BUFFER_TYPE_STANDARD 0
#define BUFFER_TYPE_DCC 1
#define BUFFER_TYPE_RAW_DATA 2
#define SERVER(buffer) ((t_irc_server *)(buffer->server))
#define CHANNEL(buffer) ((t_irc_channel *)(buffer->channel))
#define BUFFER_IS_SERVER(buffer) ((SERVER(buffer) || (buffer->all_servers)) && !CHANNEL(buffer))
#define BUFFER_IS_CHANNEL(buffer) (CHANNEL(buffer) && (CHANNEL(buffer)->type == CHANNEL_TYPE_CHANNEL))
#define BUFFER_IS_PRIVATE(buffer) (CHANNEL(buffer) && \
((CHANNEL(buffer)->type == CHANNEL_TYPE_PRIVATE) \
|| (CHANNEL(buffer)->type == CHANNEL_TYPE_DCC_CHAT)))
#define BUFFER_HAS_NICKLIST(buffer) (BUFFER_IS_CHANNEL(buffer))
#define MSG_TYPE_TIME 1
#define MSG_TYPE_PREFIX 2
#define MSG_TYPE_NICK 4
#define MSG_TYPE_INFO 8
#define MSG_TYPE_MSG 16
#define MSG_TYPE_HIGHLIGHT 32
#define MSG_TYPE_NOLOG 64
#define NOTIFY_LEVEL_MIN 0
#define NOTIFY_LEVEL_MAX 3
#define NOTIFY_LEVEL_DEFAULT NOTIFY_LEVEL_MAX
/* buffer structures */
typedef struct t_gui_line t_gui_line;
struct t_gui_line
{
int length; /* length of the line (in char) */
int length_align; /* alignment length (time or time/nick) */
int log_write; /* = 1 if line will be written to log */
int line_with_message; /* line contains a message from a user? */
int line_with_highlight; /* line contains highlight */
char *nick; /* nickname for line (may be NULL) */
char *data; /* line content */
int ofs_after_date; /* offset to first char after date */
int ofs_start_message; /* offset to first char after date/nick */
t_gui_line *prev_line; /* link to previous line */
t_gui_line *next_line; /* link to next line */
};
typedef struct t_gui_buffer t_gui_buffer;
struct t_gui_buffer
{
int num_displayed; /* number of windows displaying buffer */
int number; /* buffer number (for jump/switch) */
/* server/channel */
void *server; /* buffer's server */
int all_servers; /* =1 if all servers are displayed here */
void *channel; /* buffer's channel */
int type; /* type: standard (server/channel/pv), */
/* dcc or raw data */
/* chat content (lines, line is composed by many messages) */
t_gui_line *lines; /* lines of chat window */
t_gui_line *last_line; /* last line of chat window */
t_gui_line *last_read_line; /* last read line before jump */
int num_lines; /* number of lines in the window */
int line_complete; /* current line complete ? (\n ending) */
/* notify level: when activity should be displayed? default: 3 (always) */
int notify_level; /* 0 = never */
/* 1 = highlight only */
/* 2 = highlight + message */
/* 3 = highlight + message + join/part */
/* file to save buffer content */
char *log_filename; /* filename for saving buffer content */
FILE *log_file; /* for logging buffer to file */
/* inupt buffer */
int has_input; /* = 1 if buffer has input (DCC has not)*/
char *input_buffer; /* input buffer */
char *input_buffer_color_mask; /* color mask for input buffer */
int input_buffer_alloc; /* input buffer: allocated size in mem */
int input_buffer_size; /* buffer size in bytes */
int input_buffer_length; /* number of chars in buffer */
int input_buffer_pos; /* position into buffer */
int input_buffer_1st_display; /* first char displayed on screen */
/* completion */
t_completion completion; /* for cmds/nicks completion */
/* history */
t_history *history; /* commands history */
t_history *last_history; /* last command in history */
t_history *ptr_history; /* current command in history */
int num_history; /* number of commands in history */
/* link to previous/next buffer */
t_gui_buffer *prev_buffer; /* link to previous buffer */
t_gui_buffer *next_buffer; /* link to next buffer */
};
/* buffer variables */
extern t_gui_buffer *gui_buffers;
extern t_gui_buffer *last_gui_buffer;
extern t_gui_buffer *gui_buffer_before_dcc;
extern t_gui_buffer *gui_buffer_raw_data;
extern t_gui_buffer *gui_buffer_before_raw_data;
#endif /* gui-buffer.h */

Some files were not shown because too many files have changed in this diff Show More