aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/cmdline.cpp4
-rw-r--r--src/cmdline.h4
-rw-r--r--src/document.cpp12
-rw-r--r--src/document.h20
-rw-r--r--src/expressions.cpp4
-rw-r--r--src/expressions.h4
-rw-r--r--src/goto.cpp4
-rw-r--r--src/goto.h4
-rw-r--r--src/interface-gtk.cpp4
-rw-r--r--src/interface-gtk.h4
-rw-r--r--src/interface-ncurses.cpp4
-rw-r--r--src/interface-ncurses.h4
-rw-r--r--src/interface.h10
-rw-r--r--src/main.cpp110
-rw-r--r--src/parser.cpp4
-rw-r--r--src/parser.h4
-rw-r--r--src/qregisters.cpp4
-rw-r--r--src/qregisters.h6
-rw-r--r--src/rbtree.cpp4
-rw-r--r--src/rbtree.h4
-rw-r--r--src/ring.cpp6
-rw-r--r--src/ring.h12
-rw-r--r--src/sciteco.h4
-rw-r--r--src/search.cpp4
-rw-r--r--src/search.h4
-rw-r--r--src/spawn.cpp4
-rw-r--r--src/spawn.h4
-rwxr-xr-xsrc/symbols-extract.tes4
-rw-r--r--src/symbols-minimal.cpp4
-rw-r--r--src/symbols.cpp4
-rw-r--r--src/symbols.h4
-rw-r--r--src/undo.cpp4
-rw-r--r--src/undo.h6
33 files changed, 208 insertions, 74 deletions
diff --git a/src/cmdline.cpp b/src/cmdline.cpp
index f6d7831..e19b3c4 100644
--- a/src/cmdline.cpp
+++ b/src/cmdline.cpp
@@ -39,6 +39,8 @@
#include "spawn.h"
#include "cmdline.h"
+namespace SciTECO {
+
static inline const gchar *process_edit_cmd(gchar key);
static gchar *macro_echo(const gchar *macro);
@@ -547,3 +549,5 @@ filename_is_dir(const gchar *filename)
{
return g_str_has_suffix(filename, G_DIR_SEPARATOR_S);
}
+
+} /* namespace SciTECO */
diff --git a/src/cmdline.h b/src/cmdline.h
index c16d067..53a5d75 100644
--- a/src/cmdline.h
+++ b/src/cmdline.h
@@ -24,6 +24,8 @@
#include "parser.h"
#include "qregisters.h"
+namespace SciTECO {
+
extern gchar *cmdline;
extern gint cmdline_pos;
extern bool quit_requested;
@@ -56,4 +58,6 @@ namespace States {
extern StateSaveCmdline save_cmdline;
}
+} /* namespace SciTECO */
+
#endif
diff --git a/src/document.cpp b/src/document.cpp
index dd39a56..ff2ce2b 100644
--- a/src/document.cpp
+++ b/src/document.cpp
@@ -28,6 +28,8 @@
#include "undo.h"
#include "document.h"
+namespace SciTECO {
+
static inline void
set_representations(void)
{
@@ -55,7 +57,7 @@ public:
};
void
-TECODocument::edit(void)
+Document::edit(void)
{
if (!is_initialized())
doc = (SciDoc)interface.ssm(SCI_CREATEDOCUMENT);
@@ -73,7 +75,7 @@ TECODocument::edit(void)
}
void
-TECODocument::undo_edit(void)
+Document::undo_edit(void)
{
if (!is_initialized())
doc = (SciDoc)interface.ssm(SCI_CREATEDOCUMENT);
@@ -92,7 +94,7 @@ TECODocument::undo_edit(void)
}
void
-TECODocument::update(void)
+Document::update(void)
{
anchor = interface.ssm(SCI_GETANCHOR);
dot = interface.ssm(SCI_GETCURRENTPOS);
@@ -105,7 +107,7 @@ TECODocument::update(void)
* exchanging of document data (without any deep copying)
*/
void
-TECODocument::exchange(TECODocument &other)
+Document::exchange(Document &other)
{
SciDoc temp_doc = doc;
gint temp_anchor = anchor;
@@ -125,3 +127,5 @@ TECODocument::exchange(TECODocument &other)
other.first_line = temp_first_line;
other.xoffset = temp_xoffset;
}
+
+} /* namespace SciTECO */
diff --git a/src/document.h b/src/document.h
index 3053ea9..81700b4 100644
--- a/src/document.h
+++ b/src/document.h
@@ -26,17 +26,13 @@
#include "interface.h"
#include "undo.h"
+namespace SciTECO {
+
/*
* Classes
*/
-/*
- * NOTE: The only reason this is called TECODocument
- * is to prevent a nameclash with Scintilla which
- * does not use a proper namespace for its public
- * symbols...
- */
-class TECODocument {
+class Document {
typedef const void *SciDoc;
SciDoc doc;
@@ -45,11 +41,11 @@ class TECODocument {
gint first_line, xoffset;
public:
- TECODocument() : doc(NULL)
+ Document() : doc(NULL)
{
reset();
}
- virtual ~TECODocument()
+ virtual ~Document()
{
if (is_initialized())
interface.ssm(SCI_RELEASEDOCUMENT, 0, (sptr_t)doc);
@@ -66,7 +62,7 @@ public:
void update(void);
inline void
- update(const TECODocument &from)
+ update(const Document &from)
{
anchor = from.anchor;
dot = from.dot;
@@ -89,7 +85,7 @@ public:
undo.push_var(xoffset);
}
- void exchange(TECODocument &other);
+ void exchange(Document &other);
inline void
undo_exchange(void)
{
@@ -98,4 +94,6 @@ public:
}
};
+} /* namespace SciTECO */
+
#endif
diff --git a/src/expressions.cpp b/src/expressions.cpp
index df18822..5bad38a 100644
--- a/src/expressions.cpp
+++ b/src/expressions.cpp
@@ -26,6 +26,8 @@
#include "parser.h" // State::Error
#include "expressions.h"
+namespace SciTECO {
+
Expressions expressions;
void
@@ -271,3 +273,5 @@ Expressions::format(tecoInt number)
return p;
}
+
+} /* namespace SciTECO */
diff --git a/src/expressions.h b/src/expressions.h
index ef91333..1e61ab8 100644
--- a/src/expressions.h
+++ b/src/expressions.h
@@ -23,6 +23,8 @@
#include "undo.h"
#include "parser.h" // State::Error
+namespace SciTECO {
+
template <typename Type>
class ValueStack {
class UndoTokenPush : public UndoToken {
@@ -214,4 +216,6 @@ private:
int first_op(void);
} expressions;
+} /* namespace SciTECO */
+
#endif
diff --git a/src/goto.cpp b/src/goto.cpp
index 896aa6b..724c995 100644
--- a/src/goto.cpp
+++ b/src/goto.cpp
@@ -28,6 +28,8 @@
#include "undo.h"
#include "goto.h"
+namespace SciTECO {
+
namespace States {
StateLabel label;
StateGotoCmd gotocmd;
@@ -193,3 +195,5 @@ StateGotoCmd::done(const gchar *str)
g_strfreev(labels);
return &States::start;
}
+
+} /* namespace SciTECO */
diff --git a/src/goto.h b/src/goto.h
index fcb95e3..a919d31 100644
--- a/src/goto.h
+++ b/src/goto.h
@@ -26,6 +26,8 @@
#include "undo.h"
#include "rbtree.h"
+namespace SciTECO {
+
class GotoTable : public RBTree {
class UndoTokenSet : public UndoToken {
GotoTable *table;
@@ -121,4 +123,6 @@ namespace States {
extern StateGotoCmd gotocmd;
}
+} /* namespace SciTECO */
+
#endif
diff --git a/src/interface-gtk.cpp b/src/interface-gtk.cpp
index d4ae096..2b47019 100644
--- a/src/interface-gtk.cpp
+++ b/src/interface-gtk.cpp
@@ -41,6 +41,8 @@
#include "interface.h"
#include "interface-gtk.h"
+namespace SciTECO {
+
extern "C" {
static void scintilla_notify(ScintillaObject *sci, uptr_t idFrom,
SCNotification *notify, gpointer user_data);
@@ -305,3 +307,5 @@ exit_app(GtkWidget *w, GdkEventAny *e, gpointer p)
gtk_main_quit();
return TRUE;
}
+
+} /* namespace SciTECO */
diff --git a/src/interface-gtk.h b/src/interface-gtk.h
index 33d8b96..115845c 100644
--- a/src/interface-gtk.h
+++ b/src/interface-gtk.h
@@ -28,6 +28,8 @@
#include "interface.h"
+namespace SciTECO {
+
typedef class InterfaceGtk : public Interface {
GtkWidget *window;
GtkWidget *editor_widget;
@@ -87,4 +89,6 @@ private:
static void widget_set_font(GtkWidget *widget, const gchar *font_name);
} InterfaceCurrent;
+} /* namespace SciTECO */
+
#endif
diff --git a/src/interface-ncurses.cpp b/src/interface-ncurses.cpp
index 6215811..a956fdf 100644
--- a/src/interface-ncurses.cpp
+++ b/src/interface-ncurses.cpp
@@ -44,6 +44,8 @@
#include "interface.h"
#include "interface-ncurses.h"
+namespace SciTECO {
+
extern "C" {
static void scintilla_notify(Scintilla *sci, int idFrom,
void *notify, void *user_data);
@@ -490,3 +492,5 @@ scintilla_notify(Scintilla *sci, int idFrom, void *notify, void *user_data)
{
interface.process_notify((SCNotification *)notify);
}
+
+} /* namespace SciTECO */
diff --git a/src/interface-ncurses.h b/src/interface-ncurses.h
index b6f5cf9..f1003de 100644
--- a/src/interface-ncurses.h
+++ b/src/interface-ncurses.h
@@ -29,6 +29,8 @@
#include "interface.h"
+namespace SciTECO {
+
typedef class InterfaceNCurses : public Interface {
SCREEN *screen;
FILE *screen_tty;
@@ -96,4 +98,6 @@ private:
friend void event_loop_iter();
} InterfaceCurrent;
+} /* namespace SciTECO */
+
#endif
diff --git a/src/interface.h b/src/interface.h
index a2ff00d..e2d24de 100644
--- a/src/interface.h
+++ b/src/interface.h
@@ -27,6 +27,8 @@
#include "undo.h"
+namespace SciTECO {
+
/* avoid include dependency conflict */
class QRegister;
class Buffer;
@@ -129,6 +131,8 @@ public:
void process_notify(SCNotification *notify);
};
+} /* namespace SciTECO */
+
#ifdef INTERFACE_GTK
#include "interface-gtk.h"
#elif defined(INTERFACE_NCURSES)
@@ -137,7 +141,9 @@ public:
#error No interface selected!
#endif
-/* object defined in main.cpp */
-extern InterfaceCurrent interface;
+namespace SciTECO {
+ /* object defined in main.cpp */
+ extern InterfaceCurrent interface;
+}
#endif
diff --git a/src/main.cpp b/src/main.cpp
index 19ac777..9300b40 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -42,6 +42,8 @@
#include "ring.h"
#include "undo.h"
+namespace SciTECO {
+
#ifdef G_OS_UNIX
#define INI_FILE ".teco_ini"
#else
@@ -236,6 +238,65 @@ initialize_environment(void)
g_strfreev(env);
}
+/*
+ * Callbacks
+ */
+
+class g_bad_alloc : public std::bad_alloc {
+public:
+ const char *
+ what() const throw()
+ {
+ return "glib allocation";
+ }
+};
+
+static gpointer
+g_malloc_exception(gsize n_bytes) throw (std::bad_alloc)
+{
+ gpointer p = malloc(n_bytes);
+
+ if (!p)
+ throw g_bad_alloc();
+ return p;
+}
+
+static gpointer
+g_calloc_exception(gsize n_blocks, gsize n_block_bytes) throw (std::bad_alloc)
+{
+ gpointer p = calloc(n_blocks, n_block_bytes);
+
+ if (!p)
+ throw g_bad_alloc();
+ return p;
+}
+
+static gpointer
+g_realloc_exception(gpointer mem, gsize n_bytes) throw (std::bad_alloc)
+{
+ gpointer p = realloc(mem, n_bytes);
+
+ if (!p)
+ throw g_bad_alloc();
+ return p;
+}
+
+static void
+sigint_handler(int signal)
+{
+ sigint_occurred = TRUE;
+}
+
+} /* namespace SciTECO */
+
+/*
+ * main() must be defined in the root
+ * namespace, so we import the "SciTECO"
+ * namespace. We have no more declarations
+ * to make in the "SciTECO" namespace.
+ */
+using namespace SciTECO;
+
int
main(int argc, char **argv)
{
@@ -337,52 +398,3 @@ main(int argc, char **argv)
return 0;
}
-
-/*
- * Callbacks
- */
-
-class g_bad_alloc : public std::bad_alloc {
-public:
- const char *
- what() const throw()
- {
- return "glib allocation";
- }
-};
-
-static gpointer
-g_malloc_exception(gsize n_bytes) throw (std::bad_alloc)
-{
- gpointer p = malloc(n_bytes);
-
- if (!p)
- throw g_bad_alloc();
- return p;
-}
-
-static gpointer
-g_calloc_exception(gsize n_blocks, gsize n_block_bytes) throw (std::bad_alloc)
-{
- gpointer p = calloc(n_blocks, n_block_bytes);
-
- if (!p)
- throw g_bad_alloc();
- return p;
-}
-
-static gpointer
-g_realloc_exception(gpointer mem, gsize n_bytes) throw (std::bad_alloc)
-{
- gpointer p = realloc(mem, n_bytes);
-
- if (!p)
- throw g_bad_alloc();
- return p;
-}
-
-static void
-sigint_handler(int signal)
-{
- sigint_occurred = TRUE;
-}
diff --git a/src/parser.cpp b/src/parser.cpp
index 6350174..83638fc 100644
--- a/src/parser.cpp
+++ b/src/parser.cpp
@@ -40,6 +40,8 @@
#include "spawn.h"
#include "cmdline.h"
+namespace SciTECO {
+
//#define DEBUG
gint macro_pc = 0;
@@ -2165,3 +2167,5 @@ StateInsert::done(const gchar *str)
/* nothing to be done when done */
return &States::start;
}
+
+} /* namespace SciTECO */
diff --git a/src/parser.h b/src/parser.h
index 9cc8f07..3505a0c 100644
--- a/src/parser.h
+++ b/src/parser.h
@@ -27,6 +27,8 @@
#include "undo.h"
#include "sciteco.h"
+namespace SciTECO {
+
/* TECO uses only lower 7 bits for commands */
#define MAX_TRANSITIONS 127
@@ -474,4 +476,6 @@ namespace Execute {
void file(const gchar *filename, bool locals = true);
}
+} /* namespace SciTECO */
+
#endif
diff --git a/src/qregisters.cpp b/src/qregisters.cpp
index 673c831..aba5abf 100644
--- a/src/qregisters.cpp
+++ b/src/qregisters.cpp
@@ -37,6 +37,8 @@
#include "ring.h"
#include "qregisters.h"
+namespace SciTECO {
+
namespace States {
StatePushQReg pushqreg;
StatePopQReg popqreg;
@@ -851,3 +853,5 @@ StateCopyToQReg::got_register(QRegister &reg)
return &States::start;
}
+
+} /* namespace SciTECO */
diff --git a/src/qregisters.h b/src/qregisters.h
index 8d249cc..556ce7b 100644
--- a/src/qregisters.h
+++ b/src/qregisters.h
@@ -32,6 +32,8 @@
#include "parser.h"
#include "document.h"
+namespace SciTECO {
+
/*
* Classes
*/
@@ -39,7 +41,7 @@
class QRegisterData {
protected:
tecoInt integer;
- TECODocument string;
+ Document string;
public:
/*
@@ -431,4 +433,6 @@ namespace QRegisters {
void hook(Hook type);
}
+} /* namespace SciTECO */
+
#endif
diff --git a/src/rbtree.cpp b/src/rbtree.cpp
index 1c82f34..4fe7c16 100644
--- a/src/rbtree.cpp
+++ b/src/rbtree.cpp
@@ -23,4 +23,8 @@
#include "rbtree.h"
+namespace SciTECO {
+
RB_GENERATE(RBTree::Tree, RBTree::RBEntry, nodes, RBTree::compare_entries);
+
+} /* namespace SciTECO */
diff --git a/src/rbtree.h b/src/rbtree.h
index 8b65f54..f1bebad 100644
--- a/src/rbtree.h
+++ b/src/rbtree.h
@@ -24,6 +24,8 @@
#include "undo.h"
+namespace SciTECO {
+
class RBTree {
public:
class RBEntry;
@@ -116,4 +118,6 @@ public:
}
};
+} /* namespace SciTECO */
+
#endif
diff --git a/src/ring.cpp b/src/ring.cpp
index 939a75c..19b494f 100644
--- a/src/ring.cpp
+++ b/src/ring.cpp
@@ -44,10 +44,10 @@
#include <windows.h>
/* still need to clean up */
-#ifdef interface
#undef interface
#endif
-#endif
+
+namespace SciTECO {
namespace States {
StateEditFile editfile;
@@ -752,3 +752,5 @@ StateSaveFile::done(const gchar *str)
return &States::start;
}
+
+} /* namespace SciTECO */
diff --git a/src/ring.h b/src/ring.h
index be2689e..8fc148c 100644
--- a/src/ring.h
+++ b/src/ring.h
@@ -34,6 +34,8 @@
#include "qregisters.h"
#include "parser.h"
+namespace SciTECO {
+
/*
* Auxiliary functions
*/
@@ -54,7 +56,7 @@ gchar *get_absolute_path(const gchar *path);
* Classes
*/
-class Buffer : public TECODocument {
+class Buffer : public Document {
class UndoTokenClose : public UndoToken {
Buffer *buffer;
@@ -72,7 +74,7 @@ public:
gint savepoint_id;
bool dirty;
- Buffer() : TECODocument(),
+ Buffer() : Document(),
filename(NULL), savepoint_id(0), dirty(false) {}
~Buffer()
{
@@ -104,14 +106,14 @@ public:
inline void
edit(void)
{
- TECODocument::edit();
+ Document::edit();
interface.info_update(this);
}
inline void
undo_edit(void)
{
interface.undo_info_update(this);
- TECODocument::undo_edit();
+ Document::undo_edit();
}
void load(const gchar *filename);
@@ -254,4 +256,6 @@ current_doc_must_undo(void)
QRegisters::current->must_undo;
}
+} /* namespace SciTECO */
+
#endif
diff --git a/src/sciteco.h b/src/sciteco.h
index 4e5430c..a3352c7 100644
--- a/src/sciteco.h
+++ b/src/sciteco.h
@@ -24,6 +24,8 @@
#include "interface.h"
+namespace SciTECO {
+
#if TECO_INTEGER == 32
typedef gint32 tecoInt;
#define TECO_INTEGER_FORMAT G_GINT32_FORMAT
@@ -129,4 +131,6 @@ line(gint n)
} /* namespace Validate */
+} /* namespace SciTECO */
+
#endif
diff --git a/src/search.cpp b/src/search.cpp
index 7f8b04e..999a71b 100644
--- a/src/search.cpp
+++ b/src/search.cpp
@@ -32,6 +32,8 @@
#include "parser.h"
#include "search.h"
+namespace SciTECO {
+
namespace States {
StateSearch search;
StateSearchAll searchall;
@@ -819,3 +821,5 @@ StateReplaceDefault_ignore::done(const gchar *str)
return &States::start;
}
+
+} /* namespace SciTECO */
diff --git a/src/search.h b/src/search.h
index 3ce43f8..ec0c604 100644
--- a/src/search.h
+++ b/src/search.h
@@ -25,6 +25,8 @@
#include "ring.h"
#include "qregisters.h"
+namespace SciTECO {
+
/*
* "S" command state and base class for all other search/replace commands
*/
@@ -133,4 +135,6 @@ namespace States {
extern StateReplaceDefault_ignore replacedefault_ignore;
}
+} /* namespace SciTECO */
+
#endif
diff --git a/src/spawn.cpp b/src/spawn.cpp
index a9e8cb0..fa199c6 100644
--- a/src/spawn.cpp
+++ b/src/spawn.cpp
@@ -30,6 +30,8 @@
#include "parser.h"
#include "spawn.h"
+namespace SciTECO {
+
namespace States {
StateExecuteCommand executecommand;
StateEGCommand egcommand;
@@ -514,3 +516,5 @@ stdout_watch_cb(GIOChannel *chan, GIOCondition condition, gpointer data)
return G_SOURCE_CONTINUE;
}
+
+} /* namespace SciTECO */
diff --git a/src/spawn.h b/src/spawn.h
index 57b4f72..9658d0d 100644
--- a/src/spawn.h
+++ b/src/spawn.h
@@ -24,6 +24,8 @@
#include "parser.h"
#include "qregisters.h"
+namespace SciTECO {
+
gchar **parse_shell_command_line(const gchar *cmdline, GError **error);
class StateExecuteCommand : public StateExpectString {
@@ -63,4 +65,6 @@ namespace States {
extern StateEGCommand egcommand;
}
+} /* namespace SciTECO */
+
#endif
diff --git a/src/symbols-extract.tes b/src/symbols-extract.tes
index 6bd0051..2a6664c 100755
--- a/src/symbols-extract.tes
+++ b/src/symbols-extract.tes
@@ -27,6 +27,8 @@ I/*
#include "sciteco.h"
#include "symbols.h"
+namespace SciTECO {
+
static const SymbolList::Entry entries[] = {

<
@@ -36,6 +38,8 @@ static const SymbolList::Entry entries[] = {
I};
SymbolList Symbols::Q#na(entries, G_N_ELEMENTS(entries));
+
+} /* namespace SciTECO */

! write output file !
diff --git a/src/symbols-minimal.cpp b/src/symbols-minimal.cpp
index 5d79157..b6d0e8a 100644
--- a/src/symbols-minimal.cpp
+++ b/src/symbols-minimal.cpp
@@ -22,7 +22,11 @@
#include "sciteco.h"
#include "symbols.h"
+namespace SciTECO {
+
namespace Symbols {
SymbolList scintilla;
SymbolList scilexer;
}
+
+} /* namespace SciTECO */
diff --git a/src/symbols.cpp b/src/symbols.cpp
index 7983920..987fb3f 100644
--- a/src/symbols.cpp
+++ b/src/symbols.cpp
@@ -26,6 +26,8 @@
#include "sciteco.h"
#include "symbols.h"
+namespace SciTECO {
+
/*
* Since symbol lists are presorted constant arrays we can do a simple
* binary search.
@@ -69,3 +71,5 @@ SymbolList::get_glist(void)
return list;
}
+
+} /* namespace SciTECO */
diff --git a/src/symbols.h b/src/symbols.h
index 9e29525..a82b656 100644
--- a/src/symbols.h
+++ b/src/symbols.h
@@ -21,6 +21,8 @@
#include <string.h>
#include <glib.h>
+namespace SciTECO {
+
class SymbolList {
public:
struct Entry {
@@ -60,4 +62,6 @@ namespace Symbols {
extern SymbolList scilexer;
}
+} /* namespace SciTECO */
+
#endif
diff --git a/src/undo.cpp b/src/undo.cpp
index dabb8d7..55df610 100644
--- a/src/undo.cpp
+++ b/src/undo.cpp
@@ -32,6 +32,8 @@
#include "interface.h"
#include "undo.h"
+namespace SciTECO {
+
//#define DEBUG
UndoStack undo;
@@ -91,3 +93,5 @@ UndoStack::~UndoStack()
SLIST_FOREACH_SAFE(token, &head, tokens, next)
delete token;
}
+
+} /* namespace SciTECO */
diff --git a/src/undo.h b/src/undo.h
index feb742c..5cc3b3a 100644
--- a/src/undo.h
+++ b/src/undo.h
@@ -29,6 +29,8 @@
#include "parser.h"
#endif
+namespace SciTECO {
+
class UndoToken {
public:
SLIST_ENTRY(UndoToken) tokens;
@@ -192,4 +194,6 @@ public:
void clear(void);
} undo;
-#endif \ No newline at end of file
+} /* namespace SciTECO */
+
+#endif