The Final Cut now also compiles under Solaris

This commit is contained in:
Markus Gans 2017-12-17 01:06:53 +01:00
parent c10a88008c
commit ec57ec6f74
31 changed files with 1673 additions and 1392 deletions

View File

@ -1,6 +1,7 @@
exclude: exclude:
- /fonts/newfont.h - /fonts/newfont.h
- /fonts/vgafont.h - /fonts/vgafont.h
- /fonts/unicodemap.h
- /ltmain.sh - /ltmain.sh
component_depth: 3 component_depth: 3
languages: languages:

View File

@ -1,3 +1,6 @@
2017-12-17 Markus Gans <guru.mail@muenster.de>
* The Final Cut now also compiles under Solaris
2017-12-14 Markus Gans <guru.mail@muenster.de> 2017-12-14 Markus Gans <guru.mail@muenster.de>
* Add Sun Microsystems workstation console support * Add Sun Microsystems workstation console support

View File

@ -17,6 +17,14 @@
> su -c "make install" > su -c "make install"
``` ```
### Supported platforms
* Linux
* FreeBSD
* NetBSD
* OpenBSD
* macOS
* Solaris
The Final Cut The Final Cut
============= =============
The Final Cut is a C++ class library and widget toolkit with full mouse support for creating a [text-based user interface](https://en.wikipedia.org/wiki/Text-based_user_interface). The library supports the programmer to develop an application for the text console. It allows the simultaneous handling of multiple text windows on the screen. The Final Cut is a C++ class library and widget toolkit with full mouse support for creating a [text-based user interface](https://en.wikipedia.org/wiki/Text-based_user_interface). The library supports the programmer to develop an application for the text console. It allows the simultaneous handling of multiple text windows on the screen.

View File

@ -91,7 +91,15 @@ esac
JOBS="$((CPU_COUNT/2))" JOBS="$((CPU_COUNT/2))"
test "$JOBS" -eq 0 && JOBS=1 test "$JOBS" -eq 0 && JOBS=1
if make V=1 -j$JOBS if make -h 2<&1 | grep -q "\\-\\-jobs"
then
MAKE="make V=1 -j$JOBS"
else
MAKE="make V=1"
fi
if $MAKE
then then
echo "${GREEN}Successful compiled${NORMAL}" echo "${GREEN}Successful compiled${NORMAL}"
else else

View File

@ -8,6 +8,7 @@ FONTFILE="8x16graph.bdf"
echo -e "// newfont.h\\n" echo -e "// newfont.h\\n"
echo -e "#ifndef FNEWFONT_H" echo -e "#ifndef FNEWFONT_H"
echo -e "#define FNEWFONT_H\\n" echo -e "#define FNEWFONT_H\\n"
echo -e "namespace fc\\n{"
echo -e "\\nstatic unsigned char __8x16graph[] =\\n{" echo -e "\\nstatic unsigned char __8x16graph[] =\\n{"
grep -A${HEIGHT} ^BITMAP "$FONTFILE" \ grep -A${HEIGHT} ^BITMAP "$FONTFILE" \
@ -26,6 +27,7 @@ FONTFILE="8x16graph.bdf"
done done
echo -e "};" echo -e "};"
echo -e "\\n} // namespace fc"
echo -e "\\n#endif // FNEWFONT_H" echo -e "\\n#endif // FNEWFONT_H"
) > newfont.h ) > newfont.h

View File

@ -8,6 +8,7 @@ FONTFILE="8x16std"
echo -e "// vgafont.h\\n" echo -e "// vgafont.h\\n"
echo -e "#ifndef FVGAFONT_H" echo -e "#ifndef FVGAFONT_H"
echo -e "#define FVGAFONT_H\\n" echo -e "#define FVGAFONT_H\\n"
echo -e "namespace fc\\n{\\n"
xxd -g 1 -i -c $HEIGHT $FONTFILE \ xxd -g 1 -i -c $HEIGHT $FONTFILE \
| sed -e 's/ {$/\n{/' \ | sed -e 's/ {$/\n{/' \
@ -24,5 +25,6 @@ FONTFILE="8x16std"
fi fi
done done
echo -e "\\n} // namespace fc"
echo -e "\\n#endif // FVGAFONT_H" echo -e "\\n#endif // FVGAFONT_H"
) > vgafont.h ) > vgafont.h

View File

