1 // IOstreamDasherEdit.cc
2 // (c) 2003 Yann Dirson
3 // Derived from GtkDasherEdit.cc
4 // (c) 2002 Philip Cowans
8 #include "IOstreamDasherEdit.h"
15 IOstreamDasherEdit::IOstreamDasherEdit(CDasherInterface
*_interface
, std::ostream
*os
)
16 :Dasher::CDashEditbox(), flush_count(0), interface(_interface
), outstream(os
) {
18 snprintf(encstr
, 255, "ISO-8859-%d", enc
);
20 *outstream
<< "Dasher starting\n";
23 IOstreamDasherEdit::~IOstreamDasherEdit() {
26 void IOstreamDasherEdit::write_to_file() {
29 void IOstreamDasherEdit::kill_flush() {
33 void IOstreamDasherEdit::get_new_context(std::string
&str
, int max
) {
37 void IOstreamDasherEdit::unflush() {
41 for(; flush_count
> 0; flush_count
--)
45 void IOstreamDasherEdit::output(symbol Symbol
) {
46 // FIXME - again, label is utf-8 encoded, and insert is probably not
47 // expecting this to be the case
50 label
= interface
->GetEditText(Symbol
);
52 label
= interface
->GetEditText(Symbol
);
54 iconv_t cdesc
= iconv_open(encstr
, "UTF-8");
56 char *convbuffer
= new char[256];
57 char *inbuffer
= new char[256];
62 strncpy(inbuffer
, label
.c_str(), 255);
64 size_t inb
= label
.length();
67 iconv(cdesc
, (ICONV_CONST
char **)&inbuffer
, &inb
, &convbuffer
, &outb
);
69 std::string
csymbol(cb
, 256 - outb
);
74 *outstream
<< csymbol
;
77 void IOstreamDasherEdit::flush(symbol Symbol
) {
78 // We seem to be passed Symbol 0 (root node) sometimes, so ignore
86 label
= interface
->GetEditText(Symbol
);
88 iconv_t cdesc
= iconv_open(encstr
, "UTF-8");
90 char *convbuffer
= new char[256];
91 char *inbuffer
= new char[256];
96 strncpy(inbuffer
, label
.c_str(), 255);
98 size_t inb
= label
.length();
101 iconv(cdesc
, (ICONV_CONST
char **)&inbuffer
, &inb
, &convbuffer
, &outb
);
103 std::string
csymbol(cb
, 256 - outb
);
108 *outstream
<< csymbol
;
113 void IOstreamDasherEdit::Clear() {
116 void IOstreamDasherEdit::TimeStampNewFiles(bool Value
) {
119 void IOstreamDasherEdit::deletetext() {
122 void IOstreamDasherEdit::SetEncoding(Opts::FileEncodingFormats Encoding
) {
125 void IOstreamDasherEdit::SetFont(std::string Name
, long Size
) {
128 void IOstreamDasherEdit::set_display_encoding(int _enc
) {
132 snprintf(encstr
, 255, "ISO-8859-%d", enc
);
136 bool IOstreamDasherEdit::SaveAs(std::string filename
, bool a
) {
140 bool IOstreamDasherEdit::Save(bool a
) {
144 bool IOstreamDasherEdit::Open(std::string filename
) {