Exemple #1
0
//col_num = col_num(in main)-1
void InsertData(LIST* plist, int line_num, int col_num, char dat){
	ListNode* temp = SearchLine(plist,line_num);
	ListNode* temp_next = NULL;
	int a = col_num;
	int b = 0;
	char temp_c;
	if(temp == NULL && plist->head == NULL)
		temp = InsertLine(plist,0);

	if(temp->next == NULL)
		temp_next = InsertLine(plist,line_num);	

	if(temp->data[col_num] == ' '){ 
		if (col_num < max_col)//empty data
			temp->data[col_num] = dat;//end if
		else{
			temp = temp->next;
			col_num = 0;
			temp->data[col_num] = dat;
		}
	}//end if
	else{ //enter the middle
		b = SearchData_NULL(plist,temp,col_num);//find space
		while(b>=0){
			while(a < max_col){
				temp_c = temp->data[a];
				temp->data[a] = dat;
				dat = temp_c;
				a++;
				b--;
				if(b < 0){
					break;
				}
			}//end while(a);
			if(a == max_col && temp->data[max_col] =='\n'){
				if(temp->data[max_col-1] != ' '){
					temp->data[max_col] = ' ';
					temp_next = InsertLine(plist,temp->key);
					temp_next->data[max_col] = '\n';
				}//end if
				else
					break;
			}
			if(temp->next != NULL)
				temp = temp->next;
			else
				temp = InsertLine(plist,line_num);//end else
			a = 0;
		}//end while(b)
	}//end else
		
	if(temp->data[max_col] == '\n' && temp->data[max_col-1] != ' '){
		temp->data[max_col] = ' ';
		temp->next->data[max_col] = '\n';
	}
//	KEY_view(plist);
//	print_Data(plist,line_num,col_num+1);
	return ;		
}
Exemple #2
0
void DeleteLine(LIST* pList, int keyNum){
	ListNode* DeleteNode = SearchLine(pList,keyNum);
	//if DeleteNode doesn't exist, this function is ended
	if (DeleteNode == NULL)
		return;
	//tempNode points previous node of DeleteNode
	ListNode* tempNode = pList->head;

	if(DeleteNode == tempNode){//if you want to delete first input node
		if(pList->tail == pList-> head){//if there is only one node in list
			pList->tail == NULL;
			pList->head == NULL;
		}
		else
			pList->head = DeleteNode->next;
	}
	else{//if you want to delete node existing between of nodes
		while(tempNode->next != DeleteNode)
			tempNode = tempNode->next;//find previous node of DeletNode
	if(DeleteNode == pList->tail)//if you want to delete node first input node
		pList->tail = tempNode;
	//connect previous node of DeleteNode and next  node of it
	//tempNode = node of befor delete node
	if(tempNode->data[max_col]==' ' && DeleteNode->data[max_col]=='\n')
		tempNode->data[max_col] == '\n';
	tempNode->next = DeleteNode->next;
	}
	
	key_modify(pList,DeleteNode->next,DeleteNode->key);
	//delete Deletenode.
	DeleteNode->key = 0;
	DeleteNode->next = NULL;
	free(DeleteNode);
	//modified line number;
//	key_modify(pList->head,1);
	pList->line_count--;//count - 1

	return ;
}
Exemple #3
0
//tail = last line, head = first line
ListNode* InsertLine(LIST* plist, int prevline_num){
	int n = 0;
	plist->line_count++;
	//allocate memory in new node
	ListNode* newPtr = (ListNode*)malloc(sizeof(ListNode));
	ListNode* prevline = SearchLine(plist,prevline_num);
	if(newPtr == NULL)
		return ;//if allocating memory failed return NULL

	newPtr->next = NULL;
	newPtr->key = prevline_num+1;

	while(n < max_col){
		newPtr->data[n] = ' ';
		n++;
	//	if(n==max_col){
	//		newPtr->data[n] = '\n';}
	}
	newPtr->data[max_col] = '\n';
	if(prevline == NULL){//if previous node doesn't exist
		if(plist->tail == NULL)//when first node add
			plist->tail = newPtr;//tail = new node
		//when add new node at the start of list
		newPtr->next = plist->head;
		plist->head = newPtr;
	}
	else{//when add new node at between two already existing node
		newPtr->next = prevline->next;
		prevline->next = newPtr;
		if(newPtr->next == NULL)//last input
			plist->tail = newPtr;
	//	printf("else\n");
	//	KEY_view(plist);
	}

	key_modify(plist,newPtr->next,newPtr->key+1);
//	KEY_view(plist);
	return newPtr;
}
Exemple #4
0
void print_Data(LIST* plist, int line, int col ){

	ListNode* temp = SearchLine(plist, line);
	if(col==80){
		printf("\n");
		col = 0;
		temp = temp->next;
	}
//	while(temp->data[col] != ' '){
	while(temp->next != NULL){
		if(col <  max_col){
			if(temp->data[col]!=94)
				printf("%c",temp->data[col]);
			else printf("%c",' ');
			col++;
			if(col==80){
				printf("\n");
				col = 0;
				temp = temp->next;
			}
		}
	}
	return ;
}
Exemple #5
0
void DeleteData(LIST* plist, int line_num, int col_num){
	//temp = present line
	ListNode* temp = SearchLine(plist,line_num);
//	ListNode* temp_next = NULL;
	int a = col_num;
	int b = 0;
	int n = 0;
	char temp_c;
		b = SearchData_NULL(plist,temp,col_num);//find newline(\n)
		if(a < 0){
			return ;
//			temp_next = temp
//			temp = SearchLine(plist,line_num-1);
//			a = max_col;
//			if(temp->data[a] == '\n'){
//				if(temp->next->data[0] != ' ')
//					temp->data[a] == ' ';
//				else{
//					while(temp->data[n] == ' '){//comfirm all line empty
//						n++;
//						if(n == 80)
//							DeleteLine_N(plist,temp->next);
//					}
//					if(n < 80)
//						temp->data[a] = ' ';
//				}
//			}
					
		}
		while(b>=0){
			while(a < max_col-1){
				temp->data[a] = temp->data[a+1];
				a++;
				b--;
				if(b==0)
					temp->data[a] = ' ';//null
				if(b < 0){
					break;
				}
			}//end while(a);
			if(a == (max_col-1) && temp->data[max_col] ==' '){
				temp->data[a] = temp->next->data[0];
		//		if(temp->next->data[0] = ' '){//no data;
		//			DeleteLine_N(plist,temp->next);
		//			temp->data[max_col] = '\n';
		//			break;
		//		}
		//		else{
					temp = temp->next;
					a = 0;
		//		}
			}
			else if(temp->data[max_col] == '\n')
					break;
		}//end while(b)
//	}//end else
		
	if(temp->data[max_col] == '\n' && temp->data[max_col-1] != ' '){
		temp->data[max_col] = ' ';
		temp->next->data[max_col] = '\n';
	}
	return ;		
}
Exemple #6
0
/*----------------------------------------------------------------------
  ShowBox displays the box pBox at the requested position in the window.
  The parameter position is:
  0 for the top of the window
  1 for the middle of the window
  2 for the bottom of the window
  When the position = 0, percent gives the percent from the top of the
  window.
  scrollUpdate is TRUE when scrollbars must be recomputed
  ----------------------------------------------------------------------*/
void ShowBox (int frame, PtrBox pBox, int position, int percent,
              ThotBool scrollUpdate)
{
  PtrAbstractBox      pBlock;
  PtrBox              pBox1;
  PtrLine             pLine;
  ViewFrame          *pFrame;
  int                 ymin, ymax;
  int                 width, height;
  int                 y, dy, h;

  if (pBox == NULL)
    return;
  pBox1 = pBox;
  pBlock = NULL;
  pLine = NULL;
  if (pBox->BxType == BoGhost ||
      pBox->BxType == BoStructGhost ||
      pBox->BxType == BoFloatGhost)
    {
      while (pBox &&
             (pBox->BxType == BoGhost ||
              pBox->BxType == BoStructGhost ||
              pBox->BxType == BoFloatGhost))
        pBox = pBox->BxAbstractBox->AbFirstEnclosed->AbBox;
      if (!pBox)
        {
          pBox = pBox1;
          while (pBox->BxType == BoGhost ||
                 pBox->BxType == BoStructGhost ||
                 pBox->BxType == BoFloatGhost)
            pBox = pBox->BxAbstractBox->AbEnclosing->AbBox;
        }
      /* manage the line instead of the box itself */
      pLine = SearchLine (pBox, frame);
      if (pLine)
        {
          pBlock = pBox->BxAbstractBox;
          while (pBlock && pBlock->AbBox->BxType != BoBlock &&
                 pBlock->AbBox->BxType != BoFloatBlock &&
                 pBlock->AbBox->BxType != BoCellBlock)
            pBlock = pBlock->AbEnclosing;
        }
    }

  if (pBox->BxType == BoSplit)
    pBox = pBox->BxNexChild;

  pFrame = &ViewFrameTable[frame - 1];
  if (pBlock && pBlock->AbBox)
    {
      y = pBlock->AbBox->BxYOrg + pLine->LiYOrg;
      h = pLine->LiHeight;
    }
  else
    {
      y = pBox->BxYOrg;
      h = pBox->BxHeight;
    }
  /* largeur et hauteur de la fenetre */
  GetSizesFrame (frame, &width, &height);
  ymin = pFrame->FrYOrg;
  ymax = ymin + height;

  /* On debloque eventuellement l'affichage */
  pFrame->FrReady = TRUE;

  if (position == 0)
    /* Affiche le haut de la boite a pourcent du haut de la fenetre */
    dy = y - ymin - ((height * percent) / 100);
  else if (position == 1)
    /* Centre le milieu de la boite sur le milieu de la fenetre */
    dy = y + (h / 2) - ymin - (height / 2);
  else
    /* Affiche en bas de la fenetre */
    dy = y + h - ymax;

  /* Il faut realiser l'affichage par scroll ou par appel explicite */
  if (dy != 0)
    VerticalScroll (frame, dy, 1);
  else if (GL_prepare (frame))
    {
      RedrawFrameBottom (frame, dy, NULL);
#ifdef _GL
      /* to be sure the scrolled page has been displayed */
      GL_Swap (frame);
#endif /* _GL */
      /* Mise a jour des ascenseurs */
      if (scrollUpdate)
        UpdateScrollbars (frame);
    }
}