Exemplo n.º 1
0
		public void Setup()
		{
			s1 = new SelectionHelper.SelInfo();
			s1.rgvsli = new SelLevInfo[2];
			s2 = new SelectionHelper.SelInfo();
			s2.rgvsli = new SelLevInfo[2];
		}
Exemplo n.º 2
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		///
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public override void FixtureTeardown()
		{
			base.FixtureTeardown();
			s1 = null;
			s2 = null;
		}
		void SetMorphemes(string currentMorphemes)
		{
			if (currentMorphemes.Length == 0)
			{
				// Reconstructing the sandbox rootbox after deleting all morpheme characters
				// will cause the user to lose the ability to type in the morpheme line (cf. LT-1621).
				// So just return here, since there are no morphemes to process.
				return;
			}
			using (new SandboxEditMonitorHelper(this, true))
			{
				// This code largely duplicates that found in UpdateMorphBreaks() following the call
				// to the EditMorphBreaksDlg, with addition of the m_monitorPropChanges flag and setting
				// the selection to stay in synch with the typing.  Modifying the code to more
				// closely follow that code fixed LT-1023.
				IVwCacheDa cda = (IVwCacheDa)m_sda;
				SandboxBase.MorphemeBreaker mb = new SandboxBase.MorphemeBreaker(m_sandbox.Caches,
					currentMorphemes, m_hvoSbWord, VernWsForPrimaryMorphemeLine, m_sandbox);
				mb.IchSel = m_ichSel;
				mb.Run();
				m_fNeedMorphemeUpdate = false;
				m_sandbox.RootBox.Reconstruct(); // Everything changed, more or less.
				mb.MakeSel();
				m_infoDelayed = null;
				if (m_needDelayedSelection)
				{
					// Gather up the information needed to recreate the current selection at idle time.
					var vwsel = m_sandbox.RootBox.Selection;
					m_infoDelayed = new SelectionHelper.SelInfo();
					int cvsli = vwsel.CLevels(false);
					cvsli--; // CLevels includes the string property itself, but AllTextSelInfo doesn't need it.
					int ichEnd;
					m_infoDelayed.rgvsli = SelLevInfo.AllTextSelInfo(vwsel, cvsli,
						out m_infoDelayed.ihvoRoot,
						out m_infoDelayed.tagTextProp,
						out m_infoDelayed.cpropPrevious,
						out m_infoDelayed.ich,
						out ichEnd,
						out m_infoDelayed.ws,
						out m_infoDelayed.fAssocPrev,
						out m_infoDelayed.ihvoEnd,
						out m_infoDelayed.ttpSelProps);
					Debug.Assert(ichEnd == m_infoDelayed.ich);
					Application.Idle += RecreateDelayedSelection;
				}
			}
		}
Exemplo n.º 4
0
		/// <summary>
		/// Executes in two distinct scenarios.
		///
		/// 1. If disposing is true, the method has been called directly
		/// or indirectly by a user's code via the Dispose method.
		/// Both managed and unmanaged resources can be disposed.
		///
		/// 2. If disposing is false, the method has been called by the
		/// runtime from inside the finalizer and you should not reference (access)
		/// other managed objects, as they already have been garbage collected.
		/// Only unmanaged resources can be disposed.
		/// </summary>
		/// <param name="disposing"></param>
		/// <remarks>
		/// If any exceptions are thrown, that is fine.
		/// If the method is being done in a finalizer, it will be ignored.
		/// If it is thrown by client code calling Dispose,
		/// it needs to be handled by fixing the bug.
		///
		/// If subclasses override this method, they should call the base implementation.
		/// </remarks>
		protected override void Dispose(bool disposing)
		{
			//Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************");
			// Must not be run more than once.
			if (IsDisposed)
				return;

			if (disposing)
			{
				// Dispose managed resources here.
			}

			// Dispose unmanaged resources here, whether disposing is true or false.
			s1 = null;
			s2 = null;

			base.Dispose(disposing);
		}
		/// <summary>
		/// Recreate a selection that has (almost certainly) been overwritten by TSF since it can't handle a
		/// "selection changed" notification in the middle of it calling into our code to deliver new text.
		/// </summary>
		/// <remarks>
		/// See https://jira.sil.org/browse/LT-16766 "Keyman 9 IPA - insert morpheme breaks can put cursor
		/// in undesirable location, or cause a crash".
		/// </remarks>
		private void RecreateDelayedSelection(object sender, EventArgs e)
		{
			Application.Idle -= RecreateDelayedSelection;
			if (m_sandbox != null && m_infoDelayed != null && m_sandbox.RootBox != null)
			{
				m_sandbox.RootBox.MakeTextSelection(
					m_infoDelayed.ihvoRoot,
					m_infoDelayed.rgvsli.Length,
					m_infoDelayed.rgvsli,
					m_infoDelayed.tagTextProp,
					m_infoDelayed.cpropPrevious,
					m_infoDelayed.ich,
					m_infoDelayed.ich,
					m_infoDelayed.ws,
					m_infoDelayed.fAssocPrev,
					m_infoDelayed.ihvoEnd,
					m_infoDelayed.ttpSelProps,
					true);
			}
			m_infoDelayed = null;
			m_needDelayedSelection = false;
		}