From: <gi...@cr...> - 2011-03-31 23:06:41
|
via 452ff385766f7f82e4ff92f319dd3a284795fd2e (commit) via 5485922b1f7b6c4e369d0b885ccfbff0e6e0d850 (commit) via df54441bbb03ba74af9baac922abe5654011c0e2 (commit) via dc162fa72b2abbece727bbbb95de76569ed0856a (commit) via e3935d4ae743c1ab42ce5ff5c67613ae65e8344e (commit) via 0e31a338be71f0968e0613e36c91ca6dad0a2a26 (commit) via a975bb5545e51090570127d9d733d61ae6788b2b (commit) via acb1ca09f83b2259a56a9beb9ef902f631aa7039 (commit) via 6422797ca72c9f6bb17ab016e55ae0cf4e873524 (commit) via 24b7e99d302e3772084df880cb322334b7f88bb5 (commit) via 5f8530060b0f55ceb29ec249356f40acd945f970 (commit) via aa3932b2c466a0e0b99b3b823731558f8a0bb109 (commit) via c782dd144f745a9355fac90de386bd8ef1f4cec5 (commit) via ba04275a65160b24d4d3438ea1ff29b82b854013 (commit) via 586997c4f116517b34a7d752fcc7780d83af81b8 (commit) via 9c0a425e56f3c7b337c0a0276d26de2d8f38cfbf (commit) via 1beff1240c1563c548b2ffd9ebbed6b32481c6be (commit) via 6f1033c0763f8226e28e79ba7ec9ccc39c715cea (commit) via d3697953552df3e272b77eb1e7528bacd59643d5 (commit) via 51b381ba462cf6a355f401e817ee2b63518c077b (commit) via e7c3fa432cecc5eeb49d79109033fd85ee3cad2a (commit) via e5001fba77867a842c1b0b192ec6969aab1cf102 (commit) via d562ab002f5aad0a15d8e94830aa710f78c52513 (commit) via bbc1968de451ed0b88b7a11f5ab302bf3ede5df7 (commit) via b6d532090f7160882446e3630d3dabadfa07924d (commit) via e5e08161e7e4aef95c45b8604f00f5c2034c81b1 (commit) via 5600077b0b13747f1481787fe0e0d252241c09fa (commit) via 4732151a9c0f1686b701caf8ba53e5774d29c8c3 (commit) via 8d74ffd849f0c250e58e3c0e1b40a6854e11c074 (commit) via cb38198de7c8356d5fce17ef04f2dc809f8b2801 (commit) via ad3bbac308f31e2c8bef95e921152f34f00cc785 (commit) via c182b846613a797cb37fcda578553e40814b7e65 (commit) via 64ca3ade493233cf0d4c43dfc68cf22622d23b76 (commit) via 851cdeb3d20406d126469933afefbec5e233a417 (commit) via 7642fc171f80cfc9e7484b20cc8e9fc7a2b69e76 (commit) via 322329c0e7c0ea12bc26a7a1d4e9c66c410fa053 (commit) via 203b11eb25997c8e225acac19da9ac206e3d4f48 (commit) via 28b815a469419b7ab6ac7d88e7ce41aac34d83da (commit) via 1e52b0fc52905ca92e10a42eafd8fce40e321ed6 (commit) via bc9e9f380e904300572398d676a95e4b359276b7 (commit) via bf51478a1c49fbd4bb8806f02b5c162b6e1cebac (commit) via ebfb02749fc10bd0ed8c358fcf06cd4dde1707c3 (commit) via f7717330f1e10f18464a68edc1b595dd6a6b9527 (commit) via e7572d74b30900124d9a896843f42b1c957d20c2 (commit) via 634ab294f302c98be55389a97e94cd7205860310 (commit) via 931040fac24525a457a62e21331572648a2104be (commit) via 8083632f65832778889f5f5ec1a18f06f8caac40 (commit) via 1c07180018c8183adbfa4618d59d55b451a2e35e (commit) via bdae12daabc138c0c233adc644deeb470377d290 (commit) via c06bb0543518fe61abd215b88ff758ae626a4129 (commit) via 12fd65966922741bd06a9cffee555f89b53932bf (commit) via c4124e3d91afade784ed3368f43a924d7a7b6be8 (commit) via e65b29e9f2a9a79731f38787384f9c877eec430f (commit) via 0fac9b0ec9f22978b94594373d65c5a70a4441fd (commit) from 778a975c1cf474d6c585d2177956daff30cffc24 (commit) ----------------------------------------------------------------------- commit 452ff385766f7f82e4ff92f319dd3a284795fd2e Merge: 778a975 5485922 Author: Adam Borowski <kil...@an...> Date: Fri Apr 1 01:00:14 2011 +0200 Merge branch 'unicode'. There are some issues left, like incorrect wrapping in some cases, but we can fix them later. commit 5485922b1f7b6c4e369d0b885ccfbff0e6e0d850 Author: Adam Borowski <kil...@an...> Date: Fri Apr 1 00:55:37 2011 +0200 Documentation updates. commit df54441bbb03ba74af9baac922abe5654011c0e2 Author: Adam Borowski <kil...@an...> Date: Fri Apr 1 00:47:29 2011 +0200 Axe a test display. commit dc162fa72b2abbece727bbbb95de76569ed0856a Author: Adam Borowski <kil...@an...> Date: Fri Apr 1 00:45:20 2011 +0200 Allow only regular printable chars of width 1 as glyphs. Control characters are, duh, no good. Combining characters might be acceptable atop of a space. CJK take two spaces. commit e3935d4ae743c1ab42ce5ff5c67613ae65e8344e Author: Adam Borowski <kil...@an...> Date: Fri Apr 1 00:42:38 2011 +0200 Allow specifying cset, feature and mon_glyph as literals. Like: mon_glyph = giant eye : white Πcommit 0e31a338be71f0968e0613e36c91ca6dad0a2a26 Author: Adam Borowski <kil...@an...> Date: Fri Apr 1 00:35:05 2011 +0200 Make feature= and mon_glyph= work again in CSET_IBM and CSET_DEC. Due to the old syntax allowing redefining them before setting the charset, there's a hack: * overrides already in UCS use positive numbers * overrides specified by number are negative The latter are converted if needed when overrides are applied. commit a975bb5545e51090570127d9d733d61ae6788b2b Author: Adam Borowski <kil...@an...> Date: Fri Apr 1 00:04:31 2011 +0200 Make cset overrides more sane. You don't need to specify the charset anymore, save for cset_ibm and cset_dec which are for compatibility with legacy config files. You can even use cset_ibm without char_set=ibm, it will work. commit acb1ca09f83b2259a56a9beb9ef902f631aa7039 Author: Adam Borowski <kil...@an...> Date: Thu Mar 31 22:30:39 2011 +0200 Fix a miscast in is_vowel(). It doesn't yet actually support å or ë yet. commit 6422797ca72c9f6bb17ab016e55ae0cf4e873524 Author: Adam Borowski <kil...@an...> Date: Thu Mar 31 22:26:55 2011 +0200 No need to hack around rename() anymore. commit 24b7e99d302e3772084df880cb322334b7f88bb5 Author: Adam Borowski <kil...@an...> Date: Thu Mar 31 22:22:24 2011 +0200 Axe some debugging code. I'm getting tired of rebasing it away from the history. commit 5f8530060b0f55ceb29ec249356f40acd945f970 Author: Adam Borowski <kil...@an...> Date: Thu Mar 31 22:10:54 2011 +0200 Unbreak arrow keys on win32 console. commit aa3932b2c466a0e0b99b3b823731558f8a0bb109 Author: Adam Borowski <kil...@an...> Date: Thu Mar 31 15:37:03 2011 +0200 Working commands on Unix console. commit c782dd144f745a9355fac90de386bd8ef1f4cec5 Author: Adam Borowski <kil...@an...> Date: Thu Mar 31 02:58:51 2011 +0200 Input on win32 console. commit ba04275a65160b24d4d3438ea1ff29b82b854013 Author: Adam Borowski <kil...@an...> Date: Wed Mar 30 05:36:18 2011 +0200 Doxygen header. commit 586997c4f116517b34a7d752fcc7780d83af81b8 Author: Adam Borowski <kil...@an...> Date: Thu Mar 31 02:35:05 2011 +0200 Get rid of remaining uses of putch(). One was actually wrong, too -- mangling redefined explosions. commit 9c0a425e56f3c7b337c0a0276d26de2d8f38cfbf Author: Adam Borowski <kil...@an...> Date: Sun Mar 13 21:29:41 2011 +0100 Unicode support in the line_reader, including CJK and combining. There are sadly some redraw errors when there's line-wrapping involved, especially if you're editing something not at the end of the buffer, but these appear to be not regressions so I left them for now. I am tempted to just brute-force it by redrawing the whole thing and let ncurses optimize it... commit 1beff1240c1563c548b2ffd9ebbed6b32481c6be Author: Adam Borowski <kil...@an...> Date: Tue Feb 15 02:33:59 2011 +0100 Use system's locale in all ports, from the very start. commit 6f1033c0763f8226e28e79ba7ec9ccc39c715cea Author: Adam Borowski <kil...@an...> Date: Mon Feb 14 16:35:42 2011 +0100 Basic cursesw input. No direction keys yet... commit d3697953552df3e272b77eb1e7528bacd59643d5 Author: Adam Borowski <kil...@an...> Date: Mon Feb 14 01:16:12 2011 +0100 Evict all non-character key codes to negative values (tiles). commit 51b381ba462cf6a355f401e817ee2b63518c077b Merge: e7c3fa4 ce4dbcf Author: Adam Borowski <kil...@an...> Date: Sun Mar 13 01:48:10 2011 +0100 Merge branch 'master' into unicode ----------------------------------------------------------------------- Summary of changes: crawl-ref/docs/options_guide.txt | 40 +-- crawl-ref/licence.txt | 479 +++++++++++++++++++++------- crawl-ref/settings/init.txt | 3 +- crawl-ref/source/AppHdr.h | 13 +- crawl-ref/source/chardump.cc | 29 +- crawl-ref/source/cio.cc | 199 ++++++++---- crawl-ref/source/cio.h | 8 +- crawl-ref/source/clua.cc | 14 +- crawl-ref/source/cmd-keys.h | 60 ++-- crawl-ref/source/command.cc | 15 +- crawl-ref/source/database.cc | 16 +- crawl-ref/source/dbg-maps.cc | 4 +- crawl-ref/source/decks.cc | 4 +- crawl-ref/source/defines.h | 2 + crawl-ref/source/dgl-message.cc | 2 +- crawl-ref/source/directn.cc | 2 +- crawl-ref/source/enum.h | 9 +- crawl-ref/source/feature.cc | 4 +- crawl-ref/source/feature.h | 4 +- crawl-ref/source/files.cc | 109 +------ crawl-ref/source/fontwrapper-ft.cc | 61 +++-- crawl-ref/source/fontwrapper-ft.h | 4 +- crawl-ref/source/hints.cc | 3 +- crawl-ref/source/initfile.cc | 204 ++++++------ crawl-ref/source/initfile.h | 35 +-- crawl-ref/source/itemname.cc | 4 +- crawl-ref/source/itemname.h | 2 +- crawl-ref/source/items.cc | 2 +- crawl-ref/source/libdos.h | 2 - crawl-ref/source/libgui.cc | 29 +-- crawl-ref/source/libgui.h | 12 +- crawl-ref/source/libunix.cc | 266 ++++------------ crawl-ref/source/libunix.h | 13 +- crawl-ref/source/libutil.cc | 18 +- crawl-ref/source/libw32c.cc | 236 ++------------ crawl-ref/source/libw32c.h | 8 +- crawl-ref/source/macro.cc | 32 +- crawl-ref/source/main.cc | 1 + crawl-ref/source/makefile | 8 - crawl-ref/source/makefile.obj | 2 + crawl-ref/source/maps.cc | 17 +- crawl-ref/source/mon-enum.h | 1 - crawl-ref/source/mon-util.cc | 2 +- crawl-ref/source/monster.h | 1 - crawl-ref/source/msvc.h | 22 -- crawl-ref/source/ng-input.cc | 10 +- crawl-ref/source/options.h | 10 +- crawl-ref/source/ouch.cc | 1 + crawl-ref/source/output.cc | 10 +- crawl-ref/source/package.cc | 6 +- crawl-ref/source/package.h | 1 - crawl-ref/source/player.h | 1 - crawl-ref/source/random.cc | 1 - crawl-ref/source/rng.cc | 1 - crawl-ref/source/sha256.cc | 2 - crawl-ref/source/show.cc | 2 - crawl-ref/source/sqldbm.cc | 11 + crawl-ref/source/startup.cc | 4 +- crawl-ref/source/stash.cc | 76 ++--- crawl-ref/source/stash.h | 13 +- crawl-ref/source/state.cc | 7 +- crawl-ref/source/state.h | 4 - crawl-ref/source/stuff.cc | 3 - crawl-ref/source/syscalls.cc | 156 +++++++++- crawl-ref/source/syscalls.h | 16 +- crawl-ref/source/tags.cc | 3 +- crawl-ref/source/tags.h | 1 - crawl-ref/source/tiledoll.cc | 5 +- crawl-ref/source/tilefont.h | 4 +- crawl-ref/source/tilereg-msg.cc | 6 +- crawl-ref/source/tilereg-text.cc | 38 ++-- crawl-ref/source/tilereg-text.h | 11 +- crawl-ref/source/unicode.cc | 574 +++++++++++++++++++++++++++++++++ crawl-ref/source/unicode.h | 85 +++++ crawl-ref/source/view.cc | 104 ++---- crawl-ref/source/view.h | 2 +- crawl-ref/source/viewchar.cc | 49 ++-- crawl-ref/source/viewchar.h | 3 +- crawl-ref/source/viewgeom.h | 6 +- crawl-ref/source/wcwidth.cc | 247 ++++++++++++++ crawl-ref/source/windowmanager-sdl.cc | 14 +- crawl-ref/source/wiz-fsim.cc | 6 +- crawl-ref/source/wiz-item.cc | 6 +- crawl-ref/source/wiz-you.cc | 2 +- 84 files changed, 2136 insertions(+), 1366 deletions(-) create mode 100644 crawl-ref/source/unicode.cc create mode 100644 crawl-ref/source/unicode.h create mode 100644 crawl-ref/source/wcwidth.cc diff --git a/crawl-ref/docs/options_guide.txt b/crawl-ref/docs/options_guide.txt index 9fd1702..c3f794c 100644 --- a/crawl-ref/docs/options_guide.txt +++ b/crawl-ref/docs/options_guide.txt @@ -119,8 +119,7 @@ The contents of this text are: 6- Miscellaneous. 6-a All OS. mouse_input, wiz_mode, char_set, classic_item_colours, - colour, char_set, cset_ascii, cset_ibm, cset_dec, - cset_unicode, feature, mon_glyph, pizza, + colour, cset, feature, mon_glyph, pizza, use_fake_player_cursor, show_player_species 6-b DOS and Windows. @@ -2051,16 +2050,16 @@ wiz_mode = (no | never | yes) of game never -- never allow a wizard command to be used -char_set = (ascii | ibm | dec | unicode) - Chooses different character sets for the game play screen. DOS - and Windows users will want to use the IBM character set, Unix - users will prefer DEC or plain ASCII. +char_set = (default | ascii | ibm | dec | unicode) + Chooses different pre-set character sets for the game play screen. + Unlike previous versions of Crawl, this does not select the I/O + encoding anymore. - On Unix, Crawl may be built with Unicode support, in which case - you can use char_set = unicode to use unicode characters in the - map display. + Setting char_set = ibm or dec has a side effect of making numeric + codes inside cset, feature and mon_glyph lines interpreted as, + respectively, CP437 codes or VT100 line-drawing characters + 128. - Has no effect in the Tiles build. + Has negligible effect in the Tiles build. classic_item_colours = false Crawl uses 4.0 b26/0.1.x-like item colours if @@ -2086,20 +2085,7 @@ colour.OLDCOLOUR = NEWCOLOUR colour.lightcyan = cyan colour.yellow = brown -cset_ascii, cset_ibm, cset_dec, cset_unicode, cset_any - Can be used to change individual characters in a specific - character set (the character set used for display is determined - by the char_set option). The syntax is the same for all of - these; cset_any changes characters in all character sets. - - * cset_ascii is limited to 7-bit characters only; these always work. - * cset_ibm stands for legacy CP437. Unlikely to work unless you - manually select this encoding. - * cset_dec uses VT100 line-drawing characters. - * cset_unicode means UTF-8. Ubiquitous on modern systems save for - Windows. - -cset_XXX = <dungeon_character_name : symbol> +cset = <dungeon_character_name : symbol> a list of these is allowed, as well. The possible entries for dungeon_character_name are: @@ -2116,8 +2102,10 @@ cset_XXX = <dungeon_character_name : symbol> character for water creatures submerged in shallow water, or invisible creatures wading in shallow water. - Symbols can be specified using a letter, or by a number (decimal - code), or a hexadecimal number (prefixed with x): + Symbols can be specified using a letter, or by its ASCII/Unicode + code: a decimal number or a hexadecimal one (prefixed with x). + For compatibility with old config files, you can use cset_ibm or + cset_dec to use IBM code page 437 or vt100 graphic characters. For an example on IBM displays, cset_ibm = wall:219, arch:0, wavy:x7E diff --git a/crawl-ref/licence.txt b/crawl-ref/licence.txt index 80e67fe..bb5c5f3 100644 --- a/crawl-ref/licence.txt +++ b/crawl-ref/licence.txt @@ -1,119 +1,360 @@ -****************************************************************************** -* IMPORTANT: Due to the on-going relicensing, we ask for all future * -* contributions you submit to be dual licensed under the old Crawl license * -* and the GNU General Public License version 2 or higher. * -* * -* Note that if you prefer some other license, anything that is GPL * -* compatible (ie, nearly all Free Software licenses) can satisfy the second * -* requirement. For the time being, though, you need to allow the old Crawl * -* license as well as it doesn't allow mixing with code under any license * -* other than itself. * -* * -* Also, you are encouraged to put tile graphics into the Public Domain / CC0 * -* so they can be contributed back to the rltiles project. This is merely * -* a request, tiles contributions under the regular dual licensing are fine. * -****************************************************************************** - - Crawl General Public Licence - - Linley Henzell - (Copyright 1997-1999 Linley Henzell) - - Yes, this is an almost exact copy of the Nethack Licence, but has - obviously been adapted for Crawl (under the 'terms for other - programs' portion of paragraph one). Crawl contains no code from - Nethack in any shape or form. - - Based on the NETHACK GENERAL PUBLIC LICENCE - (Copyright 1989 M. Stephenson) - - Based on the BISON GENERAL PUBLIC LICENCE - (Copyright 1988 Richard M. Stallman) - - Everyone is permitted to copy and distribute verbatim copies of - this licence, but changing it is not allowed. You can also use this - wording to make the terms for other programs. - - The licence agreements of most software companies keep you at the - mercy of those companies. By contrast, our general public licence - is intended to give everyone the right to share Crawl. To make sure - that you get the rights we want you to have, we need to make - restrictions that forbid anyone to deny you these rights or to ask - you to surrender the rights. Hence this licence agreement. - - Specifically, we want to make sure that you have the right to give - away copies of Crawl, that you receive source code or else can get - it if you want it, that you can change Crawl or use pieces of it in - new free programs, and that you know you can do these things. - - To make sure that everyone has such rights, we have to forbid you - to deprive anyone else of these rights. For example, if you - distribute copies of Crawl, you must give the recipients all the - rights that you have. You must make sure that they, too, receive or - can get the source code. And you must tell them their rights. - - Also, for our own protection, we must make certain that everyone - finds out that there is no warranty for Crawl. If Crawl is modified - by someone else and passed on, we want its recipients to know that - what they have is not what we distributed. - - Therefore I (Linley Henzell, the copyright holder of Crawl) make - the following terms which say what you must do to be allowed to - distribute or change Crawl. - - COPYING POLICIES - - 1. You may copy and distribute verbatim copies of Crawl source code - as you receive it, in any medium, provided that you keep intact - the notices on all files that refer to copyrights, to this Licence - Agreement, and to the absence of any warranty; and give any other - recipients of the Crawl program a copy of this Licence Agreement - along with the program. - 2. You may modify your copy or copies of Crawl or any portion of it, - and copy and distribute such modifications under the terms of - Paragraph 1 above (including distributing this Licence Agreement), - provided that you also do the following: - a. cause the modified files to carry prominent notices stating - that you changed the files and the date of any change; and - b. cause the whole of any work that you distribute or publish, - that in whole or in part contains or is a derivative of Crawl - or any part thereof, to be licensed at no charge to all third - parties on terms identical to those contained in this Licence - Agreement (except that you may choose to grant more extensive - warranty protection to some or all third parties, at your - option) - c. You may charge a distribution fee for the physical act of - transferring a copy, and you may at your option offer - warranty protection in exchange for a fee. - 3. You may copy and distribute Crawl (or a portion or derivative of - it, under Paragraph 2) in object code or executable form under the - terms of Paragraphs 1 and 2 above provided that you also do one of - the following: - a. accompany it with the complete machine-readable source code, - which must be distributed under the terms of Paragraphs 1 and - 2 above; or, - b. accompany it with full information as to how to obtain the - complete machine-readable source code from an appropriate - archive site. (This alternative is allowed only for - noncommercial distribution.) - For these purposes, complete source code means either the full - source distribution as available from my web site or updated - copies of the files in this distribution used to create the object - code or executable. - 4. You may not copy, sublicence, distribute or transfer Crawl except - as expressly provided under this Licence Agreement. Any attempt - otherwise to copy, sublicence, distribute or transfer Crawl is - void and your rights to use the program under this Licence - agreement shall be automatically terminated. However, parties who - have received computer software programs from you with this - Licence Agreement will not have their licences terminated so long - as such parties remain in full compliance. - - Stated plainly: You are prohibited by the terms of this Licence - Agreement from using Crawl for gainful purposes. You are permitted - to modify Crawl, or otherwise use parts of Crawl, provided that you - comply with the conditions specified above; in particular, your - modified Crawl or program containing parts of Crawl must remain - freely available as provided in this Licence Agreement. In other - words, go ahead and share Crawl, but don't try to stop anyone else - from sharing it farther. +Dungeon Crawl Stone Soup +Copyright 1997-2010 Linley Henzell, the dev team, and the contributors +(please refer to CREDITS.txt for details). + +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. + +Certain pieces come with different licenses, all compatible with the GPL. +These include: +* 3-clause BSD: mt19937ar.cc, MSVC/stdint.h +* 2-clause BSD: all contributions by Steve Noonan and Jesse Luehrs +* Public Domain|CC0: most of tiles + +While a vast majority of the tiles are in the Public Domain, there is no +accurate list. To err on the side of caution, please refer to Chris Hamons' +collection at http://code.google.com/p/crawl-tiles/ + +*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&* + + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + <signature of Ty Coon>, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. diff --git a/crawl-ref/settings/init.txt b/crawl-ref/settings/init.txt index 44deeac..1b2599e 100644 --- a/crawl-ref/settings/init.txt +++ b/crawl-ref/settings/init.txt @@ -406,8 +406,7 @@ note_monsters = orb of fire, ancient lich, Sigmund # show_player_species = true # See options_guide.txt for the options -# cset_ascii, cset_ibm, cset_dec, cset_unicode, cset_any, -# feature, mon_glyph +# cset, feature, mon_glyph ##### 6-b DOS and Windows ####################### # diff --git a/crawl-ref/source/AppHdr.h b/crawl-ref/source/AppHdr.h index 121851b..b621177 100644 --- a/crawl-ref/source/AppHdr.h +++ b/crawl-ref/source/AppHdr.h @@ -17,6 +17,7 @@ #define APPHDR_H #include "platform.h" +#include <stdint.h> #ifdef TARGET_COMPILER_VC /* Disable warning about: @@ -35,14 +36,6 @@ // #define CLUA_MAX_MEMORY_USE (2 * 1024) -// Enable support for Unicode character glyphs. Note that this needs -// to be accompanied by changes to linker and compiler options and may -// not be available on all platforms. In most cases you want to set -// this option from your makefile, not directly in AppHdr.h (See -// INSTALL for more details.) -// -// #define UNICODE_GLYPHS - // Uncomment to prevent Crawl from looking for a list of saves when // asking the player to enter a name. This can speed up startup // considerably if you have a lot of saves lying around. @@ -116,9 +109,6 @@ #define CHARACTER_SET 0 #ifndef USE_TILE - // NOTE: Tiles relies on the IBM character set for evaluating glyphs - // of magic mapped dungeon cells. - #define USE_ASCII_CHARACTERS #define USE_CURSES #endif @@ -188,7 +178,6 @@ #include "libw32c.h" #endif #define CHARACTER_SET A_ALTCHARSET - #define getstr(X,Y) get_console_string(X,Y) // NT and better are happy with /; I'm not sure how 9x reacts. #define FILE_SEPARATOR '/' diff --git a/crawl-ref/source/chardump.cc b/crawl-ref/source/chardump.cc index ec04bf1..2095adb 100644 --- a/crawl-ref/source/chardump.cc +++ b/crawl-ref/source/chardump.cc @@ -54,6 +54,7 @@ #include "env.h" #include "transform.h" #include "travel.h" +#include "unicode.h" #include "view.h" #include "viewchar.h" #include "xom.h" @@ -1253,13 +1254,6 @@ std::string morgue_directory() void dump_map(FILE *fp, bool debug, bool dist) { - // Duplicate the screenshot() trick. - FixedVector<unsigned, NUM_DCHAR_TYPES> char_table_bk; - char_table_bk = Options.char_table; - - init_char_table(CSET_ASCII); - init_show_table(); - if (debug) { // Write the whole map out without checking for mappedness. Handy @@ -1279,7 +1273,10 @@ void dump_map(FILE *fp, bool debug, bool dist) fputc('0' + travel_point_distance[x][y], fp); } else - fputc(get_feature_def(grd[x][y]).symbol, fp); + { + fputs(OUTS(stringize_glyph( + get_feature_def(grd[x][y]).symbol)), fp); + } } fputc('\n', fp); } @@ -1301,15 +1298,14 @@ void dump_map(FILE *fp, bool debug, bool dist) for (int y = min_y; y <= max_y; ++y) { for (int x = min_x; x <= max_x; ++x) - fputc(get_cell_glyph(coord_def(x, y)).ch, fp); + { + fputs(OUTS(stringize_glyph( + get_cell_glyph(coord_def(x, y)).ch)), fp); + } fputc('\n', fp); } } - - // Restore char and feature tables - Options.char_table = char_table_bk; - init_show_table(); } void dump_map(const char* fname, bool debug, bool dist) @@ -1351,7 +1347,7 @@ static bool _write_dump(const std::string &fname, dump_params &par, if (handle != NULL) { - fputs(par.text.c_str(), handle); + fputs(OUTS(par.text), handle); fclose(handle); succeeded = true; if (print_dump_path) @@ -1415,6 +1411,7 @@ void whereis_record(const char *status) if (FILE *handle = fopen_replace(file_name.c_str())) { + // no need to bother with supporting ancient charsets for DGL fprintf(handle, "%s:status=%s\n", xlog_status_line().c_str(), status? status : ""); @@ -1470,7 +1467,7 @@ std::string dgl_timestamp_filename() // of a known version. bool dgl_unknown_timestamp_file(const std::string &filename) { - if (FILE *inh = fopen(filename.c_str(), "rb")) + if (FILE *inh = fopen_u(filename.c_str(), "rb")) { reader r(inh); const uint32_t file_version = unmarshallInt(r); @@ -1494,7 +1491,7 @@ FILE *dgl_timestamp_filehandle() // First check if there's already a timestamp file. If it exists // but has a different version, we cannot safely modify it, so bail. if (!dgl_unknown_timestamp_file(filename)) - timestamp_file = fopen(filename.c_str(), "ab"); + timestamp_file = fopen_u(filename.c_str(), "ab"); } return timestamp_file; } diff --git a/crawl-ref/source/cio.cc b/crawl-ref/source/cio.cc index 3415620..da03299 100644 --- a/crawl-ref/source/cio.cc +++ b/crawl-ref/source/cio.cc @@ -12,6 +12,7 @@ #include "macro.h" #include "message.h" #include "state.h" +#include "unicode.h" #include "viewgeom.h" #include <queue> @@ -30,15 +31,15 @@ static keycode_type _numpad2vi(keycode_type key) case CK_DOWN: key = 'j'; break; case CK_LEFT: key = 'h'; break; case CK_RIGHT: key = 'l'; break; - case 1001: key = 'b'; break; - case 1002: key = 'j'; break; - case 1003: key = 'n'; break; - case 1004: key = 'h'; break; - case 1005: key = '.'; break; - case 1006: key = 'l'; break; - case 1007: key = 'y'; break; - case 1008: key = 'k'; break; - case 1009: key = 'u'; break; + case -1001: key = 'b'; break; + case -1002: key = 'j'; break; + case -1003: key = 'n'; break; + case -1004: key = 'h'; break; + case -1005: key = '.'; break; + case -1006: key = 'l'; break; + case -1007: key = 'y'; break; + case -1008: key = 'k'; break; + case -1009: key = 'u'; break; } if (key >= '1' && key <= '9') { @@ -372,17 +373,26 @@ int line_reader::read_line(bool clear_previous) start = cgetpos(region); length = strlen(buffer); + int width = strwidth(buffer); // Remember the previous cursor position, if valid. - if (pos < 0 || pos > length) - pos = length; + if (pos < 0 || pos > width) + pos = width; - cur = buffer + pos; + cur = buffer; + int cpos = 0; + while (*cur && cpos < pos) + { + ucs_t c; + int s = utf8towc(&c, cur); + cur += s; + cpos += wcwidth(c); + } if (length) wrapcprintf(wrapcol, "%s", buffer); - if (pos != length) + if (pos != width) cursorto(pos); if (history) @@ -426,29 +436,30 @@ int line_reader::read_line(bool clear_previous) void line_reader::backspace() { - if (pos) - { - buffer[length] = 0; - --cur; - char *c = cur; - while (*c) - { - *c = *(c+1); - c++; - } - --pos; - --length; + if (!pos) + return; - cursorto(pos); - buffer[length] = 0; - wrapcprintf(wrapcol, "%s ", cur); - cursorto(pos); - } + char *np = prev_glyph(cur, buffer); + ASSERT(np); + ucs_t ch; + utf8towc(&ch, np); + buffer[length] = 0; + length -= cur - np; + char *c = cur; + cur = np; + while (*c) + *np++ = *c++; + calc_pos(); + + cursorto(pos); + buffer[length] = 0; + wrapcprintf(wrapcol, "%s ", cur); + cursorto(pos); } -bool line_reader::is_wordchar(int c) +bool line_reader::is_wordchar(ucs_t c) { - return isalnum(c) || c == '_' || c == '-'; + return iswalnum(c) || c == '_' || c == '-'; } void line_reader::kill_to_begin() @@ -456,11 +467,12 @@ void line_reader::kill_to_begin() if (!pos || cur == buffer) return; + int rest = length - (cur - buffer); buffer[length] = 0; cursorto(0); - wrapcprintf(wrapcol, "%s%*s", cur, cur - buffer, ""); - memmove(buffer, cur, length - pos); - length -= pos; + wrapcprintf(wrapcol, "%s%*s", cur, pos, ""); + memmove(buffer, cur, rest); + buffer[length = rest] = 0;; pos = 0; cur = buffer; cursorto(pos); @@ -468,19 +480,52 @@ void line_reader::kill_to_begin() void line_reader::killword() { - if (!pos || cur == buffer) + if (cur == buffer) return; bool foundwc = false; - while (pos) + char *word = cur; + int ew = 0; + while (1) { - if (is_wordchar(cur[-1])) + char *np = prev_glyph(word, buffer); + if (!np) + break; + + ucs_t c; + utf8towc(&c, np); + if (is_wordchar(c)) foundwc = true; else if (foundwc) break; - backspace(); + word = np; + ew += wcwidth(c); + } + memmove(word, cur, strlen(cur) + 1); + length -= cur - word; + cur = word; + calc_pos(); + + cursorto(0); + wrapcprintf(wrapcol, "%s%*s", buffer, ew); + cursorto(pos); +} + +void line_reader::calc_pos() +{ + int p = 0; + const char *cp = buffer; + ucs_t c; + int s; + while (cp < cur && (s = utf8towc(&c, cp))) + { + // FIXME: this won't handle a CJK character wrapping prematurely + // (if there's only one space left) + cp += s; + p += wcwidth(c); } + pos = p; } int line_reader::process_key(int ch) @@ -500,19 +545,19 @@ int line_reader::process_key(int ch) if (text) { - int olen = length; + int olen = strwidth(buffer); length = text->length(); if (length >= static_cast<int>(bufsz)) length = bufsz - 1; memcpy(buffer, text->c_str(), length); buffer[length] = 0; + cur = buffer + length; + calc_pos(); cursorto(0); - int clear = length < olen ? olen - length : 0; + int clear = pos < olen ? olen - pos : 0; wrapcprintf(wrapcol, "%s%*s", buffer, clear, ""); - pos = length; - cur = buffer + pos; cursorto(pos); } break; @@ -526,26 +571,25 @@ int line_reader::process_key(int ch) case CONTROL('K'): { // Kill to end of line. - int erase = length - pos; - if (erase) + if (*cur) { - length = pos; - buffer[length] = 0; + int erase = strwidth(cur); + length = cur - buffer; + *cur = 0; wrapcprintf(wrapcol, "%*s", erase, ""); cursorto(pos); } break; } case CK_DELETE: - if (pos < length) + if (*cur) { + char *np = next_glyph(cur); + ASSERT(np); char *c = cur; - while (c - buffer < length) - { - *c = c[1]; - c++; - } - --length; + while (*np) + *c++ = *np++; + length = np - buffer; cursorto(pos); buffer[length] = 0; @@ -567,54 +611,65 @@ int line_reader::process_key(int ch) break; case CK_LEFT: - if (pos) + if (char *np = prev_glyph(cur, buffer)) { - --pos; - cur = buffer + pos; + cur = np; + calc_pos(); cursorto(pos); } break; case CK_RIGHT: - if (pos < length) + if (char *np = next_glyph(cur)) { - ++pos; - cur = buffer + pos; + cur = np; + calc_pos(); cursorto(pos); } break; case CK_HOME: case CONTROL('A'): pos = 0; - cur = buffer + pos; + cur = buffer; cursorto(pos); break; case CK_END: case CONTROL('E'): - pos = length; - cur = buffer + pos; + cur = buffer + length; + calc_pos(); cursorto(pos); break; case CK_MOUSE_CLICK: return (-1); default: - if (isprint(ch) && length < static_cast<int>(bufsz) - 1) + if (wcwidth(ch) >= 0 && length + wclen(ch) < static_cast<int>(bufsz)) { - if (pos < length) + int w = wcwidth(ch); + int len = wclen(ch); + if (*cur) { char *c = buffer + length - 1; while (c >= cur) { - c[1] = *c; + c[len] = *c; c--; } } - *cur++ = static_cast<char>(ch); - ++length; + wctoutf8(cur, ch); + cur += len; + length += len; buffer[length] = 0; - ++pos; - putch(ch); - if (pos < length) - wrapcprintf(wrapcol, "%s", cur); + pos += w; + if (!w) + { + cursorto(0); + wrapcprintf(wrapcol, "%s", buffer); + } + else + { + putwch(ch); + if (*cur) + wrapcprintf(wrapcol, "%s", cur); + } cursorto(pos); } break; diff --git a/crawl-ref/source/cio.h b/crawl-ref/source/cio.h index 6e647ad..6a188d3 100644 --- a/crawl-ref/source/cio.h +++ b/crawl-ref/source/cio.h @@ -140,8 +140,7 @@ enum KEYS CK_BKSP = 8, CK_ESCAPE = ESCAPE, - // 128 is off-limits because it's the code that's used when running - CK_DELETE = 129, + CK_DELETE = -255, // This sequence of enums should not be rearranged. CK_UP, @@ -190,7 +189,7 @@ enum KEYS CK_CTRL_TAB, // Mouse codes. - CK_MOUSE_MOVE = 10001, + CK_MOUSE_MOVE = -10009, CK_MOUSE_CMD, CK_MOUSE_B1, CK_MOUSE_B2, @@ -241,8 +240,9 @@ protected: void backspace(); void killword(); void kill_to_begin(); + void calc_pos(); - bool is_wordchar(int c); + bool is_wordchar(ucs_t c); protected: char *buffer; diff --git a/crawl-ref/source/clua.cc b/crawl-ref/source/clua.cc index 567cf0b..d1fbb02 100644 --- a/crawl-ref/source/clua.cc +++ b/crawl-ref/source/clua.cc @@ -15,6 +15,8 @@ #include "libutil.h" #include "state.h" #include "stuff.h" +#include "syscalls.h" +#include "unicode.h" #include <algorithm> @@ -150,7 +152,7 @@ int CLua::file_write(lua_State *ls) FILE *CLua::CLuaSave::get_file() { if (!handle) - handle = fopen(filename, "w"); + handle = fopen_u(filename, "w"); return (handle); } @@ -248,7 +250,15 @@ int CLua::loadfile(lua_State *ls, const char *filename, bool trusted, make_stringf("Can't find \"%s\"", filename).c_str()); return (-1); } - return (luaL_loadfile(ls, file.c_str())); + + FileLineInput f(file.c_str()); + std::string script; + while (!f.eof()) + script += f.get_line() + "\n"; + + // prefixing with @ stops lua from adding [string "%s"] + return luaL_loadbuffer(ls, &script[0], script.length(), + ("@" + file).c_str()); } int CLua::execfile(const char *filename, bool trusted, bool die_on_fail, diff --git a/crawl-ref/source/cmd-keys.h b/crawl-ref/source/cmd-keys.h index 7660fed..57a10e7 100644 --- a/crawl-ref/source/cmd-keys.h +++ b/crawl-ref/source/cmd-keys.h @@ -18,15 +18,15 @@ {CK_PGDN, CMD_MOVE_DOWN_RIGHT}, {CK_PGUP, CMD_MOVE_UP_RIGHT}, {CK_HOME, CMD_MOVE_UP_LEFT}, -{1001, CMD_MOVE_DOWN_LEFT}, -{1004, CMD_MOVE_LEFT}, -{1002, CMD_MOVE_DOWN}, -{1008, CMD_MOVE_UP}, -{1006, CMD_MOVE_RIGHT}, -{1003, CMD_MOVE_DOWN_RIGHT}, -{1009, CMD_MOVE_UP_RIGHT}, -{1007, CMD_MOVE_UP_LEFT}, -{1005, CMD_REST}, +{-1001, CMD_MOVE_DOWN_LEFT}, +{-1004, CMD_MOVE_LEFT}, +{-1002, CMD_MOVE_DOWN}, +{-1008, CMD_MOVE_UP}, +{-1006, CMD_MOVE_RIGHT}, +{-1003, CMD_MOVE_DOWN_RIGHT}, +{-1009, CMD_MOVE_UP_RIGHT}, +{-1007, CMD_MOVE_UP_LEFT}, +{-1005, CMD_REST}, {'b', CMD_MOVE_DOWN_LEFT}, {'h', CMD_MOVE_LEFT}, {'j', CMD_MOVE_DOWN}, @@ -219,15 +219,15 @@ {CK_PGDN, CMD_TARGET_DOWN_RIGHT}, {CK_PGUP, CMD_TARGET_UP_RIGHT}, {CK_HOME, CMD_TARGET_UP_LEFT}, -{1001, CMD_TARGET_DOWN_LEFT}, -{1004, CMD_TARGET_LEFT}, -{1002, CMD_TARGET_DOWN}, -{1008, CMD_TARGET_UP}, -{1006, CMD_TARGET_RIGHT}, -{1003, CMD_TARGET_DOWN_RIGHT}, -{1009, CMD_TARGET_UP_RIGHT}, -{1007, CMD_TARGET_UP_LEFT}, -{1005, CMD_TARGET_SELECT}, +{-1001, CMD_TARGET_DOWN_LEFT}, +{-1004, CMD_TARGET_LEFT}, +{-1002, CMD_TARGET_DOWN}, +{-1008, CMD_TARGET_UP}, +{-1006, CMD_TARGET_RIGHT}, +{-1003, CMD_TARGET_DOWN_RIGHT}, +{-1009, CMD_TARGET_UP_RIGHT}, +{-1007, CMD_TARGET_UP_LEFT}, +{-1005, CMD_TARGET_SELECT}, {'B', CMD_TARGET_DIR_DOWN_LEFT}, {'H', CMD_TARGET_DIR_LEFT}, {'J', CMD_TARGET_DIR_DOWN}, @@ -273,14 +273,14 @@ {CK_PGDN, CMD_MAP_MOVE_DOWN_RIGHT}, {CK_PGUP, CMD_MAP_MOVE_UP_RIGHT}, {CK_HOME, CMD_MAP_MOVE_UP_LEFT}, -{1001, CMD_MAP_MOVE_DOWN_LEFT}, -{1004, CMD_MAP_MOVE_LEFT}, -{1002, CMD_MAP_MOVE_DOWN}, -{1008, CMD_MAP_MOVE_UP}, -{1006, CMD_MAP_MOVE_RIGHT}, -{1003, CMD_MAP_MOVE_DOWN_RIGHT}, -{1009, CMD_MAP_MOVE_UP_RIGHT}, -{1007, CMD_MAP_MOVE_UP_LEFT}, +{-1001, CMD_MAP_MOVE_DOWN_LEFT}, +{-1004, CMD_MAP_MOVE_LEFT}, +{-1002, CMD_MAP_MOVE_DOWN}, +{-1008, CMD_MAP_MOVE_UP}, +{-1006, CMD_MAP_MOVE_... [truncated message content] |