public MainWindow() : base(Gtk.WindowType.Toplevel) { Build(); Preferences.AddNotify(new GConf.NotifyEventHandler(OnGConfChanged)); manager = new SourceLanguageManager(); language = manager.GetLanguage("c-sharp"); buffer = new SourceBuffer(language); textView = new SourceView(buffer); textView.TabWidth = 4; OnGConfChanged(null, null); buffer.Changed += new EventHandler(OnBufferChanged); buffer.MarkSet += new MarkSetHandler(OnBufferMarkSet); scrolledwindow.Add(textView); scrolledwindow.ShowAll(); Focus = textView; originalBuffer = ""; NewFile(); }
public SourceManage(SourceBuffer sb, INIOperation source, ExecuteBuffer executeBuffer) { InitializeComponent(); _sb = sb; _source = source; _excBuffer = executeBuffer; }
public static MyTextView CreateNewTextView() { SourceLanguage lang = MyTextView.LanguageManager.GetLanguageFromMimeType ("text/x-csharp"); SourceBuffer buffer = new SourceBuffer(lang); buffer.Highlight = true; return new MyTextView(buffer); }
public DyObject Parse(ExecutionContext ctx, DyObject expression) { if (expression.TypeId != DyType.String) { return(ctx.InvalidType(expression)); } try { var p = new DyParser(); var res = p.Parse(SourceBuffer.FromString(expression.GetString())); if (!res.Success) { return(ctx.FailedReadLiteral(res.Messages.First().ToString())); } if (res.Value.Root == null || res.Value.Root.Nodes.Count == 0) { return(ctx.FailedReadLiteral("Empty expression.")); } else if (res.Value.Root.Nodes.Count > 1) { return(ctx.FailedReadLiteral("Only single expressions allowed.")); } return(LiteralEvaluator.Eval(res.Value.Root.Nodes[0])); } catch (Exception ex) { return(ctx.FailedReadLiteral(ex.Message)); } }
public void QueuePlayback(AudioSource audioSource, byte[] data) { if (this.isDisposed) { throw new ObjectDisposedException("OpenALPlaybackProvider"); } if (audioSource == null) { throw new ArgumentNullException("audioSource"); } Stack <SourceBuffer> bufferStack; if (!this.buffers.TryGetValue(audioSource, out bufferStack)) { this.buffers[audioSource] = bufferStack = new Stack <SourceBuffer>(); } lock (this.pool.SyncRoot) { Source source = this.pool.RequestSource(audioSource); Tuple <float, float> gain; if (this.gains.TryGetValue(audioSource, out gain)) { source.Gain = gain.Item2; } else { source.Gain = this.normalGain; } const int bufferLen = 4; if (data.Length == 0) { return; } if (!source.IsPlaying) { OpenAL.DebugFormat("{0} bound to {1} isn't playing, inserting silent buffers", audioSource, source); RequireBuffers(bufferStack, source, bufferLen); for (int i = 0; i < bufferLen; ++i) { OpenALAudioFormat format = audioSource.CodecSettings.ToOpenALFormat(); SourceBuffer wait = bufferStack.Pop(); wait.Buffer(new byte[format.GetBytes((uint)audioSource.CodecSettings.FrameSize)], format, (uint)audioSource.CodecSettings.SampleRate); source.QueueAndPlay(wait); } } RequireBuffers(bufferStack, source, 1); SourceBuffer buffer = bufferStack.Pop(); buffer.Buffer(data, audioSource.CodecSettings.ToOpenALFormat(), (uint)audioSource.CodecSettings.SampleRate); source.QueueAndPlay(buffer); } }
/// <summary> /// 从基础字符读取器中读取字符,并填充到新的缓冲区中。 /// </summary> /// <returns>从基础字符读取器中读取的字符数量。</returns> private int PrepareBuffer() { if (reader.Peek() == -1) { return(0); } if (length > 0) { if (last.Next == first) { // 没有可用的空缓冲区,则需要新建立一块。 SourceBuffer buffer = new SourceBuffer(); buffer.Buffer = new char[BufferSize]; buffer.Next = last.Next; buffer.Prev = current; last.Next.Prev = buffer; last.Next = buffer; } last = last.Next; } else { // len 为 0 应仅当 last == current 时。 Debug.Assert(last == current); } lastLength = reader.ReadBlock(last.Buffer, 0, BufferSize); if (length == 0) { length = lastLength; } return(lastLength); }
public ShowTextDialog(string text, string mimeType) { this.Build(); SourceLanguagesManager lm = new SourceLanguagesManager(); SourceLanguage lang = null; if (String.IsNullOrEmpty(mimeType)) { lang = lm.GetLanguageFromMimeType(mimeType); } SourceBuffer buf = null; if (lang == null) { SourceTagTable table = new SourceTagTable(); buf = new SourceBuffer(table); } else { buf = new SourceBuffer(lang); buf.Highlight = true; } sourceView = new SourceView(buf); sourceView.ShowLineNumbers = true; sourceView.Editable = false; vboxContent.PackStart(sourceView, true, true, 0); vboxContent.ShowAll(); if (text != null) { sourceView.Buffer.Text = text; } }
public SchemeShell() : base() { mgr = new SourceLanguagesManager(); language = mgr.GetLanguageFromMimeType("text/plain"); // Set up syntax highlighting buffer = new SourceBuffer(language); buffer.Highlight = true; source_view = new ShellSourceView(buffer, "> "); // Change the font to fixed-width: Pango.FontDescription font = new Pango.FontDescription(); font.Family = "Monospace"; source_view.ModifyFont(font); // Event Handlers: source_view.WrapMode = Gtk.WrapMode.Word; source_view.AutoIndent = true; source_view.Execute += execute; // Encoding encoding = Encoding.UTF8; // Probably a more direct way to do these things: // command("import sys"); // command("sys.path.append('.')"); // command("sys.path.append('python')"); // command("sys.path.append('DLLs')"); // buffer.Text += "# Python " + command("sys.version") + "\n" + // "# " + command("sys.copyright") + "\n"; // command("del sys"); source_view.AddPrompt(); }
public bool Compile(string fileName, out Unit unit) { unit = null; var made = default(Result <Unit>); try { var buffer = SourceBuffer.FromFile(fileName); made = Linker.Compile(buffer); } catch (Exception ex) { Printer.Error($"Unable to read file \"{fileName}\": {ex.Message}"); return(false); } if (made.Messages.Any()) { Printer.PrintErrors(made.Messages); } if (!made.Success) { return(false); } unit = made.Value; return(true); }
/// <summary> /// 令源代码位置计数器前进指定缓冲的部分。 /// </summary> /// <param name="buffer">要前进的字符的缓冲区。</param> /// <param name="start">要前进的字符的起始长度。</param> /// <param name="len">要前进的字符的长度。</param> private void Forward(SourceBuffer buffer, int start, int len) { Tuple <int, string> placeholder = CurrentPlaceHolder(); if (placeholder == null) { locator.Forward(buffer.Buffer, start, len); } else { int end = start + len; int local = placeholder.Item1 - buffer.StartIndex; while (local < end) { this.placeHolders.Dequeue(); locator.Forward(buffer.Buffer, start, local - start); locator.Forward(placeholder.Item2); start = local + 1; if ((placeholder = CurrentPlaceHolder()) == null) { break; } local = placeholder.Item1 - buffer.StartIndex; } if (start < end) { locator.Forward(buffer.Buffer, start, end - start); } } }
/// <summary> /// 返回文本读取器中之后的 <paramref name="idx"/> 索引的字符,但不使用它。 /// Peek(0) 就相当于 Peek(),但效率不如 Peek()。 /// </summary> /// <returns>文本读取器中之后的 <paramref name="idx"/> 索引的字符, /// 或为 <c>-1</c>(如果没有更多的可用字符)。</returns> /// <exception cref="ObjectDisposedException">当前 <see cref="SourceReader"/> 已关闭。</exception> /// <exception cref="ArgumentOutOfRangeException"><paramref name="idx"/> 小于 <c>0</c>。</exception> public int Peek(int idx) { if (idx < 0) { throw CommonExceptions.ArgumentNegative("idx", idx); } Contract.EndContractBlock(); CheckDisposed(); SourceBuffer temp = current; int tempLen = length; idx += index; while (true) { if (idx >= tempLen) { idx -= tempLen; if (temp == last && (tempLen = PrepareBuffer()) == 0) { // 没有可读数据了,返回。 return(-1); } temp = temp.Next; } else { return(temp.Buffer[idx]); } } }
public ShowTextDialog (string text, string mimeType) { this.Build(); SourceLanguagesManager lm = new SourceLanguagesManager (); SourceLanguage lang = null; if (String.IsNullOrEmpty (mimeType)) lang = lm.GetLanguageFromMimeType (mimeType); SourceBuffer buf = null; if (lang == null) { SourceTagTable table = new SourceTagTable (); buf = new SourceBuffer (table); } else { buf = new SourceBuffer (lang); buf.Highlight = true; } sourceView = new SourceView (buf); sourceView.ShowLineNumbers = true; sourceView.Editable = false; vboxContent.PackStart (sourceView, true, true, 0); vboxContent.ShowAll (); if (text != null) sourceView.Buffer.Text = text; }
/// <summary> /// 切换到下一块缓冲区。如果没有有效的数据,则从基础字符读取器中读取字符,并填充到缓冲区中。 /// </summary> /// <returns>如果切换成功,则为 <c>true</c>;否则为 <c>false</c>。</returns> private bool SwitchNextBuffer() { Contract.Requires(index == length); Contract.Requires(reader != null); if (current == last) { // 下一块缓冲区没有数据,需要从基础字符读取器中读取。 if (PrepareBuffer() == 0) { return(false); } length = lastLength; current = last; } else { // 下一块缓冲区有数据,直接后移。 current = current.Next; if (current == last) { length = lastLength; } } index = 0; return(length > 0); }
/// <summary> /// 从基础字符读取器中读取字符,并填充到新的缓冲区中。 /// </summary> /// <returns>从基础字符读取器中读取的字符数量。</returns> private int PrepareBuffer() { if (reader.Peek() == -1) { return(0); } if (length > 0) { if (last.Next == first) { // 没有可用的空缓冲区,则需要新建立一块。 SourceBuffer buffer = new SourceBuffer { Next = last.Next, Prev = current }; last.Next.Prev = buffer; last.Next = buffer; } last = last.Next; last.StartIndex = last.Prev.StartIndex + BufferSize; } else { // len 为 0 应仅当 last == current 时。 Contract.Assert(last == current); } lastLength = reader.ReadBlock(last.Buffer, 0, BufferSize); if (length == 0) { length = lastLength; } return(lastLength); }
public override void OnAwake() { _collector.Open(); _input = state.Get <SourceBuffer <EventSource> >(); _output = state.Get <SourceBuffer <TokenSource> >(); _cache = state.Get <TokenCache>(); }
protected void Dispose(bool disposing) { if (this.isDisposed) { return; } OpenAL.DebugFormat("Freeing OpenALPlaybackProvider. Disposing: ", disposing); if (disposing) { this.pool.Dispose(); if (this.device != null) { this.device.Dispose(); } } SourceBuffer.Clear(); OpenALRunner.RemoveUser(); OpenALRunner.RemovePlaybackProvider(this); this.pool = null; this.device = null; this.isDisposed = true; }
/// <summary> /// 返回文本读取器中之后的 <paramref name="idx"/> 索引的字符,但不使用它。 /// Peek(0) 就相当于 Peek(),但效率不如 Peek()。 /// </summary> /// <returns>文本读取器中之后的 <paramref name="idx"/> 索引的字符, /// 或为 <c>-1</c>(如果没有更多的可用字符)。</returns> public int Peek(int idx) { if (reader == null) { throw ExceptionHelper.SourceReaderClosed(); } if (idx < 0) { throw ExceptionHelper.ArgumentOutOfRange("count"); } SourceBuffer temp = current; int tempLen = length; idx += index; while (true) { if (idx >= tempLen) { idx -= tempLen; if (temp == last && (tempLen = PrepareBuffer()) == 0) { // 没有可读数据了,返回。 return(-1); } temp = temp.Next; } else { return(temp.Buffer[idx]); } } }
public override void OnAwake(ILoopState state) { _events = state.Get <SourceBuffer <EventSource> >(); _physics = state.Get <SourceBuffer <PhysicsSource> >(); _timer = state.Get <Ticker>(); _intMap = state.Get <ValueMap <int> >(); }
static public MyTextView CreateNewTextView() { SourceLanguage lang = MyTextView.LanguageManager.GetLanguageFromMimeType("text/x-csharp"); SourceBuffer buffer = new SourceBuffer(lang); buffer.Highlight = true; return(new MyTextView(buffer)); }
/// <summary> /// 使用指定的起始位置和 Tab 宽度初始化 <see cref="SourceReader"/> 类的新实例。 /// </summary> /// <param name="initPosition">起始位置。</param> /// <param name="tabSize">Tab 的宽度。</param> private SourceReader(SourcePosition initPosition, int tabSize) { locator = new SourceLocator(initPosition, tabSize); current = first = last = new SourceBuffer(); firstIndex = lastLength = 0; current.Next = current; current.StartIndex = 0; }
public MyTextView(SourceBuffer buffer) : base(buffer) { CursorVisible = false; Editable = false; ModifyFont(Pango.FontDescription.FromString("Vera Sans Mono 14")); ShowLineNumbers = true; sourceBuffer = buffer; }
/// <summary> /// 使用指定的字符读取器和 Tab 宽度初始化 <see cref="SourceReader"/> 类的新实例。 /// </summary> /// <param name="reader">用于读取源文件的字符读取器。</param> /// <param name="tabSize">Tab 的宽度。</param> public SourceReader(TextReader reader, int tabSize) { ExceptionHelper.CheckArgumentNull(reader, "reader"); locator = new SourceLocator(tabSize); this.reader = reader; current = first = last = new SourceBuffer(); firstIndex = lastLength = 0; current.Buffer = new char[BufferSize]; current.Next = current; }
public MyTextView(SourceBuffer buffer) : base(buffer) { CursorVisible = false; Editable = false; ModifyFont(Pango.FontDescription.FromString("Vera Sans Mono 14")); ShowLineNumbers = true; sourceBuffer = buffer; }
public void RenderCoverage (SourceBuffer buf, CodeRecord rec) { foreach ( var line in rec.GetLines() ){ var hits = rec.GetHits(line); if ( hits > 0 ){ var hittag = hits == 1 ? "visited_once" : "visited_more"; buf.ApplyTag (hittag, buf.GetIterAtLine (line - 1), buf.GetIterAtLine (line)); } } }
/// <summary> /// 执行与释放或重置非托管资源相关的应用程序定义的任务。 /// </summary> public void Dispose() { if (this.reader == null) { return; } this.reader.Dispose(); this.reader = null; this.current = this.last = this.first = null; this.builder = null; }
/// <summary> /// 执行与释放或重置非托管资源相关的应用程序定义的任务。 /// </summary> public void Dispose() { if (reader == null) { return; } reader.Dispose(); reader = null; current = last = first = null; builder = null; }
public Result <DyCodeModel> Parse(SourceBuffer buffer) { var ip = new InternalParser(new Scanner(buffer)); ip.Parse(); var cd = new DyCodeModel(ip.Root, ip.Imports.ToArray(), buffer.FileName ?? MEMORY); return(ip.Errors.Count == 0 ? Result.Create(cd) : Result.Create(cd, ip.Errors)); }
public static Result <DyCodeModel> Parse(SourceBuffer buffer) { var fileName = buffer.FileName ?? DefaultBuffer; var ip = new InternalParser(fileName, new(buffer)); ip.Parse(); var cd = new DyCodeModel(ip.Root, ip.Imports.ToArray(), fileName); return(ip.Errors.Count == 0 ? Result.Create(cd) : Result.Create(cd, ip.Errors)); }
public void RenderCoverage(SourceBuffer buf, CodeRecord rec) { foreach (var line in rec.GetLines()) { var hits = rec.GetHits(line); if (hits > 0) { var hittag = hits == 1 ? "visited_once" : "visited_more"; buf.ApplyTag(hittag, buf.GetIterAtLine(line - 1), buf.GetIterAtLine(line)); } } }
private static void PushBuffers(Stack <SourceBuffer> bufferStack, int number) { SourceBuffer[] sbuffers = SourceBuffer.Generate(number); if (sbuffers.Length != number) { throw new Exception("Generated buffer count doesn't match requested."); } for (int i = 0; i < sbuffers.Length; ++i) { bufferStack.Push(sbuffers[i]); } }
/// <summary> /// 将当前位置之前的数据全部丢弃,之后的 <see cref="Unget()"/> 操作至多回退到当前位置。 /// </summary> public void Drop() { CheckDisposed(); while (first != current) { this.Forward(first, firstIndex, BufferSize - firstIndex); startIndex += BufferSize - firstIndex; firstIndex = 0; first = first.Next; } this.Forward(current, firstIndex, index - firstIndex); startIndex += index - firstIndex; firstIndex = index; }
/// <summary> /// 将指定缓冲区中从指定索引开始,指定长度的字符串复制到 <see cref="builder"/> 中。 /// </summary> /// <param name="buffer">要复制字符串的缓冲区。</param> /// <param name="start">要复制的起始长度。</param> /// <param name="len">要复制的长度。</param> private void CopyToBuilder(SourceBuffer buffer, int start, int len) { Contract.Requires(start >= 0); Contract.Requires(start + len <= BufferSize); if (builderCopiedLen == builder.Length) { builder.Append(buffer.Buffer, start, len); builderCopiedLen += len; } else if ((builderCopiedLen += len) > builder.Length) { int l = builderCopiedLen - builder.Length; builder.Append(buffer.Buffer, len - l, l); } }
/// <summary> /// 将当前位置之前的数据全部丢弃,之后的 <see cref="Unget()"/> 操作至多回退到当前位置。 /// </summary> public void Drop() { if (reader == null) { throw ExceptionHelper.SourceReaderClosed(); } while (first != current) { locator.Forward(first.Buffer, firstIndex, BufferSize - firstIndex); firstIndex = 0; first = first.Next; } locator.Forward(current.Buffer, firstIndex, index - firstIndex); firstIndex = index; }
private void Update(EvaluationContext context) { var resourceManager = ResourceManager.Instance(); var device = resourceManager.Device; var deviceContext = device.ImmediateContext; var targetBuffer = TargetBuffer.GetValue(context); var sourceBufferUav = SourceBuffer.GetValue(context); if (targetBuffer == null || sourceBufferUav == null) { return; } deviceContext.CopyStructureCount(targetBuffer, DstAlignedByteOffset.GetValue(context), sourceBufferUav); }
public SqlEditorWidget() { this.Build(); SourceLanguagesManager lm = new SourceLanguagesManager (); SourceLanguage lang = lm.GetLanguageFromMimeType ("text/x-sql"); SourceBuffer buf = new SourceBuffer (lang); buf.Highlight = true; sourceView = new SourceView (buf); sourceView.ShowLineNumbers = true; sourceView.Buffer.Changed += new EventHandler (BufferChanged); sourceView.PopulatePopup += new PopulatePopupHandler (OnPopulatePopup); scrolledwindow.Add (sourceView); ShowAll (); }
/// <summary> /// See <see cref="BaseColorDitherer.OnProcessPixel"/> for more details. /// </summary> protected override Boolean OnProcessPixel(Pixel sourcePixel, Pixel targetPixel) { // only process dithering when reducing from truecolor to indexed if (!TargetBuffer.IsIndexed) { return(false); } // retrieves the colors Color sourceColor = SourceBuffer.GetColorFromPixel(sourcePixel); Color targetColor = TargetBuffer.GetColorFromPixel(targetPixel); // converts alpha to solid color sourceColor = QuantizationHelper.ConvertAlpha(sourceColor); // calculates the difference (error) Int32 redError = sourceColor.R - targetColor.R; Int32 greenError = sourceColor.G - targetColor.G; Int32 blueError = sourceColor.B - targetColor.B; // only propagate non-zero error if (redError != 0 || greenError != 0 || blueError != 0) { // processes the matrix for (Int32 shiftY = -MatrixSideHeight; shiftY <= MatrixSideHeight; shiftY++) { for (Int32 shiftX = -MatrixSideWidth; shiftX <= MatrixSideWidth; shiftX++) { Int32 targetX = sourcePixel.X + shiftX; Int32 targetY = sourcePixel.Y + shiftY; Byte coeficient = CachedMatrix[shiftY + MatrixSideHeight, shiftX + MatrixSideWidth]; Single coeficientSummed = CachedSummedMatrix[shiftY + MatrixSideHeight, shiftX + MatrixSideWidth]; if (coeficient != 0 && targetX >= 0 && targetX < TargetBuffer.Width && targetY >= 0 && targetY < TargetBuffer.Height) { ProcessNeighbor(targetPixel, targetX, targetY, coeficientSummed, redError, greenError, blueError); } } } } // pixels are not processed, only neighbors are return(false); }
/// <summary> /// 返回当前位置之前的数据。 /// </summary> /// <returns>当前位置之前的数据。</returns> public string ReadedBlock() { CheckDisposed(); InitBuilder(); // 将字符串复制到 StringBuilder 中。 SourceBuffer buf = first; int fIndex = firstIndex; while (buf != current) { CopyToBuilder(buf, fIndex, BufferSize - fIndex); fIndex = 0; buf = buf.Next; } CopyToBuilder(buf, fIndex, index - fIndex); builder.Length = builderCopiedLen; return(builder.ToString()); }
public MainWindow() : base(Gtk.WindowType.Toplevel) { Build (); var lang = SourceLanguageManager.Default.GetLanguage ("xml"); sb = new SourceBuffer (lang); sb.HighlightSyntax = true; sb.HighlightMatchingBrackets = true; sv = new SourceView (sb); scrolledwindow1.Add (sv); updateTimer.Elapsed += delegate { RunUpdate (); }; sb.Changed += delegate { UpdatePreview (); }; vbox1.ShowAll (); }
public XmlEditorViewContent() { xmlEditorWindow = new XmlEditorWindow(this); view = xmlEditorWindow.View; buffer = (SourceBuffer)view.Buffer; buffer.Changed += BufferChanged; view.SchemaCompletionDataItems = XmlSchemaManager.SchemaCompletionDataItems; SetInitialValues(); // Watch for changes to the source editor properties. propertyChangedHandler = (EventHandler<PropertyChangedEventArgs>)DispatchService.GuiDispatch(new EventHandler<PropertyChangedEventArgs>(SourceEditorPropertyChanged)); TextEditorProperties.Properties.PropertyChanged += propertyChangedHandler; buffer.ModifiedChanged += new EventHandler (OnModifiedChanged); XmlEditorAddInOptions.PropertyChanged += new EventHandler<PropertyChangedEventArgs>(XmlEditorPropertyChanged); XmlSchemaManager.UserSchemaAdded += new EventHandler(UserSchemaAdded); XmlSchemaManager.UserSchemaRemoved += new EventHandler(UserSchemaRemoved); xmlEditorWindow.ShowAll(); }
public SqlQueryView() : base() { control = new Frame (); control.Show (); VBox vbox = new VBox (); vbox.Show (); Tooltips tips = new Tooltips (); Toolbar toolbar = new Toolbar (); vbox.PackStart (toolbar, false, true, 0); toolbar.Show (); Image image = new Image (); image.Pixbuf = Gdk.Pixbuf.LoadFromResource ("MonoQuery.Execute"); image.Show (); Button execute = new Button (image); execute.Clicked += new EventHandler (OnExecute); execute.Relief = ReliefStyle.None; tips.SetTip (execute, "Execute", ""); toolbar.Add (execute); execute.Show (); image = new Image (); image.Pixbuf = Gdk.Pixbuf.LoadFromResource ("MonoQuery.RunFromCursor"); image.Show (); Button run = new Button (image); run.Clicked += new EventHandler (OnRunFromCursor); run.Relief = ReliefStyle.None; tips.SetTip (run, "Run from cursor", ""); toolbar.Add (run); run.Show (); image = new Image (); image.Pixbuf = Gdk.Pixbuf.LoadFromResource ("MonoQuery.Explain"); image.Show (); Button explain = new Button (image); explain.Clicked += new EventHandler (OnExplain); explain.Relief = ReliefStyle.None; tips.SetTip (explain, "Explain query", ""); toolbar.Add (explain); explain.Show (); image = new Image (); image.Pixbuf = Gdk.Pixbuf.LoadFromResource ("MonoQuery.Stop"); image.Show (); Button stop = new Button (image); stop.Clicked += new EventHandler (OnStop); stop.Relief = ReliefStyle.None; stop.Sensitive = false; tips.SetTip (stop, "Stop", ""); toolbar.Add (stop); stop.Show (); VSeparator sep = new VSeparator (); toolbar.Add (sep); sep.Show (); model = new ListStore (typeof (string), typeof (DbProviderBase)); providers = new ComboBox (); providers.Model = model; CellRendererText ctext = new CellRendererText (); providers.PackStart (ctext, true); providers.AddAttribute (ctext, "text", 0); toolbar.Add (providers); providers.Show (); SourceLanguagesManager lm = new SourceLanguagesManager (); SourceLanguage lang = lm.GetLanguageFromMimeType ("text/x-sql"); SourceBuffer buf = new SourceBuffer (lang); buf.Highlight = true; sourceView = new SourceView (buf); sourceView.ShowLineNumbers = true; sourceView.Show (); ScrolledWindow scroller = new ScrolledWindow (); scroller.Add (sourceView); scroller.Show (); vbox.PackStart (scroller, true, true, 0); control.Add (vbox); service = (MonoQueryService) ServiceManager.GetService (typeof (MonoQueryService)); changedHandler = (EventHandler) Runtime.DispatchService.GuiDispatch ( new EventHandler (OnProvidersChanged)); service.Providers.Changed += changedHandler; foreach (DbProviderBase p in service.Providers) { model.AppendValues (p.Name, p); } }
SourceBuffer CreateBuffer() { SourceBuffer buffer = new SourceBuffer (language); buffer.HighlightSyntax = true; buffer.HighlightMatchingBrackets = true; StreamReader sr = File.OpenText (filename); buffer.Text = sr.ReadToEnd (); sr.Close (); return buffer; }
public void OpenSourceFile (List<CodeRecord> recs) { if (recs.Count == 0) return; var filename = recs [0].SourceFile; var origfile = filename; var fbname = System.IO.Path.GetFileName(filename); if (openFiles.Contains (filename)) return; if ( fsmap.SourceMap.ContainsKey( filename ) ){ filename = fsmap.SourceMap[filename]; } while (!File.Exists(filename)) { var fc = new FileChooserDialog("Locate source file " + origfile, this, FileChooserAction.SelectFolder, "Cancel", ResponseType.Cancel, "Select", ResponseType.Apply); fc.Filter = new Gtk.FileFilter(){ Name = fbname }; fc.Filter.AddPattern( fbname ); fc.Response += (o, args) => { Console.Error.WriteLine( fc.Filename ); fc.Hide(); }; fc.Run(); if ( fc.Filename != null ){ filename = System.IO.Path.Combine( fc.Filename, fbname ); } else { return; } } fsmap.AddMapping( origfile, filename ); openFiles.Add (origfile); SourceLanguage language = sourceManager.GetLanguage ("c-sharp"); var buf = new SourceBuffer (language); TextTag visitedOnce = new TextTag ("visited_once") { Background = VisitedOnceBG }; TextTag visitedMore = new TextTag ("visited_more") { Background = VisitedMoreBG }; buf.TagTable.Add (visitedOnce); buf.TagTable.Add (visitedMore); buf.HighlightSyntax = true; buf.Text = System.IO.File.ReadAllText (filename); var page = new SourcePage (); var sv = new SourceView (buf); // sv.ScrollToIter (buf.GetIterAtLineOffset (22, 0), 1.1, false, 0.0, 0.0); sv.HighlightCurrentLine = true; sv.Editable = false; sv.ShowLineNumbers = true; var fp = System.IO.Path.GetFullPath (filename); page.Window.Add (sv); page.SetHeadingText (fp); page.SetSubHeadingText (""); var fname = System.IO.Path.GetFileName (filename); var tab = CloserTabLabel.InsertTabPage (notebook1, page, fname); tab.CloseKeyData = filename; page.ShowAll (); int total_lines = 0; int covered_lines = 0; buf.Text = File.ReadAllText (filename); foreach (var rec in recs) { RenderCoverage (buf, rec); total_lines += rec.GetLines().Length; covered_lines += rec.GetHits(); } double cov = (1.0 * covered_lines) / total_lines; page.SetCoverage (cov); notebook1.Page = notebook1.NPages - 1; sourceviews [filename] = sv; }
void SetupCode( string code ) { SourceLanguage language = null; SourceStyleScheme scheme = null; switch (_currentConfigPad.GetCurrentLang()) { case PadConfig.Languages.CSHARP: { language = SourceLanguageManager.Default.GetLanguage("c-sharp"); scheme = csharpsourceSchema; break; } case PadConfig.Languages.VBASIC: { language = SourceLanguageManager.Default.GetLanguage("vbnet"); scheme = vbsourceSchema; break; } default: { language = SourceLanguageManager.Default.GetLanguage("html"); break; } } SourceBuffer buffer = new SourceBuffer(language); buffer.StyleScheme = scheme; buffer.MaxUndoLevels = 20; buffer.HighlightSyntax = true; buffer.HighlightMatchingBrackets = true; buffer.Text = code; _codeView.Buffer = buffer; }
public SourceBuffer[] Dequeue(int buffers) { OpenAL.DebugFormat ("Dequeing {0} buffers for source {1}", buffers, this.sourceID); uint[] bufferIDs = new uint[buffers]; alSourceUnqueueBuffers (this.sourceID, buffers, bufferIDs); OpenAL.ErrorCheck (); SourceBuffer[] dequeued = new SourceBuffer[bufferIDs.Length]; for (int i = 0; i < bufferIDs.Length; ++i) { OpenAL.DebugFormat ("Dequeued source buffer {0} for source {1}", bufferIDs[i], this.sourceID); dequeued[i] = SourceBuffer.GetBuffer (bufferIDs[i]); } return dequeued; }
public void Queue(SourceBuffer buffer) { Queue (new [] { buffer.bufferID }); }
public void QueueAndPlay(SourceBuffer buffer) { this.Queue (buffer); this.Play (); }