diff --git a/uppsrc/CtrlLib/Text.cpp b/uppsrc/CtrlLib/Text.cpp index 029764c78..289655c56 100644 --- a/uppsrc/CtrlLib/Text.cpp +++ b/uppsrc/CtrlLib/Text.cpp @@ -114,10 +114,14 @@ void TextCtrl::Load(Stream& s, byte charset) { PlaceCaret(0); } -void TextCtrl::Save(Stream& s, byte charset) const { +void TextCtrl::Save(Stream& s, byte charset, bool crlf) const { charset = ResolveCharset(charset); for(int i = 0; i < line.GetCount(); i++) { - if(i) s.PutEol(); + if(i) + if(crlf) + s.PutCrLf(); + else + s.PutEol(); String txt = charset == CHARSET_UTF8 ? line[i].text : FromUnicode(line[i], charset); const char *e = txt.End(); diff --git a/uppsrc/CtrlLib/TextEdit.h b/uppsrc/CtrlLib/TextEdit.h index 6b9478f5e..579b545c8 100644 --- a/uppsrc/CtrlLib/TextEdit.h +++ b/uppsrc/CtrlLib/TextEdit.h @@ -102,7 +102,7 @@ public: void CachePos(int pos); void Load(Stream& s, byte charset = CHARSET_DEFAULT); - void Save(Stream& s, byte charset = CHARSET_DEFAULT) const; + void Save(Stream& s, byte charset = CHARSET_DEFAULT, bool crlf = false) const; int GetInvalidCharPos(byte charset = CHARSET_DEFAULT) const; bool CheckCharset(byte charset = CHARSET_DEFAULT) const { return GetInvalidCharPos(charset) < 0; } diff --git a/uppsrc/CtrlLib/src.tpp/TextCtrl$en-us.tpp b/uppsrc/CtrlLib/src.tpp/TextCtrl$en-us.tpp index baff60782..0c974f5b2 100644 --- a/uppsrc/CtrlLib/src.tpp/TextCtrl$en-us.tpp +++ b/uppsrc/CtrlLib/src.tpp/TextCtrl$en-us.tpp @@ -114,11 +114,13 @@ Unlikely to be used in the client code.&] [s2;%% Loads the text from the stream with defined [%-*@3 charset].&] [s3;%% &] [s4; &] -[s5;:TextCtrl`:`:Save`(Stream`&`,byte`)const: [@(0.0.255) void]_[* Save]([_^Stream^ Stream][@(0.0.255) `& -]_[*@3 s], [_^byte^ byte]_[*@3 charset]_`=_CHARSET`_DEFAULT)_[@(0.0.255) const]&] +[s5;:TextCtrl`:`:Save`(Stream`&`,byte`,bool`)const: [@(0.0.255) void]_[* Save]([_^Stream^ S +tream][@(0.0.255) `&]_[*@3 s], [_^byte^ byte]_[*@3 charset]_`=_CHARSET`_DEFAULT, +bool [*@3 crlf])_[@(0.0.255) const]&] [s2;%% Saves the text to the stream with defined [%-*@3 charset]. Characters that cannot be represented in suggested [%-*@3 charset] are saved -as `'?`'.&] +as `'?`'. If [%-*@3 crlf] is true, line endings are forced to be +`"`\r`\n`" even on POSIX platforms.&] [s3;%% &] [s4; &] [s5;:TextCtrl`:`:GetInvalidCharPos`(byte`)const: [@(0.0.255) int]_[* GetInvalidCharPos]([_^byte^ b diff --git a/uppsrc/ide/Setup.cpp b/uppsrc/ide/Setup.cpp index bcfe67343..a3d4c80d5 100644 --- a/uppsrc/ide/Setup.cpp +++ b/uppsrc/ide/Setup.cpp @@ -350,6 +350,7 @@ void Ide::SetupFormat() { (edt.tabs_grouping, tabs_grouping) (edt.tabs_serialize, tabs_serialize) (edt.filetabs, filetabs) + (edt.forcecrlf, force_crlf) (edt.numbers, line_numbers) (edt.bookmark_pos, bookmark_pos) (edt.header_guards, header_guards) diff --git a/uppsrc/ide/ide.h b/uppsrc/ide/ide.h index 7d0f02612..c0c5e6885 100644 --- a/uppsrc/ide/ide.h +++ b/uppsrc/ide/ide.h @@ -601,6 +601,7 @@ public: bool show_status_bar; bool toolbar_in_row; bool show_tabs; + bool force_crlf; bool tabs_icons; bool tabs_crosses; bool tabs_grouping; diff --git a/uppsrc/ide/ide.lay b/uppsrc/ide/ide.lay index 69305a340..e5638f110 100644 --- a/uppsrc/ide/ide.lay +++ b/uppsrc/ide/ide.lay @@ -424,6 +424,7 @@ LAYOUT(SetupEditorLayout, 488, 280) ITEM(Option, tabs_grouping, SetLabel(t_("Grouping")).LeftPosZ(196, 64).TopPosZ(200, 18)) ITEM(Option, tabs_serialize, SetLabel(t_("Persistent tabs")).LeftPosZ(264, 108).TopPosZ(200, 18)) ITEM(Switch, insert_include, SetLabel(t_("No #include in new sources\n#include first\n#include previous")).LeftPosZ(316, 156).TopPosZ(24, 56)) + ITEM(Option, forcecrlf, SetLabel(t_("Force CRLF line endings")).LeftPosZ(316, 160).TopPosZ(100, 20)) ITEM(Option, header_guards, SetLabel(t_("Insert guards to new headers")).LeftPosZ(316, 164).TopPosZ(4, 15)) ITEM(Option, auto_enclose, SetLabel(t_("[ { ( \" / * enclose selection")).LeftPosZ(12, 168).TopPosZ(220, 15)) ITEM(Option, mark_lines, SetLabel(t_("Mark lines with errors, warning and changes")).LeftPosZ(12, 256).TopPosZ(240, 16)) @@ -484,7 +485,7 @@ LAYOUT(SetupAstyleLayout, 544, 280) ITEM(Option, TabSpaceConversionMode, SetLabel(t_("Convert tabs to spaces")).HSizePosZ(12, 400).TopPosZ(256, 18)) ITEM(Button, Test, SetLabel(t_("Test")).LeftPosZ(284, 56).TopPosZ(252, 23)) ITEM(LabelBox, dv___30, SetLabel(t_("Test box")).LeftPosZ(344, 196).TopPosZ(4, 272)) - ITEM(LineEdit, TestBox, SetFont(ScreenFixedZ(11)).LeftPosZ(348, 188).TopPosZ(20, 252)) + ITEM(LineEdit, TestBox, SetFont(MonospaceZ(11)).LeftPosZ(348, 188).TopPosZ(20, 252)) ITEM(Button, Defaults, SetLabel(t_("Upp defaults")).LeftPosZ(176, 72).TopPosZ(252, 23)) END_LAYOUT diff --git a/uppsrc/ide/idefile.cpp b/uppsrc/ide/idefile.cpp index 0165fb35c..eb85061f2 100644 --- a/uppsrc/ide/idefile.cpp +++ b/uppsrc/ide/idefile.cpp @@ -304,7 +304,7 @@ void Ide::SaveFile(bool always) } } else - editor.Save(out, editor.GetCharset()); + editor.Save(out, editor.GetCharset(), force_crlf); out.Close(); if(out.IsError()) { Exclamation(NFormat("Error writing temporary file [* \1%s\1].", tmpfile)); diff --git a/uppsrc/ide/idewin.cpp b/uppsrc/ide/idewin.cpp index ea63d5225..d74e09573 100644 --- a/uppsrc/ide/idewin.cpp +++ b/uppsrc/ide/idewin.cpp @@ -80,7 +80,7 @@ void Ide::ConsolePaste() } void Ide::Serialize(Stream& s) { - int version = 13; + int version = 15; s.Magic(0x1234); s / version; s % main; @@ -110,6 +110,9 @@ void Ide::Serialize(Stream& s) { s % tabs_grouping; s % tabs_serialize; } + if(version >= 15) { + s % force_crlf; + } s % no_parenthesis_indent; s % hilite_scope; s % hilite_if_endif; diff --git a/uppsrc/upp.log b/uppsrc/upp.log new file mode 100644 index 000000000..e69de29bb