aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/cmdline.cpp
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2014-12-12 16:39:46 +0100
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2015-03-16 07:20:05 +0100
commitc310c7d875c8aa871180de130e820ed19a2489f5 (patch)
treea42eacf47ba714c99af5ec04ff2ce1b4e9f87765 /src/cmdline.cpp
parenteee4f1ae84bcbb18a9ac0f5f450510533014dd40 (diff)
downloadsciteco-c310c7d875c8aa871180de130e820ed19a2489f5.tar.gz
implemented automatic EOL translation support
* activated via bit 4 of the ED flag (enabled by default) * automatic EOL guessing on file loading and translation to LFs. * works with files that have inconsistent EOL sequences. * automatic translation to original EOL sequences on file saving * works with inconsistent EOL sequences in the buffer. This should usually not happen if the file was read in with automatic EOL translation enabled. * also works with the EC and EG commands * performance is OK, depending on the file being translated. When reading files with UNIX EOLs, the overhead is minimal typically-sized files. For DOS EOLs the overhead is larger but still acceptable. * Return (line feed) is now an immediate editing command. This centralizes EOL sequence insertion. Later, other features like auto-indent could be added to the editing command. * get_eol() has been moved to main.cpp (now called get_eol_seq() * Warn if file ownership could not be preserved when saving files. * IOView has been almost completely rewritten based on GIOChannels. The EOL translation code is also in IOView.
Diffstat (limited to 'src/cmdline.cpp')
-rw-r--r--src/cmdline.cpp23
1 files changed, 9 insertions, 14 deletions
diff --git a/src/cmdline.cpp b/src/cmdline.cpp
index 84d09c3..e7ce066 100644
--- a/src/cmdline.cpp
+++ b/src/cmdline.cpp
@@ -258,6 +258,15 @@ void
Cmdline::process_edit_cmd(gchar key)
{
switch (key) {
+ case '\n': /* insert EOL sequence */
+ interface.popup_clear();
+
+ if (Flags::ed & Flags::ED_AUTOEOL)
+ insert("\n");
+ else
+ insert(get_eol_seq(interface.ssm(SCI_GETEOLMODE)));
+ break;
+
case CTL_KEY('G'): /* toggle immediate editing modifier */
interface.popup_clear();
@@ -507,20 +516,6 @@ Cmdline::fnmacro(const gchar *name)
}
}
-const gchar *
-get_eol(void)
-{
- switch (interface.ssm(SCI_GETEOLMODE)) {
- case SC_EOL_CR:
- return "\r";
- case SC_EOL_CRLF:
- return "\r\n";
- case SC_EOL_LF:
- default:
- return "\n";
- }
-}
-
static gchar *
filename_complete(const gchar *filename, gchar completed)
{