From 1b907dae072f2aa93d75d8c056a9bd02555a17f8 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Mon, 3 Mar 2025 01:44:34 +0300 Subject: rename sample.teco_ini to fallback.teco_ini and mung it by default * After installation, SciTECO will therefore start into a more userfriendly mode even if the user does not create a custom ~/.teco_ini. It is hoped that this will scare away less of new users, who are not willing to read through all of the documentation. Still, users are warned in the absence of ~/.teco_ini. This warning however, might not be immediately visible, especially not when running gsciteco without an attached console. (This will change once I redo the UI and allow a number of messages to be queued in the message area.) * Theoretically, you could also just extend fallback.teco_ini from ~/.teco_ini, but that would require installing it into $SCITECOPATH. * Since the fallback profile will now be munged automatically on a wide range of systems, we set up xclip only when detecting X11 ($DISPLAY is non-empty). E.g. when running under Wayland or the Linux console, you still won't get the clipboard registers, which is probably better than having the clipboard operations fail once you try to use them. * xclip is now "suggested" on Debian/Ubuntu. Unfortunately we cannot pull it in only in the presence of X11. --- .github/workflows/nightly.yml | 4 +- INSTALL | 2 +- Makefile.am | 2 +- TODO | 11 ++--- debian/control | 1 + distribute.mk.in | 4 +- doc/sciteco.1.in | 13 ++++-- fallback.teco_ini | 95 +++++++++++++++++++++++++++++++++++++++++++ freebsd/files/pkg-message.in | 2 +- freebsd/pkg-plist | 2 +- sample.teco_ini | 93 ------------------------------------------ src/main.c | 26 +++++++++++- 12 files changed, 141 insertions(+), 114 deletions(-) create mode 100644 fallback.teco_ini delete mode 100644 sample.teco_ini diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index af16dbe..35645ba 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -254,7 +254,7 @@ jobs: cp -r /mingw64/bin/{gsciteco.exe,sciteco.exe,grosciteco.tes,tedoc.tes} ./ # datadir is relative to bindir cp -r /mingw64/bin/{lib,*.tmac} ./ - cp /mingw64/bin/sample.teco_ini .teco_ini + cp /mingw64/bin/fallback.teco_ini .teco_ini cp -r /mingw64/share/doc/sciteco/* ./ cp ../COPYING ../ChangeLog ./ cp /mingw64/bin/gspawn-win64-helper*.exe ./ @@ -330,7 +330,7 @@ jobs: cp -r /mingw64/bin/{lib,*.tmac} ./ # FIXME: Maybe there should be a separate win32/.teco_ini with # a few pre-enabled settings? - cp /mingw64/bin/sample.teco_ini .teco_ini + cp /mingw64/bin/fallback.teco_ini .teco_ini cp /mingw64/bin/fallback.css .teco_css cp -r /mingw64/share/doc/sciteco/* ./ cp ../COPYING ../ChangeLog ./ diff --git a/INSTALL b/INSTALL index 9a46b30..b5aff56 100644 --- a/INSTALL +++ b/INSTALL @@ -134,7 +134,7 @@ To install SciTECO, type something like: $ sudo make install -You are recommended to use the included "sample.teco_ini" as a starting +You are recommended to use the included "fallback.teco_ini" as a starting point for your profile. On UNIX, you can copy it to your $HOME directory at "~/.teco_ini" while on Windows, it should be in the same directory as `sciteco.exe` unless you adapt the $SCITECOCONFIG variable. diff --git a/Makefile.am b/Makefile.am index c9ba183..f6bcf86 100644 --- a/Makefile.am +++ b/Makefile.am @@ -7,7 +7,7 @@ MAYBE_DLMALLOC = contrib/dlmalloc endif SUBDIRS = lib $(MAYBE_DLMALLOC) contrib/rb3ptr src doc tests -dist_scitecodata_DATA = sample.teco_ini +dist_scitecodata_DATA = fallback.teco_ini EXTRA_DIST = README TODO diff --git a/TODO b/TODO index 08b195c..32b2333 100644 --- a/TODO +++ b/TODO @@ -124,7 +124,7 @@ Known Bugs: which is correct. Without --incremental even the formatting is broken. This could well be a Git bug. * Margins, identions and the like are not configured on the unnamed - buffer by sample.teco_ini. + buffer by fallback.teco_ini. And this is probably correct. However when saving a new unnamed file for the first time, nothing will change either and it's tricky to apply the correct @@ -308,6 +308,8 @@ Features: Video TECO had ET for the same purpose. TECO 10 had a ^W regular command for case folding all strings, but I don't think it's worth supporting. + * n:"x to leave on the stack (i.e. only peek). This simplifies + expressions like Qa"N Qa ... * Perhaps there should be a command for converting absolute line numbers to positions (i.e. ESPOSITIONFROMLINE$$:^E). This should also include the opposite as currently supported by :^Q. @@ -593,11 +595,6 @@ Features: * Erroneous constructs could be highlighted up to the previous start state. E.g. when redefining labels, the entire label would be highlighted. - * Instead of defaulting to nothing in the absence of ~/.teco_ini, - we should load the installed sample.teco_ini, which - gives a more user-friendly experience. - Or perhaps even simpler, should the profile be missing, just log - a warning on startup. * NLS (Native Language Support). I could at least add German and Russian. There aren't many localizable strings in SciTECO. Should be optional. @@ -708,7 +705,7 @@ Documentation: * People are demanding a Youtube tutorial. * Vimtutor like tutorial. Could be a woman-page. Perhaps sciteco-tutorial would copy the files to /tmp and - open them always with sample.teco_ini. + open them always with fallback.teco_ini. * The HTML manuals lack monospaced fonts. This is partly because an.tmac removes the Courier family in nroff mode, but it still doesn't work if you undo this. diff --git a/debian/control b/debian/control index e1d67f8..7e8a0df 100644 --- a/debian/control +++ b/debian/control @@ -14,6 +14,7 @@ Vcs-Git: git://github.com/rhaberkorn/sciteco.git Package: sciteco-curses Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends}, sciteco-common (= ${source:Version}) +Suggests: xclip Description: Scintilla-based Text Editor and Corrector (curses) SciTECO is an interactive TECO dialect, similar to Video TECO. It also adds features from classic Standard TECO-11, diff --git a/distribute.mk.in b/distribute.mk.in index 0a82b2c..ab79262 100644 --- a/distribute.mk.in +++ b/distribute.mk.in @@ -104,7 +104,7 @@ poudriere: # and static linking of all dependant libraries (no DLLs are # added to the zip). # If a win32.teco_ini exists, it is added to the release -# instead of sample.teco_ini. +# instead of fallback.teco_ini. # This also adds gspawn-win32-helper-console.exe to the archive # which is required by the glib spawn functions. # If we ever build a non-console version on Windows, @@ -141,7 +141,7 @@ mingw-binary : @PACKAGE@-@PACKAGE_VERSION@-win32.zip temp-install/usr/share/doc/sciteco/* \ temp-bin/ cp @srcdir@/win32.teco_ini temp-bin/.teco_ini || \ - cp temp-install/usr/bin/sample.teco_ini \ + cp temp-install/usr/bin/fallback.teco_ini \ temp-bin/.teco_ini cp @srcdir@/COPYING @srcdir@/ChangeLog temp-bin/ rm -rf temp-install/ diff --git a/doc/sciteco.1.in b/doc/sciteco.1.in index b7084c5..0d2662e 100644 --- a/doc/sciteco.1.in +++ b/doc/sciteco.1.in @@ -152,7 +152,11 @@ option is absent, \*(ST will mung On UNIX/Linux, the default profile is at .I ~/.teco_ini (see \fBENVIRONMENT\fP). -It will consequently not expect a \fIscript\fP file name as +If the per-user profile is missing, \*(ST falls back to +.IR @scitecodatadir@/fallback.teco_ini . +Without +.BR \-\-mung , +a \fIscript\fP file name will consequently not be expected as the first non-option argument. The profile will usually set up various Scintilla and \*(ST options, configure syntax highlighting, @@ -342,7 +346,7 @@ via \*(ST code. \# That would only be possible by rewriting everything with GSpawn. .SCITECO_TOPIC xclip See -.B @scitecodatadir@/sample.teco_ini +.B @scitecodatadir@/fallback.teco_ini for an example of how to integrate the X11 clipboard via .BR xclip (1). Integrating with Wayland and the Mac OS clipboards is of course also possible. @@ -398,8 +402,9 @@ program termination or user-programmed behaviour. .B $SCITECOCONFIG/.teco_ini Default profile macro. .TP -.B @scitecodatadir@/sample.teco_ini -Sample profile macro configuring commonly used run-time options, +.SCITECO_TOPIC "fallback.teco_ini" +.B @scitecodatadir@/fallback.teco_ini +Fallback profile macro configuring commonly used run-time options, syntax highlighting, session handling and opening files specified on the command line. .TP diff --git a/fallback.teco_ini b/fallback.teco_ini new file mode 100644 index 0000000..0211ade --- /dev/null +++ b/fallback.teco_ini @@ -0,0 +1,95 @@ +!* TECO.INI *! + +!* Set default terminal color scheme *! +EMQ[$SCITECOPATH]/color.tes +:EMQ[$SCITECOPATH]/colors/terminal.tes + +!* Load lexer and buffer session libraries *! +EMQ[$SCITECOPATH]/lexer.tes +EMQ[$SCITECOPATH]/session.tes +EMQ[$SCITECOPATH]/opener.tes + +!* Automatic lexing and session management using ED hooks *! +@#ED{ + Oadd,edit,close,quit + !add! + !* Add code here to execute when a document is added *! + :Q*+1Oedit + 32,0ED + + !* non-UTF-8 documents are assumed to be in latin1 (8859-1) *! + EE"N 1024<:C; -A"T 1EE 1;'> J ' + + M[lexer.auto] + + !* Set up margins *! + [_:M[lexer.test.woman]]_"F + 33ESTEXTWIDTH9U.w + 5*Q.w,0ESSETMARGINWIDTHN + Q.w,2ESSETMARGINWIDTHN + ' + + 0,32ED + !* fall through *! + + !edit! + !* Add code here to execute when a document is edited *! + ESGETCOLUMN,4EJ +  + + !close! + !* Add code here to execute when a document is closed *! +  + + !quit! + !* Add code here to execute when SciTECO quits *! + M[session.save] +} +0,32ED + +!* Uncomment to enable automatic case folding *! +!!0,8ED + +!* + * Tweak the default font name and size. + * The size unit is 1pt/100 + *! +!![lexer.font]Monospace 1300U[lexer.font] + +!* Enable default function key macros *! +EMQ[$SCITECOPATH]/fnkeys.tes + +!* Comment out to disable mouse interaction on Curses *! +0,64ED + +!* Uncomment if terminal emulator supports OSC-52 clipboards *! +!!0,256ED + +:Q[$DISPLAY]"> + !* For integrating with xclip on ncurses *! + [$SCITECO_CLIPBOARD_SET]xclip -in -selection {} + [$SCITECO_CLIPBOARD_GET]xclip -out -selection {} || true +' + +!* Uncomment to enable Unicode icons in the Curses UI *! +!!0,512ED + +!* Uncomment to tweak the memory limit *! +!!500*1000*1000,2EJ + +!* + * If files are given on the command-line, open them + * and disable session saving. + * Otherwise open a buffer session. + *! +Z"= + !* + * Uncomment to use a separate session per VCS repository or + * working copy (see session.tes): + *! + !!M[session.vcs] + M[session.load] +| + [session.path] !* disables session saving *! + M[opener] -EF +' diff --git a/freebsd/files/pkg-message.in b/freebsd/files/pkg-message.in index b91ee06..7d95cdb 100644 --- a/freebsd/files/pkg-message.in +++ b/freebsd/files/pkg-message.in @@ -1,7 +1,7 @@ [ { type: install message: < J ' - - M[lexer.auto] - - !* Set up margins *! - [_:M[lexer.test.woman]]_"F - 33ESTEXTWIDTH9U.w - 5*Q.w,0ESSETMARGINWIDTHN - Q.w,2ESSETMARGINWIDTHN - ' - - 0,32ED - !* fall through *! - - !edit! - !* Add code here to execute when a document is edited *! - ESGETCOLUMN,4EJ -  - - !close! - !* Add code here to execute when a document is closed *! -  - - !quit! - !* Add code here to execute when SciTECO quits *! - M[session.save] -} -0,32ED - -!* Uncomment to enable automatic case folding *! -!!0,8ED - -!* - * Tweak the default font name and size. - * The size unit is 1pt/100 - *! -!![lexer.font]Monospace 1300U[lexer.font] - -!* Enable default function key macros *! -EMQ[$SCITECOPATH]/fnkeys.tes - -!* Comment out to disable mouse interaction on Curses *! -0,64ED - -!* Uncomment if terminal emulator supports OSC-52 clipboards *! -!!0,256ED - -!* For integrating with xclip on ncurses *! -[$SCITECO_CLIPBOARD_SET]xclip -in -selection {} -[$SCITECO_CLIPBOARD_GET]xclip -out -selection {} || true - -!* Uncomment to enable Unicode icons in the Curses UI *! -!!0,512ED - -!* Uncomment to tweak the memory limit *! -!!500*1000*1000,2EJ - -!* - * If files are given on the command-line, open them - * and disable session saving. - * Otherwise open a buffer session. - *! -Z"= - !* - * Uncomment to use a separate session per VCS repository or - * working copy (see session.tes): - *! - !!M[session.vcs] - M[session.load] -| - [session.path] !* disables session saving *! - M[opener] -EF -' diff --git a/src/main.c b/src/main.c index 7849798..0a33d64 100644 --- a/src/main.c +++ b/src/main.c @@ -465,11 +465,33 @@ main(int argc, char **argv) goto cleanup; } - if (!mung_filename && teco_mung_profile) + if (!mung_filename && teco_mung_profile) { /* NOTE: Still safe to use g_getenv() */ mung_filename = g_build_filename(g_getenv("SCITECOCONFIG"), INI_FILE, NULL); + if (!g_file_test(mung_filename, G_FILE_TEST_IS_REGULAR)) { + g_autofree gchar *datadir = teco_file_get_datadir(); + gchar *fallback = g_build_filename(datadir, "fallback.teco_ini", NULL); + if (g_file_test(fallback, G_FILE_TEST_IS_REGULAR)) { + teco_interface_msg(TECO_MSG_WARNING, + "Profile \"%s\" not found: Falling back to \"%s\".", + mung_filename, fallback); + g_free(mung_filename); + mung_filename = fallback; + } else { + teco_interface_msg(TECO_MSG_WARNING, + "No profile found to mung."); + g_free(mung_filename); + g_free(fallback); + mung_filename = NULL; + } + } + } - if (mung_filename && g_file_test(mung_filename, G_FILE_TEST_IS_REGULAR)) { + if (mung_filename) { + /* + * NOTE: Theoretically there is a small timeframe when the file could + * disappear, in which case there will be an error. + */ if (!teco_execute_file(mung_filename, &local_qregs, &error) && !g_error_matches(error, TECO_ERROR, TECO_ERROR_QUIT)) goto error; -- cgit v1.2.3