Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Sun 21 Oct 2018, 02:58
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
Building a universal file viewer
Post new topic   Reply to topic View previous topic :: View next topic
Page 13 of 17 [255 Posts]   Goto page: Previous 1, 2, 3, ..., 11, 12, 13, 14, 15, 16, 17 Next
Author Message
technosaurus


Joined: 18 May 2008
Posts: 4841
Location: Blue Springs, MO

PostPosted: Sun 25 Feb 2018, 00:39    Post subject:  

Can you post a tar.gz of the file... It may just have a stray non-ascii character.
_________________
Check out my github repositories. I may eventually get around to updating my blogspot.
Back to top
View user's profile Send private message Visit poster's website 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1663
Location: Japan

PostPosted: Sun 25 Feb 2018, 04:18    Post subject:  

greengeek wrote:
Seems to work fine.
Obviously not. Your viewer pane is empty Wink

technosaurus wrote:
Can you post a tar.gz of the file... It may just have a stray non-ascii character.
You must have misunderstood. See greengeek's example.

step wrote:
mm_view shows and empty pane and detects:
/tmp/testfile │ application/octet-stream; charset=binary
Are you sure? You see "charset=binary"? Here it reports no charset at all.
"charset=binary" for a file containing a single ASCII character would be even more disturbing.
MMview uses command file -i filename.
Code:
# T=/tmp/testfile           
# echo -n > $T ; file -i $T
/tmp/testfile: application/x-empty; charset=binary
# echo -n A > $T ; file -i $T
/tmp/testfile: application/octet-stream
# echo -n AA > $T ; file -i $T
/tmp/testfile: text/plain; charset=us-asci
Back to top
View user's profile Send private message 
fredx181


Joined: 11 Dec 2013
Posts: 3481
Location: holland

PostPosted: Sun 25 Feb 2018, 07:41    Post subject:  

Same as step for me on Debian Stretch:

Code:
# echo -n A > $T ; file -i $T
/tmp/testfile: application/octet-stream; charset=binary

_________________
Dog Linux website
Back to top
View user's profile Send private message 
puppy_apprentice


Joined: 07 Feb 2012
Posts: 194

PostPosted: Sun 25 Feb 2018, 14:04    Post subject:  

Another info:

Code:

# echo -n > test.txt ; file test.txt
test.txt: empty
# echo -n A > test.txt ; file test.txt
test.txt: very short file (no magic)
# echo -n AA > test.txt ; file test.txt
test.txt: ASCII text, with no line terminators


Slacko 5.7, UTF-8, Locale PL

Last edited by puppy_apprentice on Mon 26 Feb 2018, 07:40; edited 1 time in total
Back to top
View user's profile Send private message 
peebee


Joined: 21 Sep 2008
Posts: 3497
Location: Worcestershire, UK

PostPosted: Sun 25 Feb 2018, 15:43    Post subject:  

LxPupSc (Slackware Current)......
Code:
# file -v
file-5.32
magic file from /etc/file/magic
# echo -n > test.txt ; file -i test.txt
test.txt: inode/x-empty; charset=binary
# echo -n A > test.txt ; file -i test.txt
test.txt: application/octet-stream; charset=binary
# echo -n AA > test.txt ; file -i test.txt
test.txt: text/plain; charset=us-ascii

_________________
LxPup = Puppy + LXDE
Back to top
View user's profile Send private message Visit poster's website 
some1

Joined: 17 Jan 2013
Posts: 84

PostPosted: Mon 26 Feb 2018, 19:05    Post subject:  

Just meddling:

MM may need feedback on the VERSION of file
peebee provided the version in his post.
Furthermore: test with the -i-switch - MM parses the mime.

I think that I recall, that file was changed,so that 1-char followed by \0 - was to be interpreted as a binary.

(Unrelated - but common rule of thumb :No \0 in a file -> text-file)
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1663
Location: Japan

PostPosted: Tue 27 Feb 2018, 06:41    Post subject:  

Thanks to all for the feedback. I'm using file version 5.03. Interesting how file has gone through so many versions and IMO has changed for the worse. It's OK to produce no charset when for whatever reasons it is unable to classify a single ASCII, but now binary? But then to classify a zero length file as "binary" is equally strange.

