예제 #1
0
        void ExportSelectedItemsToBASIC(C64Models.BASIC.Dialect Dialect)
        {
            foreach (ListViewItem item in listFiles.SelectedItems)
            {
                RetroDevStudio.Types.FileInfo fileToExport = (RetroDevStudio.Types.FileInfo)item.Tag;

                ExportToBASIC(fileToExport, Dialect);
            }
        }
예제 #2
0
        private void ExportToBASIC(Types.FileInfo fileToExport, C64Models.BASIC.Dialect Dialect)
        {
            RetroDevStudio.Types.FileInfo fileInfo = null;

            if (m_Media != null)
            {
                fileInfo = m_Media.LoadFile(fileToExport.Filename);
            }
            if (fileInfo != null)
            {
                if (fileInfo.Data.Length >= 2)
                {
                    //if ( startAddress == 0x0801 )
                    {
                        // can only load from that address

                        List <string> lines;

                        // trunc load address
                        var parser = new Parser.BasicFileParser(new Parser.BasicFileParser.ParserSettings());
                        parser.SetBasicDialect(Dialect);
                        if (parser.Disassemble(fileInfo.Data.SubBuffer(2), out lines))
                        {
                            var document = new SourceBasicEx(Core);
                            document.ShowHint = DockState.Document;

                            document.Core = Core;
                            document.Show(Core.MainForm.panelMain);
                            document.SetBASICDialect(Dialect);

                            StringBuilder sb = new StringBuilder();
                            foreach (string line in lines)
                            {
                                sb.AppendLine(line);
                            }
                            document.FillContent(sb.ToString(), false);
                        }
                    }
                }
            }
        }
예제 #3
0
        public override void HighlightSyntax(Language Language, Range ChangedRange)
        {
            if (_Parser.Settings.BASICDialect == null)
            {
                _Dialect = C64Models.BASIC.Dialect.BASICV2;
                _Parser.Settings.BASICDialect = _Dialect;
            }
            // get full lines in covered range
            int firstLine = ChangedRange.Start.iLine;
            int lastLine  = ChangedRange.End.iLine;

            if (firstLine > lastLine)
            {
                int dummy = firstLine;
                firstLine = lastLine;
                lastLine  = dummy;
            }

            for (int i = firstLine; i <= lastLine; ++i)
            {
                int lastLineNo = i;
                var line       = ChangedRange.tb.Lines[i];
                if (line.Length == 0)
                {
                    continue;
                }

                var info = _Parser.PureTokenizeLine(line);

                /*
                 * int dummyLine = -1;
                 * var info = _Parser.TokenizeLine( line, -1, ref dummyLine );*/

                var lineRange = ChangedRange.tb.GetLine(i);
                lineRange.ClearStyle(StyleIndex.All);

                bool hadREM = false;

                foreach (var token in info.Tokens)
                {
                    var subRange = new Range(ChangedRange.tb, token.StartIndex, i, token.StartIndex + token.Content.Length, i);
                    if (hadREM)
                    {
                        subRange.SetStyle(StyleIndex.Style3);
                        continue;
                    }
                    switch (token.TokenType)
                    {
                    case Parser.BasicFileParser.Token.Type.BASIC_TOKEN:
                        subRange.SetStyle(StyleIndex.Style8);
                        if (_Parser.IsComment(token))
                        {
                            hadREM = true;
                        }
                        break;

                    case Parser.BasicFileParser.Token.Type.DIRECT_TOKEN:
                        subRange.SetStyle(StyleIndex.Style6);
                        break;

                    case Parser.BasicFileParser.Token.Type.EX_BASIC_TOKEN:
                        subRange.SetStyle(StyleIndex.Style2);
                        break;

                    case Parser.BasicFileParser.Token.Type.LINE_NUMBER:
                        subRange.SetStyle(StyleIndex.Style5);
                        break;

                    case Parser.BasicFileParser.Token.Type.NUMERIC_LITERAL:
                        subRange.SetStyle(StyleIndex.Style5);
                        break;

                    case Parser.BasicFileParser.Token.Type.STRING_LITERAL:
                        subRange.SetStyle(StyleIndex.Style4);
                        break;

                    case Parser.BasicFileParser.Token.Type.COMMENT:
                    case Parser.BasicFileParser.Token.Type.HARD_COMMENT:
                        subRange.SetStyle(StyleIndex.Style3);
                        break;

                    case Parser.BasicFileParser.Token.Type.MACRO:
                        subRange.SetStyle(StyleIndex.Style7);
                        break;

                    case Parser.BasicFileParser.Token.Type.VARIABLE:
                        subRange.SetStyle(StyleIndex.Style9);
                        break;
                    }
                }
            }
            _Parser.Clear();
        }
예제 #4
0
 public void SetBASICDialect(C64Models.BASIC.Dialect Dialect)
 {
     _Parser.Settings.BASICDialect = Dialect;
 }