示例#1
0
		void ComposeLines(Algorithm.Diff.Range range, char style, int otherStart, Table table, uint startRow, bool axn, uint col, bool wrap, Pango.FontDescription font, bool lineNumbers) {
			if (range.Count == 0) return;
			
			StringBuilder text = new StringBuilder();
			for (uint i = 0; i < range.Count; i++) {
				if (axn) {
					text.Append(style);
					text.Append(' ');
				}

				if (lineNumbers) {
					string lineNo = (range.Start + i + 1).ToString();
					if (otherStart != -1 && range.Start != otherStart)
					lineNo += "/" + (otherStart + i + 1).ToString();
					text.Append(lineNo);
					text.Append('\t');
				}
				
				text.Append((string)range[(int)i]);
				if (i < range.Count-1) text.Append('\n');
			}
			RangeEventBox rangebox = new RangeEventBox(new RangeRenderer(text.ToString(), style, wrap, font));
			table.Attach(rangebox, 0,1, startRow,(uint)(startRow+range.Count));
			
			/*
				int off1 = lineNumbers ? 1 : 0;
				int off2 = off1 + (axn ? 1 : 0);
				
				for (uint i = 0; i < range.Count; i++) {
					if (lineNumbers) {
						string lineNo = (range.Start + i + 1).ToString();
						if (otherStart != -1 && range.Start != otherStart)
						lineNo += "/" + (otherStart + i + 1).ToString();
					
						Label label = new Label(lineNo);
						label.ModifyFont( font );
						label.Yalign = 0;
						table.Attach(label, col,col+1, startRow+i,startRow+i+1, AttachOptions.Shrink, AttachOptions.Shrink, 1, 1);
					}
					
					if (axn) {
						Label actionlabel = new Label(style.ToString());
						table.Attach(actionlabel, (uint)(col+off1),(uint)(col+off1+1), startRow+i,startRow+i+1, AttachOptions.Shrink, AttachOptions.Shrink, 1, 1);
					}

					RangeEventBox line = new RangeEventBox(new RangeRenderer((string)range[(int)i], style, wrap, font));
					table.Attach(line, (uint)(col+off2),(uint)(col+off2+1), startRow+i,startRow+i+1);
				}
			*/
		}
示例#2
0
        void ComposeLines(MonoDevelop.Components.Diff.Range range, char style, int otherStart, Table table, uint startRow, bool axn, uint col, bool wrap, Pango.FontDescription font, bool lineNumbers, MonoDevelop.Components.Diff.Range lastRange)
        {
            if (range.Count == 0)
            {
                return;
            }

            StringBuilder text = new StringBuilder();

            for (uint i = 0; i < range.Count; i++)
            {
                if (axn)
                {
                    text.Append(style);
                    text.Append(' ');
                }

                if (lineNumbers)
                {
                    string lineNo = (range.Start + i + 1).ToString();
                    if (otherStart != -1 && range.Start != otherStart)
                    {
                        lineNo += "/" + (otherStart + i + 1).ToString();
                    }
                    string max = lastRange.End + "/" + lastRange.End;

                    text.Append(lineNo);
                    for (int j = 0; j < max.Length - lineNo.Length + 1; j++)
                    {
                        text.Append(' ');
                    }
//					text.Append('\t');
                }

                text.Append((string)range[(int)i]);
                if (i < range.Count - 1)
                {
                    text.Append('\n');
                }
            }
            RangeEventBox rangebox = new RangeEventBox(new RangeRenderer(this, text.ToString(), style, wrap, font));

            table.Attach(rangebox, 0, 1, startRow, (uint)(startRow + range.Count));

            /*
             *      int off1 = lineNumbers ? 1 : 0;
             *      int off2 = off1 + (axn ? 1 : 0);
             *
             *      for (uint i = 0; i < range.Count; i++) {
             *              if (lineNumbers) {
             *                      string lineNo = (range.Start + i + 1).ToString();
             *                      if (otherStart != -1 && range.Start != otherStart)
             *                      lineNo += "/" + (otherStart + i + 1).ToString();
             *
             *                      Label label = new Label(lineNo);
             *                      label.ModifyFont( font );
             *                      label.Yalign = 0;
             *                      table.Attach(label, col,col+1, startRow+i,startRow+i+1, AttachOptions.Shrink, AttachOptions.Shrink, 1, 1);
             *              }
             *
             *              if (axn) {
             *                      Label actionlabel = new Label(style.ToString());
             *                      table.Attach(actionlabel, (uint)(col+off1),(uint)(col+off1+1), startRow+i,startRow+i+1, AttachOptions.Shrink, AttachOptions.Shrink, 1, 1);
             *              }
             *
             *              RangeEventBox line = new RangeEventBox(new RangeRenderer((string)range[(int)i], style, wrap, font));
             *              table.Attach(line, (uint)(col+off2),(uint)(col+off2+1), startRow+i,startRow+i+1);
             *      }
             */
        }