From b0d70f028f9ad7a575734c3e2c98ed093ea55aa2 Mon Sep 17 00:00:00 2001 From: "Crom (Thibaut CHARLES)" Date: Fri, 13 Mar 2015 00:11:05 +0100 Subject: [PATCH] underscore handling in column names --- source/window.d | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/source/window.d b/source/window.d index d22b53c..8a6457a 100644 --- a/source/window.d +++ b/source/window.d @@ -4,6 +4,7 @@ import std.path; import std.stdio; import std.string; import std.conv : to; +import std.array : replace; import gtk.MainWindow; import gtk.HeaderBar; @@ -291,7 +292,7 @@ class Window : MainWindow{ size_t colSize[]; colSize.length = tree.getNColumns; foreach(i ; 0..tree.getNColumns) - colSize[i] = tree.getColumn(i).getTitle.length +1;//+1 space + colSize[i] = tree.getColumn(i).getTitle.replace("__", "_").length +1;//+1 space TreeIter it = new TreeIter(); if(store.getIterFirst(it)){ @@ -314,7 +315,7 @@ class Window : MainWindow{ auto file = File(openedFile, "w"); foreach(i ; 0..tree.getNColumns) - file.write(leftJustify(tree.getColumn(i).getTitle, colSize[i])); + file.write(leftJustify(tree.getColumn(i).getTitle.replace("__", "_"), colSize[i])); file.write("\n"); it = new TreeIter(); @@ -454,7 +455,7 @@ private: cr.setData("colnumber", cast(void*)cast(int)index); - auto col = new TreeViewColumn(sName, cr, "text", cast(int)index); + auto col = new TreeViewColumn(sName.replace("_", "__"), cr, "text", cast(int)index); col.setData("colnumber", cast(void*)cast(int)index); col.setResizable(true); col.setMinWidth(10); @@ -470,12 +471,12 @@ private: auto renamebox = new HBox(false, 0); dlg.getContentArea.packStart(renamebox, false, false, 0); - auto renameentry = new Entry(col.getTitle); + auto renameentry = new Entry(col.getTitle.replace("__", "_")); auto renamebutton = new Button("object-select-symbolic", GtkIconSize.SMALL_TOOLBAR); renamebutton.addOnClicked((Button){ auto newname = renameentry.getText.strip; if(newname.countchars(" \t\n\r")==0) - col.setTitle(newname); + col.setTitle(newname.replace("_", "__")); else displayMessage("Spaces are forbidden in column name"); });