⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 colors

📁 EPIC IRC客户端。来源于IRCII客户端但做了很多性能和功能的优化。
💻
字号:
(Not everything in this file is 100% accurate...)This version of epic contains J. Kean Johnston's color strippingcode.  This code is an attempt at making color support more UNIX friendlyin IRC clients.  The color parsing code has been designed to fit in withmy term.c replacement as well.The aim of this code is to strip all incoming messages of non-portablecolor codes, and to convert those color codes to the codes specific to theterminal type of the user, if such codes exist. It also extends mIRC andPIRCH's Ctrl-C color codes to allow for an easier set of supported colors.Please encourage the authors of those programs to adhere to this set, sothat we can have uniformity amongst the competing clients out there.Since ANSI escape codes have been around for so long, and are so widelyused in so many environments, this code uses the ANSI escape codes as itsbase.  That is, it can understand ANSI escape sequences in incomingstrings, and map those sequences down to terminal-specific escapesequences.  The color numbers supported in Ctrl-C type strings also matchthe ANSI color set.  For your reference, here are the extended Ctrl-Csequences this code recognises, and the ANSI escape sequences recognised.These map down to a specific color on the display:+---------------------------------------------------------------------+|                   Extended Ctrl-C color numbers                     |+-----------------+-----------------------+---------------------------+| Ctrl-C Number   |  ANSI Escape Sequence | Color                     |+-----------------+-----------------------+---------------------------+|       30        | ESC [ 0; 30 m         | Black foreground          ||       31        | ESC [ 0; 31 m         | Red foreground            ||       32        | ESC [ 0; 32 m         | Green foreground          ||       33        | ESC [ 0; 33 m         | Brown foreground          ||       34        | ESC [ 0; 34 m         | Blue foreground           ||       35        | ESC [ 0; 35 m         | Magenta foreground        ||       36        | ESC [ 0; 36 m         | Cyan foreground           ||       37        | ESC [ 0; 37 m         | White foreground          ||       40        | ESC [ 40 m            | Black background          ||       41        | ESC [ 41 m            | Red background            ||       42        | ESC [ 42 m            | Green background          ||       43        | ESC [ 43 m            | Brown background          ||       44        | ESC [ 44 m            | Blue background           ||       45        | ESC [ 45 m            | Magenta background        ||       46        | ESC [ 46 m            | Cyan background           ||       47        | ESC [ 47 m            | White background          ||       50        | ESC [ 1; 30 m         | Grey foreground           ||       51        | ESC [ 1; 31 m         | Bright red foreground     ||       52        | ESC [ 1; 32 m         | Bright green foreground   ||       53        | ESC [ 1; 33 m         | Yellow foreground         ||       54        | ESC [ 1; 34 m         | Bright blue foreground    ||       55        | ESC [ 1; 35 m         | Bright magenta foreground ||       56        | ESC [ 1; 36 m         | Bright cyan foreground    ||       57        | ESC [ 1; 37 m         | Bright white foreground   |+-----------------+-----------------------+---------------------------+In order to support existing mIRC color codes, the following map is appliedto Ctrl-C colors with the given values.  Note that each color can have aslightly different value when interpreted as a foreground or a backgroundcolor. This is the problem with the color set the mIRC author chose. Unlessthe user is on a graphics device with a large color pallete, the mappingsare inaccurate.+-------------------------------------------------------------------------+|                     mIRC Ctrl-C color mappings                          |+----------+-----------------+-----------------+--------------------------+| Ctrl-C # | Foreground ANSI | Background ANSI | Fore / back Color        |+----------+-----------------+-----------------+--------------------------+|    0     | ESC [ 1; 37 m   | ESC [ 47 m      | Bright white / White     ||    1     | ESC [ 0; 30 m   | ESC [ 40 m      | Black / Black            ||    2     | ESC [ 0; 34 m   | ESC [ 44 m      | Blue / Blue              ||    3     | ESC [ 0; 32 m   | ESC [ 42 m      | Green / Green            ||    4     | ESC [ 0; 31 m   | ESC [ 41 m      | Red / Red                ||    5     | ESC [ 0; 33 m   | ESC [ 43 m      | Brown / Brown            ||    6     | ESC [ 0; 35 m   | ESC [ 45 m      | Magenta / Magenta        ||    7     | ESC [ 1; 31 m   | ESC [ 41 m      | Bright red / Red         ||    8     | ESC [ 1; 33 m   | ESC [ 43 m      | Yellow / brown           ||    9     | ESC [ 1; 32 m   | ESC [ 42 m      | Bright green / Green     ||    10    | ESC [ 0; 36 m   | ESC [ 46 m      | Cyan / Cyan              ||    11    | ESC [ 1; 36 m   | ESC [ 46 m      | Bright Cyan  Cyan        ||    12    | ESC [ 1; 34 m   | ESC [ 44 m      | Bright blue / Blue       ||    13    | ESC [ 1; 35 m   | ESC [ 45 m      | Bright Magenta / Magenta ||    14    | ESC [ 1; 30 m   | ESC [ 40 m      | Grey / Black             ||    15    | ESC [ 0; 37 m   | ESC [ 40 m      | Grey / White             |+----------+-----------------+-----------------+--------------------------+By special dispensation, there is also a function which can be used forpreparing strings with color in scripts or in settable variables.  There isa function which will replace these special formatting variables with theappropriate Ctrl-C colors, if colorization is turned on.  The table belowlists the escape sequences recognised, and what they are replaced with.+-------------------------------------------------------------+|              Embedded color escape sequences                |+---------+-----------------------+---------------------------+| % char  |  ANSI Escape Sequence | Color                     |+---------+-----------------------+---------------------------+|   %k    | ESC [ 0; 30 m         | Black foreground          ||   %K    | ESC [ 1; 30 m         | Grey foreground           ||   %r    | ESC [ 0; 31 m         | Red foreground            ||   %R    | ESC [ 1; 31 m         | Bright red foreground     ||   %g    | ESC [ 0; 32 m         | Green foreground          ||   %G    | ESC [ 1; 32 m         | Bright green foreground   ||   %y    | ESC [ 0; 33 m         | Brown foreground          ||   %Y    | ESC [ 1; 33 m         | Yellow foreground         ||   %b    | ESC [ 0; 34 m         | Blue foreground           ||   %B    | ESC [ 1; 34 m         | Bright blue foreground    || %m / %p | ESC [ 0; 35 m         | Magenta foreground        || %M / %P | ESC [ 1; 35 m         | Bright magenta foreground ||   %c    | ESC [ 0; 36 m         | Cyan foreground           ||   %C    | ESC [ 1; 36 m         | Bright cyan foreground    ||   %w    | ESC [ 0; 37 m         | White foreground          ||   %W    | ESC [ 1; 37 m         | Bright white foreground   ||   %F    | ESC [ 5 m             | Turn blinking on          ||   %f    | ESC [ 6 m             | Turn blinking off         ||   %n    | Variable              | All colors turned off     ||   %N    | Nothing               | Dont clear colors at EOS  ||   %%    | %                     | A litteral % character    |+---------+-----------------------+---------------------------+What colors.c does------------------The colorization module provides several utility functions designed to easethe display of strings on the local client.  These functions should be usedto prepare the final output string to the clients screen.  Firstly, thereis a "stripper" function.  This will remove all color formatting charactersand escape sequences from the specified string, and return it.  Thisfucntion can optionally repove any graphics characters from the string aswell (upper PC ASCII characters, and all lower ASCII characters).  NOTE:this will remove characters such as ^B, ^V and ^_, the characters used toturn on bold, inverse and underline in a string.  This function is ratherbrutal in its removal of string characters.Another function provided will take the given input string and convert anyembedded ANSI or Ctrl-C color codes to the color codes supported by theusers terminal.  It will also insert the escape sequences for turning onand off the bold, inverse and underline modes when ^B, ^V and ^_ areencountered in the string.  This function can be used to prepare a "final"string for display.  The function will optionally convert any upper andlower ASCII characters to their graphics equivalents if your terminalsupports them, or will inverse the characters or strip off the high bit ifyour terminal does not support the display of special PC characters.A third function is basically an extension of the second, except it takes"fill prefix" and width arguments, and will prepare a set of strings readyto display to the client, including wrapping and insertion of the fillstring.  This correctly calculates the string lengths so as to excludespecial characters when calculating when to wrap the string.User control over the colorization process------------------------------------------There are a few variables the user can set to control the colorization andstripping process.  They are:/set CONTROL_C_COLOR	OFF - Dont allow any color codes at all	ON  - Allow all coolors codes/set DISPLAY_ANSI	OFF - Do not do any ansi-code translation, Mangle escapes	ON  - Translate all 'safe' codes to their logical equivalents.	      Strip out all other codes.DISPLAY_PC_CHARACTERS  Legal values: 0, 1, 2, 3, 4, 5  0  - Strip all upper ASCII and lower ASCII strings except for ^B, ^V,       ^_ and ^F.  1  - If the terminal has dispc/S1 capability, use it.       Otherwise, use the "traditional" 7-bit interverted translation.       (eg: (x | 0x40 & 0x7f) (you have to see it to understand)) (default)  2  - Same as #1, except the translation is done in a more 'sane' way and       attempts to render in a way more friendly to scripts that are using       8 bit characters to "draw".  Translated characters are inverted so       that you know they were translated.  3  - Same as #2, except translated characters are not inverted.  4  - Always display characters without translation.  5  - Always display characters with "sane" translation.Things still to do------------------a) Preparing long display strings for display optimizationb) Making the input stuff color / ROM CHAR friendly  (done!)c) Make the graphics character translation map configurabled) Some minor cleanups which reduce function overheade) Calculate more values at the start of the display calc loop for speedf) Much more testingg) Handle things where terminal cant turn off auto-margins (I think this   is already handled correctly). (durn bogus terminals!)h) Make more code use the accululator to speed up displaysi) Actually write the accumulator :-)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -