Deutsch English Français Italiano |
<v3rhps$1c8tl$1@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!npeer.as286.net!npeer-ng0.as286.net!weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: BGB <cr88192@gmail.com> Newsgroups: comp.lang.c Subject: Re: Running an editor from ANSI C Date: Thu, 6 Jun 2024 00:34:42 -0500 Organization: A noiseless patient Spider Lines: 60 Message-ID: <v3rhps$1c8tl$1@dont-email.me> References: <v3pge7$uf2i$1@dont-email.me> <v3r2pl$16mtl$1@dont-email.me> <v3r7v8$1b57j$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Thu, 06 Jun 2024 07:34:53 +0200 (CEST) Injection-Info: dont-email.me; posting-host="2c5f89f7b32c72e623fde2b2c4de8965"; logging-data="1450933"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/J4LlLedlQREUc2xd9E9FeRdX/AR99pYE=" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:UaIreiz8/FvBHfd/Cs/0T8txnOA= Content-Language: en-US In-Reply-To: <v3r7v8$1b57j$1@dont-email.me> Bytes: 2730 On 6/5/2024 9:47 PM, Malcolm McLean wrote: > On 06/06/2024 02:18, Lawrence D'Oliveiro wrote: >> On Wed, 5 Jun 2024 11:59:19 +0100, Malcolm McLean wrote: >> >>> So I just call system with nano. >> >> The trouble with system(3) is it requires a shell as an intermediary, >> with >> consequent pitfalls involving command-line parsing. >> >> More robust to use posix_spawn(3). > > > The concept is an ANSI C only shell. > > I can write my own text editor on top of Posix easily enough. > But I want to implent an "edit" command so that users can edit files. > > And you just can't edit files without non-ASCII keys. > > So at the moment I call system with nano, and it wotks. But it's a > clunky solution. > Theoretically, if you do a text editor with a similar interface to "ed" or "edlin", it could be done entirely within the limits of ANSI C. Well, or use slightly more verbose/"intuitive" commands, like old style BASIC. Say: 10 first line 20 second line 30 third line list // prints previously entered lines 15 new line between first and second line ... When saving files, it would likely discard the line numbers, and then regenerate new line numbers when loading a file (possibly following the de-facto convention of line numbers that step in units of 10). Say, because this might be slightly easier to make sense of than, say: a first line second line third line . ,p 2i new line between first and second line . Well, and 'ed' having its notably unhelpful error message style of: ? ....