S + have/had/has + -ing form
Used to describe the continuous background (state or activity) to an action in the past.
I had been seeing her for months before she told me she was married.
You had been watching TV for 2 hours until I told you to go out and get some fresh air.
Casi or queenbu will no doubt post some great links; I'm waiting....