Exemplo n.º 1
0
        static void ClipboardGet(Gtk.Clipboard clipboard, Gtk.SelectionData seldata, uint info)
        {
            if (selection == null)
            {
                return;
            }

            if (info == TextType)
            {
                seldata.Text = selection.OuterXml;
            }
            else
            {
                seldata.Set(WidgetUtils.ApplicationXSteticAtom, 8, System.Text.Encoding.UTF8.GetBytes(selection.OuterXml));
            }
        }
Exemplo n.º 2
0
			public void SetData (SelectionData selection_data, uint info)
			{
				if (selection_data == null)
					return;
				switch (info) {
				case TextType:
					// Windows specific hack to work around bug: Bug 661973 - copy operation in TextEditor braks text lines with duplicate line endings when the file has CRLF
					// Remove when https://bugzilla.gnome.org/show_bug.cgi?id=640439 is fixed.
					if (Platform.IsWindows) {
						selection_data.Text = copiedDocument.Text.Replace ("\r\n", "\n");
					} else {
						selection_data.Text = copiedDocument.Text;
					}
					break;
				case RichTextType:
					selection_data.Set (RTF_ATOM, UTF8_FORMAT, System.Text.Encoding.UTF8.GetBytes (RtfWriter.GenerateRtf (copiedDocument, mode, docStyle, options)));
					break;
				case HTMLTextType:
					selection_data.Set (HTML_ATOM, UTF8_FORMAT, System.Text.Encoding.UTF8.GetBytes (HtmlWriter.GenerateHtml (copiedDocument, mode, docStyle, options)));
					break;
				case MonoTextType:
					byte[] rawText = System.Text.Encoding.UTF8.GetBytes (monoDocument.Text);
					byte[] data = new byte [rawText.Length + 1];
					rawText.CopyTo (data, 1);
					data [0] = 0;
					if (isBlockMode)
						data [0] |= 1;
					if (isLineSelectionMode)
						data [0] |= 2;
					selection_data.Set (MD_ATOM, UTF8_FORMAT, data);
					break;
				}
			}
Exemplo n.º 3
0
			public void SetData (SelectionData selection_data, uint info)
			{
				if (selection_data == null)
					return;
				switch (info) {
				case TextType:
					selection_data.Text = copiedDocument.Text;
					break;
				case RichTextType:
					selection_data.Set (RTF_ATOM, UTF8_FORMAT, System.Text.Encoding.UTF8.GetBytes (GenerateRtf (copiedDocument, mode, docStyle, options)));
					break;
				case MonoTextType:
					byte[] rawText = System.Text.Encoding.UTF8.GetBytes (monoDocument.Text);
					byte[] data    = new byte [rawText.Length + 1];
					rawText.CopyTo (data, 1);
					data[0] = 0;
					if (isBlockMode)
						data[0] |= 1;
					if (isLineSelectionMode)
						data[0] |= 2;
					selection_data.Set (MD_ATOM, UTF8_FORMAT, data);
					break;
				}
			}
Exemplo n.º 4
0
			public void SetData (SelectionData selection_data, uint info)
			{
				if (selection_data == null)
					return;
				switch (info) {
				case TextType:
					// Windows specific hack to work around bug: Bug 661973 - copy operation in TextEditor braks text lines with duplicate line endings when the file has CRLF
					// Remove when https://bugzilla.gnome.org/show_bug.cgi?id=640439 is fixed.


					selection_data.Text = GetCopiedPlainText ();
					break;
				case RichTextType:
					var rtf = RtfWriter.GenerateRtf (copiedColoredChunks, docStyle, options);
					selection_data.Set (RTF_ATOM, UTF8_FORMAT, Encoding.UTF8.GetBytes (rtf));
					break;
				case HTMLTextType:
					var html = HtmlWriter.GenerateHtml (copiedColoredChunks, docStyle, options);
//					Console.WriteLine ("html:" + html);
					selection_data.Set (HTML_ATOM, UTF8_FORMAT, Encoding.UTF8.GetBytes (html));
					break;
				case MonoTextType:
					byte[] rawText = Encoding.UTF8.GetBytes (GetCopiedPlainText ());
					var copyDataLength = (byte)(copyData != null ? copyData.Length : 0);
					var dataOffset = 1 + 1 + copyDataLength;
					byte[] data = new byte [rawText.Length + dataOffset];
					data [1] = copyDataLength;
					if (copyDataLength > 0)
						copyData.CopyTo (data, 2);
					rawText.CopyTo (data, dataOffset);
					data [0] = 0;
					if (isBlockMode)
						data [0] |= 1;
					if (isLineSelectionMode)
						data [0] |= 2;
					selection_data.Set (MD_ATOM, UTF8_FORMAT, data);
					break;
				}
			}
Exemplo n.º 5
0
        /// <summary>
        /// Gets complex data from item and sets as content when requested.
        /// </summary>
        /// <param name="clipboard">Clipboard.</param>
        /// <param name="selectionData">Selection data.</param>
        /// <param name="info">Target index.</param>
        internal void GetDataFunc(Gtk.Clipboard clipboard, SelectionData selectionData, uint info)
        {
            switch (info)
            {
                case 0:
                    selectionData.Set(this.Target, 8, this.Data);
                    break;

                case 1:
                default:
                    selectionData.Set(Targets.Atoms[Targets.UtfString], 8, this.DataText);
                    break;
            }
        }
Exemplo n.º 6
0
			public void SetData (SelectionData selection_data, uint info)
			{
				if (selection_data == null)
					return;
				switch (info) {
				case TextType:
					selection_data.Text = GetCopiedPlainText ();
					break;
				case RichTextType:
					var rtf = RtfWriter.GenerateRtf (copiedColoredChunks, docStyle, options);
					selection_data.Set (RTF_ATOM, UTF8_FORMAT, Encoding.UTF8.GetBytes (rtf));
					break;
				case HTMLTextType:
					var html = HtmlWriter.GenerateHtml (copiedColoredChunks, docStyle, options);
//					Console.WriteLine ("html:" + html);
					selection_data.Set (HTML_ATOM, UTF8_FORMAT, Encoding.UTF8.GetBytes (html));
					break;
				case MonoTextType:
					byte[] rawText = Encoding.UTF8.GetBytes (GetCopiedPlainText ());
					var copyDataLength = (byte)(copyData != null ? copyData.Length : 0);
					var dataOffset = 1 + 1 + copyDataLength;
					byte[] data = new byte [rawText.Length + dataOffset];
					data [1] = copyDataLength;
					if (copyDataLength > 0)
						copyData.CopyTo (data, 2);
					rawText.CopyTo (data, dataOffset);
					data [0] = 0;
					if (isBlockMode)
						data [0] |= 1;
					if (isLineSelectionMode)
						data [0] |= 2;
					selection_data.Set (MD_ATOM, UTF8_FORMAT, data);
					break;
				}
			}
Exemplo n.º 7
0
		void FillSelectionData (SelectionData aData, uint aInfo) 
		{
			if (aInfo < (int) TransferDataType.X_Special)
				aData.Set (aData.Target, 8, System.Text.Encoding.UTF8.GetBytes (GetTimeAsString (copyBuffer)),
				           System.Text.Encoding.UTF8.GetBytes (GetTimeAsString(copyBuffer)).Length);
			else {
				byte[] num = BitConverter.GetBytes (copyBuffer.Hour);
				byte[] data = new byte[num.Length*4];
				num.CopyTo (data, 0);
				num = BitConverter.GetBytes (copyBuffer.Minute);
				num.CopyTo (data, num.Length);
				num = BitConverter.GetBytes (copyBuffer.Second);
				num.CopyTo (data, num.Length*2);
				num = BitConverter.GetBytes (copyBuffer.Millisecond);
				num.CopyTo (data, num.Length*3);
				aData.Set (aData.Target, 8, data, data.Length);
			}
		}
Exemplo n.º 8
0
		protected override void OnDragDataGet (Gdk.DragContext ctx, Gtk.SelectionData data, uint info, uint time)
		{
			byte[] uri = System.Text.Encoding.UTF8.GetBytes (Hit.EscapedUri + "\r\n");
			data.Set (data.Target, 8, uri);
		}
 public void AssignToSelection(Gtk.SelectionData selectionData, Gdk.Atom target)
 {
     byte [] data = this;
     selectionData.Set(target, 8, data, data.Length);
 }
Exemplo n.º 10
0
		/// <summary>
		/// Fills selection with data
		/// </summary>
		/// <param name="aData">
		/// Data <see cref="SelectionData"/>
		/// </param>
		/// <param name="aInfo">
		/// Type <see cref="System.UInt32"/>
		/// </param>
		private void FillSelectionData (SelectionData aData, uint aInfo) 
		{
			aData.Set (aData.Target, 8, System.Text.Encoding.UTF8.GetBytes (TargetUrl),
			           System.Text.Encoding.UTF8.GetBytes (TargetUrl).Length);
		}
Exemplo n.º 11
0
    private void ClearGet(Gtk.Clipboard clipboard, Gtk.SelectionData selection, uint info)
    {
        var temp = _action + "\n" + _source;

        selection.Set(selection.Target, 8, _encoding.GetBytes(temp));
    }