Commit Graph

34 Commits (8a47c103fc738fc7c09376459c62a1dc20105cc4)

Author SHA1 Message Date
Ryan Williams bc0def4342
MiscUtils word_wrap: Add option to trim only leading whitespace after wrapping (#2169)
* Update changelog.txt
2022-05-30 22:58:46 -04:00
Tim Siegel 55e4008925
MiscUtils: teach word_wrap() to optionally preserve whitespace 2022-05-09 13:42:11 -04:00
George Murray 74a3e0eddf Use a string and .reserve for normalizing instead of stringbuf 2020-09-24 15:22:58 -07:00
George Murray f5c3712778 Nicer formatting for the normalized character mapping table 2020-09-24 14:32:58 -07:00
George Murray 38c9c28250 Fix wrong variable usage in to_search_normalized 2020-09-24 10:52:03 -07:00
George Murray a3c565b243 Add to_search_normalized to search for characters with accents 2020-09-24 07:31:10 -07:00
lethosor 46e53fc3b3 Make df2console only call df2utf if the output stream is a console
Fixes output in command-prompt, for example
2018-07-09 11:00:28 -04:00
Pauli 7a2245c2fa Remove null byte from string length
I noticed an extra null when trying to grep dfhack.run ls output.

std::string manages null byte at end(). Pre C++11 didn't require null
termination for std::string but C++11 add the null termination to make
c_str() and data() truely const. It is undefined behavior to modify the
internal null termination but this modification sets the null to null.
2018-06-30 12:51:38 +03:00
Pauli 4cfdd7d92e Check if second vsnprintf does something unexpected 2018-06-13 23:33:13 +03:00
Pauli 82e7b8300a Make stl_vsprintf return if there is an vsnprintf error
vsnprintf man page claims:
"If an output error is encountered, a negative value is returned."

That means we has to call vsnprintf twice at most to have whole output
written to a string. But in case of error we return an empty string.

The code also optimizes an expected common case of outputting single
line with a small stack allocated buffer. If the stack buffer is too
small then it uses std::string::resize to allocate exactly enough memory
and writes directly to std::string.

Second call could use vsprintf because memory is known to be large
enough. But I think that difference isn't detectable outside micro
benchmarks.
2018-06-10 16:23:31 +03:00
Ben Lubar 7bbfd456d3
Fix compile errors on Ubuntu 18.04 Bionic Beaver 2018-03-08 11:42:58 -06:00
lethosor 19b65c2d1e Remove Error.h include (#1224) 2018-02-07 20:14:36 -05:00
lethosor c1e2633e17 Refactor DFHack exception classes
Move implementations out of MiscUtils.cpp to Error.cpp and make what() return a
more useful description
2018-02-05 19:18:35 -05:00
lethosor 0332a5c25a Replace a call to abort() with a VTableMissing exception
This makes some scripts crash less when the viewscreen vtable is unavailable,
for example.
2017-12-25 20:13:15 -05:00
lethosor 15ed1bfd67 stl_vsprintf: avoid truncating 4096-byte strings 2017-07-13 13:08:27 -04:00
lethosor ce1158780f Fix crash in stl_vsprintf() from reusing va_list 2017-07-13 13:07:58 -04:00
Japa 0918efd02d fix word_wrap not returning a value. 2016-06-16 20:52:16 +05:30
lethosor 022a1bf9e8 Wrap script descriptions in `ls` output and remove description length cap 2016-06-14 21:24:27 -04:00
lethosor a8a8fc43ef Add df2console() wrapper
Closes #522
2015-02-13 17:56:29 -05:00
Alexander Gavrilov 3ff5d38a5c Add a few utility functions to the main library. 2012-10-30 12:40:26 +04:00
Petr Mrázek 8812238bf6 Update license, add contributors file, bump release number 2012-09-30 04:03:37 +02:00
Alexander Gavrilov 7774f5f2c1 Add a mechanism converting ui focus to a string representation.
The idea is to make ui handling more modular, dispensing with
huge functions that switch or if/else on lots of variables.
For now, used to split up functions in the sort plugin.
2012-05-19 19:50:36 +04:00
Alexander Gavrilov 05e8083c84 Allow constructing itemless actual buildings. 2012-05-06 10:09:39 +04:00
Alexander Gavrilov 3bd44e5367 Move some things that won't work in dfhack-client to a separate file. 2012-05-05 21:07:18 +04:00
Alexander Gavrilov d4d6349f48 Expose builtin commands to dfhack-run, and add lua script support.
Move builtin command implementation to Core methods, and fall
back to hack/scripts/*.lua for otherwise unrecognized commands.
2012-05-04 19:47:18 +04:00
Alexander Gavrilov 5afe2ca002 Update dfhack for specific_ref. 2012-05-03 11:47:04 +04:00
Alexander Gavrilov 2303a25bde Implement unconstructed building instance creation and linking into world.
For more flexibility, the base api is split into 3 phases:
alloc, setSize, and construct. No support for non-actual
buildings like stockpiles and activity zones at the moment.
2012-04-29 21:07:39 +04:00
Alexander Gavrilov 9eed9f0d24 Wrap a few utility functions defined on the c++ side for lua. 2012-04-05 19:55:59 +04:00
Alexander Gavrilov 28a741082f Encode & decode names in utf-8 for transfer in remote messages.
That's the encoding required by the protobuf spec.
2012-04-05 18:10:16 +04:00
Alexander Gavrilov 58eb199036 Add many new template functions for enums & bitfields.
An incompatible change: ENUM_KEY_STR returns std::string now.
The old behavior is available via enum_item_key_str function.
2012-03-17 12:52:22 +04:00
Alexander Gavrilov 560e977f05 Implement trivial RPC interface for dfhack via TCP & protobufs.
Use it to make an executable capable of calling commands remotely.
2012-03-14 19:57:29 +04:00
Alexander Gavrilov ea790f1346 Move a few functions into the core, and add some more. 2012-01-08 20:02:12 +04:00
Alexander Gavrilov 326c58f793 Add a plugin to tweak inorganic materials in jobs.
It also auto-seeks in the build item list if used in that context.
2012-01-02 18:46:24 +04:00
Petr Mrázek 52dfa842cc Add missing MiscUtils.cpp 2011-12-31 13:14:08 +01:00