Term::...::Base(3pm)

πŸ“¦
version 0.07 Β· 2 versions
  • 0.07 Β· debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 0.07 Β· ubuntu jammy
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– Term::...::Base β€” the atomic routines page, bestie edition πŸ’–

okay so you know Term::ReadLine::Zoid? This is the little base class underneath all of it β€” Term::ReadLine::Zoid::Base, from the User Contributed Perl Documentation, and it's literally just the atomic routines that every single Zoid object leans on. It's meant to be a base class, so don't go instantiating it like it's the main character. 🫢


✨ NAME ✨

Term::ReadLine::Zoid::Base β€” atomic routines. tiny building blocks, huge slay. πŸ’…


🌸 DESCRIPTION 🌸

This module is where all the small atomic operations live, and every Term::ReadLine::Zoid object uses them. Think of it as a base class, not a finished product β€” it's giving scaffolding, not penthouse. πŸŽ€

At the very least, a child class needs two things to even function:

  1. a default() function, so it can handle key bindings
  2. a draw() function, which in turn calls print()

And also β€” this part is not optional, bestie β€” the attributes IN and OUT should contain valid filehandles. no filehandles, no vibes. πŸ™ˆ


πŸ¦‹ METHODS πŸ¦‹

🌈 ANSI stuff

  • cursor_at($x, $y) β€” puts the cursor on the screen at that spot. heads up: the dimensions are 1-based, not 0-based, so don't come at it with programmer-brain. πŸ“
  • clear_screen() β€” clears the screen. that's it. that's the whole method. iconic minimalism. ✨
  • title($string) β€” sets the terminal title to $string. if you're using something like xterm(1), this is the window name you're setting. 🏷️
  • print_length($string) β€” returns the printable length of $string, and it does not count (some) ansi sequences. so escape codes don't inflate your count. lowkey the hero of the page. πŸ“

πŸ”’ Private api

These methods are for use in overload classes. Please avoid using them from the application. like, they're backstage. you do not have a backstage pass. πŸ™…

  • bell() β€” notify the user of an error or limit. πŸ””
  • loop() β€” a low level function used by readline. it calls draw() and do_key(). πŸ”
  • beat() β€” a method called by intervals while waiting for input, meant to be overloaded. πŸ’“
  • read_key() β€” returns one key read from input. and note bestie: this is the named key, not the char, when it's been mapped. ⌨️
  • do_key($key) β€” execute a key; calls the subroutine for a key binding, or the default binding. if $key is undefined, read_key() gets called first. 🎯
  • press($string) β€” does the chars in $string like they were typed on the keyboard. used for testing puposes and to make macros possible.
if you give more then one argument, these are considered individual characters β€” use this to press named keys. 🫰
  • unread_key($string) β€” unshifts characters on the read buffer. arguments are the same as press(). βͺ
  • key_name($chr) β€” returns a name for a character or character sequence. 🏷️
  • key_binding($key, $mode) β€” returns the keybinding for $key in $mode. $mode defaults to the current one. πŸ—ΊοΈ
  • bindchr($chr, $key) β€” bind a key name to a character, or a character sequence. all bindings of this kind are global β€” and honestly, (you're using only one keyboard, right ?) 😭
  • recalc_chr_map() β€” recalculates the chr map. you need to call this after deleting from %chr_names. don't skip it, fr fr. ♻️
  • print($lines, $pos) β€” low level function used by draw. both arguments need to be array references. πŸ“š

πŸ’€ BUGS πŸ’€

Undefined behaviour when the buffer has more lines then the terminal. so like… don't do that. πŸ™ˆ

Please mail the author if you find any other bugs. they want to know!! 🫢


πŸ‘‘ AUTHOR πŸ‘‘

Jaap Karmsenberg || Pardus [Larus] <pardus@cpan.org>

Copyright (c) 2004 Jaap G Karmsenberg. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


🌟 SEE ALSO 🌟

  • Term::ReadLine::Zoid

and that's the whole page, bestie β€” no cap, every flag, every method, every caveat, all accounted for. πŸ’œ

cute little sign-off: this page ships as part of perl v5.34.0, dated 2022-06-17. go forth and bind some keys. slay. πŸ’…βœ¨

πŸ“¦ where this page comes from