This project is read-only.

Styles are overwritten?

Topics: Developer Forum, User Forum
Apr 11, 2015 at 2:54 AM
Edited Apr 11, 2015 at 3:21 AM
So, I'm programming my custom styles for my disassembler. Unfortunately, it seems like it always overwrites the style to the latest characters. Here my code:
            if (Base)
            {
                ITypeBase Instr = new ITypeBase();
                Instr = BaseTypeSplit(bits, Instr);
                
                Disassemble._dis.updateOP(CheckOpcode(Instr.opcode) + " ");
                Disassemble._dis.updateREG(CheckReg(Instr.rt));
                Disassemble._dis.updateCOMMA(", ");
                Disassemble._dis.updateIMM(CheckImm(Instr.imm));
                Disassemble._dis.updateREGB("(" + CheckReg(Instr.@base) + ")");
            }
Yes, my main code calls the scintilla Box from another class. I use my constructor from the other class (_dis = this;) to access it.

And here my functions which do the styling:

        public Disassemble()
        {
            InitializeComponent();
            _dis = this;
         }

        public static Disassemble _dis;


        public void updateOP(string message)
        {
            int length = scintilla1.TextLength; 
            int length2 = message.Length; 
            int sum = length + length2; 

            scintilla1.Styles[1].Font = new Font("Arial", 25, FontStyle.Bold);
            scintilla1.Styles[1].ForeColor = Color.FromArgb(255, 128, 0);
            scintilla1.Text += message;

            int n = length;

            while (length < sum)
            {
                scintilla1.GetRange(n).SetStyle(1);
                n = length + 1;
                length += 1;
            }
        }

        public void updateREG(string message)
        {
            int length = scintilla1.TextLength; 
            int length2 = message.Length;
            int sum = length + length2; 

            scintilla1.Styles[2].Font = new Font("Arial", 25, FontStyle.Bold);
            scintilla1.Styles[2].ForeColor = Color.FromArgb(128, 0, 0);
            scintilla1.Text += message;

            int n = length;

            while (length < sum)
            {
                scintilla1.GetRange(n).SetStyle(2);
                n = length + 1;
                length += 1;
            }
        }

        public void updateREGB(string message)
        {
            int length = scintilla1.TextLength; 
            int length2 = message.Length; 
            int sum = length + length2; 

            scintilla1.Styles[5].Font = new Font("Arial", 25, FontStyle.Bold);
            scintilla1.Styles[5].ForeColor = Color.FromArgb(172, 172, 172);
            scintilla1.Text += message;

            int n = length;

            while (length < sum)
            {
                scintilla1.GetRange(n).SetStyle(5);
                n = length + 1;
                length += 1;
            }
        }

        public void updateCOMMA(string message)
        {
            int length = scintilla1.TextLength;
            int length2 = message.Length;
            int sum = length + length2;

            scintilla1.Styles[3].Font = new Font("Arial", 25, FontStyle.Bold);
            scintilla1.Styles[3].ForeColor = Color.FromArgb(0, 0, 0);
            scintilla1.Text += message;

            int n = length;

            while (length < sum)
            {
                scintilla1.GetRange(n).SetStyle(3);
                n = length + 1;
                length += 1;
            }
        }

        public void updateIMM(string message)
        {
            int length = scintilla1.TextLength;
            int length2 = message.Length;
            int sum = length + length2;

            scintilla1.Styles[4].Font = new Font("Arial", 25, FontStyle.Bold);
            scintilla1.Styles[4].ForeColor = Color.FromArgb(0, 0, 255);
            scintilla1.Text += message;

            int n = length;

            while (length < sum)
            {
                scintilla1.GetRange(n).SetStyle(4);
                n = length + 1;
                length += 1;
            }
        }
And this is what I get, always:
Image

I've tried some (horrible) ways, but they also didn't result in what I wanted. Does someone have an idea what could be the cause of this? For additional information, I use Visual Studio 2012, .NET 4.5
Apr 29, 2015 at 3:25 AM
Please read the documentation regarding "Custom Syntax Highlighting" at the new GitHub repo:
https://github.com/jacobslusser/ScintillaNET

If you still have additional questions you can PM me via the GitHub repo or open an issue there. Support at CodePlex has discontinued.


Thanks,
Jacob