MCPcopy Create free account
hub / github.com/ashkulz/NppFTP / SetHistoryLength

Method SetHistoryLength

UTCP/src/uh_ctrl.cpp:748–795  ·  view source on GitHub ↗

SetHistoryLength Sets the minimum number of items that the history list can hold Params len - mimimum number of items Return 0 - (UH_SUCCESS) 1 - (UH_ERROR) ***********************************/

Source from the content-addressed store, hash-verified

746 1 - (UH_ERROR)
747***********************************/
748int CUH_Control::SetHistoryLength(int len){
749
750 //make sure the min history length is the
751 //number of items visible on the screen
752 if(m_hWnd != NULL){
753 RECT rect;
754 GetClientRect(m_hWnd,&rect);
755 //get the number of screen lines
756 int screenLen = (rect.bottom / m_fontHeight);
757 if(len < screenLen)
758 len = screenLen;
759 }
760
761 //if the list length is zero then just clear it
762 if(len == 0){
763 ClearHistory();
764 m_historyListMaxLen = 0;
765 }
766 else{
767
768 m_historyListMaxLen = len;
769
770 //if the current position is now out of range, re-adjust
771 while(m_HLCurrentPos >= m_historyListMaxLen){
772 if(m_HLCurrentPosPtr->m_prev != NULL){
773 m_HLCurrentPosPtr = m_HLCurrentPosPtr->m_prev;
774 m_HLCurrentPos --;
775 }
776 }
777
778 //delete any items out of range
779 UH_HistoryList *prev = NULL;
780 while(m_HLEndPos >= m_historyListMaxLen){
781 if(m_HLEndPosPtr != NULL){
782 if(m_HLEndPosPtr->m_string != NULL)
783 delete[] m_HLEndPosPtr->m_string;
784 prev = m_HLEndPosPtr->m_prev;
785 prev = m_HLEndPosPtr->m_next = NULL;
786 delete m_HLEndPosPtr;
787 }
788
789 m_HLEndPosPtr = prev;
790 }
791 UpdateScrollRange();
792 }
793
794 return UH_SUCCESS;
795}
796
797/**********************************
798SetAligment

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected