emma1997
Posts: 695
Joined: Sun Nov 08, 2015 7:00 pm
Location: New England (not that old one)

How To Get Mousepad To Read Standard Text Files

Tue Mar 03, 2020 9:07 pm

I'm trying to get a Linux editor that works as close as possible to Notepad or Wordpad.

Most large files ported from PC to Pi and read with Mousepad a warning comes up that it's not UTF8. This happens because 8bit ASCII are present. Clicking 'other' and 'ok' works and text behaves properly regarding CRLF etc but it's annoying to do this every time.

If I tediously remove all the 8bit characters the warning goes away but now that nasty Unix double spacing occurs. This is more than an annoyance.

Is there any easy way to get Mousepad to behave by default like it's been clicked through the warning? Or some easy way to permanently stop the double spacing without modifying source?

By easy I mean ideally without recompiling kernal modules or downloading anything new. Something that can be communicated over a phone to non-technical individuals and does not require mailing any more SD cards to the people I'm trying to help. Any assistance here would be greatly appreciated.

Heater
Posts: 15343
Joined: Tue Jul 17, 2012 3:02 pm

Re: How To Get Mousepad To Read Standard Text Files

Tue Mar 03, 2020 9:58 pm

I have no idea what mousepad is. Is that a text editor or some such?

Whatever "nasty Unix double spacing occurs" is likely a consequence of MSDOS/Windows not adopting the Unix standard for text files back in the day. Which is really annoying sometimes.

Anyway, under Raspbian we can apt-get install dos2unix and unix2dos to fix up files corrupted my Microsoft.

Or just use an editor that works this out for itself.
Memory in C++ is a leaky abstraction .

klricks
Posts: 7020
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA
Contact: Website

Re: How To Get Mousepad To Read Standard Text Files

Tue Mar 03, 2020 10:37 pm

Heater wrote:
Tue Mar 03, 2020 9:58 pm
I have no idea what mousepad is. Is that a text editor or some such?
...
Mousepad is now the default GUI text editor replacing Leafpad.
Unless specified otherwise my response is based on the latest and fully updated Raspbian Buster w/ Desktop OS.

Heater
Posts: 15343
Joined: Tue Jul 17, 2012 3:02 pm

Re: How To Get Mousepad To Read Standard Text Files

Tue Mar 03, 2020 11:13 pm

klricks wrote:
Tue Mar 03, 2020 10:37 pm
Heater wrote:
Tue Mar 03, 2020 9:58 pm
I have no idea what mousepad is. Is that a text editor or some such?
...
Mousepad is now the default GUI text editor replacing Leafpad.
That good too hear. Maybe.

Now tell me, what on Earth is "Leafpad"?
Memory in C++ is a leaky abstraction .

emma1997
Posts: 695
Joined: Sun Nov 08, 2015 7:00 pm
Location: New England (not that old one)

Re: How To Get Mousepad To Read Standard Text Files

Tue Mar 03, 2020 11:31 pm

Leafpad was the default (did I mention default?) editor before Mousepad became the default editor. By default I mean what comes up on a brand new Raspbian install when you click on a text file.

It would be nice to discuss endless benefits of Unix operating systems but long before that there were teletypes (ASR33 etc) that needed both CR and LF in order for human legible printout. Similar to what 99% of desktop computers use today. Let's not get into that food fight right now because I need help, not another locked thread.

BTW Notepad and Wordpad are not my own goto tools. I prefer a very old one (Desmet SEE.EXE) but even though I have source now (thanks to Scruss IIRC), and was able to fix many bugs, porting to Linux is beyond my competence.

As I mentioned alternate editors are not a good option in this case unless built-in because 2 of the 3 individuals don't have internet at all and for the 3rd it's inconvenient. If it's the only way then maybe but I would like to avoid mailing out more SD cards. I've been doing this a lot and its getting old.

Also as I mentioned altering the source is not feasible here either because these have to go back into a regular PC at some point.

It would be really great if there was a way to get Mousepad to skip the UTF*8 warning and still work exactly the same.

Heater
Posts: 15343
Joined: Tue Jul 17, 2012 3:02 pm

Re: How To Get Mousepad To Read Standard Text Files

Tue Mar 03, 2020 11:55 pm

I was not meaning to get into a "editor war" here.

Rather it amazes me that we have been building computers and operating systems and all the rest for the best part of a hundred years but still we have problems with the most basic things. Like line endings in simple text files, or endianness in binary files and so on.

Grief, I was puzzling over the simple cut and paste operation this morning. What works in Windows is not the same as what works in Ubutu is not the same as what woks in Debian. As I move from machine to machine it confuses the socks of me.

Unicode, UTF-8 and all that does not help.

So, OK, I'm rambling and have no solution.

I do have a question though: What does it mean by "standard text file" in the title of this thread? Whose standard does it mean?
Memory in C++ is a leaky abstraction .

W. H. Heydt
Posts: 11974
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: How To Get Mousepad To Read Standard Text Files

Wed Mar 04, 2020 12:13 am

Personally... I use vi. You can take care of the DOS/Windows "CR/LF" line ending with a straightforward global command...
:g/^V^M$/s///
Where "^X" means "Ctrl+X".

emma1997
Posts: 695
Joined: Sun Nov 08, 2015 7:00 pm
Location: New England (not that old one)

Re: How To Get Mousepad To Read Standard Text Files

Wed Mar 04, 2020 12:27 am

Yes, that is a nice feature. SEE has it. I generally prefer skipping that control whole key bit too. Others seem to actually prefer doing twice the work. Thousands of time a day. lol

I did use vi on a DEC machine many years back. Is it part of the Rasbian image? If not won't help in this current situation.

Also should mention that with only 120 megabytes left on most of my own card partitions size does matter. Avoid bloatware is high on the list. Mousepad is around 400 megabytes but it's built-in so essentially 0. Notably SEE is 43 kbytes and no DLL, DOTNET, JAVA or other dependencies. Ahhh... progress.

I wonder if Leafpad has the same annoying auto UTF8 detect 'feature' and runs on modern Pi? If that works maybe delete and replace Mousepad. Might actually be smaller and free up a few megabytes?

bls
Posts: 535
Joined: Mon Oct 22, 2018 11:25 pm
Location: Seattle, WA
Contact: Twitter

Re: How To Get Mousepad To Read Standard Text Files

Wed Mar 04, 2020 3:48 am

Use

Code: Select all

sudo apt install dos2unix
which installs two nice little command-line commands (dos2unix and unix2dos) on your Pi.

Be sure to check out the -n switch because it appears that dos2unix overwrites the input file with the converted file by default.

jahboater
Posts: 5413
Joined: Wed Feb 04, 2015 6:38 pm
Location: West Dorset

Re: How To Get Mousepad To Read Standard Text Files

Wed Mar 04, 2020 6:12 am

W. H. Heydt wrote:
Wed Mar 04, 2020 12:13 am
Personally... I use vi. You can take care of the DOS/Windows "CR/LF" line ending with a straightforward global command...

Code: Select all

:g/^V^M$/s///
Where "^X" means "Ctrl+X".
I thought you could get rid of the CRLF problem with:-

Code: Select all

:1,$s/.$//
needs no control characters!.
But its decades since I had to do it.
Or use dos2unix of course.
emma1997 wrote:
Wed Mar 04, 2020 12:27 am
I did use vi on a DEC machine many years back. Is it part of the Rasbian image? If not won't help in this current situation.
Yes of course its pre-installed. Try also nano which might be more familiar. Or emacs.
These all work fine when there is no GUI (Raspbian Lite).

The standard text file on Raspbian (and MacOS, IOS, UNIX, and Linux in general) has LF only for obvious reasons.
CRLF is wasted space and a block boundary may occur within a record separator - yuk!
There is no longer any need to support ASR33 teletypes.
Last edited by jahboater on Wed Mar 04, 2020 6:20 am, edited 5 times in total.
"We are in the beginning of a mass extinction, and all you can talk
about is money and fairy tales of eternal economic growth."
- Greta Thunberg

User avatar
TheMindVirus
Posts: 146
Joined: Mon Jul 29, 2019 12:38 am
Location: Cornwall, UK

Re: How To Get Mousepad To Read Standard Text Files

Wed Mar 04, 2020 6:15 am

jahboater wrote:Try also nano which might be more familiar
I can't live without nano, it's my absolute favourite command-line text editor.
Alastair Cota
Embedded Firmware Developer
[ERR]: Sense of Humour Failure

jahboater
Posts: 5413
Joined: Wed Feb 04, 2015 6:38 pm
Location: West Dorset

Re: How To Get Mousepad To Read Standard Text Files

Wed Mar 04, 2020 6:23 am

emma1997 wrote:
Tue Mar 03, 2020 9:07 pm
Most large files ported from PC to Pi and read with Mousepad a warning comes up that it's not UTF8. This happens because 8bit ASCII are present.
CR and LF are 7-bit ASCII, this message sounds like a bug, or CRLF is not the problem; in which case dos2unix will not help.
"We are in the beginning of a mass extinction, and all you can talk
about is money and fairy tales of eternal economic growth."
- Greta Thunberg

KenT2
Posts: 31
Joined: Thu Aug 16, 2012 8:34 pm
Contact: Website

Re: How To Get Mousepad To Read Standard Text Files

Wed Mar 04, 2020 7:42 am

You could try some better editors. These have better support for line ending modes and conversion thereof

notepad++ can be downloaded free for a PC

Geany is installed on Raspbian out of the box.

User avatar
PeterO
Posts: 5701
Joined: Sun Jul 22, 2012 4:14 pm

Re: How To Get Mousepad To Read Standard Text Files

Wed Mar 04, 2020 10:18 am

Note what OP said
Something that can be communicated over a phone to non-technical individuals and does not require mailing any more SD cards to the people I'm trying to help.

So all these suggestions that include "apt install" are not really very helpful !
PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

User avatar
TheMindVirus
Posts: 146
Joined: Mon Jul 29, 2019 12:38 am
Location: Cornwall, UK

Re: How To Get Mousepad To Read Standard Text Files

Wed Mar 04, 2020 10:28 am

PeterO wrote:So all these suggestions that include "apt install" are not really very helpful !
PeterO
Sorry, my mistake. I was replying mainly to previous comments, not the original post.
It came from trying to find a simple enough Linux workaround for a standard text editor as replacement to Mousepad.
Without downloading anything or changing the source, the only thing that can be changed is Mousepad Settings.
I will look into this further on my Pi4 since you have reported it.

EDIT:
On the latest Raspbian Buster Image, I have been able to open text files with LF&CR from Notepad in Windows saved under:
ANSI, UTF-8, UTF-8-BOM, UTF-16-LE and UTF-16-BE without the error message popping up.
May I ask which file format and encoding you are trying to convert from and which specific characters cause the problem?
Alastair Cota
Embedded Firmware Developer
[ERR]: Sense of Humour Failure

emma1997
Posts: 695
Joined: Sun Nov 08, 2015 7:00 pm
Location: New England (not that old one)

Re: How To Get Mousepad To Read Standard Text Files

Wed Mar 04, 2020 6:35 pm

Yes, thank you for taking time on this. I need Mousepad to go into iso-8859-14 mode without the warning.

It is not an option to convert anything to anything. Just stop the message. Not a fatal flaw but mostly huge waste of time and effort because I may use this hundreds of times a day (no exaggeration). Quite annoying to have to click 3 times every time all the time. And big delay. Not a bug because I understand most nixies have no need for MS compatibility and probably need to be warned.

Also worth mentioning it is not CRLF causing trouble. It's eight bit characters that make Mousepad halt. If you add some 8 bit characters (ie trademark symbol) you will see what I see.

Many years ago I wrote a Turbo C program to not only fix the CRLF issue but remove all 8 bit characters. Problem is when I use that then Mousepad no longer warns but goes into double space (CR) mode. And altering the source file is not desirable anyway.

IDK what Mousepad 'settings' are but here's nothing obvious in 'preferences' relating to UTF etc.

I must say all these replies have been helpful, if not exactly this situation then other things on my mind. What's great about this website is the 'education' motif. Not all of us are grade school noobs but probably everybody learns something every time we log in. Thanks again for the tidbits.

So to sum up, I just need it to go into iso-8859-14 (PC) mode but skip that startup fuss.

W. H. Heydt
Posts: 11974
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: How To Get Mousepad To Read Standard Text Files

Wed Mar 04, 2020 9:51 pm

emma1997 wrote:
Wed Mar 04, 2020 12:27 am
I did use vi on a DEC machine many years back. Is it part of the Rasbian image? If not won't help in this current situation.
Vi, or some superset of it, is part of the standard Raspbian install. (At least, I've never had to add it to use it.) The executable is 2.12MB. It will, of course, need more than that when running, but nothing like 120MB.

User avatar
TheMindVirus
Posts: 146
Joined: Mon Jul 29, 2019 12:38 am
Location: Cornwall, UK

Re: How To Get Mousepad To Read Standard Text Files

Wed Mar 04, 2020 10:23 pm

You may like to refer to this piece of documentation: https://www.raspberrypi.org/documentati ... editors.md
as assistance for describing how to use vi over the phone.

It also details available desktop and command-line text editors available on Raspbian.
As part of the new Raspbian Buster Image, the following alternatives come/don't come pre-installed:

Pre-installed (Command Line): nano, vi
Pre-installed (Desktop): Mousepad/Leafpad, Geany, Thonny
Not-installed (Command Line): vim, emacs, etc.
Not-installed (Desktop): GVim, etc.

I hope this information helps you and your clients.
Alastair Cota
Embedded Firmware Developer
[ERR]: Sense of Humour Failure

emma1997
Posts: 695
Joined: Sun Nov 08, 2015 7:00 pm
Location: New England (not that old one)

Re: How To Get Mousepad To Read Standard Text Files

Wed Mar 04, 2020 11:15 pm

Not so much clients in this case as friends and family. Clients generally have internet and don't use Pi or run into the same issues. Mostly it's for the other three (me, myself, and I, lol). But I suspect here are hundreds or even millions out there who could use a nice, well behaved, GUI text editor.

It turns out vim is built-in but just locks up my Pi4. IIRC not likely to have Notepad-like interface anyway. Geany behaves fine for all my files but just absurd clutter and I suspect not really an editor but more IDE. I will check out that link and Thonny too when I get access.

So in a nutshell as close to Evil Winders Notepad or Wordpad as possible.

I'm pretty sure this annoying warning did not pop up couple years ago. Can anyone give me a hint how to get an old version of Leafpad running? Maybe it lacks this 'feature'. I probably have a version in some old distribution like Jessie or Stretch but those don't work for Pi4 and didn't immediately find it available. Is it still downloadable anywhere else? Google did not help much.

klricks
Posts: 7020
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA
Contact: Website

Re: How To Get Mousepad To Read Standard Text Files

Wed Mar 04, 2020 11:27 pm

emma1997 wrote:
Wed Mar 04, 2020 11:15 pm
......... Can anyone give me a hint how to get an old version of Leafpad running? ....
Leafpad and countless other text editors are in the repository.

Code: Select all

sudo apt install leafpad
Unless specified otherwise my response is based on the latest and fully updated Raspbian Buster w/ Desktop OS.

User avatar
TheMindVirus
Posts: 146
Joined: Mon Jul 29, 2019 12:38 am
Location: Cornwall, UK

Re: How To Get Mousepad To Read Standard Text Files

Wed Mar 04, 2020 11:45 pm

emma1997 wrote:I'm pretty sure this annoying warning did not pop up couple years ago. Can anyone give me a hint how to get an old version of Leafpad running? Maybe it lacks this 'feature'. I probably have a version in some old distribution like Jessie or Stretch but those don't work for Pi4 and didn't immediately find it available. Is it still downloadable anywhere else? Google did not help much.
You could try an offline install:

On the Pi with internet access:
Download leafpad using apt with "--download-only".

Code: Select all

sudo apt-get install --download-only leafpad
It will download into the folder "/var/cache/apt/archives/".
You can find it with a file browser, or by using grep:

Code: Select all

ls /var/cache/apt/archives/ | grep "leafpad"
Then connect a USB stick and copy across the downloaded .deb file.
Eject/Unmount the USB stick safely before removing.

On the Pi without internet access:
Connect the USB stick to the Pi.
Copy the leafpad .deb file you downloaded earlier and paste it in "/home/pi".
You should then be able to install it with:

Code: Select all

sudo dpkg -i /home/pi/leafpad_<version>.deb
Replace "leafpad_<version>.deb" with the name of the .deb file that you downloaded.
Again, remember to eject the USB stick safely before removing.

If dependencies are missing, you will need those .deb files as well as the leafpad.deb,
using the same process above to download, transfer and install them.
Please ensure that for the Pi, the .deb file you downloaded is the armhf version (or armel for Pi0 and Pi1).
Alastair Cota
Embedded Firmware Developer
[ERR]: Sense of Humour Failure

jahboater
Posts: 5413
Joined: Wed Feb 04, 2015 6:38 pm
Location: West Dorset

Re: How To Get Mousepad To Read Standard Text Files

Thu Mar 05, 2020 9:38 am

emma1997 wrote:
Wed Mar 04, 2020 11:15 pm
It turns out vim is built-in but just locks up my Pi4.
That's odd. Vi is very old and mature. I just tried "vi largefile" (a 12,000 line source file) and it loaded instantly on a Pi4.
emma1997 wrote:
Wed Mar 04, 2020 11:15 pm
IIRC not likely to have Notepad-like interface anyway.
Yes. Agreed. Perhaps not suitable for beginners. Very powerful though.

Have you tried nano by the way? it is very simple (but not the same as leadpad unfortunately).

What about this? Claims to be 8-bit clean.
https://www.gnu.org/software/moe/
"We are in the beginning of a mass extinction, and all you can talk
about is money and fairy tales of eternal economic growth."
- Greta Thunberg

emma1997
Posts: 695
Joined: Sun Nov 08, 2015 7:00 pm
Location: New England (not that old one)

Re: How To Get Mousepad To Read Standard Text Files

Thu Mar 05, 2020 7:47 pm

Yes, I use nano several times a day and really like it. Starting out a long time ago with Ed (CPM) and Edlin (DOS) it's like a breath of fresh air. I specially like ability to cut and paste from GUI to CLI. Impossible with real mode MSDOS command line.

Anyway, after much trial and tribulation (had to backup and resize some partitions again), Leafpad is up and running and fixes the problem. I had no idea it would be that easy. Not perfect because it will be necessary to send cards out to my sister and pals who don't have easy internet but thanks to those instructions on offline loading should only have to do that one time and easy to instruct over the phone.

For some reason I thought repositories only had current default software but glad I was wrong.

I do wonder what if any real difference Leafpad compared to Mousepad. Hopefully another shoe will not drop. lol

P.S. vi wasn't locking up my Pi after all. It wasn't obvious to include a filename without which everything just seems dead. Anyway, as mentioned, not even close to Notepad/Leafpad etc as far as interface so moot. For now nano and Leafpad are doing their respective jobs well.

Thanks for the tips guys. I knew, as usual, this was THE place to get help.

andrum99
Posts: 1151
Joined: Fri Jul 20, 2012 2:41 pm

Re: How To Get Mousepad To Read Standard Text Files

Fri Mar 06, 2020 2:57 am

emma1997 wrote:
Thu Mar 05, 2020 7:47 pm
Anyway, after much trial and tribulation (had to backup and resize some partitions again), Leafpad is up and running and fixes the problem.
That's interesting - Leafpad was the default GUI text editor in Raspbian, but for some reason they switched to Mousepad. Do feel free to file a bug at https://github.com/RPi-Distro/pi-gen to ask them to switch it back - at the very least that should elicit some justification for the switch. The release notes (http://downloads.raspberrypi.org/raspbi ... _notes.txt) don't really give much of a clue as to why the change was made:
* Mousepad used as simple text editor instead of leafpad
I read that as implying that the switch was made because Mousepad has a simpler UI than Leafpad.

User avatar
scruss
Posts: 3061
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: How To Get Mousepad To Read Standard Text Files

Fri Mar 06, 2020 4:10 am

emma1997 wrote:
Wed Mar 04, 2020 6:35 pm
Yes, thank you for taking time on this. I need Mousepad to go into iso-8859-14 mode without the warning.

It is not an option to convert anything to anything. Just stop the message.
Using ISO-8859-* character sets in 2020 is a bit quaint. 8859-14 is pretty niche, and entirely covered by UTF-8. It's been at least a decade since 8-bit chars were the norm.

But I'm not going to rain on your eisteddfod. What do you get when you type

Code: Select all

echo $LANG
?
Unless you're using (or have installed) the cy_GB locale, you're not going to see 8859-14 characters. You might want to install it (and cy_GB.UTF-8 too) from raspi-config. If you want to temporarily edit in 8-bit Welsh, do this:

Code: Select all

LANG=cy_GB leafpad file.txt
Emacs handles CRLFs fairly gracefully without conversion. Personally, I'd use a dos2unix / iconv / edit / iconv / unix2dos chain to edit the files. Windows editors have been less picky about CRLFs over the last few years.

And you're using the Compose key to generate characters like ŵ, right?
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.
Pronouns: he/him

Return to “General discussion”