Deutsch English Français Italiano |
<v3smua$1io29$1@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!3.eu.feeder.erje.net!feeder.erje.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Malcolm McLean <malcolm.arthur.mclean@gmail.com> Newsgroups: comp.lang.c Subject: Re: Running an editor from ANSI C Date: Thu, 6 Jun 2024 17:08:42 +0100 Organization: A noiseless patient Spider Lines: 40 Message-ID: <v3smua$1io29$1@dont-email.me> References: <v3pge7$uf2i$1@dont-email.me> <v3r2pl$16mtl$1@dont-email.me> <v3r7v8$1b57j$1@dont-email.me> <v3slcu$1ijch$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Thu, 06 Jun 2024 18:08:42 +0200 (CEST) Injection-Info: dont-email.me; posting-host="fd1a4517109bed24a981b559f1527ee3"; logging-data="1663049"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19+KZR7B+I91tCB5gaDB2d8geVLxMfUZNg=" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:WdKvcM98fjC4xflppwUTIdazaLU= In-Reply-To: <v3slcu$1ijch$1@dont-email.me> Content-Language: en-GB Bytes: 2694 On 06/06/2024 16:42, Mikko wrote: > On 2024-06-06 02:47:04 +0000, Malcolm McLean said: > >> 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. > > Just make the editor a part of the shell. > When I was learning C I was given a text editor to write as a starter exercise. So it's not exactly a challenging program to write. If you can intercept arrow keys so that the user can move the cursor about the screen, and keypresses so that you write a character at the cursor location. And fundamentally you are moving a cursor over a raster in response to arrow keys, and that program takes an hour or so to write, and that is the heart of a simple editor. There's more to it than that, of course, but basically you are editing short text files. And you just can't do that in ANSI C. There is no way of intercepting the arrow keys (you can always ask the user for the dimensions of his terminal, output is not impossible). It's input which is the killer. -- Check out Basic Algorithms and my other books: https://www.lulu.com/spotlight/bgy1mm