248 |
#endif |
#endif |
249 |
|
|
250 |
m_lineNrBuffer = Gtk::TextBuffer::create(m_tagTable); |
m_lineNrBuffer = Gtk::TextBuffer::create(m_tagTable); |
251 |
|
m_lineNrView.set_size_request(22,14); |
252 |
m_lineNrView.set_buffer(m_lineNrBuffer); |
m_lineNrView.set_buffer(m_lineNrBuffer); |
253 |
m_lineNrView.set_left_margin(3); |
m_lineNrView.set_left_margin(3); |
254 |
m_lineNrView.set_right_margin(3); |
m_lineNrView.set_right_margin(3); |
255 |
m_lineNrTextViewSpacer.set_size_request(5); |
m_lineNrView.property_editable() = false; |
256 |
|
m_lineNrView.property_sensitive() = false; |
257 |
|
m_lineNrTextViewSpacer.set_size_request(5,14); |
258 |
|
m_lineNrTextViewSpacer.property_editable() = false; |
259 |
|
m_lineNrTextViewSpacer.property_sensitive() = false; |
260 |
{ |
{ |
261 |
#if 1 //(GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
#if 1 //(GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
262 |
Gdk::Color color; |
Gdk::Color color; |
448 |
//printf("text : '%s'\n", txt.c_str()); |
//printf("text : '%s'\n", txt.c_str()); |
449 |
m_textBuffer->set_text(txt); |
m_textBuffer->set_text(txt); |
450 |
m_textBuffer->set_modified(false); |
m_textBuffer->set_modified(false); |
451 |
|
|
452 |
|
// on Gtk 3 the respective text change callback would not be called, so force this update here |
453 |
|
if (txt.empty()) |
454 |
|
updateLineNumbers(); |
455 |
} |
} |
456 |
|
|
457 |
void ScriptEditor::updateLineNumbers() { |
void ScriptEditor::updateLineNumbers() { |
458 |
const int n = m_textBuffer->get_line_count(); |
int n = m_textBuffer->get_line_count(); |
459 |
const int old = m_lineNrBuffer->get_line_count(); |
int old = m_lineNrBuffer->get_line_count(); |
460 |
if (n == old) return; |
if (n == old && old > 1) return; |
461 |
|
if (n < 1) n = 1; |
462 |
const int digits = log10(n) + 1; |
const int digits = log10(n) + 1; |
463 |
const int bufSz = digits + 2; |
const int bufSz = digits + 2; |
464 |
char* buf = new char[bufSz]; |
char* buf = new char[bufSz]; |