-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Win10 - TextArea newline character error #76
Comments
@WilliamDraco The handling of line break characters is done by Windows. When I press return in a text area and read the |
Sorry for the lazy initial example. Here's a better example that might bring certainty: import parsecfg
import nigui
app.init()
var window = newWindow("test")
var cPrime = newLayoutContainer(Layout_Horizontal)
var loadButton = newButton("Load")
var saveButton = newButton("Save")
var textarea = newTextArea()
window.add(cPrime)
cPrime.add(loadButton)
cPrime.add(saveButton)
cPrime.add(textarea)
loadButton.onClick = proc(event:ClickEvent) =
var cfg:Config
try:
cfg = loadConfig("test.cfg")
textarea.text = cfg.getSectionvalue("Testing", "TextAreaText")
except:
return
saveButton.onClick = proc(event:ClickEvent) =
var cfg: Config
try:
cfg = loadConfig("test.cfg")
except:
cfg = newConfig()
cfg.setSectionkey("Testing", "TextAreaText", textarea.text)
cfg.writeConfig("test.cfg")
window.show()
app.run() If you type a text into the textarea, including at least one return/enter/newline, then hit the save button, then the load button - all new lines are removed. Reviewing the test.cfg file written shows that only a \n character was written to file. |
I've added the helper proc textarea.text = cfg.getSectionvalue("Testing", "TextAreaText").convertLineBreaks A related question is, why the line breaks stored not exactly by parsecfg. I will have a look on that. See nim-lang/Nim#12970 |
On Win10, the resultant text area is:
Due to the windows newline requiring \r\n (or \p) to achieve.
In my usecase, user types multi-line text into textarea. I save the textarea.text to file, and when saved this way it saves with only the \n escape characters. When textarea.text is then populated on loading the same file, the single-line version appears per above.
Recommended to have textarea.text receive enter/return presses as a \p escape character instead of \n
The text was updated successfully, but these errors were encountered: