Skip to content

Instantly share code, notes, and snippets.

@NoahBres
Created February 26, 2021 19:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NoahBres/ebcf955f7ad11245b83992dfe0201ed3 to your computer and use it in GitHub Desktop.
Save NoahBres/ebcf955f7ad11245b83992dfe0201ed3 to your computer and use it in GitHub Desktop.
public class RubaiyatPOC extends LinearOpMode {
public void runOpMode() {
telemetry = new Rubaiyat(Rubayait.getInstance(), telemetry);
Rubayait.Style r = new Rubaiyat.Style;
telemetry.clear();
// Rubaiyat should convert to html display format transparently
telemetry
.addLine(
"Title",
r.bold,
r.center,
r.italic,
r.red,
),
.addLine()
// list automatically switch to monospace to
.addList(
r.listStyle.dot,
r.paddingLeft(3),
r.separator(": "), // default is colon space
r.alignSeparator(true) // true by default
)
// if item is called w/o preceding list, a list will be created transparently
// addline will break out of a list
.item("title", value, r.red)
.item("title", value, r.underline.if(() -> value > 3)) // conditional styles
.item("tag", value, r.red) // if styles are applied after both tag and value, then styles are applied to both
.item(r.text("tag", r.red), value) // styles can be isolated using r.span
.item("tag", r.text(value, r.underline))
// Group share the same styles
// Lists are just groups
.startGroup(r.blue, r.underline)
.addLine("text")
.addText("text", r.start) // text can do start, middle, end. prepends, appends and the end, or middle
// the aligns only work in an addText tag
// addText can take a r.text tag. does the same thing.
.addText("test", r.textWidth(5, "start")) // text width keeps text constant width
// text width should be ignored in list items
.endGroup()
.addData("tag", value, r.truncate(10, '...')) // truncate does 10 chars including '...'
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment