Repository navigation
wxStyledTextCtrl::SetLexer() #105
Copy link
Copy link
Open
Description
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
<?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));
}
?>
source.asm :
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
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
jgmdev commentedon Nov 22, 2015
wxStyledTextCtrl is one of the less documented components of wxWidgets, the constant wxEVT_STC_CHANGE that you mentioned wasn't available on the wxWidgets documentation in a easy to parse form, and I had to push it directly into the wxPHP generator by manually reading the C++ header file, that's why It isn't listed on the generated wxPHP documentation. On Christmas I get less busy from normal job so I will try to resolve some of the issues listed on github, but I'm not sure if I should give more priority to working on generating PHP 7 compatible code in order for wxPHP to keep working on the future releases of PHP.
I indeed believe that targeting PHP 7 has higher priority right now, what do you think?