some1 wrote:
JI think that I recall, that file was changed,so that 1-char followed by \0 - was to be interpreted as a binary.
That would be perfectly OK and that's the result I get (see below)

Quote:
(Unrelated - but common rule of thumb :No \0 in a file -> text-file)
Not that simple. My file command classifies 1 ASCII char followed by a nul char as "application/octet-stream". Good.
And for 2 or more ASCII chars followed by a nul char? Surprise! See yourself:
Code:
# echo -ne 'A\0' > /tmp/testfile ; file -i /tmp/testfile 
/tmp/testfile: application/octet-stream; charset=binary
# echo -ne 'AA\0' > /tmp/testfile ; file -i /tmp/testfile
/tmp/testfile: text/plain; charset=binary
Back to top
View user's profile Send private message 
puppy_apprentice


Joined: 07 Feb 2012
Posts: 194

PostPosted: Tue 27 Feb 2018, 08:37    Post subject:  

Ok i've had some suspicions so made some tests.

When my system Locale and Keyboard is Polish i have:
(all files made in PL settings)
Code:

# file -i empty.txt
empty.txt: application/x-empty; charset=binary
# file -i A.txt
A.txt: application/octet-stream
# file -i AA.txt
AA.txt: text/plain; charset=us-ascii


When changed to ENG/GB i have:
(all files made in ENG/GB settings)
Code:

# file -i emptyGB.txt
emptyGB.txt: application/octet-stream
# file -i AGB.txt
AGB.txt: text/plain; charset=us-ascii
# file -i AAGB.txt
AAGB.txt: text/plain; charset=us-ascii
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1663
Location: Japan

PostPosted: Mon 19 Mar 2018, 01:57    Post subject:  

1-byte files
Thanks again for the feedback. One way to handle such funny "octet-stream" would be another case condition. On the other hand I really want to keep the main routine, the one that kicks in whenever the user makes a new selection, as lean and fast as possible. Therefore I will not give special treatment to such files. Nevertheless I can't ignore them, so I plan to make them viewable through a viewing mode for binaries, something that's on my agenda.

edit v. text
Another thing I need to address is line wrapping mode. Has been requested before and with the new support for ebooks has gained some usefulness. Currently I force ebook displays to wrap latest after 60 characters (and HTML after 90).This wrapping is achieved by using the busybox fold command and is not dynamic.

Since gtkdialog does not support to change line wrapping programmatically, the only solution would be to prepare 2 separate widgets, differing only in their line wrapping properties.

I thought that using the text widget for the viewer instead of the currently used edit widget would provide some advantages. After all an edit widget seems odd when there is nothing to edit, and text should be faster too. That's what I thought...

Wrong I was. Here a small demo of both widgets. While edit works as expected I can't figure out how to make the text widget wrap at the window boundaries. If this is impossible then text is a no-go.
Code:
#!/bin/sh
echo '
<vbox>
   <edit editable="false" wrap-mode="3">
      <width>200</width>
      <height>400</height>
      <input file>/etc/rc.d/rc.sysinit</input>
   </edit>
</vbox>'|gtkdialog -s

echo '
<vbox scrollable="true" width="200" height="400">
   <text selectable="true" can-focus="false" xalign="0" wrap="true">
      <input file>/etc/rc.d/rc.sysinit</input>
   </text>
</vbox>'|gtkdialog -s

However the real show stopper is speed, or better the lack of it. And I'm not talking of milliseconds. In above demo you might notice that the text widget loads slowly. The filesize of /etc/rc.d/rc.sysinit is about 40KB. I also tried a much bigger file (/root/puppy-reference/doc/index.html), which is about 1MB. While edit showed the file instantly on my lame netbook, text needed more that a minute to display an empty window, followed by another minute to display the file. That's more than 2 min for plain text! Unless something is wrong with my distro the text widget is flawed. This is not acceptable and disqualifies the text widget for any larger text portion.