@ -3,6 +3,8 @@
#ifndef FNEWFONT_H #ifndef FNEWFONT_H
#define FNEWFONT_H #define FNEWFONT_H
namespace fc
{
static unsigned char __8x16graph[] = static unsigned char __8x16graph[] =
{ {
@ -264,4 +266,6 @@ static unsigned char __8x16graph[] =
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 /* 255 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 /* 255 */
}; };
} // namespace fc
#endif // FNEWFONT_H #endif // FNEWFONT_H

View File

@ -3,6 +3,9 @@
#ifndef FUNICODEMAP_H #ifndef FUNICODEMAP_H
#define FUNICODEMAP_H #define FUNICODEMAP_H
namespace fc
{
static struct unipair unicode_cp437_pairs[] = static struct unipair unicode_cp437_pairs[] =
{ {
// .----------- unicode // .----------- unicode
@ -313,4 +316,6 @@ static struct unipair unicode_cp437_pairs[] =
{0xfffd, 0xfe} {0xfffd, 0xfe}
}; };
} // namespace fc
#endif // FUNICODEMAP_H #endif // FUNICODEMAP_H

View File

@ -3,6 +3,9 @@
#ifndef FVGAFONT_H #ifndef FVGAFONT_H
#define FVGAFONT_H #define FVGAFONT_H
namespace fc
{
static unsigned char __8x16std[] = static unsigned char __8x16std[] =
{ {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0 */
@ -263,4 +266,6 @@ static unsigned char __8x16std[] =
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 /* 255 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 /* 255 */
}; };
} // namespace fc
#endif // FVGAFONT_H #endif // FVGAFONT_H

View File

@ -0,0 +1,93 @@
/***********************************************************************
* emptyfstring.h - Creates an empty FString object *
* *
* This file is part of the Final Cut widget toolkit *
* *
* Copyright 2015-2017 Markus Gans *
* *
* The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License *
* as published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. *
* *
* The Final Cut 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 Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this program. If not, see *
* <http://www.gnu.org/licenses/>. *
***********************************************************************/
#ifndef EMPTYFSTRING_H
#define EMPTYFSTRING_H
#if !defined (USE_FINAL_H) && !defined (COMPILE_FINAL_CUT)
#error "Only <final/final.h> can be included directly."
#endif
#include "final/fstring.h"
namespace fc
{
//----------------------------------------------------------------------
// class emptyFString
//----------------------------------------------------------------------
class emptyFString
{
public:
emptyFString()
{ }
static bool isNull();
static const FString& get();
static void clear();
private:
// Disable copy constructor
emptyFString (const emptyFString&);
// Disable assignment operator (=)
emptyFString& operator = (const emptyFString&);
// Data Member
static const FString* empty_string;
};
// emptyFString inline functions
//----------------------------------------------------------------------
inline bool emptyFString::isNull()
{
return ( empty_string ) ? false : true;
}
//----------------------------------------------------------------------
inline const FString& emptyFString::get()
{
if ( ! empty_string )
{
try
{
empty_string = new FString("");
}
catch (const std::bad_alloc& ex)
{
std::cerr << "not enough memory to alloc " << ex.what() << std::endl;
}
}
return *empty_string;
}
//----------------------------------------------------------------------
inline void emptyFString::clear()
{
delete empty_string;
empty_string = 0;
}
} // namespace fc
#endif // EMPTYFSTRING_H

View File

