Skip to content

Instantly share code, notes, and snippets.

@DinisCruz
Created August 16, 2013 00:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DinisCruz/6246348 to your computer and use it in GitHub Desktop.
Save DinisCruz/6246348 to your computer and use it in GitHub Desktop.
O2 Script - Util - Quick Hex File Viewer
//var topPanel = panel.clear().add_Panel();
var topPanel = "Tool - Quick Hex File Viewer".popupWindow(650,400);
var tableList = topPanel.add_TableList();
tableList.field("resizeColumnsWidth",false);
tableList.links().forEach<Control>(link=>link.visible(false));
tableList.add_Columns("0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","","As String");
tableList.set_ColumnsWidth(25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,50);
tableList.white();
var infoLabel = tableList.add_Label("Drop file here to view its Hex/Bytes \n\n (recommended max size of 50k)").font("Arial",25).fill().text_Center();
Action<string> showFile =
(file)=>{
infoLabel.set_Text("...Loading...");
tableList.listView().visible(false);
tableList.clearRows().title(file);
O2Thread.mtaThread(
()=>{
var bytes = file.fileContents_AsByteArray().toList();
var blocksOf16 = (bytes.size() / 16);
for(var i=0 ; i <= blocksOf16 ; i++)
{
var pos = i*16;
var asString = "";
var rowData = new List<string>();
for(var j=0; j< 16; j++)
{
rowData.add(bytes.value(pos+j).hex());
asString += (char)bytes.value(pos+j);
}
rowData.add("").add(asString);
tableList.add_Row(rowData);
}
tableList.listView().visible(true);
});
};
tableList.listView().visible(false);
tableList.onDrop(showFile);
tableList.listView().onDrop(showFile);
//showFile("O2Logo_Small.gif".local());
//O2Embed:Utility.ico
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment