Author Topic: Lua-based Ebook Reader (Does not require ndless)  (Read 20148 times)

0 Members and 2 Guests are viewing this topic.

Offline whatkindofausernameisthis

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 11
  • Rating: +11/-0
    • View Profile
Lua-based Ebook Reader (Does not require ndless)
« on: December 13, 2011, 07:17:23 pm »
Hey everybody. I made this a while ago:
http://ourl.ca/9752

But to be honest, that program sucked. So I've made a new one in the only programming language available at the time--Lua. This is a simple script that will convert a plaintext file into a Lua program that can display the book on your calculator. This is still in a beta stage (there are a few bugs left to squash), but since I won't be able to work on this any more until my college applications are done, I'll release this early.

You need to have luna in the same directory as this program for it to function. Get luna here: http://www.mirari.fr/DC0p
Your folder should look like this:


Usage:
ebook.exe <book.txt>
It will prompt you for the title of the book

Alternatively, you can just drag and drop a *.txt file onto ebook.exe

Included is a copy of Brandon Sanderson's Free online ebook, Warbreaker

Bugs:
  • Overflow errors on the last line of a paragraph
  • I haven't found an elegant way of going backwards a page, so the back button goes back a paragraph instead.
  • No support (yet) for formatting (i.e. italics, bold, underline)
  • No search or jump-to function

Notes:
  • The page number is measured in thousands of characters, i.e. one "page" = 1000 characters
  • to jump to a particular spot, insert a calculator page and enter "curpos:=###" where ### is the character you want to jump to
  • +/- to change font size
  • Left/Right to navigate

Pictures:




Download:
http://dl.dropbox.com/u/4752797/Nspire%20Ebook%20Reader%202.zip

Offline annoyingcalc

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1953
  • Rating: +140/-72
  • Found in Eclipse.exe
    • View Profile
Re: Lua-based Ebook Reader (Does not require ndless)
« Reply #1 on: December 13, 2011, 07:27:16 pm »
Nice!
This used to contain a signature.

Offline Yeong

  • Not a bridge
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3739
  • Rating: +278/-12
  • Survivor of Apocalypse
    • View Profile
Re: Lua-based Ebook Reader (Does not require ndless)
« Reply #2 on: December 13, 2011, 09:51:05 pm »
wow. how big will be the file per page?
Sig wipe!

Offline Jim Bauwens

  • Lua! Nspire! Linux!
  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1881
  • Rating: +206/-7
  • Linux!
    • View Profile
    • nothing...
Re: Lua-based Ebook Reader (Does not require ndless)
« Reply #3 on: December 14, 2011, 06:54:59 am »
Looks good =)

Offline Lionel Debroux

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2135
  • Rating: +290/-45
    • View Profile
    • TI-Chess Team
Re: Lua-based Ebook Reader (Does not require ndless)
« Reply #4 on: December 14, 2011, 07:18:25 am »
Interesting project :)

The Nspire's horsepower being somewhat larger than that of the TI-68k series, third-party programs could be even more powerful than Hib-View / uView, or TICT eBook Reader, are on the TI-68k series.
Member of the TI-Chess Team.
Co-maintainer of GCC4TI (GCC4TI online documentation), TILP and TIEmu.
Co-admin of TI-Planet.

Offline Jim Bauwens

  • Lua! Nspire! Linux!
  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1881
  • Rating: +206/-7
  • Linux!
    • View Profile
    • nothing...
Re: Lua-based Ebook Reader (Does not require ndless)
« Reply #5 on: December 14, 2011, 08:11:54 am »
There is also much more space, so pictures might be possible.
And adding support for styling/different font sizes isn't too hard either :)

Offline Hayleia

  • Programming Absol
  • Coder Of Tomorrow
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3367
  • Rating: +393/-7
    • View Profile
Re: Lua-based Ebook Reader (Does not require ndless)
« Reply #6 on: December 14, 2011, 10:57:35 am »
D: I got:


Error: Failed attempt to launch program or document:
Action: <totns.bat>
Params: <"test">

Specifically: Le fichier spédifié est introuvable


        Line#
--->  012: Run,totns.bat "%bookName%"

The current thread will exit.


I dragged and dropped the txt file on the exe with all the needed files in the folder ??? I don't know what the problem is
« Last Edit: December 14, 2011, 10:57:59 am by Hayleia »
I own: 83+ ; 84+SE ; 76.fr ; CX CAS ; Prizm ; 84+CSE
Sorry if I answer with something that seems unrelated, English is not my primary language and I might not have understood well. Sorry if I make English mistakes too.

click here to know where you got your last +1s

Offline whatkindofausernameisthis

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 11
  • Rating: +11/-0
    • View Profile
