数据通信源代码(牧云水务信息大数据存储与分析系统).docx
《数据通信源代码(牧云水务信息大数据存储与分析系统).docx》由会员分享,可在线阅读,更多相关《数据通信源代码(牧云水务信息大数据存储与分析系统).docx(60页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、牧云水务信息大数据存储与分析系统 V1.0 60/* linenoise.c - guerrilla line editing library against the idea that a * * Copyright (c) 2010, Salvatore Sanfilippo * Copyright (c) 2010, Pieter Noordhuis * * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are perm
2、itted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the f
3、ollowing disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of Redis nor the names of its contributors may be used * to endorse or promote products derived from this software without * specific prior written permission. * * THIS SOFTWARE IS
4、PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR AN
5、Y DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABIL
6、ITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * line editing lib needs to be 20,000 lines of C code. * * You can find the latest source code at: * * * * Does a number of crazy assumptions
7、that happen to be true in 99.9999% of * the 2010 UNIX computers around. * * References: * - http:/invisible- * - * * Todo list: * - Switch to gets() if $TERM is something we cant support. * - Filter bogus Ctrl+ combinations. * - Win32 support * * Bloat: * - Completion? * - History search like Ctrl+r
8、 in readline? * * List of escape sequences used by this program, we do everything just * with three sequences. In order to be so cheap we may have some * flickering effect with some slow terminal, but the lesser sequences * the more compatible. * * CHA (Cursor Horizontal Absolute) * Sequence: ESC n
9、G * Effect: moves cursor to column n (1 based) * * EL (Erase Line) * Sequence: ESC n K * Effect: if n is 0 or missing, clear from cursor to end of line * Effect: if n is 1, clear from beginning of line to cursor * Effect: if n is 2, clear entire line * * CUF (Cursor Forward) * Sequence: ESC n C * Ef
10、fect: moves cursor forward of n chars * * The following are used to clear the screen: ESC H ESC 2 J * This is actually composed of two sequences: * * cursorhome * Sequence: ESC H * Effect: moves the cursor to upper left corner * * ED2 (Clear entire screen) * Sequence: ESC 2 J * Effect: clear the who
11、le screen * */#ifdef _WIN32#include #include #include #define snprintf _snprintf / Microsoft headers use underscores in some names#define strcasecmp _stricmp#define strdup _strdup#define isatty _isatty#define write _write#define STDIN_FILENO 0#else /* _WIN32 */#include #include #include #include #in
12、clude #include #include #include #include #endif /* _WIN32 */#include #include #include #include linenoise.h#include linenoise_utf8.h#include mk_wcwidth.h#include #include #include using std:string;using std:vector;using boost:scoped_array;using linenoise_utf8:UChar8;using linenoise_utf8:UChar32;usi
13、ng linenoise_utf8:copyString8to32;using linenoise_utf8:copyString32;using linenoise_utf8:copyString32to8;using linenoise_utf8:strlen32;using linenoise_utf8:strncmp32;using linenoise_utf8:write32;using linenoise_utf8:Utf8String;using linenoise_utf8:Utf32String;struct linenoiseCompletions vector compl
14、etionStrings;#define LINENOISE_DEFAULT_HISTORY_MAX_LEN 100#define LINENOISE_MAX_LINE 4096/ make control-characters more readable#define ctrlChar( upperCaseASCII ) ( upperCaseASCII - 0x40 )/* * Recompute widths of all characters in a UChar32 buffer * param text input buffer of Unicode characters * pa
15、ram widths output buffer of character widths * param charCount number of characters in buffer */static void recomputeCharacterWidths( const UChar32* text, char* widths, int charCount ) for ( int i = 0; i 0 ) int charsThisRow = ( x + charsRemaining screenColumns ) ? charsRemaining : screenColumns - x
16、; xOut = x + charsThisRow; yOut = y; charsRemaining -= charsThisRow; x = 0; +y; if ( xOut = screenColumns ) / we have to special-case line wrap xOut = 0; +yOut; /* * Calculate a column width using mk_wcswidth() * param buf32 text to calculate * param len length of text to calculate */static int calc
17、ulateColumnPosition( UChar32* buf32, int len) int width = mk_wcswidth( reinterpret_cast( buf32 ), len ); if ( width = -1 ) return len; else return width;static bool isControlChar( UChar32 testChar ) return ( testChar = 0x7F & testChar = 0x9F ); / DEL and C1 controlsstruct PromptBase / a convenience
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 数据通信 源代码 水务 信息 数据 存储 分析 系统
限制150内