💾 Archived View for gem.girlmeow.autos › log › log › 2022-12-09%20Making%20a%20gemini%20browser.gmi captured on 2023-01-29 at 15:52:14. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2023-01-29)

-=-=-=-=-=-=-

Making a gemini browser

📝Back to log

🏠Back to home

Well, I wasn't feeling super motivated yesterday to do it but I felt like using the computer today, so I started tackling my next pet project of making a Gemini browser. Originally I was gonna do a proper GUI one with PyQt or something but I didn't feel like it today, so I decided I'd make a terminal based one with Curses instead for now, and do something more graphical later (so 21st century).

Day one it's already pretty functional; it nicely displays text and does what formatting can be done in a terminal for links and headings and whatever. I got the socket + SSL library in there so it can look at local files as well as stuff online (obviously pretty important). The main thing for it's functionality that I got going is you can follow links in the browser. It can tell if the links are relative or not or if they point to other domains or protocols, but so far I haven't gotten it to handle other protocols yet. I'll also add mouse support if I can, but since it's in a terminal I'm trying to make sure it's fully and easily navigable with a keyboard first.

I have to refactor a bunch of stuff that's jank and hardcoded into a million globals tomorrow or whenever. Right now it just stores all the information that's loaded for the page into some disparate global arrays, but one of my priorities is adding multiple tab support, so I need to move all the stupid global arrays into tab objects.

I get to use recursion, too... here's some pseudocode of roughly how the word wrapping works:

function break_line(array, index, wrapping_width):
  if array[index].length > wrapping_width:
    old_line = array[index][0:index_of_first(" ")]
    new_line = array[index][index_of_first(" "):end_of_string]
    array[index] = old_line
    array.insert(new_line at index+1)
    break_line(array, index+1, wrapping_width)

lines = split(delimiter="\n", page_contents)
for i = lines.length, i>=0, i--:
  break_line(lines, i, wrapping_width)

eh?

...yea whatever, everyone else in this place can program way above my paygrade. Don't roll your eyes at me LOL

But anyway I have high hopes for this project. Could turn into something pretty cute, and I wanna put my little piece of something into gemspace too. I think I can make a pretty fully functional browser with the tools I've got now. I wanna add all the other bells and whistles over time, bookmarks, browser history, feed subscriptions, and what little customization is possible. More pressingly though, I also need to get server certificate verification, client certificate generation support, and the ability to download unsupported files, as well as do something reasonable with https links (and whatnot). Probably though I'll get it to at least have some basic support for rendering whatever is encoded in utf-8, even though that probably just involves looking at raw HTML and such. Oh, and support for terminals that don't display colour.

I got my work cut out for me...

★Star