Re: Lua-based Ebook Reader (Does not require ndless)
« Reply #7 on: December 14, 2011, 11:51:20 am »
There is also much more space, so pictures might be possible.
And adding support for styling/different font sizes isn't too hard either :)

Pictures are definitely a possibility, but I haven't come up with an easy, user-friendly way of getting pictures (like covers, maps, and chapter delimiters) embedded in the correct position in the book.
Styling is limited in Lua for the nspire to only "serif" and "sansserif" fonts. Font sizing is already supported (use +/-) to increase/decrease font size.

wow. how big will be the file per page?

Size depends a lot on how easily the book can be compressed, but a 600 page book (The Three Musketeers) ended up being about 580 KB, so I would say roughly 1 KB per physical page.

D: I got:


Error: Failed attempt to launch program or document:
Action: <totns.bat>
Params: <"test">

Specifically: Le fichier spédifié est introuvable


        Line#
--->  012: Run,totns.bat "%bookName%"

The current thread will exit.


I dragged and dropped the txt file on the exe with all the needed files in the folder ??? I don't know what the problem is

Whoops. Looks I forgot to package one of the files. Should be fixed now. Try downloading it again.
« Last Edit: December 14, 2011, 12:02:57 pm by whatkindofausernameisthis »

Offline Jim Bauwens

  • Lua! Nspire! Linux!
  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1881
  • Rating: +206/-7
  • Linux!
    • View Profile
    • nothing...
Re: Lua-based Ebook Reader (Does not require ndless)
« Reply #8 on: December 14, 2011, 01:14:39 pm »
Pictures are definitely a possibility, but I haven't come up with an easy, user-friendly way of getting pictures (like covers, maps, and chapter delimiters) embedded in the correct position in the book.
Styling is limited in Lua for the nspire to only "serif" and "sansserif" fonts. Font sizing is already supported (use +/-) to increase/decrease font size.

Well, I think a xml based system should be quite possible. To my experience nspire Lua should be fast enough to do this.
You could make something as simple as <img tree>, where tree would be a reference to a TI.Image variable. Get the width/height of the image, and just behave like the image would a bunch of new lines.

Also, you *could* make your own font with images. To improve the speed though they would have to be black+alpha though.
« Last Edit: December 14, 2011, 01:28:46 pm by jimbauwens »

Offline Lionel Debroux

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2135
  • Rating: +290/-45
    • View Profile
    • TI-Chess Team
Re: Lua-based Ebook Reader (Does not require ndless)
« Reply #9 on: December 14, 2011, 01:26:24 pm »
Why not a non-XML, but markup-based, language inspired by the one used by Hib-View and uView ? :)
Member of the TI-Chess Team.
Co-maintainer of GCC4TI (GCC4TI online documentation), TILP and TIEmu.
Co-admin of TI-Planet.

Offline Jim Bauwens

  • Lua! Nspire! Linux!
  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1881
  • Rating: +206/-7
  • Linux!
    • View Profile
    • nothing...
Re: Lua-based Ebook Reader (Does not require ndless)
« Reply #10 on: December 14, 2011, 01:36:19 pm »
That format doesn't look bad, and will be more easy to add :)
Thanks for the tip Lionel.

(http://www.hibnet.org/ti/hiblib/hibLib-tagsdoc/)

Offline ExtendeD

  • CoT Emeritus
  • LV8 Addict (Next: 1000)
  • *
  • Posts: 825
  • Rating: +167/-2
    • View Profile
Re: Lua-based Ebook Reader (Does not require ndless)
« Reply #11 on: December 14, 2011, 01:48:50 pm »
What about adapting this Lua implemention of Markdown? http://luaforge.net/projects/markdown/
Ndless.me with the finest TI-Nspire programs

Offline Reo

  • LV3 Member (Next: 100)
  • ***
  • Posts: 64
  • Rating: +15/-0
    • View Profile
Re: Lua-based Ebook Reader (Does not require ndless)
« Reply #12 on: December 14, 2011, 02:59:23 pm »
Well at this point you might as well write an EPUB reader.

Offline cyanophycean314

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 363
  • Rating: +43/-1
  • It's You!
    • View Profile
Re: Lua-based Ebook Reader (Does not require ndless)
« Reply #13 on: December 14, 2011, 04:46:35 pm »
I thought you could use gc:setFont('serif','b',x) for bold type font in Lua.

Offline Jim Bauwens

  • Lua! Nspire! Linux!
  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1881
  • Rating: +206/-7
  • Linux!
    • View Profile
    • nothing...
Re: Lua-based Ebook Reader (Does not require ndless)
« Reply #14 on: December 14, 2011, 05:12:51 pm »
Yes, but we are thinking how to store the markup in the file :)