P.S.: The text widget wraps by default, so wrap="true" is not really needed.
Interesting and undocumented (?): The wrap-mode tag attribute is also supported. Value assignments are different from those for the edit widget:
wrap-mode="0" is the same as the default wrap="true". Wraps lines at word boundaries.
wrap-mode="1" wraps lines at character boundaries
wrap-mode="2" wraps lines at word boundaries, but fall back to character boundaries if there is not enough space for a full word
edit_vs_text.png
 Description   
 Filesize   59.55 KB
 Viewed   446 Time(s)

edit_vs_text.png

Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1663
Location: Japan

PostPosted: Thu 19 Apr 2018, 07:58    Post subject:  

Update 2018-04-19 (see also initial post)

Line wrapping
Dynamic line wrapping of text (see also previous post for some of the technical aspects) pretty much reduces the need for the vertical layout. Nevertheless for reading large texts I prefer fullscreen mode (right click on viewer pane).

Line wrapping can be invoked by menu or togglebutton.
I didn't find any suitable button icon for line wrapping, so I rolled my own. Hope that the icon is clear (and not mistaken for number "2" Laughing ).

Line wrapping is off by default and any "on" status is not retained between sessions. Keeping the menu and the button in sync is a bit tricky and applying a saved status at startup, though not difficult, would require more code than I consider justified. Just my personal opinion.

Rearranged menu
I felt that "View" was not the right menu for "Play" and "Show line numbers" items.
"Play" has now its own menu and for "Show line numbers" and the new "Line Wrapping" item I created the "Document" menu, making it consistent with Geany.
Line_wrapping.jpg
 Description   
 Filesize   79.9 KB
 Viewed   360 Time(s)

Line_wrapping.jpg

Back to top
View user's profile Send private message 
slavvo67

Joined: 12 Oct 2012
Posts: 1570
Location: The other Mr. 305

PostPosted: Thu 19 Apr 2018, 12:45    Post subject:  

Mochi,

I've been following this for quite a while and I just wanted to say how great this project is. Haven't been around much since I "Cut the cord" from the monopoly cable company but wanted to express how appreciated this is.

Best,

Slavvo67
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1663
Location: Japan

PostPosted: Sun 22 Apr 2018, 00:51    Post subject:  

Thanks for your appreciation, Slavvo67. Good to know that I'm not the only one following this project.

Sorry to say that you may have to follow a bit longer before you see a version 1.0. I'm lazy and notoriously slow but I have great fun in what I am doing.
Back to top
View user's profile Send private message 
sc0ttman


Joined: 16 Sep 2009
Posts: 2603
Location: UK

PostPosted: Sun 22 Apr 2018, 10:46    Post subject:  

I also think this is class...

I like ranger, the console file manager, and this has a similar feel ... I think it's great work, and have long wanted someone more skilled than me to have a stab at something like this for Puppy..

_________________
Akita Linux, VLC-GTK, Pup Search, Pup File Search
Back to top
View user's profile Send private message 
drunkjedi


Joined: 24 May 2015
Posts: 897

PostPosted: Sun 22 Apr 2018, 11:16    Post subject:  

MochiMoppel wrote:
Good to know that I'm not the only one following this project.
That's quite an understatement.
We have been using this since day one.

It's also included in my daily driver fatdog linux.
It's in Menu > Utility > MMView.

It's good that you keep improving it, I am quite satisfied with it though.

Keep having fun.
Back to top
View user's profile Send private message 
mfb

Joined: 22 Mar 2016
Posts: 60

PostPosted: Mon 23 Apr 2018, 09:45    Post subject:  

As shown in the image - I've clicked the icon immediately below "Help" , chosen the "root" directory, then typed a lower case "m" and the single file and the three unhidden directories which start with that character are listed.

My questions are - is the list for information only - or can I view any of the four items directly from the list and, if so, how?
image.jpg
Description 
jpg

 Download 
Filename  image.jpg 
Filesize  133.7 KB 
Downloaded  123 Time(s) 
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 13 of 17 [255 Posts]   Goto page: Previous 1, 2, 3, ..., 11, 12, 13, 14, 15, 16, 17 Next
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1024s ][ Queries: 13 (0.0133s) ][ GZIP on ]