Utility Library API - brombres/Rogue GitHub Wiki

Clipboard.rogue

class Clipboard [singleton]

extends Object

Methods

Signature Return Type Description
bitmap() Bitmap
set_bitmap( bitmap:Bitmap )

class LinuxClipboard [singleton]

extends Object

Description

Implemented with assistance from: - https://stackoverflow.com/a/27995840/135791 - https://stackoverflow.com/questions/18695934/error-cant-open-display-null-when-using-xclip-to-copy-ssh-public-key - https://emacs.stackexchange.com/questions/39019/xclip-hangs-shell-command

Methods

Signature Return Type Description
bitmap( [type="png":String] ) Bitmap
set_bitmap( bitmap:Bitmap )
temp_file( [extension="png":String] ) File

class MacOSClipboard [singleton]

extends Object

Methods

Signature Return Type Description
bitmap() Bitmap
set_bitmap( bitmap:Bitmap )

class WindowsClipboard [singleton]

extends Object

Methods

Signature Return Type Description
bitmap( [existing_bitmap=null:Bitmap] ) Bitmap
open() Logical
set_bitmap( bitmap:Bitmap ) Adapted from https://stackoverflow.com/a/66401824/135791

CURL.rogue

class CURL

extends Object

Properties

Name Type Description
follow_redirects Logical
result ProcessResult
url String

Methods

Signature Return Type Description
init( url:String )
fetch() ProcessResult
fetch_bytes() Byte[]
fetch_string() String

Epilog.rogue

class Epilog [singleton]

extends Object

incorporates PrintWriter, BufferedPrintWriter<<$buffer>>

Description

Epilog is a PrintWriter log that stores all output in memory or in a file, optionally echoing to standard output. If the output is not stored to a file then all collected output is printed on program termination (including CTRL+C but not including an uncaught exception).

USAGE
  uses Utility/Epilog
  ...
  Epilog.configure( File("Log.txt"), &echo ) # optional
  ...
  Epilog.println "XYZ"
  ...

Properties

Name Type Description
buffer String
echo Logical
file File?
history String
is_finished Logical
writer PrintWriter

Methods

Signature Return Type Description
init()
close()
configure( [file=null:File?], [echo=false:Logical] )
flush()
flush( buffer:String )
indent() Int
on_finish()
print( value:Byte )
print( value:Character )
print( value:Int32 )
print( value:Int64 )
print( value:Logical )
print( value:Object )
print( value:Real64 )
print( value:Real64, decimal_places:Int32 )
print( value:String )
println()
println( value:Byte )
println( value:Character )
println( value:Int32 )
println( value:Int64 )
println( value:Logical )
println( value:Object )
println( value:Real64 )
println( value:Real64, decimal_places:Int32 )
println( value:String )
set_indent( new_indent:Int )

Expression.rogue

class AddExpression

extends BinaryExpression

Properties

Name Type Description
left Expression
right Expression

Methods

Signature Return Type Description
call() Variant
symbol() String

class BinaryExpression

extends Expression

Properties

Name Type Description
left Expression
right Expression

Methods

Signature Return Type Description
init( left:Expression, right:Expression )
symbol() String
to<<String>>() String

class DivideExpression

extends BinaryExpression

Properties

Name Type Description
left Expression
right Expression

Methods

Signature Return Type Description
call() Variant
symbol() String

class Expression

extends Object

Global Methods

Signature Return Type Description
parse( command:String, [id_lookup=null:Function(String)->Expression] ) Expression

Methods

Signature Return Type Description
call() Variant

class ExpressionParser [singleton]

extends Object

Properties

Name Type Description
id_lookup Function(String)->Expression
scanner Scanner
symbols String[]
token_reader Reader<<Variant>>
tokens Variant[]

Methods

Signature Return Type Description
consume( symbol:String ) Logical
must_consume( symbol:String )
next_is_identifier() Logical
next_is_number() Logical
parse_add_sub() Expression
parse_expression() Expression
parse_mul_div_mod() Expression
parse_post_unary() Expression
parse_pow() Expression
parse_pre_unary() Expression
parse_term() Expression
parse( command:String, [id_lookup=null:Function(String)->Expression] ) Expression
parse_add_sub( left:Expression ) Expression
parse_identifier( id:String ) Expression
parse_mul_div_mod( left:Expression ) Expression
parse_post_unary( operand:Expression ) Expression
parse_pow( left:Expression ) Expression
scan_identifier() String
scan_number() Variant
tokenize()
tokenize_another() Logical

class ModuloExpression

extends BinaryExpression

Properties

Name Type Description
left Expression
right Expression

Methods

Signature Return Type Description
call() Variant
symbol() String

class MultiplyExpression

extends BinaryExpression

Properties

Name Type Description
left Expression
right Expression

Methods

Signature Return Type Description
call() Variant
symbol() String

class NegateExpression

extends UnaryExpression

Properties

Name Type Description
operand Expression

Methods

Signature Return Type Description
call() Variant
symbol() String

class NumberExpression

extends Expression

Properties

Name Type Description
value Variant

Methods

Signature Return Type Description
init( value:Variant )
call() Variant
to<<String>>() String

class PowerExpression

extends BinaryExpression

Properties

Name Type Description
left Expression
right Expression

Methods

Signature Return Type Description
call() Variant
symbol() String

class SubtractExpression

extends BinaryExpression

Properties

Name Type Description
left Expression
right Expression

Methods

Signature Return Type Description
call() Variant
symbol() String

class UnaryExpression

extends Expression

Properties

Name Type Description
operand Expression

Methods

Signature Return Type Description
init( operand:Expression )
symbol() String
to<<String>>() String

FilePatcher.rogue

class FileDiff

extends Object

Properties

Name Type Description
hunks FileDiffHunk[]

Methods

Signature Return Type Description
init( diff:String )
init( file:File )
apply( lines:String[] )

class FileDiffAddLine

extends FileDiffLine

Properties

Name Type Description
index Int32
text String

Methods

Signature Return Type Description
init( index:Int32, text:String )
apply( n:Int32, line_rewriter:ListRewriterObject<<String>> ) Int32

class FileDiffContextLine

extends FileDiffLine

Properties

Name Type Description
index Int32
text String

Methods

Signature Return Type Description
init( index:Int32, text:String )
apply( n:Int32, line_rewriter:ListRewriterObject<<String>> ) Int32

class FileDiffHunk

extends Object

Properties

Name Type Description
first_line_index Int32
last_line_index Int32
lines FileDiffLine[]

Methods

Signature Return Type Description
init( first_line_index:Int32, count:Int32 )
contains( n:Int32 ) Logical

class FileDiffLine

extends Object

Properties

Name Type Description
index Int32
text String

Methods

Signature Return Type Description
init( index:Int32, text:String )
apply( n:Int32, line_rewriter:ListRewriterObject<<String>> ) Int32

class FileDiffRemoveLine

extends FileDiffLine

Properties

Name Type Description
index Int32
text String

Methods

Signature Return Type Description
init( index:Int32, text:String )
apply( n:Int32, line_rewriter:ListRewriterObject<<String>> ) Int32

class FilePatcher

extends Object

Properties

Name Type Description
file File
is_modified Logical
lines String[]

Methods

Signature Return Type Description
init( file:File )
add( text:String )
apply( diff:FileDiff )
contains( text:String ) Logical
delete( line_index:Int32 )
insert( text:String, [before_index=0:Int32] )
is_empty() Logical
locate( text:String, [i1=0:Int32] ) Int32?
locate_last( text:String, [i1=null:Int32?] ) Int32?
locate_last_pattern( pattern:String ) Int32?
locate_pattern( pattern:String ) Int32?
replace( old_string:String, new_string:String, &first, &last ) Logical
replace_line( index:Int32, new_text:String ) Logical
replace_line( old_line_pattern:String, new_line:String, &all ) Logical
save( [new_file=null:File?] ) Logical

GitIgnorePatcher.rogue

class GitIgnoreLine

extends Object

Properties

Name Type Description
is_new Logical
pattern String

Methods

Signature Return Type Description
init( pattern:String, [is_new=false:Logical] )

class GitIgnorePatcher

extends Object

Properties

Name Type Description
file File
is_modified Logical
sections [String:GitIgnoreSection]

Methods

Signature Return Type Description
init( file:File )
add( section_name:String, pattern:String ) Logical Returns false if all lines in 'pattern' are already in the .gitignore
add( section_name:String, patterns:String[] ) Logical
print_new_entries( [prefix="":String] )
remove( pattern:String ) Logical Returns false if the .gitfile did not contain the pattern.
save( [save_as=null:File?], &verbose ) Logical Returns false on error.
to<<String>>() String

class GitIgnoreSection

extends Object

Properties

Name Type Description
is_new Logical
lines GitIgnoreLine[]
name String
removals String[]

Methods

Signature Return Type Description
init( name:String, [is_new=false:Logical] )
add( pattern:String, &is_new ) Logical Returns false if pattern is already present.
contains( pattern:String ) Logical
is_modified() Logical
print( builder:String )
print_new_entries( prefix:String )
remove( pattern:String ) Logical

GitRepo.rogue

class GitRepo [compound]

incorporates CommonCompoundMethods

Description

A simple wrapper for command-line Git. Git must be installed separately.

EXAMPLE

  uses Utility/GitRepo

  local repo = GitRepo( "https://github.com/brombres/LSPath.git", File("LSPath") )
  if (repo.exists)
    if (not repo.has_local_changes and repo.has_remote_changes)
      repo.pull( &verbose )
    endIf
  else
    repo.clone( &verbose )
  endIf

  @trace repo.branches

  if (not repo.local_branch_exists("test_branch_1"))
    repo.create_branch( "test_branch_1", &verbose )
  endIf
  repo.checkout( "test_branch_1", &verbose )

  repo.checkout( "test_branch_2", &create_branch, &verbose )
  File("LSPath/TestFile.txt").save( "Test file content" )
  repo.add( "TestF*.txt" )
  repo.commit( "[TestFile]", &verbose )

  repo.checkout( "test_branch_1" )
  repo.pull
  repo.merge_from( "test_branch_2", &verbose )
  repo.push( &verbose )

  repo.delete_local_branch( "test_branch_2", &verbose )
  repo.checkout( "main", &verbose )
  repo.delete_branch( "test_branch_1", &verbose )

Global Methods

Signature Return Type Description
create( folder:File ) GitRepo
create( url:String, folder:File ) GitRepo

Properties

Name Type Description
folder File
url String

Methods

Signature Return Type Description
add( file:File, &verbose ) Logical
add( pattern:String, &verbose ) Logical
branch() String
branches() String[]
checkout( branch:String, &create_branch, &verbose ) Logical
clone( [branch=null:String], &verbose ) Logical
commit( message:String, &all, &allow_empty, &verbose ) Logical
create_branch( branch:String, &verbose ) Logical
delete_branch( branch_name:String, &verbose ) Logical
delete_local_branch( branch_name:String, &verbose ) Logical Deletes the specified branch locally. The specified branch cannot be the current branch.
delete_remote_branch( branch_name:String, &verbose ) Logical Deletes the specified branch from the origin.
description() String
exists() Logical
has_local_changes() Logical
has_remote_changes() Logical Note: the response may take a few moments. Due to the delay it is not recommended to automatically call this method frequentlly.
head( &short ) String
local_branch_exists( branch_name:String ) Logical
merge_from( from_branch:String, &verbose ) Logical
operator==( other:GitRepo ) Logical
print_to( buffer:PrintWriter )
pull( &verbose ) Logical
push( &force, &verbose ) Logical Pushes this branch to the origin, setting up remote tracking if necessary.
set_origin( url:String, &verbose ) Logical
tag() String
to<<Object>>() Boxed<<GitRepo>>
to<<String>>() String
to<<Variant>>() Variant
type_info() TypeInfo

TextDocFormatter.rogue

class TextDocFormatter

extends Object

Properties

Name Type Description
cur_indent String
cur_line String
max_width Int32
result String
tab_spaces String
tab_width Int Used for word wrap line length calculations. Leading tabs are preserved but internal tabs are converted to this many spaces.

Methods

Signature Return Type Description
format( text:String, [max_width=80:Int32], &console_width_limited=true ) String
indent_length( text:String ) Int32
leading_indent( text:String ) String
output_cur_line()

Timer.rogue

class Timer

extends Object

Properties

Name Type Description
counting_down Logical
duration Real
start_time Real
stop_time Real?

Methods

Signature Return Type Description
init( &stopped )
init( duration:Real, &stopped, &expired )
elapsed() Real
elapsed_ms() Int64
is_expired() Logical
is_running() Logical
is_stopped() Logical
operator+( delta_time:Real ) Timer Increase the elapsed interval of this stopwatch.
operator-( delta_time:Real ) Timer Decrease the elapsed interval of this stopwatch.
progress() Real Count-down: returns elapsed / duration Count-up: returns 0
remaining() Real If a count-up timer, returns 0. If count-down, return 0 <= seconds remaining <= duration.
restart()
restart( duration:Real )
start() Starts if currently stopped; otherwise no effect.
stop() Stops if currently running; otherwise no effect.
to<<String>>() String

UUID.rogue

class UUID

extends Object

Properties

Name Type Description
as_string String
bytes Byte[]

Methods

Signature Return Type Description
init()
to<<String>>() String

VariantListPool.rogue

class VariantListPool [singleton]

extends RecyclePool<<Variant>>

Description

USAGE
  # High GC impact if called frequently
  obj.call( @[1,2] )

  # Low/No GC impact if called frequently
  uses Utility/VariantListPool
  ...
  use args = VariantListPool
    args.add( 1 )
    args.add( 2 )
    obj.call( args )
  endUse

Properties

Name Type Description
available Variant[]

Methods

Signature Return Type Description
on_use() Variant
on_end_use( value:Variant )

VersionNumber.rogue

class VersionNumber [compound]

incorporates CommonCompoundMethods

Global Methods

Signature Return Type Description
create( version:String ) VersionNumber

Properties

Name Type Description
version String

Methods

Signature Return Type Description
count() Int32
description() String
is_compatible_with( other:String ) Logical
is_compatible_with( other:VersionNumber ) Logical Returns true if all parts of the shorter version are equal to the corresponding parts of the longer version.

Examples
  VersionNumber("3").is_compatible_with("3.2") -> true
  VersionNumber("3.1").is_compatible_with("3.2") -> false
operator<>( other:String ) Int
operator<>( other:VersionNumber ) Int Compares two multipart versions and returns:
  -1 if this < other
   0 if this = other
   1 if this > other

Each version can have any number of parts; mismatched numbers of parts are allowed. "Missing" parts are treated as 0.

No allocations are made to perform the comparison.

Examples:

  compare_versions("1.0", "1.0.0") -> 0
  compare_versions("1.0", "1.0.1") -> -1
  compare_versions("1.10.0","1.2.3") -> 1
operator==( other:VersionNumber ) Logical
part( n:Int32 ) Int32
print_to( buffer:PrintWriter )
to<<Object>>() Boxed<<VersionNumber>>
to<<String>>() String
to<<Variant>>() Variant
type_info() TypeInfo
⚠️ **GitHub.com Fallback** ⚠️