<?php
$file = "/path/to/source.asm";
$frame = new wxFrame(null, wxID_TOP, "NASM_IDE: $file", wxDefaultPosition, new wxSize(800, 800) );
$frame->SetFont(new wxFont(12, wxFONTFAMILY_TELETYPE, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, "freemono"));
$stc = new wxStyledTextCtrl($frame, wxID_ANY, new wxPoint(10, 10), new wxSize(780, 780));
$stc->Connect(wxEVT_STC_CHANGE, array(wxID_TOP, "textchanged"));
$stc->SetMarginType(0, wxSTC_MARGIN_NUMBER);
$stc->SetMarginWidth(0, 50);
$stc->SetMarginWidth(1, 1);
$stc->SetMarginWidth(2, 1);
$stc->SetUseHorizontalScrollBar(false);
$stc->SetUseTabs(true);
$stc->SetTabWidth(8);
$stc->SetLexer(wxSTC_LEX_ASM);
$stc->StyleSetFont(0, new wxFont(12, wxFONTFAMILY_TELETYPE, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, "freemono"));
$stc->StyleSetForeground(wxSTC_ASM_COMMENT, new wxColour(0, 128, 0)); //OK
$stc->StyleSetForeground(wxSTC_ASM_STRING, new wxColour(180, 0, 0)); //OK
$stc->StyleSetForeground(wxSTC_ASM_NUMBER, new wxColour(180, 0, 0)); //OK
$stc->StyleSetForeground(wxSTC_ASM_OPERATOR, new wxColour(0, 0, 128)); //no change
$stc->StyleSetForeground(wxSTC_ASM_CPUINSTRUCTION, new wxColour(0, 60, 0));
$stc->StyleSetBold(wxSTC_ASM_CPUINSTRUCTION, true);
$stc->StyleSetForeground(wxSTC_ASM_DIRECTIVE, new wxColour(0, 60, 128));
$stc->StyleSetForeground(wxSTC_ASM_REGISTER, new wxColour(80, 80, 0));
$stc->StyleSetForeground(wxSTC_ASM_CHARACTER, new wxColour(80, 80, 0));
$stc->StyleSetForeground(wxSTC_ASM_DEFAULT, new wxColour(80, 80, 0));
$frame->Show();
wxEntry();
function OnInit()
{ global $file, $stc;
$stc->SetValue(file_get_contents($file));
}
?>
BITS 64
SECTION .data
int32: equ 2147483647
string: db "a string",10
str_len: equ $-string
SECTION .text
global _start
_start:
mov rax,1 ; call = write
mov rdi,1 ; fd = stdout
mov rsi,string ; *buf = string
mov rdx,str_len ; n = string_len
syscall
mov rax,60 ;syscall exit
mov rdi,0 ;return value
syscall
I have some difficulty with wxStyledTextCtrl() too.
Maybe I don't understand, but :
I imagined SetLexer() would automatically bring in a colouring scheme, but it doesn't.
Some of the specific StyleSetForeground()s work and some don't.
StyleSetBold() doesn't work.
$frame->SetFont() works on other controls, but doesn't work on wxStyledTextCtrl().
$stc->StyleSetFont() doesn't work either.
The event constant wxEVT_STC_CHANGE works, but is not listed in http://wxphp.org/reference/constants.html
source.asm :