@ -20,14 +20,6 @@
* <http://www.gnu.org/licenses/>. * * <http://www.gnu.org/licenses/>. *
***********************************************************************/ ***********************************************************************/
/* Standalone class
*
*
*
* fc
*
*/
#ifndef FC_H #ifndef FC_H
#define FC_H #define FC_H
@ -35,9 +27,7 @@
#error "Only <final/final.h> can be included directly." #error "Only <final/final.h> can be included directly."
#endif #endif
#include "final/fstring.h" // ASCII sequences
// ascii sequences
#define ESC "\033" // Escape #define ESC "\033" // Escape
#define CSI ESC "[" // Control sequence introducer (7-bit) #define CSI ESC "[" // Control sequence introducer (7-bit)
#define ENQ "\005" // Enquiry #define ENQ "\005" // Enquiry
@ -50,15 +40,12 @@
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// class fc // Global constants and enumerations
//---------------------------------------------------------------------- //----------------------------------------------------------------------
#pragma pack(push) namespace fc
#pragma pack(1)
class fc
{ {
public:
// Event types // Event types
enum events enum events
{ {
@ -1126,10 +1113,6 @@ class fc
t_key_mouse t_key_mouse
}; };
// Data Member } // namespace fc
static const FString* empty_string;
};
#pragma pack(pop)
#endif // FC_H #endif // FC_H

View File

@ -27,6 +27,9 @@
#error "Only <final/final.h> can be included directly." #error "Only <final/final.h> can be included directly."
#endif #endif
namespace fc
{
static uInt character[][fc::NUM_OF_ENCODINGS] = static uInt character[][fc::NUM_OF_ENCODINGS] =
{ {
// .--------------------- Unicode (UTF-8) // .--------------------- Unicode (UTF-8)
@ -319,6 +322,6 @@ static uInt cp437_to_ucs[][2] =
const uInt lastCP437Item = uInt ( sizeof(cp437_to_ucs) const uInt lastCP437Item = uInt ( sizeof(cp437_to_ucs)
/ sizeof(cp437_to_ucs[0]) ) - 1; / sizeof(cp437_to_ucs[0]) ) - 1;
} // namespace fc
#endif // FCHARMAP_H #endif // FCHARMAP_H

View File

@ -147,7 +147,15 @@ class FFileDialog : public FDialog
struct dir_entry struct dir_entry
{ {
char* name; char* name;
uChar type; // Type of file
uChar fifo : 1;
uChar character_device : 1;
uChar directory : 1;
uChar block_device : 1;
uChar regular_file : 1;
uChar symbolic_link : 1;
uChar socket : 1;
uChar : 1; // padding bits
}; };
typedef std::vector<dir_entry> dirEntries; typedef std::vector<dir_entry> dirEntries;
@ -157,6 +165,7 @@ class FFileDialog : public FDialog
inline bool pattern_match (const char* const, char*&); inline bool pattern_match (const char* const, char*&);
void clear(); void clear();
int numOfDirs(); int numOfDirs();
void sortDir();
int changeDir (const FString&); int changeDir (const FString&);
void printPath (const FString&); void printPath (const FString&);
static const FString getHomeDir(); static const FString getHomeDir();

View File

@ -29,6 +29,9 @@
#include <string> #include <string>
namespace fc
{
#pragma pack(push) #pragma pack(push)
#pragma pack(1) #pragma pack(1)
@ -852,4 +855,6 @@ static keyname FkeyName[] =
{ 0 , "\0" } { 0 , "\0" }
}; };
} // namespace fc
#endif // FKEYMAP_H #endif // FKEYMAP_H

View File

@ -35,18 +35,19 @@
#error "Only <final/final.h> can be included directly." #error "Only <final/final.h> can be included directly."
#endif #endif
#include <stdint.h>
#include <sys/time.h> // need for gettimeofday #include <sys/time.h> // need for gettimeofday
#include <cstdlib> #include <cstdlib>
#include <cstring> #include <cstring>
#include <list> #include <list>
#include <vector> #include <vector>
#include "final/emptyfstring.h"
#include "final/fc.h" #include "final/fc.h"
#include "final/fevent.h" #include "final/fevent.h"
#include "final/ftypes.h" #include "final/ftypes.h"
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// class FObject // class FObject
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -35,12 +35,31 @@
#error "Only <final/final.h> can be included directly." #error "Only <final/final.h> can be included directly."
#endif #endif
// Typecast to c-string
#define C_STR const_cast<char*>
#include <assert.h> #include <assert.h>
#if defined(__sun) && defined(__SVR4)
#include <termio.h>
typedef struct termio SGTTY;
typedef struct termios SGTTYS;
#ifdef _LP64
typedef unsigned int chtype;
#else
typedef unsigned long chtype;
#endif
#include <term.h> // need for tparm #include <term.h> // need for tparm
#else
#include <term.h> // need for tparm
#endif
#include <algorithm> // need for std::swap #include <algorithm> // need for std::swap
#include "final/fc.h" #include "final/fc.h"
#include "final/ftypes.h"
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -39,7 +39,22 @@
#endif #endif
#include <assert.h> #include <assert.h>
#if defined(__sun) && defined(__SVR4)
#include <termio.h>
typedef struct termio SGTTY;
typedef struct termios SGTTYS;
#ifdef _LP64
typedef unsigned int chtype;
#else
typedef unsigned long chtype;
#endif
#include <term.h> // need for tparm #include <term.h> // need for tparm
#else
#include <term.h> // need for tparm
#endif
#include <cctype> #include <cctype>
#include <climits> #include <climits>

View File

@ -234,7 +234,9 @@ class FString
FString clear(); FString clear();
const wchar_t* wc_str() const; const wchar_t* wc_str() const;
wchar_t* wc_str();
const char* c_str() const; const char* c_str() const;
char* c_str();
const std::string toString() const; const std::string toString() const;
FString toLower() const; FString toLower() const;

View File

@ -29,6 +29,9 @@
#include "final/ftermcap.h" #include "final/ftermcap.h"
namespace fc
{
static FTermcap::tcap_map term_caps[] = static FTermcap::tcap_map term_caps[] =
{ {
// .------------- term string // .------------- term string
@ -133,4 +136,6 @@ static FTermcap::tcap_map term_caps[] =
* "XX", "Us" and "Ue" are unofficial and they are only used here. * "XX", "Us" and "Ue" are unofficial and they are only used here.
*/ */
} // namespace fc
#endif // FTCAPMAP_H #endif // FTCAPMAP_H

View File

@ -51,6 +51,9 @@
#error "Only <final/final.h> can be included directly." #error "Only <final/final.h> can be included directly."
#endif #endif
// Typecast to c-string
#define C_STR const_cast<char*>
#include "final/fconfig.h" #include "final/fconfig.h"
#ifdef F_HAVE_LIBGPM #ifdef F_HAVE_LIBGPM
@ -83,9 +86,24 @@
#include <fcntl.h> #include <fcntl.h>
#include <langinfo.h> #include <langinfo.h>
#include <term.h> // termcap
#include <termios.h> #include <termios.h>
#if defined(__sun) && defined(__SVR4)
#include <termio.h>
typedef struct termio SGTTY;
typedef struct termios SGTTYS;
#ifdef _LP64
typedef unsigned int chtype;
#else
typedef unsigned long chtype;
#endif
#include <term.h> // termcap
#else
#include <term.h> // termcap
#endif
#if F_HAVE_GETTTYNAM && F_HAVE_TTYENT_H #if F_HAVE_GETTTYNAM && F_HAVE_TTYENT_H
#include <ttyent.h> #include <ttyent.h>
#endif #endif
@ -293,6 +311,11 @@ class FTerm
#endif #endif
; ;
static void putstring (const char* const, int = 1); static void putstring (const char* const, int = 1);
#if defined(__sun) && defined(__SVR4)
static int putchar_ASCII (register char);
#endif
static int putchar_ASCII (register int); static int putchar_ASCII (register int);
static int putchar_UTF8 (register int); static int putchar_UTF8 (register int);
static int UTF8decode (const char[]); static int UTF8decode (const char[]);
@ -612,11 +635,11 @@ inline int FTerm::getMaxColor()
#if DEBUG #if DEBUG
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const FString& FTerm::getAnswerbackString() inline const FString& FTerm::getAnswerbackString()
{ return ( answer_back ) ? *answer_back : *fc::empty_string; } { return ( answer_back ) ? *answer_back : fc::emptyFString::get(); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const FString& FTerm::getSecDAString() inline const FString& FTerm::getSecDAString()
{ return ( sec_da ) ? *sec_da : *fc::empty_string; } { return ( sec_da ) ? *sec_da : fc::emptyFString::get(); }
#endif #endif
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -27,6 +27,7 @@
#error "Only <final/final.h> can be included directly." #error "Only <final/final.h> can be included directly."
#endif #endif
#include <stdint.h>
#include <sys/types.h> #include <sys/types.h>
#define null NULL #define null NULL

View File

@ -403,6 +403,11 @@ class FVTerm : public FTerm
static int appendLowerRight (char_data*&); static int appendLowerRight (char_data*&);
static void appendOutputBuffer (const std::string&); static void appendOutputBuffer (const std::string&);
static void appendOutputBuffer (const char*&); static void appendOutputBuffer (const char*&);
#if defined(__sun) && defined(__SVR4)
static int appendOutputBuffer (char);
#endif
static int appendOutputBuffer (int); static int appendOutputBuffer (int);
// Data Members // Data Members

View File

@ -82,7 +82,7 @@ FApplication::FApplication ( const int& _argc
if ( ! (_argc && _argv) ) if ( ! (_argc && _argv) )
{ {
static char* empty = const_cast<char*>(""); static char* empty = C_STR("");
app_argc = 0; app_argc = 0;
app_argv = static_cast<char**>(&empty); app_argv = static_cast<char**>(&empty);
} }
@ -410,12 +410,12 @@ void FApplication::cmd_options (const int& argc, char* argv[])
static struct option long_options[] = static struct option long_options[] =
{ {
{"encoding", required_argument, 0, 0 }, {C_STR("encoding"), required_argument, 0, 0 },
{"no-optimized-cursor", no_argument, 0, 0 }, {C_STR("no-optimized-cursor"), no_argument, 0, 0 },
{"no-terminal-detection", no_argument, 0, 0 }, {C_STR("no-terminal-detection"), no_argument, 0, 0 },
{"no-color-change", no_argument, 0, 0 }, {C_STR("no-color-change"), no_argument, 0, 0 },
{"vgafont", no_argument, 0, 0 }, {C_STR("vgafont"), no_argument, 0, 0 },
{"newfont", no_argument, 0, 0 }, {C_STR("newfont"), no_argument, 0, 0 },
{0, 0, 0, 0 } {0, 0, 0, 0 }
}; };

View File

@ -597,7 +597,7 @@ bool FButtonGroup::isRadioButton (FToggleButton* button) const
return false; return false;
return bool ( std::strcmp ( button->getClassName() return bool ( std::strcmp ( button->getClassName()
, const_cast<char*>("FRadioButton") ) == 0 ); , C_STR("FRadioButton") ) == 0 );
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -39,7 +39,7 @@ bool sortDirFirst ( const FFileDialog::dir_entry& lhs
, const FFileDialog::dir_entry& rhs ) , const FFileDialog::dir_entry& rhs )
{ {
// sort directories first // sort directories first
if ( lhs.type == DT_DIR && rhs.type != DT_DIR ) if ( lhs.directory && ! rhs.directory )
return true; return true;
else else
return false; return false;
@ -164,7 +164,7 @@ const FString FFileDialog::getSelectedFile() const
{ {
uLong n = uLong(filebrowser->currentItem() - 1); uLong n = uLong(filebrowser->currentItem() - 1);
if ( dir_entries[n].type == DT_DIR ) if ( dir_entries[n].directory )
return FString(""); return FString("");
else else
return FString(dir_entries[n].name); return FString(dir_entries[n].name);
@ -257,7 +257,6 @@ void FFileDialog::onKeyPress (FKeyEvent* ev)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
int FFileDialog::readDir() int FFileDialog::readDir()
{ {
int start, dir_num;
const char* const dir = directory.c_str(); const char* const dir = directory.c_str();
const char* const filter = filter_pattern.c_str(); const char* const filter = filter_pattern.c_str();
directory_stream = opendir(dir); directory_stream = opendir(dir);
@ -294,9 +293,28 @@ int FFileDialog::readDir()
dir_entry entry; dir_entry entry;
entry.name = strdup(next->d_name); entry.name = strdup(next->d_name);
entry.type = next->d_type;
if ( next->d_type == DT_LNK ) // symbolic link #if defined _DIRENT_HAVE_D_TYPE || defined HAVE_STRUCT_DIRENT_D_TYPE
entry.fifo = (next->d_type & DT_FIFO) == DT_FIFO;
entry.character_device = (next->d_type & DT_CHR ) == DT_CHR;
entry.directory = (next->d_type & DT_DIR ) == DT_DIR;
entry.block_device = (next->d_type & DT_BLK ) == DT_BLK;
entry.regular_file = (next->d_type & DT_REG ) == DT_REG;
entry.symbolic_link = (next->d_type & DT_LNK ) == DT_LNK;
entry.socket = (next->d_type & DT_SOCK) == DT_SOCK;
#else
struct stat s;
stat (entry.name, &s);
entry.fifo = S_ISFIFO (s.st_mode);
entry.character_device = S_ISCHR (s.st_mode);
entry.directory = S_ISDIR (s.st_mode);
entry.block_device = S_ISBLK (s.st_mode);
entry.regular_file = S_ISREG (s.st_mode);
entry.symbolic_link = S_ISLNK (s.st_mode);
entry.socket = S_ISSOCK (s.st_mode);
#endif
if ( entry.symbolic_link ) // symbolic link
{ {
char resolved_path[MAXPATHLEN] = {}; char resolved_path[MAXPATHLEN] = {};
char symLink[MAXPATHLEN] = {}; char symLink[MAXPATHLEN] = {};
@ -312,12 +330,12 @@ int FFileDialog::readDir()
if ( lstat(resolved_path, &sb) == 0 ) if ( lstat(resolved_path, &sb) == 0 )
{ {
if ( S_ISDIR(sb.st_mode) ) if ( S_ISDIR(sb.st_mode) )
entry.type = DT_DIR; entry.directory = true;
} }
} }
} }
if ( entry.type == DT_DIR ) if ( entry.directory )
dir_entries.push_back (entry); dir_entries.push_back (entry);
else if ( pattern_match(filter, entry.name) ) else if ( pattern_match(filter, entry.name) )
dir_entries.push_back (entry); dir_entries.push_back (entry);
@ -341,24 +359,8 @@ int FFileDialog::readDir()
return -2; return -2;
} }
if ( std::strcmp((*dir_entries.begin()).name, "..") == 0 ) sortDir();
start = 1;
else
start = 0;
dir_num = numOfDirs();
// directories first
std::sort ( dir_entries.begin() + start
, dir_entries.end()
, sortDirFirst );
// sort directories by name
std::sort ( dir_entries.begin() + start
, dir_entries.begin() + dir_num
, sortByName );
// sort files by name
std::sort ( dir_entries.begin() + dir_num
, dir_entries.end()
, sortByName );
// fill list with directory entries // fill list with directory entries
filebrowser->clear(); filebrowser->clear();
@ -370,7 +372,7 @@ int FFileDialog::readDir()
while ( iter != last ) while ( iter != last )
{ {
if ( (*iter).type == DT_DIR ) if ( (*iter).directory )
filebrowser->insert(FString((*iter).name), fc::SquareBrackets); filebrowser->insert(FString((*iter).name), fc::SquareBrackets);
else else
filebrowser->insert(FString((*iter).name)); filebrowser->insert(FString((*iter).name));
@ -665,7 +667,7 @@ int FFileDialog::numOfDirs()
while ( iter != last ) while ( iter != last )
{ {
if ( (*iter).type == DT_DIR && std::strcmp((*iter).name, ".") != 0 ) if ( (*iter).directory && std::strcmp((*iter).name, ".") != 0 )
n++; n++;
++iter; ++iter;
@ -674,6 +676,31 @@ int FFileDialog::numOfDirs()
return n; return n;
} }
//----------------------------------------------------------------------
void FFileDialog::sortDir()
{
int start, dir_num;
if ( std::strcmp((*dir_entries.begin()).name, "..") == 0 )
start = 1;
else
start = 0;
dir_num = numOfDirs();
// directories first
std::sort ( dir_entries.begin() + start
, dir_entries.end()
, sortDirFirst );
// sort directories by name
std::sort ( dir_entries.begin() + start
, dir_entries.begin() + dir_num
, sortByName );
// sort files by name
std::sort ( dir_entries.begin() + dir_num
, dir_entries.end()
, sortByName );
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
int FFileDialog::changeDir (const FString& dirname) int FFileDialog::changeDir (const FString& dirname)
{ {
@ -709,7 +736,7 @@ int FFileDialog::changeDir (const FString& dirname)
int i = 1; int i = 1;
std::vector<dir_entry>::const_iterator iter, last; std::vector<dir_entry>::const_iterator iter, last;
const char* const baseName = \ const char* const baseName = \
basename(const_cast<char*>(lastdir.c_str())); basename(C_STR(lastdir.c_str()));
iter = dir_entries.begin(); iter = dir_entries.begin();
last = dir_entries.end(); last = dir_entries.end();
@ -731,7 +758,7 @@ int FFileDialog::changeDir (const FString& dirname)
{ {
FString firstname = dir_entries[0].name; FString firstname = dir_entries[0].name;
if ( dir_entries[0].type == DT_DIR ) if ( dir_entries[0].directory )
filename->setText(firstname + '/'); filename->setText(firstname + '/');
else else
filename->setText(firstname); filename->setText(firstname);
@ -808,7 +835,7 @@ void FFileDialog::cb_processActivate (FWidget*, data_ptr)
{ {
if ( (*iter).name && input && ! input.isNull() if ( (*iter).name && input && ! input.isNull()
&& std::strcmp((*iter).name, input) == 0 && std::strcmp((*iter).name, input) == 0
&& (*iter).type == DT_DIR ) && (*iter).directory )
{ {
found = true; found = true;
changeDir(input); changeDir(input);
@ -834,7 +861,7 @@ void FFileDialog::cb_processRowChanged (FWidget*, data_ptr)
const FString& name = dir_entries[uLong(n - 1)].name; const FString& name = dir_entries[uLong(n - 1)].name;
if ( dir_entries[uLong(n - 1)].type == DT_DIR ) if ( dir_entries[uLong(n - 1)].directory )
filename->setText( name + '/' ); filename->setText( name + '/' );
else else
filename->setText( name ); filename->setText( name );
@ -847,7 +874,7 @@ void FFileDialog::cb_processClicked (FWidget*, data_ptr)
{ {
const uLong n = uLong(filebrowser->currentItem() - 1); const uLong n = uLong(filebrowser->currentItem() - 1);
if ( dir_entries[n].type == DT_DIR ) if ( dir_entries[n].directory )
changeDir(dir_entries[n].name); changeDir(dir_entries[n].name);
else else
done (FDialog::Accept); done (FDialog::Accept);

View File

@ -102,7 +102,7 @@ FString FListViewItem::getText (int column) const
if ( column < 1 if ( column < 1
|| column_list.empty() || column_list.empty()
|| column > int(column_list.size()) ) || column > int(column_list.size()) )
return *fc::empty_string; return fc::emptyFString::get();
column--; // Convert column position to address offset (index) column--; // Convert column position to address offset (index)
return column_list[uInt(column)]; return column_list[uInt(column)];
@ -498,7 +498,7 @@ FString FListView::getColumnText (int column) const
// Get the text of column // Get the text of column
if ( column < 1 || header.empty() || column > int(header.size()) ) if ( column < 1 || header.empty() || column > int(header.size()) )
return *fc::empty_string; return fc::emptyFString::get();
column--; // Convert column position to address offset (index) column--; // Convert column position to address offset (index)
return header[uInt(column)].name; return header[uInt(column)].name;

View File

@ -25,7 +25,7 @@
// static class attributes // static class attributes
bool FObject::timer_modify_lock; bool FObject::timer_modify_lock;
FObject::TimerList* FObject::timer_list = 0; FObject::TimerList* FObject::timer_list = 0;
const FString* fc::empty_string = 0; const FString* fc::emptyFString::empty_string = 0;
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// class FObject // class FObject
@ -60,26 +60,13 @@ FObject::FObject (FObject* parent)
return; return;
} }
} }
if ( ! fc::empty_string )
{
try
{
fc::empty_string = new FString("");
}
catch (const std::bad_alloc& ex)
{
std::cerr << "not enough memory to alloc " << ex.what() << std::endl;
return;
}
}
} }
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FObject::~FObject() // destructor FObject::~FObject() // destructor
{ {
delOwnTimer(); // delete all timers of this object delOwnTimer(); // Delete all timers of this object
if ( ! has_parent && timer_list ) if ( ! has_parent && timer_list )
{ {
@ -87,13 +74,10 @@ FObject::~FObject() // destructor
timer_list = 0; timer_list = 0;
} }
if ( ! has_parent && fc::empty_string ) if ( ! has_parent && ! fc::emptyFString::isNull() )
{ fc::emptyFString::clear();
delete fc::empty_string;
fc::empty_string = 0;
}
// delete children objects // Delete children objects
if ( hasChildren() ) if ( hasChildren() )
{ {
constFObjectIterator iter, last; constFObjectIterator iter, last;

View File

@ -546,7 +546,7 @@ char* FOptiAttr::changeAttribute (char_data*& term, char_data*& next)
if ( cygwin_terminal && (term->fg_color > 7 || term->bg_color > 7) ) if ( cygwin_terminal && (term->fg_color > 7 || term->bg_color > 7) )
{ {
// reset blink and bold mode from colors > 7 // reset blink and bold mode from colors > 7
char* rst = const_cast<char*>(CSI "m"); char* rst = C_STR(CSI "m");
append_sequence (rst); append_sequence (rst);
reset(term); reset(term);
} }
@ -1046,7 +1046,7 @@ bool FOptiAttr::setTermDefaultColor (char_data*& term)
} }
else if ( ansi_default_color ) else if ( ansi_default_color )
{ {
char* sgr_39_49 = const_cast<char*>(CSI "39;49m"); char* sgr_39_49 = C_STR(CSI "39;49m");
append_sequence (sgr_39_49); append_sequence (sgr_39_49);
term->fg_color = Default; term->fg_color = Default;
term->bg_color = Default; term->bg_color = Default;
@ -1302,7 +1302,7 @@ void FOptiAttr::change_color (char_data*& term, char_data*& next)
} }
else if ( fg == Default && term->fg_color != Default ) else if ( fg == Default && term->fg_color != Default )
{ {
char* sgr_39 = const_cast<char*>(CSI "39m"); char* sgr_39 = C_STR(CSI "39m");
append_sequence (sgr_39); append_sequence (sgr_39);
term->fg_color = Default; term->fg_color = Default;
} }
@ -1312,9 +1312,9 @@ void FOptiAttr::change_color (char_data*& term, char_data*& next)
char* op = F_orig_pair.cap; char* op = F_orig_pair.cap;
if ( op && std::strncmp (op, CSI "39;49;25m", 11) == 0 ) if ( op && std::strncmp (op, CSI "39;49;25m", 11) == 0 )
sgr_49 = const_cast<char*>(CSI "49;25m"); sgr_49 = C_STR(CSI "49;25m");
else else
sgr_49 = const_cast<char*>(CSI "49m"); sgr_49 = C_STR(CSI "49m");
append_sequence (sgr_49); append_sequence (sgr_49);
term->bg_color = Default; term->bg_color = Default;

View File

@ -774,12 +774,35 @@ FString FString::clear()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
const wchar_t* FString::wc_str() const const wchar_t* FString::wc_str() const
{ {
// Returns a constant wide character string
return string;
}
//----------------------------------------------------------------------
wchar_t* FString::wc_str()
{
// Returns a wide character string
return string; return string;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
const char* FString::c_str() const const char* FString::c_str() const
{ {
// Returns a constant c-string
if ( length > 0 )
return wc_to_c_str (string);
else
return 0;
}
//----------------------------------------------------------------------
char* FString::c_str()
{
// Returns a c-string
if ( length > 0 ) if ( length > 0 )
return wc_to_c_str (string); return wc_to_c_str (string);
else else

File diff suppressed because it is too large Load Diff

View File

@ -2521,7 +2521,6 @@ FVTerm::exit_state FVTerm::eraseCharacters ( uInt& x, uInt xmax, uInt y
// Erase a number of characters to draw simple whitespaces // Erase a number of characters to draw simple whitespaces
term_area*& vt = vterm; term_area*& vt = vterm;
bool& ut = FTermcap::background_color_erase;
char*& ec = TCAP(fc::t_erase_chars); char*& ec = TCAP(fc::t_erase_chars);
char_data* print_char = &vt->text[y * uInt(vt->width) + x]; char_data* print_char = &vt->text[y * uInt(vt->width) + x];
@ -2549,6 +2548,7 @@ FVTerm::exit_state FVTerm::eraseCharacters ( uInt& x, uInt xmax, uInt y
else else
{ {
uInt start_pos = x; uInt start_pos = x;
bool& ut = FTermcap::background_color_erase;
if ( whitespace > uInt(erase_ch_length) + uInt(cursor_addres_lengths) if ( whitespace > uInt(erase_ch_length) + uInt(cursor_addres_lengths)
&& (ut || normal) ) && (ut || normal) )
@ -2963,16 +2963,38 @@ int FVTerm::appendLowerRight (char_data*& screen_char)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FVTerm::appendOutputBuffer (const std::string& s) inline void FVTerm::appendOutputBuffer (const std::string& s)
{ {
#if defined(__sun) && defined(__SVR4)
char* c_string = C_STR(s.c_str());
#else
const char* const& c_string = s.c_str(); const char* const& c_string = s.c_str();
#endif
tputs (c_string, 1, appendOutputBuffer); tputs (c_string, 1, appendOutputBuffer);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FVTerm::appendOutputBuffer (const char*& s) inline void FVTerm::appendOutputBuffer (const char*& s)
{ {
#if defined(__sun) && defined(__SVR4)
tputs (C_STR(s), 1, appendOutputBuffer);
#else
tputs (s, 1, appendOutputBuffer); tputs (s, 1, appendOutputBuffer);
#endif
} }
#if defined(__sun) && defined(__SVR4)
//----------------------------------------------------------------------
int FVTerm::appendOutputBuffer (char ch)
{
output_buffer->push(ch);
if ( output_buffer->size() >= TERMINAL_OUTPUT_BUFFER_SIZE )
flush_out();
return ch;
}
#endif
//---------------------------------------------------------------------- //----------------------------------------------------------------------
int FVTerm::appendOutputBuffer (int ch) int FVTerm::appendOutputBuffer (int ch)
{ {