/Users/enrico/Ricerca/develop/PINS/pins-mechatronix/LibSources/submodules/embedFiglet/src/Figlet.hh Source FileΒΆ

Splines: /Users/enrico/Ricerca/develop/PINS/pins-mechatronix/LibSources/submodules/embedFiglet/src/Figlet.hh Source File
Splines
Figlet.hh
1/*--------------------------------------------------------------------------*\
2 | , __ , __ |
3 | /|/ \ /|/ \ |
4 | | __/ _ ,_ | __/ _ ,_ |
5 | | \|/ / | | | | \|/ / | | | |
6 | |(__/|__/ |_/ \_/|/|(__/|__/ |_/ \_/|/ |
7 | /| /| |
8 | \| \| |
9 | |
10 | Enrico Bertolazzi |
11 | Dipartimento di Ingegneria Industriale |
12 | Universita` degli Studi di Trento |
13 | email: enrico.bertolazzi@unitn.it |
14 | |
15\*--------------------------------------------------------------------------*/
16/*
17Copyright (c) 2014, Enrico Bertolazzi
18All rights reserved.
19
20Redistribution and use in source and binary forms, with or without
21modification, are permitted provided that the following conditions are
22met:
23
24 * Redistributions of source code must retain the above copyright
25 notice, this list of conditions and the following disclaimer.
26 * Redistributions in binary form must reproduce the above copyright
27 notice, this list of conditions and the following disclaimer in
28 the documentation and/or other materials provided with the distribution
29
30THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
31AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
32IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
33ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
34LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
35CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
36SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
37INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
38CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
39ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
40POSSIBILITY OF SUCH DAMAGE.
41*/
42
43//
44// file: Figlet.hh
45//
46
47// check for bugged compiler
48#ifdef _MSC_VER
49 #define EMBED_FIGLET_USE_VISUAL_STUDIO
50#endif
51
52// http://ruletheweb.co.uk/figlet/
53
217#ifndef FIGLET_HH
218#define FIGLET_HH
219
220#include <iostream>
221#include <cstdint>
222
226namespace Figlet {
227
228 using namespace std;
229
230 typedef std::basic_ostream<char> ostream_type;
231
232 static unsigned const maxHeight = 10;
233 static unsigned const maxLenght = 256;
234 static unsigned const maxTableSize = 256;
235
237 typedef struct {
238 unsigned short nchar;
239 uint8_t lspaces[maxHeight];
240 uint8_t rspaces[maxHeight];
241 char const * rows[maxHeight];
242 } FontFiglet;
243
245 typedef enum {
246 FIGLET_SMUSHED=0,
247 FIGLET_PACKED,
248 FIGLET_FULLWIDTH,
249 FIGLET_MONOSPACED
250 } PrintMode;
251
253 typedef enum { FIGLET_SINGLE=0, FIGLET_DOUBLE } FrameMode;
254
256 class Banner {
257
258 FontFiglet const * characters;
259 char const Hardblank;
260 unsigned const Height;
261 unsigned Width;
262 unsigned const FontMaxLen;
263 unsigned const FontSize;
264 uint8_t rspaces[maxHeight];
265 char lines[maxHeight][maxLenght];
266 char smush[maxHeight];
267 unsigned short charToTable[maxTableSize];
268 unsigned short charWidth[maxTableSize];
269 unsigned charPosition;
270
271 PrintMode printMode;
272
273 Banner const & operator = ( Banner const & );
274 Banner( Banner const & );
275
277 char smushingRules( char left, char right ) const;
278
279 bool pushMonospaced( unsigned c );
280 bool pushFullWidth( unsigned c );
281 bool pushPacked( unsigned c );
282 bool pushSmushed( unsigned c );
283 void fillForPrint( char const message[] );
284
285 public:
286
288
295 explicit
296 Banner( FontFiglet const * characters,
297 char Hardblank,
298 unsigned Height,
299 unsigned FontMaxLen,
300 unsigned FontSize );
301
303 void init();
304
306 void setMonospaced() { printMode = FIGLET_MONOSPACED; }
307
309 void setFullWidth() { printMode = FIGLET_FULLWIDTH; }
310
312 void setPacked() { printMode = FIGLET_PACKED; }
313
315 void setSmushed() { printMode = FIGLET_SMUSHED; }
316
318 unsigned
319 print(
320 char const message[],
321 ostream_type & s = cout,
322 char const top[] = "",
323 char const bottom[] = ""
324 );
325
327 void
329 char const message[],
330 ostream_type & s = cout,
331 FrameMode fm = FIGLET_SINGLE
332 );
333 };
334
335 #ifdef big
336 #undef big
337 #endif
338 #ifdef banner
339 #undef banner
340 #endif
341 #ifdef doom
342 #undef doom
343 #endif
344 #ifdef larry3d
345 #undef larry3d
346 #endif
347 #ifdef mini
348 #undef mini
349 #endif
350 #ifdef script
351 #undef script
352 #endif
353 #ifdef small
354 #undef small
355 #endif
356 #ifdef standard
357 #undef standard
358 #endif
359 #ifdef straight
360 #undef straights
361 #endif
362
363 extern Banner big;
364 extern Banner banner;
365 extern Banner doom;
366 extern Banner larry3d;
367 extern Banner mini;
368 extern Banner script;
369 extern Banner small;
370 extern Banner standard;
371 extern Banner straight;
372
373}
374
375#endif
376
377//
378// eof: Figlet.hh
379//
Class implementing the "figlet" algorithm.
Definition Figlet.hh:256
void setSmushed()
Set print mode to smushed (figlet default), see Available printing mode.
Definition Figlet.hh:315
void setMonospaced()
Set print mode to monospaced, see Available printing mode.
Definition Figlet.hh:306
void setFullWidth()
Set print mode to full width, see Available printing mode.
Definition Figlet.hh:309
void setPacked()
Set print mode to packed, see Available printing mode.
Definition Figlet.hh:312
void printFramed(char const message[], ostream_type &s=cout, FrameMode fm=FIGLET_SINGLE)
Available framing mode
Definition Figlet.cc:355
void init()
initialize Banner class
Definition Figlet.cc:90
unsigned print(char const message[], ostream_type &s=cout, char const top[]="", char const bottom[]="")
Print large letters of string message on stream s, see Available printing mode.
Definition Figlet.cc:331
Collects structures and classes for banner generation.
Definition Figlet.cc:56
FrameMode
Available way to print a frames string, see Available framing mode.
Definition Figlet.hh:253
Banner small
instance Banner class using figlet font small
Banner mini
instance Banner class using figlet font mini
Banner doom
instance Banner class using figlet font doom
Banner banner
instance Banner class using figlet font banner
Banner standard
instance Banner class using figlet font standard
Banner straight
instance Banner class using figlet font straight
Banner big
instance Banner class using figlet font big
PrintMode
Available way to print a string, see Available printing mode.
Definition Figlet.hh:245
Banner script
instance Banner class using figlet font script
Banner larry3d
instance Banner class using figlet font larry3d
Structure used to store a charater of the font.
Definition Figlet.hh:237
unsigned short nchar
character (ascii) number
Definition Figlet.hh:238